@fabriktor/fx 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/LICENSE +13 -0
- package/README.md +29 -0
- package/dist/src/auth/auth.d.ts +13 -0
- package/dist/src/auth/auth.js +6 -0
- package/dist/src/fx.d.ts +19 -0
- package/dist/src/fx.js +25 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/session/session.d.ts +25 -0
- package/dist/src/session/session.js +32 -0
- package/dist/src/users/users.d.ts +26 -0
- package/dist/src/users/users.js +40 -0
- package/package.json +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2025 Fabriktor, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Fx
|
|
2
|
+
|
|
3
|
+
![Fabriktor Logo][fabriktor-logo]
|
|
4
|
+
|
|
5
|
+
[![GitLab stars][stars-badge]][starrers-link]
|
|
6
|
+
|
|
7
|
+
[![License][license-badge]][license-link]
|
|
8
|
+
[![Pipeline Badge][pipeline-badge]][pipelines-link]
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
This package is designed exclusively for Fabriktor's frontend operational needs and is
|
|
15
|
+
not intended for public usage.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
This project is licensed under the [Apache License 2.0][license-link].
|
|
22
|
+
|
|
23
|
+
[fabriktor-logo]: https://backend.fabriktor.com/filehub/img/gitlab/truck_yellow_filling.gif
|
|
24
|
+
[stars-badge]: https://badgen.net/gitlab/stars/fabriktor/fx?icon=gitlab&color=orange
|
|
25
|
+
[license-badge]: https://badgen.net/badge/license/Apache-2.0/orange
|
|
26
|
+
[pipeline-badge]: https://gitlab.com/fabriktor/fx/badges/main/pipeline.svg
|
|
27
|
+
[starrers-link]: https://gitlab.com/fabriktor/fx/-/starrers
|
|
28
|
+
[license-link]: https://gitlab.com/fabriktor/fx/-/raw/main/LICENSE
|
|
29
|
+
[pipelines-link]: https://gitlab.com/fabriktor/fx/-/pipelines
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type AuthEmailOptions = {
|
|
2
|
+
email: string;
|
|
3
|
+
password: string;
|
|
4
|
+
};
|
|
5
|
+
export type AuthSession = {
|
|
6
|
+
token: string;
|
|
7
|
+
};
|
|
8
|
+
export interface AuthOperator {
|
|
9
|
+
signUp(opts: AuthEmailOptions): Promise<AuthSession>;
|
|
10
|
+
signIn(opts: AuthEmailOptions): Promise<AuthSession>;
|
|
11
|
+
getToken(): Promise<string>;
|
|
12
|
+
signOut(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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 {};
|
package/dist/src/fx.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UsersOperator } from "@fabriktor/client";
|
|
2
|
+
import type { AuthOperator } from "./auth/auth";
|
|
3
|
+
import type { SessionFX, SessionFXOperator } from "./session/session";
|
|
4
|
+
import type { UsersFX, UsersFXOperator } from "./users/users";
|
|
5
|
+
export type FXOptions = {
|
|
6
|
+
base_url: string;
|
|
7
|
+
auth: AuthOperator;
|
|
8
|
+
users: UsersOperator;
|
|
9
|
+
};
|
|
10
|
+
export interface FXOperator {
|
|
11
|
+
users: UsersFXOperator;
|
|
12
|
+
session: SessionFXOperator;
|
|
13
|
+
}
|
|
14
|
+
export declare class FX implements FXOperator {
|
|
15
|
+
users: UsersFX;
|
|
16
|
+
session: SessionFX;
|
|
17
|
+
constructor(opts: FXOptions);
|
|
18
|
+
}
|
|
19
|
+
export declare function newFX(opts: FXOptions): FX;
|
package/dist/src/fx.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import { newSessionFX } from "./session/session";
|
|
7
|
+
import { newUsersFX } from "./users/users";
|
|
8
|
+
export class FX {
|
|
9
|
+
users;
|
|
10
|
+
session;
|
|
11
|
+
constructor(opts) {
|
|
12
|
+
this.users = newUsersFX({
|
|
13
|
+
base_url: opts.base_url,
|
|
14
|
+
auth: opts.auth,
|
|
15
|
+
users: opts.users,
|
|
16
|
+
});
|
|
17
|
+
this.session = newSessionFX({
|
|
18
|
+
auth: opts.auth,
|
|
19
|
+
users: this.users,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function newFX(opts) {
|
|
24
|
+
return new FX(opts);
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InUser, UpsertResult } from "@fabriktor/schema";
|
|
2
|
+
import type { Op } from "@fabriktor/client";
|
|
3
|
+
import type { AuthEmailOptions, AuthOperator } from "../auth/auth";
|
|
4
|
+
import type { UsersFXOperator } from "../users/users";
|
|
5
|
+
export type SignUpAndBootstrapOptions = AuthEmailOptions & {
|
|
6
|
+
in: InUser;
|
|
7
|
+
};
|
|
8
|
+
export type SessionFXOptions = {
|
|
9
|
+
auth: AuthOperator;
|
|
10
|
+
users: UsersFXOperator;
|
|
11
|
+
};
|
|
12
|
+
export interface SessionFXOperator {
|
|
13
|
+
signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<Op<UpsertResult>>;
|
|
14
|
+
signIn(opts: AuthEmailOptions): Promise<void>;
|
|
15
|
+
signOut(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare class SessionFX implements SessionFXOperator {
|
|
18
|
+
private auth;
|
|
19
|
+
private users;
|
|
20
|
+
constructor(opts: SessionFXOptions);
|
|
21
|
+
signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<Op<UpsertResult>>;
|
|
22
|
+
signIn(opts: AuthEmailOptions): Promise<void>;
|
|
23
|
+
signOut(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare function newSessionFX(opts: SessionFXOptions): SessionFX;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 class SessionFX {
|
|
7
|
+
auth;
|
|
8
|
+
users;
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this.auth = opts.auth;
|
|
11
|
+
this.users = opts.users;
|
|
12
|
+
}
|
|
13
|
+
async signUpAndBootstrap(opts) {
|
|
14
|
+
await this.auth.signUp({
|
|
15
|
+
email: opts.email,
|
|
16
|
+
password: opts.password,
|
|
17
|
+
});
|
|
18
|
+
return await this.users.bootstrap({
|
|
19
|
+
in: opts.in,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async signIn(opts) {
|
|
23
|
+
await this.auth.signIn(opts);
|
|
24
|
+
await this.users.sync();
|
|
25
|
+
}
|
|
26
|
+
async signOut() {
|
|
27
|
+
await this.auth.signOut();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function newSessionFX(opts) {
|
|
31
|
+
return new SessionFX(opts);
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { InUser, OperationResult, UpsertResult } from "@fabriktor/schema";
|
|
2
|
+
import type { Op, UsersOperator } from "@fabriktor/client";
|
|
3
|
+
import type { AuthOperator } from "../auth/auth";
|
|
4
|
+
export type UsersFXOptions = {
|
|
5
|
+
base_url: string;
|
|
6
|
+
auth: AuthOperator;
|
|
7
|
+
users: UsersOperator;
|
|
8
|
+
};
|
|
9
|
+
export type BootstrapOptions = {
|
|
10
|
+
in: InUser;
|
|
11
|
+
};
|
|
12
|
+
export interface UsersFXOperator {
|
|
13
|
+
bootstrap(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
|
|
14
|
+
sync(): Promise<OperationResult>;
|
|
15
|
+
sendEmailVerification(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare class UsersFX implements UsersFXOperator {
|
|
18
|
+
private base_url;
|
|
19
|
+
private auth;
|
|
20
|
+
private users;
|
|
21
|
+
constructor(opts: UsersFXOptions);
|
|
22
|
+
bootstrap(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
|
|
23
|
+
sync(): Promise<OperationResult>;
|
|
24
|
+
sendEmailVerification(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export declare function newUsersFX(opts: UsersFXOptions): UsersFX;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 class UsersFX {
|
|
7
|
+
base_url;
|
|
8
|
+
auth;
|
|
9
|
+
users;
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
this.base_url = opts.base_url;
|
|
12
|
+
this.auth = opts.auth;
|
|
13
|
+
this.users = opts.users;
|
|
14
|
+
}
|
|
15
|
+
async bootstrap(opts) {
|
|
16
|
+
const token = await this.auth.getToken();
|
|
17
|
+
return await this.users.bootstrap({
|
|
18
|
+
base_url: this.base_url,
|
|
19
|
+
token,
|
|
20
|
+
in: opts.in,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async sync() {
|
|
24
|
+
const token = await this.auth.getToken();
|
|
25
|
+
return await this.users.sync({
|
|
26
|
+
base_url: this.base_url,
|
|
27
|
+
token,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async sendEmailVerification() {
|
|
31
|
+
const token = await this.auth.getToken();
|
|
32
|
+
return await this.users.sendEmailVerification({
|
|
33
|
+
base_url: this.base_url,
|
|
34
|
+
token,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function newUsersFX(opts) {
|
|
39
|
+
return new UsersFX(opts);
|
|
40
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fabriktor/fx",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/src/index.js"
|
|
8
|
+
},
|
|
9
|
+
"types": "./dist/src/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^6.0.3"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@fabriktor/client": "^0.0.6",
|
|
21
|
+
"@fabriktor/schema": "^0.0.10"
|
|
22
|
+
}
|
|
23
|
+
}
|