@temboplus/afloat 0.1.10 → 0.1.12
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/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/almost_equals.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/assert/1.0.11 → esm/deps/jsr.io/@std/assert/1.0.10}/array_includes.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/assert/1.0.11 → esm/deps/jsr.io/@std/assert/1.0.10}/assert.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/assert/1.0.11 → esm/deps/jsr.io/@std/assert/1.0.10}/assertion_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/fail.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/false.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/greater.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/greater_or_equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/instance_of.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/is_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/less.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/less_or_equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/mod.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/not_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/not_instance_of.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/not_match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/not_strict_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/object_match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/rejects.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/strict_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/string_includes.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/throws.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/unimplemented.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/unreachable.d.ts.map +1 -1
- package/esm/src/features/auth/manager.d.ts +9 -1
- package/esm/src/features/auth/manager.d.ts.map +1 -1
- package/esm/src/features/auth/manager.js +21 -3
- package/esm/src/features/contact/repository.d.ts +12 -1
- package/esm/src/features/contact/repository.d.ts.map +1 -1
- package/esm/src/features/contact/repository.js +25 -11
- package/esm/src/features/files-gen/repository.d.ts +4 -1
- package/esm/src/features/files-gen/repository.d.ts.map +1 -1
- package/esm/src/features/files-gen/repository.js +9 -1
- package/esm/src/features/payout/repository.d.ts +6 -1
- package/esm/src/features/payout/repository.d.ts.map +1 -1
- package/esm/src/features/payout/repository.js +12 -7
- package/esm/src/features/wallet/repository.d.ts +8 -1
- package/esm/src/features/wallet/repository.d.ts.map +1 -1
- package/esm/src/features/wallet/repository.js +17 -8
- package/esm/src/shared/base_repository.d.ts +25 -1
- package/esm/src/shared/base_repository.d.ts.map +1 -1
- package/esm/src/shared/base_repository.js +61 -3
- package/package.json +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/almost_equals.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/assert/1.0.11 → script/deps/jsr.io/@std/assert/1.0.10}/array_includes.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/assert/1.0.11 → script/deps/jsr.io/@std/assert/1.0.10}/assert.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/assert/1.0.11 → script/deps/jsr.io/@std/assert/1.0.10}/assertion_error.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/equal.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/fail.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/false.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/greater.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/greater_or_equal.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/instance_of.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/is_error.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/less.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/less_or_equal.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/mod.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/not_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/not_instance_of.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/not_match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/not_strict_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/object_match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/rejects.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/strict_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/string_includes.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/throws.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/unimplemented.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.11 → 1.0.10}/unreachable.d.ts.map +1 -1
- package/script/src/features/auth/manager.d.ts +9 -1
- package/script/src/features/auth/manager.d.ts.map +1 -1
- package/script/src/features/auth/manager.js +22 -4
- package/script/src/features/contact/repository.d.ts +12 -1
- package/script/src/features/contact/repository.d.ts.map +1 -1
- package/script/src/features/contact/repository.js +31 -17
- package/script/src/features/files-gen/repository.d.ts +4 -1
- package/script/src/features/files-gen/repository.d.ts.map +1 -1
- package/script/src/features/files-gen/repository.js +9 -1
- package/script/src/features/payout/repository.d.ts +6 -1
- package/script/src/features/payout/repository.d.ts.map +1 -1
- package/script/src/features/payout/repository.js +12 -7
- package/script/src/features/wallet/repository.d.ts +8 -1
- package/script/src/features/wallet/repository.d.ts.map +1 -1
- package/script/src/features/wallet/repository.js +17 -8
- package/script/src/shared/base_repository.d.ts +25 -1
- package/script/src/shared/base_repository.d.ts.map +1 -1
- package/script/src/shared/base_repository.js +61 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BaseRepository } from "../../shared/base_repository.js";
|
|
2
2
|
import { contract } from "./contract.js";
|
|
3
3
|
import { AfloatFilesRepo } from "../files-gen/repository.js";
|
|
4
|
-
import { AfloatAuth } from "../auth/manager.js";
|
|
5
4
|
import { Permissions } from "../../models/permission.js";
|
|
6
5
|
import { PermissionError } from "../../errors/index.js";
|
|
7
6
|
/**
|
|
@@ -12,9 +11,15 @@ import { PermissionError } from "../../errors/index.js";
|
|
|
12
11
|
export class WalletRepo extends BaseRepository {
|
|
13
12
|
/**
|
|
14
13
|
* Creates an instance of WalletRepo initialized with the wallet contract.
|
|
14
|
+
* @param {Object} [options] - Optional configuration
|
|
15
|
+
* @param {string} [options.root] - Custom API root URL
|
|
16
|
+
* @param {AfloatAuth} [options.auth] - Auth instance to use
|
|
15
17
|
*/
|
|
16
|
-
constructor() {
|
|
17
|
-
super("wallet", contract
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super("wallet", contract, {
|
|
20
|
+
root: props?.root,
|
|
21
|
+
auth: props?.auth,
|
|
22
|
+
});
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Gets an instance of the file generation repository.
|
|
@@ -22,7 +27,7 @@ export class WalletRepo extends BaseRepository {
|
|
|
22
27
|
* @returns {AfloatFilesRepo} A new instance of AfloatFilesRepo
|
|
23
28
|
*/
|
|
24
29
|
get fileGenRepo() {
|
|
25
|
-
return new AfloatFilesRepo();
|
|
30
|
+
return new AfloatFilesRepo({ auth: this.auth });
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* Retrieves the current available balance for the wallet.
|
|
@@ -31,8 +36,9 @@ export class WalletRepo extends BaseRepository {
|
|
|
31
36
|
* @returns {Promise<number>} The available balance amount
|
|
32
37
|
*/
|
|
33
38
|
async getBalance() {
|
|
39
|
+
const auth = this.getAuthForPermissionCheck();
|
|
34
40
|
const requirePerm = Permissions.Wallet.ViewBalance;
|
|
35
|
-
if (!
|
|
41
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
36
42
|
throw new PermissionError({
|
|
37
43
|
message: "You are not authorized to view the account balance.",
|
|
38
44
|
requiredPermissions: [requirePerm],
|
|
@@ -69,8 +75,9 @@ export class WalletRepo extends BaseRepository {
|
|
|
69
75
|
* @returns {Promise<WalletStatementItem[]>} Array of statement items for the specified period
|
|
70
76
|
*/
|
|
71
77
|
async getStatement(props) {
|
|
78
|
+
const auth = this.getAuthForPermissionCheck();
|
|
72
79
|
const requirePerm = Permissions.Wallet.ViewStatement;
|
|
73
|
-
if (!
|
|
80
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
74
81
|
throw new PermissionError({
|
|
75
82
|
message: "You are not authorized to view the statement.",
|
|
76
83
|
requiredPermissions: [requirePerm],
|
|
@@ -100,8 +107,9 @@ export class WalletRepo extends BaseRepository {
|
|
|
100
107
|
* @returns {Promise<StatementFile>} The generated statement file
|
|
101
108
|
*/
|
|
102
109
|
async genStatement(fileType, props) {
|
|
110
|
+
const auth = this.getAuthForPermissionCheck();
|
|
103
111
|
const requirePerm = Permissions.Wallet.ViewStatement;
|
|
104
|
-
if (!
|
|
112
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
105
113
|
throw new PermissionError({
|
|
106
114
|
message: "You are not authorized to view the statement.",
|
|
107
115
|
requiredPermissions: [requirePerm],
|
|
@@ -120,8 +128,9 @@ export class WalletRepo extends BaseRepository {
|
|
|
120
128
|
* @returns {Promise<StatementFile>} The generated PDF file containing wallet details
|
|
121
129
|
*/
|
|
122
130
|
async genWalletDetailsPDF() {
|
|
131
|
+
const auth = this.getAuthForPermissionCheck();
|
|
123
132
|
const requirePerm = Permissions.Wallet.ViewBalance;
|
|
124
|
-
if (!
|
|
133
|
+
if (!auth.checkPermission(requirePerm)) {
|
|
125
134
|
throw new PermissionError({
|
|
126
135
|
message: "You are not authorized to view the account details.",
|
|
127
136
|
requiredPermissions: [requirePerm],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AppRouter } from "@ts-rest/core";
|
|
2
2
|
import type { InitClientArgs } from "@ts-rest/core";
|
|
3
|
+
import { AfloatAuth } from "../features/auth/manager.js";
|
|
3
4
|
/**
|
|
4
5
|
* BaseRepository
|
|
5
6
|
*
|
|
@@ -28,15 +29,38 @@ export declare class BaseRepository<TContract extends AppRouter> {
|
|
|
28
29
|
* @protected
|
|
29
30
|
*/
|
|
30
31
|
protected root: string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The auth instance to use for authentication
|
|
34
|
+
*
|
|
35
|
+
* @protected
|
|
36
|
+
*/
|
|
37
|
+
protected auth: AfloatAuth | undefined;
|
|
31
38
|
/**
|
|
32
39
|
* Constructs a new instance of `BaseRepository`.
|
|
33
40
|
*
|
|
34
|
-
* @param contract - The "ts-rest" contract
|
|
35
41
|
* @param endpoint - API endpoint
|
|
42
|
+
* @param contract - The "ts-rest" contract
|
|
43
|
+
* @param args - Optional constructor arguments
|
|
44
|
+
* @param args.root - Optional API root URL
|
|
45
|
+
* @param args.auth - Optional auth instance to use
|
|
36
46
|
*/
|
|
37
47
|
constructor(endpoint: string, contract: TContract, args?: {
|
|
38
48
|
root?: string;
|
|
49
|
+
auth?: AfloatAuth;
|
|
39
50
|
});
|
|
51
|
+
/**
|
|
52
|
+
* Gets an auth instance that can be used for permission checks.
|
|
53
|
+
* Follows a fallback strategy to find a valid auth instance.
|
|
54
|
+
*
|
|
55
|
+
* @protected
|
|
56
|
+
* @returns {AfloatAuth} A valid auth instance
|
|
57
|
+
* @throws {Error} If no valid auth instance is available
|
|
58
|
+
*/
|
|
59
|
+
protected getAuthForPermissionCheck(): AfloatAuth;
|
|
60
|
+
/**
|
|
61
|
+
* Gets the initialized client for making API requests.
|
|
62
|
+
* Uses authentication token if available.
|
|
63
|
+
*/
|
|
40
64
|
get client(): { [TKey in keyof TContract]: TContract[TKey] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey], InitClientArgs>> : TContract[TKey] extends AppRouter ? TContract[TKey] extends infer T extends AppRouter ? { [TKey_1 in keyof T]: TContract[TKey][TKey_1] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1], InitClientArgs>> : TContract[TKey][TKey_1] extends AppRouter ? TContract[TKey][TKey_1] extends infer T_1 extends AppRouter ? { [TKey_2 in keyof T_1]: TContract[TKey][TKey_1][TKey_2] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2] extends AppRouter ? TContract[TKey][TKey_1][TKey_2] extends infer T_2 extends AppRouter ? { [TKey_3 in keyof T_2]: TContract[TKey][TKey_1][TKey_2][TKey_3] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3] extends infer T_3 extends AppRouter ? { [TKey_4 in keyof T_3]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends infer T_4 extends AppRouter ? { [TKey_5 in keyof T_4]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends infer T_5 extends AppRouter ? { [TKey_6 in keyof T_5]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends infer T_6 extends AppRouter ? { [TKey_7 in keyof T_6]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends infer T_7 extends AppRouter ? { [TKey_8 in keyof T_7]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends infer T_8 extends AppRouter ? { [TKey_9 in keyof T_8]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends infer T_9 extends AppRouter ? { [TKey_10 in keyof T_9]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10] extends AppRouter ? any : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; };
|
|
41
65
|
/**
|
|
42
66
|
* Handles the API response by checking the HTTP status code and returning the response body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_repository.d.ts","sourceRoot":"","sources":["../../../src/src/shared/base_repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,eAAe,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"base_repository.d.ts","sourceRoot":"","sources":["../../../src/src/shared/base_repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,eAAe,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAe,MAAM,6BAA6B,CAAC;AAEtE;;;;;;;;GAQG;AACH,qBAAa,cAAc,CAAC,SAAS,SAAS,SAAS;IACrD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC;IAE9B;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAEvC;;;;;;;;OAQG;gBACS,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE;QACxD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,UAAU,CAAC;KACnB;IASD;;;;;;;OAOG;IACH,SAAS,CAAC,yBAAyB,IAAI,UAAU;IAgBjD;;;OAGG;IACH,IAAI,MAAM,k0LA+BT;IAED;;;;;;;;;OASG;IACH,cAAc,CAAC,CAAC,EACd,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EACzC,iBAAiB,EAAE,MAAM,GACxB,CAAC;CAgBL"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { initClient } from "@ts-rest/core";
|
|
2
2
|
import { APIError } from "../errors/api_error.js";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
|
4
|
-
import { AfloatAuth } from "../features/auth/
|
|
4
|
+
import { AfloatAuth, AuthContext } from "../features/auth/manager.js";
|
|
5
5
|
/**
|
|
6
6
|
* BaseRepository
|
|
7
7
|
*
|
|
@@ -15,8 +15,11 @@ export class BaseRepository {
|
|
|
15
15
|
/**
|
|
16
16
|
* Constructs a new instance of `BaseRepository`.
|
|
17
17
|
*
|
|
18
|
-
* @param contract - The "ts-rest" contract
|
|
19
18
|
* @param endpoint - API endpoint
|
|
19
|
+
* @param contract - The "ts-rest" contract
|
|
20
|
+
* @param args - Optional constructor arguments
|
|
21
|
+
* @param args.root - Optional API root URL
|
|
22
|
+
* @param args.auth - Optional auth instance to use
|
|
20
23
|
*/
|
|
21
24
|
constructor(endpoint, contract, args) {
|
|
22
25
|
/**
|
|
@@ -52,18 +55,73 @@ export class BaseRepository {
|
|
|
52
55
|
writable: true,
|
|
53
56
|
value: void 0
|
|
54
57
|
});
|
|
58
|
+
/**
|
|
59
|
+
* The auth instance to use for authentication
|
|
60
|
+
*
|
|
61
|
+
* @protected
|
|
62
|
+
*/
|
|
63
|
+
Object.defineProperty(this, "auth", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: void 0
|
|
68
|
+
});
|
|
55
69
|
this.contract = contract;
|
|
56
70
|
this.endpoint = endpoint;
|
|
57
71
|
this.root = args?.root;
|
|
72
|
+
// Use provided auth or try to get the current context
|
|
73
|
+
this.auth = args?.auth || AuthContext.current;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets an auth instance that can be used for permission checks.
|
|
77
|
+
* Follows a fallback strategy to find a valid auth instance.
|
|
78
|
+
*
|
|
79
|
+
* @protected
|
|
80
|
+
* @returns {AfloatAuth} A valid auth instance
|
|
81
|
+
* @throws {Error} If no valid auth instance is available
|
|
82
|
+
*/
|
|
83
|
+
getAuthForPermissionCheck() {
|
|
84
|
+
// Use the instance provided in constructor, or fallback to context
|
|
85
|
+
const auth = this.auth || AuthContext.current;
|
|
86
|
+
if (!auth) {
|
|
87
|
+
try {
|
|
88
|
+
// Last resort: try to get the client singleton
|
|
89
|
+
return AfloatAuth.instance;
|
|
90
|
+
}
|
|
91
|
+
catch (_) {
|
|
92
|
+
throw new Error(`No valid auth instance available for ${this.endpoint} repository`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return auth;
|
|
58
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets the initialized client for making API requests.
|
|
99
|
+
* Uses authentication token if available.
|
|
100
|
+
*/
|
|
59
101
|
get client() {
|
|
60
102
|
const baseUrl = this.root
|
|
61
103
|
? `${this.root}/${this.endpoint}`
|
|
62
104
|
: `https://api.afloat.money/v1/${this.endpoint}`;
|
|
105
|
+
let token = "";
|
|
106
|
+
// Try to get token from the provided auth instance
|
|
107
|
+
if (this.auth) {
|
|
108
|
+
token = this.auth.getUserToken() ?? "";
|
|
109
|
+
}
|
|
110
|
+
// Fall back to singleton if no auth was provided, but handle exceptions
|
|
111
|
+
// that occur in server environments
|
|
112
|
+
else {
|
|
113
|
+
try {
|
|
114
|
+
token = AfloatAuth.instance.getUserToken() ?? "";
|
|
115
|
+
}
|
|
116
|
+
catch (_) {
|
|
117
|
+
// This will fail when called within the server without initialization
|
|
118
|
+
// We'll proceed with an empty token
|
|
119
|
+
}
|
|
120
|
+
}
|
|
63
121
|
const args = {
|
|
64
122
|
baseUrl,
|
|
65
123
|
baseHeaders: {
|
|
66
|
-
"token":
|
|
124
|
+
"token": token,
|
|
67
125
|
"x-request-id": uuidv4(),
|
|
68
126
|
},
|
|
69
127
|
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"almost_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"almost_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/almost_equals.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,MAAM,QAmBb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"array_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/array_includes.ts"],"names":[],"mappings":"AAMA,0FAA0F;AAC1F,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EACzB,GAAG,CAAC,EAAE,MAAM,QAwBb"}
|
package/{esm/deps/jsr.io/@std/assert/1.0.11 → script/deps/jsr.io/@std/assert/1.0.10}/assert.d.ts.map
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/assert.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,CAI5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/equal.ts"],"names":[],"mappings":"AA2FA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAuGrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/equals.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QAkBb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/exists.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAOlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fail.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"fail.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/fail.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAGxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"false.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"false.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/false.ts"],"names":[],"mappings":"AAIA,uDAAuD;AACvD,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK,CAI1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greater.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"greater.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/greater.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,QAMpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greater_or_equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"greater_or_equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QASb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance_of.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"instance_of.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/instance_of.ts"],"names":[],"mappings":"AAIA,sBAAsB;AAEtB,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AACzD,4BAA4B;AAC5B,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAE9B,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAE9C,MAAM,EAAE,OAAO,EACf,YAAY,EAAE,CAAC,EACf,GAAG,SAAK,GACP,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,CA6BnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"is_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/is_error.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EACnD,KAAK,EAAE,OAAO,EAEd,UAAU,CAAC,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC/C,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAC5B,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,KAAK,IAAI,CAAC,CA8BpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"less.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"less.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/less.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,QAMjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"less_or_equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"less_or_equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/less_or_equal.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QASb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/match.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,QAMb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/mod.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"not_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/not_equals.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,QAUtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not_instance_of.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"not_instance_of.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/not_instance_of.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACtC,MAAM,EAAE,CAAC,EAET,cAAc,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAClD,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAKjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not_match.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"not_match.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/not_match.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,QAMb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not_strict_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"not_strict_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QAYb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object_match.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"object_match.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/object_match.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAE/B,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAChC,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EACtC,GAAG,CAAC,EAAE,MAAM,GACX,IAAI,CAUN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rejects.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"rejects.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/rejects.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAAC;AACpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EACnD,EAAE,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC,EAE9B,UAAU,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC9C,WAAW,CAAC,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"strict_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/strict_equals.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,IAAI,CAAC,CA+BrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"string_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/string_includes.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,QAMb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throws.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"throws.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/throws.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,OAAO,EACjB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC;AACX;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAClD,EAAE,EAAE,MAAM,OAAO,EAEjB,UAAU,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC9C,WAAW,CAAC,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unimplemented.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"unimplemented.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/unimplemented.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAGjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unreachable.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"unreachable.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/unreachable.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAG/C"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { User } from "../../models/index.js";
|
|
2
2
|
import type { Permission } from "../../models/permission.js";
|
|
3
|
+
/**
|
|
4
|
+
* Global context to hold the current auth instance reference.
|
|
5
|
+
* This provides a way to access the auth instance across the application
|
|
6
|
+
* without directly coupling to the singleton pattern.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AuthContext: {
|
|
9
|
+
current: AfloatAuth | undefined;
|
|
10
|
+
};
|
|
3
11
|
/**
|
|
4
12
|
* Main authentication class that works in both client and server environments.
|
|
5
13
|
* Provides authentication functionality and user management.
|
|
@@ -12,7 +20,7 @@ export declare class AfloatAuth {
|
|
|
12
20
|
/** client AfloatAuth instance */
|
|
13
21
|
private static _instance;
|
|
14
22
|
/**
|
|
15
|
-
* Private constructor to
|
|
23
|
+
* Private constructor to maintain control over instantiation.
|
|
16
24
|
* @param {AuthStore} store - The auth store implementation to use
|
|
17
25
|
* @param {TokenHandler} tokenHandler - The token handler implementation to use
|
|
18
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAU7D;;;GAGG;AACH,qBAAa,UAAU;IACrB,oCAAoC;IACpC,OAAO,CAAC,KAAK,CAAY;IAEzB,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAAe;IAEnC,iCAAiC;IACjC,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2B;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/src/features/auth/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAU7D;;;;GAIG;AACH,eAAO,MAAM,WAAW;aAEA,UAAU,GAAG,SAAS;CAC7C,CAAC;AAEF;;;GAGG;AACH,qBAAa,UAAU;IACrB,oCAAoC;IACpC,OAAO,CAAC,KAAK,CAAY;IAEzB,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAAe;IAEnC,iCAAiC;IACjC,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2B;IAEnD;;;;OAIG;IACH,OAAO;IAKP;;;;;;;;;;;;OAYG;IACH,WAAkB,QAAQ,IAAI,UAAU,CAYvC;IAED;;;;;;;OAOG;WACiB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA8BxE;;;;OAIG;IACH,OAAO,KAAK,IAAI,GAEf;IAED;;;OAGG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC;;;OAGG;IACH,IAAI,WAAW,IAAI,IAAI,GAAG,SAAS,CAElC;IAED;;;;OAIG;IACH,cAAc,IAAI,IAAI,GAAG,SAAS;IAIlC;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAI1C;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3D;;;;;;OAMG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvE;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,OAAO,CAAC,cAAc;CAIvB"}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AfloatAuth = void 0;
|
|
3
|
+
exports.AfloatAuth = exports.AuthContext = void 0;
|
|
4
4
|
const repository_js_1 = require("./repository.js");
|
|
5
5
|
const client_store_js_1 = require("./storage/client_store.js");
|
|
6
6
|
const client_token_handler_js_1 = require("./storage/client_token_handler.js");
|
|
7
7
|
const server_store_js_1 = require("./storage/server_store.js");
|
|
8
8
|
const server_token_handler_js_1 = require("./storage/server_token_handler.js");
|
|
9
|
+
/**
|
|
10
|
+
* Global context to hold the current auth instance reference.
|
|
11
|
+
* This provides a way to access the auth instance across the application
|
|
12
|
+
* without directly coupling to the singleton pattern.
|
|
13
|
+
*/
|
|
14
|
+
exports.AuthContext = {
|
|
15
|
+
// Default undefined state - will be set during initialization
|
|
16
|
+
current: undefined,
|
|
17
|
+
};
|
|
9
18
|
/**
|
|
10
19
|
* Main authentication class that works in both client and server environments.
|
|
11
20
|
* Provides authentication functionality and user management.
|
|
12
21
|
*/
|
|
13
22
|
class AfloatAuth {
|
|
14
23
|
/**
|
|
15
|
-
* Private constructor to
|
|
24
|
+
* Private constructor to maintain control over instantiation.
|
|
16
25
|
* @param {AuthStore} store - The auth store implementation to use
|
|
17
26
|
* @param {TokenHandler} tokenHandler - The token handler implementation to use
|
|
18
27
|
*/
|
|
@@ -48,7 +57,12 @@ class AfloatAuth {
|
|
|
48
57
|
* const serverAuth = await AfloatAuth.initializeServer(token);
|
|
49
58
|
*/
|
|
50
59
|
static get instance() {
|
|
51
|
-
|
|
60
|
+
if (!AfloatAuth._instance) {
|
|
61
|
+
AfloatAuth._instance = new AfloatAuth((0, client_store_js_1.createClientStore)(), client_token_handler_js_1.ClientTokenHandler.instance);
|
|
62
|
+
// Set as current instance for global access
|
|
63
|
+
exports.AuthContext.current = AfloatAuth._instance;
|
|
64
|
+
}
|
|
65
|
+
return AfloatAuth._instance;
|
|
52
66
|
}
|
|
53
67
|
/**
|
|
54
68
|
* Creates a new server-side instance of AfloatAuth.
|
|
@@ -69,10 +83,14 @@ class AfloatAuth {
|
|
|
69
83
|
const user = await tokenHandler.constructUser();
|
|
70
84
|
store.setUser(user);
|
|
71
85
|
// Create and initialize auth instance
|
|
72
|
-
|
|
86
|
+
const auth = new AfloatAuth(store, tokenHandler);
|
|
87
|
+
// Set as current instance for global access
|
|
88
|
+
exports.AuthContext.current = auth;
|
|
89
|
+
return auth;
|
|
73
90
|
}
|
|
74
91
|
catch (error) {
|
|
75
92
|
if (error instanceof Error) {
|
|
93
|
+
console.log(error.stack);
|
|
76
94
|
throw new Error(`Failed to initialize server auth: ${error.message}`);
|
|
77
95
|
}
|
|
78
96
|
throw new Error("Failed to initialize server auth");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseRepository } from "../../shared/base_repository.js";
|
|
2
2
|
import { contract } from "./contract.js";
|
|
3
3
|
import { Contact, type ContactInput } from "../../models/contact/index.js";
|
|
4
|
+
import type { AfloatAuth } from "../auth/manager.js";
|
|
4
5
|
/**
|
|
5
6
|
* Repository class for managing `Contact` data through API interactions.
|
|
6
7
|
* Extends the `BaseRepository` to leverage shared functionality.
|
|
@@ -8,12 +9,19 @@ import { Contact, type ContactInput } from "../../models/contact/index.js";
|
|
|
8
9
|
export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
9
10
|
/**
|
|
10
11
|
* Creates an instance of `ContactRepository` using the contact contract.
|
|
12
|
+
* @param {Object} [props] - Optional constructor properties
|
|
13
|
+
* @param {AfloatAuth} [props.auth] - Optional auth instance to use
|
|
14
|
+
* @param {string} [props.root] - Optional API root URL
|
|
11
15
|
*/
|
|
12
|
-
constructor(
|
|
16
|
+
constructor(props?: {
|
|
17
|
+
auth?: AfloatAuth;
|
|
18
|
+
root?: string;
|
|
19
|
+
});
|
|
13
20
|
/**
|
|
14
21
|
* Creates a new contact record.
|
|
15
22
|
* @param {ContactInput} input - The data required to create a new contact.
|
|
16
23
|
* @returns {Promise<Contact>} A promise that resolves to the newly created contact.
|
|
24
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
17
25
|
* @throws {APIError} If the response status code is not 201.
|
|
18
26
|
*/
|
|
19
27
|
create(input: ContactInput): Promise<Contact>;
|
|
@@ -22,6 +30,7 @@ export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
|
22
30
|
* @param {string} id - The unique identifier of the contact to edit.
|
|
23
31
|
* @param {ContactInput} input - The data to update the contact with.
|
|
24
32
|
* @returns {Promise<Contact>} A promise that resolves to the updated contact.
|
|
33
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
25
34
|
* @throws {APIError} If the response status code is not 200.
|
|
26
35
|
*/
|
|
27
36
|
edit(id: string, input: ContactInput): Promise<Contact>;
|
|
@@ -29,6 +38,7 @@ export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
|
29
38
|
* Deletes a contact record by ID.
|
|
30
39
|
* @param {string} id - The unique identifier of the contact to remove.
|
|
31
40
|
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
41
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
32
42
|
* @throws {APIError} If the response status code is not 200.
|
|
33
43
|
*/
|
|
34
44
|
remove(id: string): Promise<void>;
|
|
@@ -37,6 +47,7 @@ export declare class ContactRepository extends BaseRepository<typeof contract> {
|
|
|
37
47
|
* Results are ordered in descending order by default.
|
|
38
48
|
*
|
|
39
49
|
* @returns {Promise<Contact[]>} A promise that resolves to an array of contacts.
|
|
50
|
+
* @throws {PermissionError} If the user lacks required permissions
|
|
40
51
|
* @throws {APIError} If the response status code is not 200 or the range is invalid.
|
|
41
52
|
* @example
|
|
42
53
|
* const repository = new ContactRepository();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/contact/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,OAAO,EAEP,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/contact/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,OAAO,EAEP,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,OAAO,QAAQ,CAAC;IACpE;;;;;OAKG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAIxD;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBnD;;;;;;;OAOG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAmB7D;;;;;;OAMG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAevC;;;;;;;;;;OAUG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAgBnC"}
|