firstly 0.0.3 → 0.0.5
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} +4 -5
- package/esm/{KitFields.js → FF_Fields.js} +41 -55
- package/esm/ROUTES.d.ts +4 -2
- package/esm/ROUTES.js +4 -7
- 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 +1 -0
- package/esm/auth/Adapter.js +10 -8
- package/esm/auth/{AuthController.d.ts → AuthController.server.d.ts} +2 -2
- package/esm/auth/{AuthController.js → AuthController.server.js} +15 -51
- package/esm/auth/Entities.d.ts +18 -17
- package/esm/auth/Entities.js +66 -63
- package/esm/auth/README.md +13 -0
- package/esm/auth/{RoleController.d.ts → RoleHelpers.d.ts} +2 -4
- package/esm/auth/RoleHelpers.js +43 -0
- package/esm/auth/client/Auth.d.ts +69 -0
- package/esm/auth/client/Auth.js +121 -0
- package/esm/auth/client/index.d.ts +2 -0
- package/esm/auth/client/index.js +2 -0
- package/esm/auth/index.d.ts +10 -11
- package/esm/auth/index.js +37 -21
- 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-BwHye0GW.d.ts → Page-BYzkK4q3.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-BwHye0GW.js → Page-BYzkK4q3.js} +1 -1
- package/esm/auth/static/assets/Page-ByIhtXVt.d.ts +5 -0
- package/esm/auth/static/assets/Page-ByIhtXVt.js +8190 -0
- package/esm/auth/static/assets/{Page-BMOLAIFx.d.ts → Page-Do7F0Mzd.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-BMOLAIFx.js → Page-Do7F0Mzd.js} +1 -1
- package/esm/auth/static/assets/index-czJ1PA1n.js +2 -0
- package/esm/auth/static/index.html +1 -1
- package/esm/bin/cmd.js +182 -83
- package/esm/cellsBuildor.d.ts +45 -0
- package/esm/{kitCellsBuildor.js → cellsBuildor.js} +24 -14
- package/esm/feedback/ui/DialogIssue.svelte +2 -2
- package/esm/formats/dates.js +2 -2
- package/esm/formats/strings.js +0 -11
- package/esm/handle/index.d.ts +1 -0
- package/esm/helper.d.ts +8 -10
- package/esm/helper.js +13 -12
- package/esm/index.d.ts +37 -48
- package/esm/index.js +29 -20
- package/esm/{kitStoreItem.d.ts → storeItem.d.ts} +1 -1
- package/esm/{kitStoreItem.js → storeItem.js} +3 -3
- package/esm/{kitStoreList.d.ts → storeList.d.ts} +4 -4
- package/esm/{kitStoreList.js → storeList.js} +1 -1
- package/esm/ui/Button.svelte +7 -9
- package/esm/ui/Button.svelte.d.ts +2 -2
- package/esm/ui/Field.svelte +9 -8
- package/esm/ui/Field.svelte.d.ts +2 -2
- package/esm/ui/FieldGroup.svelte +5 -3
- package/esm/ui/FieldGroup.svelte.d.ts +4 -4
- package/esm/ui/Grid.svelte.d.ts +5 -5
- package/esm/ui/GridPaginate.svelte +3 -6
- package/esm/ui/Icon.svelte +6 -7
- package/esm/ui/LibIcon.js +0 -2
- package/esm/ui/dialog/DialogForm.svelte +5 -6
- 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 +7 -5
- package/esm/ui/dialog/dialog.js +1 -0
- package/esm/ui/index.d.ts +2 -2
- package/esm/ui/internals/FieldContainer.svelte +1 -1
- package/esm/ui/internals/Input.svelte +1 -1
- package/esm/ui/internals/select/MultiSelectMelt.svelte +16 -19
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +3 -3
- package/esm/ui/internals/select/SelectMelt.svelte +10 -14
- 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 +0 -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 +10 -5
- package/esm/SqlDatabase/LogToConsoleCustom.d.ts +0 -1
- package/esm/auth/RoleController.js +0 -57
- package/esm/auth/static/assets/Page-BMFREPjF.d.ts +0 -5
- package/esm/auth/static/assets/Page-BMFREPjF.js +0 -18
- package/esm/auth/static/assets/index-CKmKKRRL.js +0 -2
- package/esm/kitCellsBuildor.d.ts +0 -45
- /package/esm/auth/static/assets/{index-CKmKKRRL.d.ts → index-czJ1PA1n.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# firstly
|
|
2
2
|
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#20](https://github.com/jycouet/firstly/pull/20)
|
|
8
|
+
[`5b365a4`](https://github.com/jycouet/firstly/commit/5b365a474619f611b0eb0bfe38bbbb262acb3a7e)
|
|
9
|
+
Thanks [@jycouet](https://github.com/jycouet)! - [BREAKING] Renaming almost all exports! (Some
|
|
10
|
+
`FF_` and `ff_` only when direct collision with other packages)
|
|
11
|
+
|
|
12
|
+
- [#20](https://github.com/jycouet/firstly/pull/20)
|
|
13
|
+
[`b1ea110`](https://github.com/jycouet/firstly/commit/b1ea1101c45c137e477a937a8c6d130b346b2bb9)
|
|
14
|
+
Thanks [@jycouet](https://github.com/jycouet)! - tweak cli, update github auth
|
|
15
|
+
|
|
16
|
+
## 0.0.4
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#16](https://github.com/jycouet/firstly/pull/16)
|
|
21
|
+
[`ac00e70`](https://github.com/jycouet/firstly/commit/ac00e703af515009bbe7e078998f77ef3a9e9ce5)
|
|
22
|
+
Thanks [@jycouet](https://github.com/jycouet)! - WIP next version / split client & server imports.
|
|
23
|
+
|
|
3
24
|
## 0.0.3
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import { type IdFilter } from 'remult';
|
|
2
|
-
import type {
|
|
3
|
-
export type
|
|
2
|
+
import type { FindOptionsBase, Repository } from 'remult';
|
|
3
|
+
export type FF_Icon = {
|
|
4
4
|
data?: string | string[];
|
|
5
5
|
size?: string | number;
|
|
6
6
|
class?: string | string[];
|
|
7
7
|
style?: string | string[];
|
|
8
8
|
caption?: string;
|
|
9
9
|
};
|
|
10
|
-
export type
|
|
10
|
+
export type BaseItem = BaseEnumOptions & {
|
|
11
|
+
id: string;
|
|
12
|
+
captionSub?: string | (string | undefined)[];
|
|
13
|
+
href?: string;
|
|
14
|
+
repo?: Repository<any>;
|
|
15
|
+
sub?: {
|
|
16
|
+
captionPre?: string;
|
|
17
|
+
repo?: Repository<any>;
|
|
18
|
+
item?: any;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type BaseEnumOptions<Entity = any> = {
|
|
11
22
|
caption?: string;
|
|
12
|
-
icon?:
|
|
23
|
+
icon?: FF_Icon;
|
|
13
24
|
where?: IdFilter<Entity> | FindOptionsBase<Entity>['where'];
|
|
14
25
|
class?: string;
|
|
15
26
|
};
|
|
16
|
-
export declare class
|
|
27
|
+
export declare class BaseEnum<Entity = any> {
|
|
17
28
|
id: string;
|
|
18
29
|
caption?: string;
|
|
19
|
-
icon?:
|
|
30
|
+
icon?: FF_Icon;
|
|
20
31
|
where?: IdFilter<Entity> | FindOptionsBase<Entity>['where'];
|
|
21
32
|
class?: string;
|
|
22
|
-
constructor(_id: string | number, options?:
|
|
33
|
+
constructor(_id: string | number, options?: BaseEnumOptions<Entity>);
|
|
23
34
|
getWhere: () => this | Entity[] | {
|
|
24
35
|
$ne?: Entity | Entity[] | undefined;
|
|
25
36
|
'!='?: Entity | Entity[] | undefined;
|
|
@@ -31,5 +42,3 @@ export declare class KitBaseEnum<Entity = any> {
|
|
|
31
42
|
} ? number : string>;
|
|
32
43
|
} | import("remult").EntityFilter<Entity> | NonNullable<Entity>;
|
|
33
44
|
}
|
|
34
|
-
export declare const getEnum: <T extends KitBaseEnum<any>>(baseEnum: ClassType<T>, id: string | undefined | null) => T | undefined;
|
|
35
|
-
export declare const getEnums: <T extends KitBaseEnum<any>>(baseEnum: ClassType<T>) => T[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export class
|
|
1
|
+
import {} from 'remult';
|
|
2
|
+
export class BaseEnum {
|
|
3
3
|
id;
|
|
4
4
|
caption;
|
|
5
5
|
icon;
|
|
@@ -19,14 +19,3 @@ export class KitBaseEnum {
|
|
|
19
19
|
return this.where ? this.where : this;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export const getEnum = (baseEnum, id) => {
|
|
23
|
-
if (!id) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
const found = getValueList(baseEnum).find((c) => c.id === id);
|
|
28
|
-
return found;
|
|
29
|
-
};
|
|
30
|
-
export const getEnums = (baseEnum) => {
|
|
31
|
-
return getValueList(baseEnum) || [];
|
|
32
|
-
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type EntityOptions } from 'remult';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function FF_Entity<entityType>(key: string, options: EntityOptions<entityType extends new (...args: any) => any ? InstanceType<entityType> : entityType>): (target: any, info?: import("remult/src/remult3/remult3").ClassDecoratorContextStub<entityType extends infer T ? T extends entityType ? T extends new (...args: any) => any ? T : never : never : never> | undefined) => any;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Entity } from 'remult';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (permission) {
|
|
5
|
-
|
|
6
|
-
return permission.map((p) => p.id);
|
|
7
|
-
}
|
|
8
|
-
return permission.id;
|
|
2
|
+
const toAllow = (permission) => {
|
|
3
|
+
if (permission) {
|
|
4
|
+
if (Array.isArray(permission)) {
|
|
5
|
+
return permission.map((p) => p.id);
|
|
9
6
|
}
|
|
10
|
-
return
|
|
11
|
-
}
|
|
7
|
+
return permission.id;
|
|
8
|
+
}
|
|
9
|
+
return undefined;
|
|
10
|
+
};
|
|
11
|
+
export function FF_Entity(key, options) {
|
|
12
12
|
return Entity(key, {
|
|
13
13
|
...options,
|
|
14
14
|
allowApiCrud: options.allowApiCrud ?? toAllow(options.permissionApiCrud),
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type FieldOptions, type
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
static
|
|
5
|
-
static currency<entityType = any, valueType = any>(o?: FieldOptions<entityType> & FieldOptions<entityType>): import("remult").ClassFieldDecorator<entityType, number | undefined>;
|
|
1
|
+
import { type FieldOptions, type StringFieldOptions } from 'remult';
|
|
2
|
+
export declare class FF_Fields {
|
|
3
|
+
static string<entityType = unknown, valueType = string>(o?: StringFieldOptions<entityType, valueType>): import("remult").ClassFieldDecorator<entityType, valueType | undefined>;
|
|
4
|
+
static currency<entityType = unknown>(o?: FieldOptions<entityType, number>): import("remult").ClassFieldDecorator<entityType, number | undefined>;
|
|
6
5
|
static dateOnly<entityType = any>(o?: FieldOptions<entityType, Date>): import("remult").ClassFieldDecorator<entityType, Date | undefined>;
|
|
7
6
|
static arrayEnum<enumType = any, entityType = any>(enumClass: enumType, o?: FieldOptions<entityType, any[]>): import("remult").ClassFieldDecorator<entityType, any[] | undefined>;
|
|
8
7
|
static arrayEnumToGql<enumType = any, entityType = any>(enumClass: enumType, o?: FieldOptions<entityType, any[]>): import("remult").ClassFieldDecorator<entityType, any[] | undefined>;
|
|
@@ -1,50 +1,56 @@
|
|
|
1
1
|
import { Fields, Validators, } from 'remult';
|
|
2
2
|
import { displayCurrency } from './formats';
|
|
3
|
-
import { getEnums } from './
|
|
3
|
+
import { getEnums } from './helper';
|
|
4
4
|
// Translate default messages
|
|
5
5
|
// REMULT P3 JYC: I need to set this here the one of my app are not overwriting these...
|
|
6
6
|
// It look like I have 2 remult loaded... But even trying to remove one, I still have the issue
|
|
7
7
|
Validators.unique.defaultMessage = 'Existe déjà!';
|
|
8
8
|
Validators.required.defaultMessage = 'Obligatoire!';
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const validatorsArray = Array.isArray(validators) ? validators : validators ? [validators] : [];
|
|
14
|
-
return atStart ? [...newValidators, ...validatorsArray] : [...validatorsArray, ...newValidators];
|
|
15
|
-
}
|
|
16
|
-
// static string<entityType = any, valueType = string>(
|
|
17
|
-
// ...param: Parameters<typeof Fields.string<entityType, valueType>>
|
|
9
|
+
// export function addValidators(
|
|
10
|
+
// validators: FieldOptions['validate'],
|
|
11
|
+
// newValidator: FieldOptions['validate'],
|
|
12
|
+
// atStart = false,
|
|
18
13
|
// ) {
|
|
19
|
-
|
|
14
|
+
// if (!newValidator) return validators
|
|
15
|
+
// const newValidators = Array.isArray(newValidator) ? newValidator : [newValidator]
|
|
16
|
+
// const validatorsArray = Array.isArray(validators) ? validators : validators ? [validators] : []
|
|
17
|
+
// return atStart ? [...newValidators, ...validatorsArray] : [...validatorsArray, ...newValidators]
|
|
18
|
+
// }
|
|
19
|
+
// REMULT P2: A/ Add in the doc that allowNull is false by default
|
|
20
|
+
// B/ Would be great to have a Validators.required automatically when allowNull is not true.
|
|
21
|
+
// C/ WARNING Validators.required is also checking for empty string
|
|
22
|
+
const validate_update_when_not_allow_null = (o) => {
|
|
23
|
+
const validate = [];
|
|
24
|
+
if (o.includeInApi !== false &&
|
|
25
|
+
o.serverExpression === undefined &&
|
|
26
|
+
o.sqlExpression === undefined &&
|
|
27
|
+
(o.allowNull === undefined || o.allowNull === false) &&
|
|
28
|
+
// if require: false is explicitly set, then we don't need to add required validator
|
|
29
|
+
o.required !== false) {
|
|
30
|
+
// addValidators(o.validate, [Validators.required], true)
|
|
31
|
+
validate.push(Validators.required);
|
|
32
|
+
}
|
|
33
|
+
// let's add original validate if any
|
|
34
|
+
if (o.validate) {
|
|
35
|
+
if (Array.isArray(o.validate)) {
|
|
36
|
+
validate.push(...o.validate);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
validate.push(o.validate);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return validate;
|
|
43
|
+
};
|
|
44
|
+
export class FF_Fields {
|
|
20
45
|
static string(o) {
|
|
21
|
-
// const f = Fields.string(...param)
|
|
22
|
-
// f.validate = addValidator(f.validate, Validators.required)
|
|
23
|
-
// return f
|
|
24
|
-
// empty if there is nothing coming here.
|
|
25
46
|
if (o === undefined) {
|
|
26
47
|
o = {};
|
|
27
48
|
}
|
|
28
|
-
const validate = [];
|
|
29
|
-
if (o.includeInApi !== false &&
|
|
30
|
-
(!o.allowNull || o.required) &&
|
|
31
|
-
// if require: false is explicitly set, then we don't need to add required validator
|
|
32
|
-
o.required !== false) {
|
|
33
|
-
// REMULT P2 JYC (Open an issue): to repro + issue type issue? - Probably typescript
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
validate.push(Validators.required);
|
|
36
|
-
}
|
|
37
|
-
// let's add original validate if any
|
|
38
|
-
if (o.validate) {
|
|
39
|
-
if (Array.isArray(o.validate)) {
|
|
40
|
-
validate.push(...o.validate);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
validate.push(o.validate);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
49
|
// let's return the field
|
|
47
|
-
return Fields.string({
|
|
50
|
+
return Fields.string({
|
|
51
|
+
...o,
|
|
52
|
+
validate: validate_update_when_not_allow_null(o),
|
|
53
|
+
});
|
|
48
54
|
}
|
|
49
55
|
static currency(o) {
|
|
50
56
|
// let's return the field
|
|
@@ -80,27 +86,9 @@ export class KitFields {
|
|
|
80
86
|
if (o === undefined) {
|
|
81
87
|
o = {};
|
|
82
88
|
}
|
|
83
|
-
const validate = [];
|
|
84
|
-
if (o.includeInApi !== false &&
|
|
85
|
-
(!o.allowNull || o.required) &&
|
|
86
|
-
// if require: false is explicitly set, then we don't need to add required validator
|
|
87
|
-
o.required !== false) {
|
|
88
|
-
// REMULT P2 JYC (Open an issue): to repro + issue type issue? - Probably typescript
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
validate.push(Validators.required);
|
|
91
|
-
}
|
|
92
|
-
// let's add original validate if any
|
|
93
|
-
if (o.validate) {
|
|
94
|
-
if (Array.isArray(o.validate)) {
|
|
95
|
-
validate.push(...o.validate);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
validate.push(o.validate);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
89
|
o.inputType = 'dateOnly';
|
|
102
90
|
// let's return the field
|
|
103
|
-
return Fields.dateOnly({ ...o, validate });
|
|
91
|
+
return Fields.dateOnly({ ...o, validate: validate_update_when_not_allow_null(o) });
|
|
104
92
|
}
|
|
105
93
|
static arrayEnum(enumClass, o) {
|
|
106
94
|
return Fields.json(() => Array, {
|
|
@@ -126,7 +114,6 @@ export class KitFields {
|
|
|
126
114
|
return `{${[...new Set((arr ?? []).map((c) => c.id))].join(',')}}`;
|
|
127
115
|
},
|
|
128
116
|
displayValue: (v) => {
|
|
129
|
-
// TODO to transform in enum & item one day
|
|
130
117
|
return v.map((c) => c.caption).join(', ');
|
|
131
118
|
},
|
|
132
119
|
// REMULT P2 Noam: how to do this in an official way?
|
|
@@ -152,7 +139,6 @@ export class KitFields {
|
|
|
152
139
|
return `{${[...new Set((arr ?? []).map((c) => c.id))].join(',')}}`;
|
|
153
140
|
},
|
|
154
141
|
displayValue: (v) => {
|
|
155
|
-
// TODO to transform in enum & item one day
|
|
156
142
|
return v.map((c) => c.caption).join(', ');
|
|
157
143
|
},
|
|
158
144
|
// REMULT P2 Noam: how to do this in an official way?
|
package/esm/ROUTES.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ type FunctionKeys<T> = {
|
|
|
25
25
|
}[keyof T];
|
|
26
26
|
type FunctionParams<T> = T extends (...args: infer P) => any ? P : never;
|
|
27
27
|
declare const AllObjs: {
|
|
28
|
-
|
|
28
|
+
firstly_sign_in: string;
|
|
29
29
|
remult_admin: string;
|
|
30
30
|
github: (params?: {
|
|
31
31
|
owner?: (string | number);
|
|
@@ -39,6 +39,8 @@ declare const AllObjs: {
|
|
|
39
39
|
"/ui": string;
|
|
40
40
|
};
|
|
41
41
|
type AllTypes = typeof AllObjs;
|
|
42
|
+
export type Routes = keyof AllTypes extends `${string}/${infer Route}` ? `/${Route}` : keyof AllTypes;
|
|
43
|
+
export declare const routes: ("/" | "/remult" | "/remult/auth" | "/remult/enum" | "/remult/select" | "/ui" | "firstly_sign_in" | "remult_admin" | "github")[];
|
|
42
44
|
/**
|
|
43
45
|
* To be used like this:
|
|
44
46
|
* ```ts
|
|
@@ -76,7 +78,7 @@ export type KIT_ROUTES = {
|
|
|
76
78
|
SERVERS: Record<string, never>;
|
|
77
79
|
ACTIONS: Record<string, never>;
|
|
78
80
|
LINKS: {
|
|
79
|
-
'
|
|
81
|
+
'firstly_sign_in': never;
|
|
80
82
|
'remult_admin': never;
|
|
81
83
|
'github': 'owner' | 'repo';
|
|
82
84
|
};
|
package/esm/ROUTES.js
CHANGED
|
@@ -27,7 +27,7 @@ const ACTIONS = {};
|
|
|
27
27
|
* LINKS
|
|
28
28
|
*/
|
|
29
29
|
const LINKS = {
|
|
30
|
-
"
|
|
30
|
+
"firstly_sign_in": `/ff/auth/sign-in`,
|
|
31
31
|
"remult_admin": `/api/admin`,
|
|
32
32
|
"github": (params) => {
|
|
33
33
|
params = params ?? {};
|
|
@@ -80,13 +80,10 @@ export const currentSp = () => {
|
|
|
80
80
|
}
|
|
81
81
|
return record;
|
|
82
82
|
};
|
|
83
|
-
function StringOrUndefined(val) {
|
|
84
|
-
if (val === undefined) {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
return String(val);
|
|
88
|
-
}
|
|
89
83
|
const AllObjs = { ...PAGES, ...ACTIONS, ...SERVERS, ...LINKS };
|
|
84
|
+
export const routes = [
|
|
85
|
+
...new Set(Object.keys(AllObjs).map((route) => /^\/.*|[^ ]?\/.*$/.exec(route)?.[0] ?? route)),
|
|
86
|
+
];
|
|
90
87
|
export function route(key, ...params) {
|
|
91
88
|
if (AllObjs[key] instanceof Function) {
|
|
92
89
|
const element = AllObjs[key];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FF_LogToConsole: (duration: number, query: string, args: Record<string, any>, short?: boolean) => string | undefined;
|
|
@@ -16,7 +16,7 @@ const typeQuery = new Map([
|
|
|
16
16
|
]);
|
|
17
17
|
const keys = ['FROM', 'WHERE', 'LIMIT', 'OFFSET'];
|
|
18
18
|
const typeQueryKey = Array.from(typeQuery.keys());
|
|
19
|
-
export const
|
|
19
|
+
export const FF_LogToConsole = (duration, query, args, short = true) => {
|
|
20
20
|
const rawSql = query
|
|
21
21
|
.replace(/(\r\n|\n|\r|\t)/gm, ' ')
|
|
22
22
|
.replace(/ +/g, ' ')
|
package/esm/api/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, type MaybePromise, type RequestEvent } from '@sveltejs/kit';
|
|
2
3
|
import { type ClassType } from 'remult';
|
|
3
4
|
import type { RemultServerOptions } from 'remult/server';
|
package/esm/auth/Adapter.js
CHANGED
|
@@ -6,16 +6,18 @@ export class RemultLuciaAdapter {
|
|
|
6
6
|
const session = await remult.repo(oSafe.Session).findId(sessionId);
|
|
7
7
|
if (session) {
|
|
8
8
|
const user = await remult.repo(oSafe.User).findId(session.userId);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
attributes: {
|
|
9
|
+
if (user) {
|
|
10
|
+
return [
|
|
11
|
+
{ ...session, attributes: {} },
|
|
12
|
+
{
|
|
14
13
|
...user,
|
|
15
|
-
|
|
14
|
+
attributes: {
|
|
15
|
+
...user,
|
|
16
|
+
session: { id: session.id, expiresAt: session.expiresAt },
|
|
17
|
+
},
|
|
16
18
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
];
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
return [null, null];
|
|
21
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AuthorizationURLOptions } from '.';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class AuthControllerServer {
|
|
3
3
|
/**
|
|
4
4
|
* Sign out the current user
|
|
5
5
|
*/
|
|
@@ -45,7 +45,7 @@ export declare class AuthController {
|
|
|
45
45
|
*
|
|
46
46
|
* To be used like this for example:
|
|
47
47
|
* ```
|
|
48
|
-
* const url = await
|
|
48
|
+
* const url = await Auth.signInOAuthGetUrl('github')
|
|
49
49
|
* window.location.href = url
|
|
50
50
|
* ```
|
|
51
51
|
*
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
1
|
import { generateCodeVerifier, generateState } from 'arctic';
|
|
8
2
|
import { DEV } from 'esm-env';
|
|
9
3
|
import { generateId } from 'lucia';
|
|
10
4
|
import { createDate, TimeSpan } from 'oslo';
|
|
11
|
-
import {
|
|
5
|
+
import { remult } from 'remult';
|
|
12
6
|
import { green, yellow } from '@kitql/helpers';
|
|
13
7
|
import { AUTH_OPTIONS, getSafeOptions, logAuth, lucia } from '.';
|
|
14
8
|
import { sendMail } from '../mail';
|
|
15
|
-
import {
|
|
9
|
+
import { FFAuthProvider } from './Entities.js';
|
|
16
10
|
import { createSession } from './helper';
|
|
17
|
-
import { mergeRoles } from './
|
|
11
|
+
import { mergeRoles } from './RoleHelpers';
|
|
18
12
|
async function getArgon() {
|
|
19
13
|
const { Argon2id } = await import('oslo/password');
|
|
20
14
|
return new Argon2id({
|
|
@@ -34,7 +28,7 @@ function checkPassword(password) {
|
|
|
34
28
|
throw Error('Invalid password');
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
|
-
export class
|
|
31
|
+
export class AuthControllerServer {
|
|
38
32
|
/**
|
|
39
33
|
* Sign out the current user
|
|
40
34
|
*/
|
|
@@ -130,7 +124,7 @@ export class AuthController {
|
|
|
130
124
|
});
|
|
131
125
|
const token = generateId(40);
|
|
132
126
|
await remult.repo(oSafe.Account).insert({
|
|
133
|
-
provider:
|
|
127
|
+
provider: FFAuthProvider.PASSWORD.id,
|
|
134
128
|
providerUserId: email,
|
|
135
129
|
userId: user.id,
|
|
136
130
|
hashPassword: await passwordHash(password),
|
|
@@ -173,8 +167,8 @@ export class AuthController {
|
|
|
173
167
|
const existingUser = await remult
|
|
174
168
|
.repo(oSafe.User)
|
|
175
169
|
.findOne({ where: { name: email }, include: { accounts: true } });
|
|
176
|
-
const accountPassword = existingUser?.accounts.find((c) => c.provider ===
|
|
177
|
-
if (accountPassword) {
|
|
170
|
+
const accountPassword = existingUser?.accounts.find((c) => c.provider === FFAuthProvider.PASSWORD.id);
|
|
171
|
+
if (accountPassword && existingUser) {
|
|
178
172
|
const validPassword = await passwordVerify(accountPassword?.hashPassword ?? '', password ?? '');
|
|
179
173
|
if (validPassword) {
|
|
180
174
|
await createSession(existingUser.id);
|
|
@@ -200,7 +194,7 @@ export class AuthController {
|
|
|
200
194
|
if (!authAccount) {
|
|
201
195
|
authAccount = remult.repo(oSafe.Account).create();
|
|
202
196
|
authAccount.userId = u.id;
|
|
203
|
-
authAccount.provider =
|
|
197
|
+
authAccount.provider = FFAuthProvider.PASSWORD.id;
|
|
204
198
|
authAccount.providerUserId = email;
|
|
205
199
|
}
|
|
206
200
|
const token = generateId(40);
|
|
@@ -236,7 +230,7 @@ export class AuthController {
|
|
|
236
230
|
}
|
|
237
231
|
const account = await remult
|
|
238
232
|
.repo(oSafe.Account)
|
|
239
|
-
.findFirst({ token, provider:
|
|
233
|
+
.findFirst({ token, provider: FFAuthProvider.PASSWORD.id });
|
|
240
234
|
if (!account) {
|
|
241
235
|
throw new Error('Invalid token');
|
|
242
236
|
}
|
|
@@ -281,12 +275,12 @@ export class AuthController {
|
|
|
281
275
|
user = await remult.repo(oSafe.User).save(user);
|
|
282
276
|
let account = await remult
|
|
283
277
|
.repo(oSafe.Account)
|
|
284
|
-
.findFirst({ userId: user.id, provider:
|
|
278
|
+
.findFirst({ userId: user.id, provider: FFAuthProvider.OTP.id });
|
|
285
279
|
if (!account) {
|
|
286
280
|
account = remult.repo(oSafe.Account).create();
|
|
287
281
|
}
|
|
288
282
|
account.userId = user.id;
|
|
289
|
-
account.provider =
|
|
283
|
+
account.provider = FFAuthProvider.OTP.id;
|
|
290
284
|
account.token = otp;
|
|
291
285
|
account.hashPassword = secretEncoded;
|
|
292
286
|
await remult.repo(oSafe.Account).save(account);
|
|
@@ -305,14 +299,14 @@ export class AuthController {
|
|
|
305
299
|
static async verifyOtp(email, otp) {
|
|
306
300
|
const oSafe = getSafeOptions();
|
|
307
301
|
const accounts = await remult.repo(oSafe.Account).find({
|
|
308
|
-
where: { token: String(otp), provider:
|
|
302
|
+
where: { token: String(otp), provider: FFAuthProvider.OTP.id },
|
|
309
303
|
});
|
|
310
304
|
if (accounts.length === 0) {
|
|
311
305
|
throw new Error('Invalid otp');
|
|
312
306
|
}
|
|
313
307
|
const account = accounts[0];
|
|
314
308
|
const user = await remult.repo(oSafe.User).findId(account.userId);
|
|
315
|
-
if (user
|
|
309
|
+
if (user?.name !== email) {
|
|
316
310
|
throw new Error('Invalid otp.');
|
|
317
311
|
}
|
|
318
312
|
const { decodeHex } = await import('oslo/encoding');
|
|
@@ -338,7 +332,7 @@ export class AuthController {
|
|
|
338
332
|
*
|
|
339
333
|
* To be used like this for example:
|
|
340
334
|
* ```
|
|
341
|
-
* const url = await
|
|
335
|
+
* const url = await Auth.signInOAuthGetUrl('github')
|
|
342
336
|
* window.location.href = url
|
|
343
337
|
* ```
|
|
344
338
|
*
|
|
@@ -399,36 +393,6 @@ export class AuthController {
|
|
|
399
393
|
throw new Error(`${o.provider} not well configured!`);
|
|
400
394
|
}
|
|
401
395
|
}
|
|
402
|
-
throw new Error(`${o.provider} is not configured
|
|
396
|
+
throw new Error(`${o.provider} is not configured! (Module: auth, section: providers.oAuths: [${o.provider}] missing)`);
|
|
403
397
|
}
|
|
404
398
|
}
|
|
405
|
-
__decorate([
|
|
406
|
-
BackendMethod({ allowed: true })
|
|
407
|
-
], AuthController, "signOut", null);
|
|
408
|
-
__decorate([
|
|
409
|
-
BackendMethod({ allowed: true })
|
|
410
|
-
], AuthController, "signInDemo", null);
|
|
411
|
-
__decorate([
|
|
412
|
-
BackendMethod({ allowed: false })
|
|
413
|
-
], AuthController, "invite", null);
|
|
414
|
-
__decorate([
|
|
415
|
-
BackendMethod({ allowed: true })
|
|
416
|
-
], AuthController, "signUpPassword", null);
|
|
417
|
-
__decorate([
|
|
418
|
-
BackendMethod({ allowed: true })
|
|
419
|
-
], AuthController, "signInPassword", null);
|
|
420
|
-
__decorate([
|
|
421
|
-
BackendMethod({ allowed: true })
|
|
422
|
-
], AuthController, "forgotPassword", null);
|
|
423
|
-
__decorate([
|
|
424
|
-
BackendMethod({ allowed: true })
|
|
425
|
-
], AuthController, "resetPassword", null);
|
|
426
|
-
__decorate([
|
|
427
|
-
BackendMethod({ allowed: true })
|
|
428
|
-
], AuthController, "signInOTP", null);
|
|
429
|
-
__decorate([
|
|
430
|
-
BackendMethod({ allowed: true })
|
|
431
|
-
], AuthController, "verifyOtp", null);
|
|
432
|
-
__decorate([
|
|
433
|
-
BackendMethod({ allowed: true })
|
|
434
|
-
], AuthController, "signInOAuthGetUrl", null);
|
package/esm/auth/Entities.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
export declare const
|
|
4
|
-
readonly Admin: "
|
|
1
|
+
import { BaseEnum } from '../';
|
|
2
|
+
import type { BaseEnumOptions } from '../';
|
|
3
|
+
export declare const FF_Auth_Role: {
|
|
4
|
+
readonly Admin: "FF_Auth_Role.Admin";
|
|
5
5
|
};
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class FFAuthUser {
|
|
7
7
|
id: string;
|
|
8
8
|
createdAt: Date;
|
|
9
9
|
updatedAt?: Date;
|
|
10
10
|
name: string;
|
|
11
11
|
roles: string[];
|
|
12
|
-
accounts:
|
|
13
|
-
sessions:
|
|
12
|
+
accounts: FFAuthAccount[];
|
|
13
|
+
sessions: FFAuthUserSession[];
|
|
14
14
|
}
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class FFAuthAccount {
|
|
16
|
+
id: string;
|
|
16
17
|
createdAt: Date;
|
|
17
18
|
updatedAt?: Date;
|
|
18
19
|
userId: string;
|
|
19
|
-
user:
|
|
20
|
+
user: FFAuthUser;
|
|
20
21
|
provider: string;
|
|
21
22
|
providerUserId: string;
|
|
22
23
|
hashPassword?: string;
|
|
@@ -24,16 +25,16 @@ export declare class KitAuthAccount {
|
|
|
24
25
|
expiresAt?: Date;
|
|
25
26
|
lastVerifiedAt?: Date;
|
|
26
27
|
}
|
|
27
|
-
export declare class
|
|
28
|
+
export declare class FFAuthUserSession {
|
|
28
29
|
id: string;
|
|
29
30
|
expiresAt: Date;
|
|
30
31
|
userId: string;
|
|
31
|
-
user:
|
|
32
|
+
user: FFAuthUser;
|
|
32
33
|
}
|
|
33
|
-
export declare class
|
|
34
|
-
static DEMO:
|
|
35
|
-
static PASSWORD:
|
|
36
|
-
static OTP:
|
|
37
|
-
static OAUTH:
|
|
38
|
-
constructor(id: string, o?:
|
|
34
|
+
export declare class FFAuthProvider extends BaseEnum {
|
|
35
|
+
static DEMO: FFAuthProvider;
|
|
36
|
+
static PASSWORD: FFAuthProvider;
|
|
37
|
+
static OTP: FFAuthProvider;
|
|
38
|
+
static OAUTH: FFAuthProvider;
|
|
39
|
+
constructor(id: string, o?: BaseEnumOptions);
|
|
39
40
|
}
|