@fabriktor/fx 0.0.33 → 0.0.34

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.
@@ -1,9 +1,9 @@
1
- import type { UpsertResult } from "@fabriktor/schema";
2
- import type { BootstrapOptions, ConnectionsOperator, OperationResultOf, UsersOperator } from "@fabriktor/client";
1
+ import type { ConnectionsOperator, UsersOperator } from "@fabriktor/client";
3
2
  import type { AuthEmailOptions, AuthOperator } from "../auth/auth.js";
4
3
  import type { UsersFXOperator } from "../users/users.js";
5
4
  type ConnectionInsert = Parameters<ConnectionsOperator["insertOneConnection"]>[0]["in"];
6
- type BootstrapInput = BootstrapOptions["in"];
5
+ type BootstrapInput = Parameters<UsersOperator["bootstrap"]>[0]["in"];
6
+ type BootstrapResult = Awaited<ReturnType<UsersOperator["bootstrap"]>>;
7
7
  export declare const SignInMode: {
8
8
  readonly Email: "email";
9
9
  readonly Username: "username";
@@ -21,9 +21,6 @@ export type SignInWithEmailOptions = AuthEmailOptions & {
21
21
  export type SignUpAndBootstrapOptions = AuthEmailOptions & {
22
22
  in: BootstrapInput;
23
23
  };
24
- export type ForgotPasswordOptions = Parameters<UsersOperator["forgotPassword"]>[0];
25
- export type SendSignInLinkOptions = Parameters<UsersOperator["sendSignInLink"]>[0];
26
- export type SendEmailVerificationOptions = Parameters<UsersOperator["sendEmailVerification"]>[0];
27
24
  export type SessionFXOptions = {
28
25
  auth: AuthOperator;
29
26
  connections: ConnectionsOperator;
@@ -31,15 +28,9 @@ export type SessionFXOptions = {
31
28
  users_fx: UsersFXOperator;
32
29
  };
33
30
  export interface SessionFXOperator {
34
- startSignUp(opts: AuthEmailOptions): Promise<void>;
35
- finishSignUp(opts: BootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
36
- signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
31
+ signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<BootstrapResult>;
37
32
  signIn(opts: SignInOptions): Promise<void>;
38
33
  signInWithEmail(opts: SignInWithEmailOptions): Promise<void>;
39
- signOut(): Promise<void>;
40
- forgotPassword(opts: ForgotPasswordOptions): Promise<void>;
41
- sendSignInLink(opts: SendSignInLinkOptions): Promise<void>;
42
- sendEmailVerification(opts: SendEmailVerificationOptions): Promise<void>;
43
34
  checkEmailVerification(): Promise<boolean>;
44
35
  }
45
36
  export declare class SessionFX implements SessionFXOperator {
@@ -48,15 +39,9 @@ export declare class SessionFX implements SessionFXOperator {
48
39
  private users;
49
40
  private usersFX;
50
41
  constructor(opts: SessionFXOptions);
51
- startSignUp(opts: AuthEmailOptions): Promise<void>;
52
- finishSignUp(opts: BootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
53
- signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
42
+ signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<BootstrapResult>;
54
43
  signIn(opts: SignInOptions): Promise<void>;
55
44
  signInWithEmail(opts: SignInWithEmailOptions): Promise<void>;
56
- signOut(): Promise<void>;
57
- forgotPassword(opts: ForgotPasswordOptions): Promise<void>;
58
- sendSignInLink(opts: SendSignInLinkOptions): Promise<void>;
59
- sendEmailVerification(opts: SendEmailVerificationOptions): Promise<void>;
60
45
  checkEmailVerification(): Promise<boolean>;
61
46
  }
62
47
  export declare function newSessionFX(opts: SessionFXOptions): SessionFX;
@@ -18,26 +18,15 @@ export class SessionFX {
18
18
  this.users = opts.users;
19
19
  this.usersFX = opts.users_fx;
20
20
  }
21
- async startSignUp(opts) {
21
+ async signUpAndBootstrap(opts) {
22
22
  await this.auth.signUp({
23
23
  email: opts.email,
24
24
  password: opts.password,
25
25
  });
26
- }
27
- async finishSignUp(opts) {
28
26
  return await this.users.bootstrap({
29
27
  in: opts.in,
30
28
  });
31
29
  }
32
- async signUpAndBootstrap(opts) {
33
- await this.startSignUp({
34
- email: opts.email,
35
- password: opts.password,
36
- });
37
- return await this.finishSignUp({
38
- in: opts.in,
39
- });
40
- }
41
30
  async signIn(opts) {
42
31
  const email = opts.mode === SignInMode.Email
43
32
  ? opts.identifier
@@ -60,18 +49,6 @@ export class SessionFX {
60
49
  });
61
50
  await this.users.sync();
62
51
  }
63
- async signOut() {
64
- await this.auth.signOut();
65
- }
66
- async forgotPassword(opts) {
67
- await this.users.forgotPassword(opts);
68
- }
69
- async sendSignInLink(opts) {
70
- await this.users.sendSignInLink(opts);
71
- }
72
- async sendEmailVerification(opts) {
73
- await this.users.sendEmailVerification(opts);
74
- }
75
52
  async checkEmailVerification() {
76
53
  await this.auth.reloadUser();
77
54
  if (!this.auth.emailVerified()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {