firstly 0.0.4 → 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.
Files changed (64) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/esm/{KitBaseEnum.d.ts → BaseEnum.d.ts} +18 -9
  3. package/esm/{KitBaseEnum.js → BaseEnum.js} +2 -13
  4. package/esm/{KitEntity.d.ts → FF_Entity.d.ts} +1 -1
  5. package/esm/{KitEntity.js → FF_Entity.js} +9 -9
  6. package/esm/{KitFields.d.ts → FF_Fields.d.ts} +2 -3
  7. package/esm/{KitFields.js → FF_Fields.js} +13 -9
  8. package/esm/ROUTES.js +1 -1
  9. package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
  10. package/esm/SqlDatabase/{LogToConsoleCustom.js → FF_LogToConsole.js} +1 -1
  11. package/esm/api/index.d.ts +1 -0
  12. package/esm/auth/AuthController.server.js +9 -9
  13. package/esm/auth/Entities.d.ts +18 -17
  14. package/esm/auth/Entities.js +66 -63
  15. package/esm/auth/RoleHelpers.d.ts +2 -2
  16. package/esm/auth/RoleHelpers.js +1 -1
  17. package/esm/auth/client/Auth.js +1 -1
  18. package/esm/auth/index.d.ts +10 -10
  19. package/esm/auth/index.js +20 -18
  20. package/esm/auth/providers/github.d.ts +22 -17
  21. package/esm/auth/providers/github.js +29 -15
  22. package/esm/auth/providers/strava.d.ts +22 -17
  23. package/esm/auth/providers/strava.js +23 -15
  24. package/esm/auth/static/assets/Page-ByIhtXVt.d.ts +1 -1
  25. package/esm/auth/static/assets/Page-ByIhtXVt.js +8178 -6
  26. package/esm/bin/cmd.js +181 -83
  27. package/esm/{kitCellsBuildor.d.ts → cellsBuildor.d.ts} +9 -9
  28. package/esm/{kitCellsBuildor.js → cellsBuildor.js} +8 -8
  29. package/esm/feedback/ui/DialogIssue.svelte +2 -2
  30. package/esm/formats/dates.js +2 -2
  31. package/esm/handle/index.d.ts +1 -0
  32. package/esm/helper.d.ts +8 -10
  33. package/esm/helper.js +13 -8
  34. package/esm/index.d.ts +37 -49
  35. package/esm/index.js +29 -27
  36. package/esm/{kitStoreItem.d.ts → storeItem.d.ts} +1 -1
  37. package/esm/{kitStoreItem.js → storeItem.js} +1 -1
  38. package/esm/{kitStoreList.d.ts → storeList.d.ts} +4 -4
  39. package/esm/{kitStoreList.js → storeList.js} +1 -1
  40. package/esm/ui/Button.svelte +1 -1
  41. package/esm/ui/Button.svelte.d.ts +2 -2
  42. package/esm/ui/Field.svelte.d.ts +2 -2
  43. package/esm/ui/FieldGroup.svelte +2 -2
  44. package/esm/ui/FieldGroup.svelte.d.ts +4 -4
  45. package/esm/ui/Grid.svelte.d.ts +5 -5
  46. package/esm/ui/dialog/DialogForm.svelte +4 -4
  47. package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +2 -2
  48. package/esm/ui/dialog/FormEditAction.svelte.d.ts +2 -2
  49. package/esm/ui/dialog/dialog.d.ts +5 -5
  50. package/esm/ui/index.d.ts +2 -2
  51. package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +3 -3
  52. package/esm/ui/internals/select/SelectMelt.svelte.d.ts +3 -3
  53. package/esm/ui/internals/select/SelectRadio.svelte.d.ts +2 -2
  54. package/esm/ui/link/LinkPlus.svelte.d.ts +2 -2
  55. package/esm/utils/types.d.ts +0 -15
  56. package/esm/utils/types.js +1 -17
  57. package/esm/virtual/Customer.js +2 -2
  58. package/esm/virtual/FilterEntity.js +1 -1
  59. package/esm/virtual/StateDemoEnum.d.ts +4 -4
  60. package/esm/virtual/StateDemoEnum.js +2 -2
  61. package/esm/virtual/UIEntity.js +4 -4
  62. package/esm/vite/index.js +1 -1
  63. package/package.json +4 -3
  64. package/esm/SqlDatabase/LogToConsoleCustom.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
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
+
3
16
  ## 0.0.4
4
17
 
5
18
  ### Patch Changes
@@ -1,25 +1,36 @@
1
1
  import { type IdFilter } from 'remult';
2
- import type { ClassType, FindOptionsBase } from 'remult';
3
- export type KitIcon = {
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 KitBaseEnumOptions<Entity = any> = {
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?: KitIcon;
23
+ icon?: FF_Icon;
13
24
  where?: IdFilter<Entity> | FindOptionsBase<Entity>['where'];
14
25
  class?: string;
15
26
  };
16
- export declare class KitBaseEnum<Entity = any> {
27
+ export declare class BaseEnum<Entity = any> {
17
28
  id: string;
18
29
  caption?: string;
19
- icon?: KitIcon;
30
+ icon?: FF_Icon;
20
31
  where?: IdFilter<Entity> | FindOptionsBase<Entity>['where'];
21
32
  class?: string;
22
- constructor(_id: string | number, options?: KitBaseEnumOptions<Entity>);
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 { getValueList } from 'remult';
2
- export class KitBaseEnum {
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 KitEntity<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;
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
- export function KitEntity(key, options) {
3
- const toAllow = (permission) => {
4
- if (permission) {
5
- if (Array.isArray(permission)) {
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 undefined;
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,6 +1,5 @@
1
- import { type FieldOptions, type FieldValidator, type StringFieldOptions } from 'remult';
2
- export declare function addValidator(validators: FieldOptions['validate'], newValidator: FieldOptions['validate'], atStart?: boolean): FieldValidator<unknown, unknown> | FieldValidator<unknown, unknown>[] | undefined;
3
- export declare class KitFields {
1
+ import { type FieldOptions, type StringFieldOptions } from 'remult';
2
+ export declare class FF_Fields {
4
3
  static string<entityType = unknown, valueType = string>(o?: StringFieldOptions<entityType, valueType>): import("remult").ClassFieldDecorator<entityType, valueType | undefined>;
5
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>;
@@ -1,18 +1,21 @@
1
1
  import { Fields, Validators, } from 'remult';
2
2
  import { displayCurrency } from './formats';
3
- import { getEnums } from './KitBaseEnum';
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 addValidator(validators, newValidator, atStart = false) {
10
- if (!newValidator)
11
- return validators;
12
- const newValidators = Array.isArray(newValidator) ? newValidator : [newValidator];
13
- const validatorsArray = Array.isArray(validators) ? validators : validators ? [validators] : [];
14
- return atStart ? [...newValidators, ...validatorsArray] : [...validatorsArray, ...newValidators];
15
- }
9
+ // export function addValidators(
10
+ // validators: FieldOptions['validate'],
11
+ // newValidator: FieldOptions['validate'],
12
+ // atStart = false,
13
+ // ) {
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
+ // }
16
19
  // REMULT P2: A/ Add in the doc that allowNull is false by default
17
20
  // B/ Would be great to have a Validators.required automatically when allowNull is not true.
18
21
  // C/ WARNING Validators.required is also checking for empty string
@@ -24,6 +27,7 @@ const validate_update_when_not_allow_null = (o) => {
24
27
  (o.allowNull === undefined || o.allowNull === false) &&
25
28
  // if require: false is explicitly set, then we don't need to add required validator
26
29
  o.required !== false) {
30
+ // addValidators(o.validate, [Validators.required], true)
27
31
  validate.push(Validators.required);
28
32
  }
29
33
  // let's add original validate if any
@@ -37,7 +41,7 @@ const validate_update_when_not_allow_null = (o) => {
37
41
  }
38
42
  return validate;
39
43
  };
40
- export class KitFields {
44
+ export class FF_Fields {
41
45
  static string(o) {
42
46
  if (o === undefined) {
43
47
  o = {};
package/esm/ROUTES.js CHANGED
@@ -27,7 +27,7 @@ const ACTIONS = {};
27
27
  * LINKS
28
28
  */
29
29
  const LINKS = {
30
- "firstly_sign_in": `/fly/auth/sign-in`,
30
+ "firstly_sign_in": `/ff/auth/sign-in`,
31
31
  "remult_admin": `/api/admin`,
32
32
  "github": (params) => {
33
33
  params = params ?? {};
@@ -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 LogToConsoleCustom = (duration, query, args, short = true) => {
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, ' ')
@@ -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';
@@ -6,7 +6,7 @@ import { remult } from 'remult';
6
6
  import { green, yellow } from '@kitql/helpers';
7
7
  import { AUTH_OPTIONS, getSafeOptions, logAuth, lucia } from '.';
8
8
  import { sendMail } from '../mail';
9
- import { AuthProvider } from './Entities.js';
9
+ import { FFAuthProvider } from './Entities.js';
10
10
  import { createSession } from './helper';
11
11
  import { mergeRoles } from './RoleHelpers';
12
12
  async function getArgon() {
@@ -124,7 +124,7 @@ export class AuthControllerServer {
124
124
  });
125
125
  const token = generateId(40);
126
126
  await remult.repo(oSafe.Account).insert({
127
- provider: AuthProvider.PASSWORD.id,
127
+ provider: FFAuthProvider.PASSWORD.id,
128
128
  providerUserId: email,
129
129
  userId: user.id,
130
130
  hashPassword: await passwordHash(password),
@@ -167,7 +167,7 @@ export class AuthControllerServer {
167
167
  const existingUser = await remult
168
168
  .repo(oSafe.User)
169
169
  .findOne({ where: { name: email }, include: { accounts: true } });
170
- const accountPassword = existingUser?.accounts.find((c) => c.provider === AuthProvider.PASSWORD.id);
170
+ const accountPassword = existingUser?.accounts.find((c) => c.provider === FFAuthProvider.PASSWORD.id);
171
171
  if (accountPassword && existingUser) {
172
172
  const validPassword = await passwordVerify(accountPassword?.hashPassword ?? '', password ?? '');
173
173
  if (validPassword) {
@@ -194,7 +194,7 @@ export class AuthControllerServer {
194
194
  if (!authAccount) {
195
195
  authAccount = remult.repo(oSafe.Account).create();
196
196
  authAccount.userId = u.id;
197
- authAccount.provider = AuthProvider.PASSWORD.id;
197
+ authAccount.provider = FFAuthProvider.PASSWORD.id;
198
198
  authAccount.providerUserId = email;
199
199
  }
200
200
  const token = generateId(40);
@@ -230,7 +230,7 @@ export class AuthControllerServer {
230
230
  }
231
231
  const account = await remult
232
232
  .repo(oSafe.Account)
233
- .findFirst({ token, provider: AuthProvider.PASSWORD.id });
233
+ .findFirst({ token, provider: FFAuthProvider.PASSWORD.id });
234
234
  if (!account) {
235
235
  throw new Error('Invalid token');
236
236
  }
@@ -275,12 +275,12 @@ export class AuthControllerServer {
275
275
  user = await remult.repo(oSafe.User).save(user);
276
276
  let account = await remult
277
277
  .repo(oSafe.Account)
278
- .findFirst({ userId: user.id, provider: AuthProvider.OTP.id });
278
+ .findFirst({ userId: user.id, provider: FFAuthProvider.OTP.id });
279
279
  if (!account) {
280
280
  account = remult.repo(oSafe.Account).create();
281
281
  }
282
282
  account.userId = user.id;
283
- account.provider = AuthProvider.OTP.id;
283
+ account.provider = FFAuthProvider.OTP.id;
284
284
  account.token = otp;
285
285
  account.hashPassword = secretEncoded;
286
286
  await remult.repo(oSafe.Account).save(account);
@@ -299,7 +299,7 @@ export class AuthControllerServer {
299
299
  static async verifyOtp(email, otp) {
300
300
  const oSafe = getSafeOptions();
301
301
  const accounts = await remult.repo(oSafe.Account).find({
302
- where: { token: String(otp), provider: AuthProvider.OTP.id },
302
+ where: { token: String(otp), provider: FFAuthProvider.OTP.id },
303
303
  });
304
304
  if (accounts.length === 0) {
305
305
  throw new Error('Invalid otp');
@@ -393,6 +393,6 @@ export class AuthControllerServer {
393
393
  throw new Error(`${o.provider} not well configured!`);
394
394
  }
395
395
  }
396
- 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)`);
397
397
  }
398
398
  }
@@ -1,22 +1,23 @@
1
- import { KitBaseEnum } from '../';
2
- import type { KitBaseEnumOptions } from '../';
3
- export declare const KitAuthRole: {
4
- readonly Admin: "KitAuthAdmin";
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 KitAuthUser {
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: KitAuthAccount[];
13
- sessions: KitAuthUserSession[];
12
+ accounts: FFAuthAccount[];
13
+ sessions: FFAuthUserSession[];
14
14
  }
15
- export declare class KitAuthAccount {
15
+ export declare class FFAuthAccount {
16
+ id: string;
16
17
  createdAt: Date;
17
18
  updatedAt?: Date;
18
19
  userId: string;
19
- user: KitAuthUser;
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 KitAuthUserSession {
28
+ export declare class FFAuthUserSession {
28
29
  id: string;
29
30
  expiresAt: Date;
30
31
  userId: string;
31
- user: KitAuthUser;
32
+ user: FFAuthUser;
32
33
  }
33
- export declare class AuthProvider extends KitBaseEnum {
34
- static DEMO: AuthProvider;
35
- static PASSWORD: AuthProvider;
36
- static OTP: AuthProvider;
37
- static OAUTH: AuthProvider;
38
- constructor(id: string, o?: KitBaseEnumOptions);
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
  }
@@ -4,17 +4,16 @@ 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
- var AuthProvider_1;
7
+ var FFAuthProvider_1;
8
8
  import { Entity, Fields, Relations, Validators, ValueListFieldType } from 'remult';
9
- import { KitBaseEnum, KitRole } from '../';
10
- export const KitAuthRole = {
11
- Admin: 'KitAuthAdmin',
9
+ import { BaseEnum, FF_Role } from '../';
10
+ export const FF_Auth_Role = {
11
+ Admin: 'FF_Auth_Role.Admin',
12
12
  };
13
- let KitAuthUser = class KitAuthUser {
13
+ let FFAuthUser = class FFAuthUser {
14
14
  id;
15
15
  createdAt;
16
16
  updatedAt;
17
- // @Fields.string<KitAuthUser>({
18
17
  name;
19
18
  roles = [];
20
19
  accounts;
@@ -22,13 +21,13 @@ let KitAuthUser = class KitAuthUser {
22
21
  };
23
22
  __decorate([
24
23
  Fields.cuid()
25
- ], KitAuthUser.prototype, "id", void 0);
24
+ ], FFAuthUser.prototype, "id", void 0);
26
25
  __decorate([
27
26
  Fields.createdAt()
28
- ], KitAuthUser.prototype, "createdAt", void 0);
27
+ ], FFAuthUser.prototype, "createdAt", void 0);
29
28
  __decorate([
30
29
  Fields.updatedAt()
31
- ], KitAuthUser.prototype, "updatedAt", void 0);
30
+ ], FFAuthUser.prototype, "updatedAt", void 0);
32
31
  __decorate([
33
32
  Fields.string({
34
33
  validate: [
@@ -39,7 +38,7 @@ __decorate([
39
38
  },
40
39
  ],
41
40
  })
42
- ], KitAuthUser.prototype, "name", void 0);
41
+ ], FFAuthUser.prototype, "name", void 0);
43
42
  __decorate([
44
43
  Fields.object({
45
44
  valueConverter: {
@@ -47,71 +46,75 @@ __decorate([
47
46
  fromDb: (x) => (x ? x.split(',') : undefined),
48
47
  },
49
48
  })
50
- ], KitAuthUser.prototype, "roles", void 0);
49
+ ], FFAuthUser.prototype, "roles", void 0);
51
50
  __decorate([
52
- Relations.toMany(() => KitAuthAccount, 'userId')
53
- ], KitAuthUser.prototype, "accounts", void 0);
51
+ Relations.toMany(() => FFAuthAccount, 'userId')
52
+ ], FFAuthUser.prototype, "accounts", void 0);
54
53
  __decorate([
55
- Relations.toMany(() => KitAuthUserSession, 'userId')
56
- ], KitAuthUser.prototype, "sessions", void 0);
57
- KitAuthUser = __decorate([
58
- Entity('kit_auth_user', {
59
- allowApiCrud: [KitAuthRole.Admin, KitRole.Admin],
60
- dbName: 'auth.kit_auth_user',
54
+ Relations.toMany(() => FFAuthUserSession, 'userId')
55
+ ], FFAuthUser.prototype, "sessions", void 0);
56
+ FFAuthUser = __decorate([
57
+ Entity('ff_auth.users', {
58
+ allowApiCrud: [FF_Auth_Role.Admin, FF_Role.Admin],
59
+ caption: 'Auth - Users',
61
60
  })
62
- ], KitAuthUser);
63
- export { KitAuthUser };
64
- let KitAuthAccount = class KitAuthAccount {
61
+ ], FFAuthUser);
62
+ export { FFAuthUser };
63
+ let FFAuthAccount = class FFAuthAccount {
64
+ id;
65
65
  createdAt;
66
66
  updatedAt;
67
67
  userId;
68
68
  user;
69
- provider = AuthProvider.PASSWORD.id;
69
+ provider = FFAuthProvider.PASSWORD.id;
70
70
  providerUserId = '';
71
71
  hashPassword;
72
72
  token;
73
73
  expiresAt;
74
74
  lastVerifiedAt;
75
75
  };
76
+ __decorate([
77
+ Fields.cuid()
78
+ ], FFAuthAccount.prototype, "id", void 0);
76
79
  __decorate([
77
80
  Fields.createdAt()
78
- ], KitAuthAccount.prototype, "createdAt", void 0);
81
+ ], FFAuthAccount.prototype, "createdAt", void 0);
79
82
  __decorate([
80
83
  Fields.updatedAt()
81
- ], KitAuthAccount.prototype, "updatedAt", void 0);
84
+ ], FFAuthAccount.prototype, "updatedAt", void 0);
82
85
  __decorate([
83
86
  Fields.string()
84
- ], KitAuthAccount.prototype, "userId", void 0);
87
+ ], FFAuthAccount.prototype, "userId", void 0);
85
88
  __decorate([
86
- Relations.toOne(() => KitAuthUser, 'userId')
87
- ], KitAuthAccount.prototype, "user", void 0);
89
+ Relations.toOne(() => FFAuthUser, 'userId')
90
+ ], FFAuthAccount.prototype, "user", void 0);
88
91
  __decorate([
89
92
  Fields.string()
90
- ], KitAuthAccount.prototype, "provider", void 0);
93
+ ], FFAuthAccount.prototype, "provider", void 0);
91
94
  __decorate([
92
95
  Fields.string()
93
- ], KitAuthAccount.prototype, "providerUserId", void 0);
96
+ ], FFAuthAccount.prototype, "providerUserId", void 0);
94
97
  __decorate([
95
98
  Fields.string({ includeInApi: false, allowNull: true })
96
- ], KitAuthAccount.prototype, "hashPassword", void 0);
99
+ ], FFAuthAccount.prototype, "hashPassword", void 0);
97
100
  __decorate([
98
101
  Fields.string({ includeInApi: false, allowNull: true })
99
- ], KitAuthAccount.prototype, "token", void 0);
102
+ ], FFAuthAccount.prototype, "token", void 0);
100
103
  __decorate([
101
104
  Fields.date({ includeInApi: false, allowNull: true })
102
- ], KitAuthAccount.prototype, "expiresAt", void 0);
105
+ ], FFAuthAccount.prototype, "expiresAt", void 0);
103
106
  __decorate([
104
107
  Fields.date({ includeInApi: false, allowNull: true })
105
- ], KitAuthAccount.prototype, "lastVerifiedAt", void 0);
106
- KitAuthAccount = __decorate([
107
- Entity('kit_auth_account', {
108
- allowApiCrud: [KitAuthRole.Admin, KitRole.Admin],
109
- dbName: 'auth.kit_auth_account',
110
- id: { provider: true, userId: true },
108
+ ], FFAuthAccount.prototype, "lastVerifiedAt", void 0);
109
+ FFAuthAccount = __decorate([
110
+ Entity('ff_auth.accounts', {
111
+ allowApiCrud: [FF_Auth_Role.Admin, FF_Role.Admin],
112
+ caption: 'Auth - Accounts',
113
+ // id: { provider: true, userId: true },
111
114
  })
112
- ], KitAuthAccount);
113
- export { KitAuthAccount };
114
- let KitAuthUserSession = class KitAuthUserSession {
115
+ ], FFAuthAccount);
116
+ export { FFAuthAccount };
117
+ let FFAuthUserSession = class FFAuthUserSession {
115
118
  id;
116
119
  expiresAt;
117
120
  userId;
@@ -119,36 +122,36 @@ let KitAuthUserSession = class KitAuthUserSession {
119
122
  };
120
123
  __decorate([
121
124
  Fields.cuid()
122
- ], KitAuthUserSession.prototype, "id", void 0);
125
+ ], FFAuthUserSession.prototype, "id", void 0);
123
126
  __decorate([
124
127
  Fields.date()
125
- ], KitAuthUserSession.prototype, "expiresAt", void 0);
128
+ ], FFAuthUserSession.prototype, "expiresAt", void 0);
126
129
  __decorate([
127
130
  Fields.string()
128
- ], KitAuthUserSession.prototype, "userId", void 0);
129
- __decorate([
130
- Relations.toOne(() => KitAuthUser, 'userId')
131
- ], KitAuthUserSession.prototype, "user", void 0);
132
- KitAuthUserSession = __decorate([
133
- Entity('kit_auth_session', {
134
- allowApiCrud: [KitAuthRole.Admin, KitRole.Admin],
135
- dbName: 'auth.kit_auth_session',
131
+ ], FFAuthUserSession.prototype, "userId", void 0);
132
+ __decorate([
133
+ Relations.toOne(() => FFAuthUser, 'userId')
134
+ ], FFAuthUserSession.prototype, "user", void 0);
135
+ FFAuthUserSession = __decorate([
136
+ Entity('ff_auth.users_sessions', {
137
+ allowApiCrud: [FF_Auth_Role.Admin, FF_Role.Admin],
138
+ caption: 'Auth - Users sessions',
136
139
  })
137
- ], KitAuthUserSession);
138
- export { KitAuthUserSession };
139
- let AuthProvider = class AuthProvider extends KitBaseEnum {
140
- static { AuthProvider_1 = this; }
141
- static DEMO = new AuthProvider_1('DEMO', { caption: 'Demo' });
142
- static PASSWORD = new AuthProvider_1('PASSWORD', { caption: 'Password' });
143
- static OTP = new AuthProvider_1('OTP', { caption: 'TOTP' });
144
- static OAUTH = new AuthProvider_1('OAUTH', { caption: 'OAUTH' });
140
+ ], FFAuthUserSession);
141
+ export { FFAuthUserSession };
142
+ let FFAuthProvider = class FFAuthProvider extends BaseEnum {
143
+ static { FFAuthProvider_1 = this; }
144
+ static DEMO = new FFAuthProvider_1('DEMO', { caption: 'Demo' });
145
+ static PASSWORD = new FFAuthProvider_1('PASSWORD', { caption: 'Password' });
146
+ static OTP = new FFAuthProvider_1('OTP', { caption: 'TOTP' });
147
+ static OAUTH = new FFAuthProvider_1('OAUTH', { caption: 'OAUTH' });
145
148
  constructor(id, o) {
146
149
  super(id, {
147
150
  ...o,
148
151
  });
149
152
  }
150
153
  };
151
- AuthProvider = AuthProvider_1 = __decorate([
154
+ FFAuthProvider = FFAuthProvider_1 = __decorate([
152
155
  ValueListFieldType()
153
- ], AuthProvider);
154
- export { AuthProvider };
156
+ ], FFAuthProvider);
157
+ export { FFAuthProvider };
@@ -1,6 +1,6 @@
1
1
  import type { ClassType } from 'remult';
2
2
  import { Log } from '@kitql/helpers';
3
- import { KitAuthUser } from './Entities';
3
+ import { FFAuthUser } from './Entities';
4
4
  /**
5
5
  * will merge the roles and remove duplicates
6
6
  * will return a new array & a status if the array was changed
@@ -9,4 +9,4 @@ export declare const mergeRoles: (existing: string[], newOnes: string[] | undefi
9
9
  roles: string[];
10
10
  changed: boolean;
11
11
  };
12
- export declare const initRoleFromEnv: (log: Log, userEntity: ClassType<KitAuthUser>, envValue: string, role: string) => Promise<void>;
12
+ export declare const initRoleFromEnv: (log: Log, userEntity: ClassType<FFAuthUser>, envValue: string | undefined, role: string) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { repo } from 'remult';
2
2
  import { cyan, green, Log, yellow } from '@kitql/helpers';
3
- import { KitAuthUser } from './Entities';
3
+ import { FFAuthUser } from './Entities';
4
4
  /**
5
5
  * will merge the roles and remove duplicates
6
6
  * will return a new array & a status if the array was changed
@@ -86,7 +86,7 @@ export class Auth {
86
86
  * _(popup example should work too, and a nice example/componant would be appreciated)_
87
87
  */
88
88
  static async signInOAuthGetUrl(o) {
89
- return await Auth.signInOAuthGetUrlFn(o.provider, o.options, o.redirect);
89
+ return await Auth.signInOAuthGetUrlFn(o);
90
90
  }
91
91
  }
92
92
  __decorate([
@@ -4,32 +4,32 @@ import type { ClassType, UserInfo } from 'remult';
4
4
  import { Log } from '@kitql/helpers';
5
5
  import type { Module } from '../api';
6
6
  import type { ResolvedType } from '../utils/types';
7
- import { AuthProvider, KitAuthAccount, KitAuthUser, KitAuthUserSession } from './Entities';
7
+ import { FFAuthAccount, FFAuthProvider, FFAuthUser, FFAuthUserSession } from './Entities';
8
8
  import type { firstlyData } from './types';
9
9
  export type { firstlyData };
10
- export { KitAuthUser, KitAuthAccount, AuthProvider, KitAuthUserSession };
10
+ export { FFAuthUser, FFAuthAccount, FFAuthProvider, FFAuthUserSession };
11
11
  export type AuthorizationURLOptions = Record<string, {
12
12
  scopes?: string[];
13
13
  }>;
14
- export type DynamicAuthorizationURLOptions<T extends KitOAuth2Provider[] = KitOAuth2Provider[]> = T extends Array<infer O> ? O extends KitOAuth2Provider ? {
14
+ export type DynamicAuthorizationURLOptions<T extends FFOAuth2Provider[] = FFOAuth2Provider[]> = T extends Array<infer O> ? O extends FFOAuth2Provider ? {
15
15
  [P in O['name']]: ReturnType<O['authorizationURLOptions']>;
16
16
  } : never : never;
17
17
  export declare const logAuth: Log;
18
- export { KitAuthRole } from './Entities';
18
+ export { FF_Auth_Role } from './Entities';
19
19
  type OAuth2UserInfo = {
20
20
  raw?: any;
21
21
  providerUserId: string;
22
22
  /** Will take the first option available */
23
23
  nameOptions: string[];
24
24
  };
25
- export type KitOAuth2Provider<LitName extends string = string, T extends ArcticOAuth2Provider | ArcticOAuth2ProviderWithPKCE = ArcticOAuth2Provider> = {
25
+ export type FFOAuth2Provider<LitName extends string = string, T extends ArcticOAuth2Provider | ArcticOAuth2ProviderWithPKCE = ArcticOAuth2Provider> = {
26
26
  name: LitName;
27
27
  getArcticProvider: () => T;
28
28
  isPKCE: T extends ArcticOAuth2Provider ? false : T extends ArcticOAuth2ProviderWithPKCE ? true : never;
29
29
  authorizationURLOptions: () => T extends ArcticOAuth2Provider ? Parameters<T['createAuthorizationURL']>[1] : T extends ArcticOAuth2ProviderWithPKCE ? Parameters<T['createAuthorizationURL']>[2] : never;
30
30
  getUserInfo(tokens: ResolvedType<ReturnType<T['validateAuthorizationCode']>>): Promise<OAuth2UserInfo>;
31
31
  };
32
- type AuthOptions<TUserEntity extends KitAuthUser = KitAuthUser, TSessionEntity extends KitAuthUserSession = KitAuthUserSession, TAccountEntity extends KitAuthAccount = KitAuthAccount> = {
32
+ type AuthOptions<TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity extends FFAuthUserSession = FFAuthUserSession, TAccountEntity extends FFAuthAccount = FFAuthAccount> = {
33
33
  customEntities?: {
34
34
  User?: ClassType<TUserEntity>;
35
35
  Session?: ClassType<TSessionEntity>;
@@ -111,14 +111,14 @@ type AuthOptions<TUserEntity extends KitAuthUser = KitAuthUser, TSessionEntity e
111
111
  uri: string;
112
112
  }) => Promise<void>;
113
113
  };
114
- oAuths?: KitOAuth2Provider[];
114
+ oAuths?: FFOAuth2Provider[];
115
115
  };
116
116
  };
117
117
  export declare let AUTH_OPTIONS: AuthOptions;
118
118
  export declare const getSafeOptions: () => {
119
- User: ClassType<KitAuthUser>;
120
- Session: ClassType<KitAuthUserSession>;
121
- Account: ClassType<KitAuthAccount>;
119
+ User: ClassType<FFAuthUser>;
120
+ Session: ClassType<FFAuthUserSession>;
121
+ Account: ClassType<FFAuthAccount>;
122
122
  signUp: boolean;
123
123
  password_enabled: boolean;
124
124
  otp_enabled: boolean;