@fabriktor/fx 0.0.14 → 0.0.16

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,7 +1,6 @@
1
1
  export * from "./auth/auth.js";
2
2
  export * from "./fx.js";
3
3
  export * from "./session/session.js";
4
- export * from "./session/signup.js";
5
4
  export * from "./users/phone.js";
6
5
  export * from "./users/username.js";
7
6
  export * from "./users/users.js";
package/dist/src/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from "./auth/auth.js";
2
2
  export * from "./fx.js";
3
3
  export * from "./session/session.js";
4
- export * from "./session/signup.js";
5
4
  export * from "./users/phone.js";
6
5
  export * from "./users/username.js";
7
6
  export * from "./users/users.js";
@@ -1,7 +1,7 @@
1
1
  import type { InUser, PLUsersForgotPassword, PLUsersSignInLink, UpsertResult } from "@fabriktor/schema";
2
2
  import type { Op } from "@fabriktor/client";
3
3
  import type { AuthEmailOptions, AuthOperator } from "../auth/auth.js";
4
- import type { UsersFXOperator } from "../users/users.js";
4
+ import type { BootstrapOptions, UsersFXOperator } from "../users/users.js";
5
5
  export type SignInMode = "email" | "username";
6
6
  export type SignInOptions = {
7
7
  mode: SignInMode;
@@ -16,6 +16,8 @@ export type SessionFXOptions = {
16
16
  users: UsersFXOperator;
17
17
  };
18
18
  export interface SessionFXOperator {
19
+ startSignUp(opts: AuthEmailOptions): Promise<void>;
20
+ finishSignUp(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
19
21
  signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<Op<UpsertResult>>;
20
22
  signIn(opts: SignInOptions): Promise<void>;
21
23
  signInWithEmail(opts: AuthEmailOptions): Promise<void>;
@@ -28,6 +30,8 @@ export declare class SessionFX implements SessionFXOperator {
28
30
  private auth;
29
31
  private users;
30
32
  constructor(opts: SessionFXOptions);
33
+ startSignUp(opts: AuthEmailOptions): Promise<void>;
34
+ finishSignUp(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
31
35
  signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<Op<UpsertResult>>;
32
36
  signIn(opts: SignInOptions): Promise<void>;
33
37
  signInWithEmail(opts: AuthEmailOptions): Promise<void>;
@@ -10,17 +10,28 @@ export class SessionFX {
10
10
  this.auth = opts.auth;
11
11
  this.users = opts.users;
12
12
  }
13
- async signUpAndBootstrap(opts) {
13
+ async startSignUp(opts) {
14
14
  await this.auth.signUp({
15
15
  email: opts.email,
16
16
  password: opts.password,
17
17
  });
18
+ }
19
+ async finishSignUp(opts) {
18
20
  const out = await this.users.bootstrap({
19
21
  in: opts.in,
20
22
  });
21
23
  await this.users.sendEmailVerification();
22
24
  return out;
23
25
  }
26
+ async signUpAndBootstrap(opts) {
27
+ await this.startSignUp({
28
+ email: opts.email,
29
+ password: opts.password,
30
+ });
31
+ return await this.finishSignUp({
32
+ in: opts.in,
33
+ });
34
+ }
24
35
  async signIn(opts) {
25
36
  const email = opts.mode === "email"
26
37
  ? opts.identifier
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,7 +17,7 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/client": "^0.0.12",
21
- "@fabriktor/schema": "^0.0.11"
20
+ "@fabriktor/client": "^0.0.13",
21
+ "@fabriktor/schema": "^0.0.12"
22
22
  }
23
23
  }
@@ -1,34 +0,0 @@
1
- import { UserTypeClient, UserTypeEmployee, UserTypeEmployer } from "@fabriktor/schema";
2
- import type { InUser, Owner, Privacy } from "@fabriktor/schema";
3
- export type SignUpUserType = typeof UserTypeClient | typeof UserTypeEmployee | typeof UserTypeEmployer;
4
- export type SignUpAddressInput = {
5
- address_timezone?: string;
6
- lat?: number;
7
- lon?: number;
8
- street?: string;
9
- city?: string;
10
- state?: string;
11
- postal_code?: string;
12
- country?: string;
13
- formatted_address?: string;
14
- place_name?: string;
15
- place_id?: string;
16
- };
17
- export type SignUpInput = {
18
- email: string;
19
- password: string;
20
- username: string;
21
- first_name: string;
22
- last_name: string;
23
- company_name?: string;
24
- user_type: SignUpUserType;
25
- preferred_language: string;
26
- phone?: string;
27
- address?: SignUpAddressInput;
28
- privacy?: Privacy;
29
- picture_id?: string;
30
- qr_id?: string;
31
- };
32
- export declare function newInUserFromSignUp(opts: SignUpInput): InUser;
33
- export declare function newDefaultPrivacy(): Privacy;
34
- export declare function newZeroOwner(): Owner;
@@ -1,42 +0,0 @@
1
- // Copyright (C) Fabriktor, Inc. 2025-present.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
- // not use this file except in compliance with the License. You may obtain
5
- // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- export function newInUserFromSignUp(opts) {
7
- return {
8
- address_timezone: opts.address?.address_timezone ?? "",
9
- lat: opts.address?.lat ?? 0,
10
- lon: opts.address?.lon ?? 0,
11
- street: opts.address?.street ?? "",
12
- city: opts.address?.city ?? "",
13
- state: opts.address?.state ?? "",
14
- postal_code: opts.address?.postal_code ?? "",
15
- country: opts.address?.country ?? "",
16
- formatted_address: opts.address?.formatted_address ?? "",
17
- place_name: opts.address?.place_name ?? "",
18
- place_id: opts.address?.place_id ?? "",
19
- username: opts.username,
20
- first_name: opts.first_name,
21
- last_name: opts.last_name,
22
- phone: opts.phone ?? "",
23
- company_name: opts.company_name ?? "",
24
- user_type: opts.user_type,
25
- user_type_switch: opts.user_type,
26
- privacy: opts.privacy ?? newDefaultPrivacy(),
27
- picture_id: opts.picture_id ?? "",
28
- qr_id: opts.qr_id ?? "",
29
- ExternalOwner: newZeroOwner(),
30
- };
31
- }
32
- export function newDefaultPrivacy() {
33
- return {
34
- is_searchable: true,
35
- is_messageable: true,
36
- };
37
- }
38
- export function newZeroOwner() {
39
- return {
40
- owner_id: "",
41
- };
42
- }