@stacksjs/browser 0.70.36 → 0.70.42

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.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Auto-initialize the browser API configuration
3
+ * This runs automatically when the module is imported
4
+ */
5
+ declare function autoInit(): void;
6
+ // Export for manual re-initialization if needed
7
+ export { autoInit, isInitialized };
@@ -9,8 +9,8 @@ export type {
9
9
  // `/browser` subpath — re-export it from there. The runtime code in this file
10
10
  // uses only the `/browser` entry, so server-only code paths are still avoided.
11
11
  export type { BrowserConfig } from 'bun-query-builder';
12
- export * from './composables';
13
- export * from './utils';
12
+ export * from './composables/index';
13
+ export * from './utils/index';
14
14
  export * from './model-loader';
15
15
  // Re-export browser query builder from bun-query-builder.
16
16
  //
@@ -0,0 +1,55 @@
1
+ import type { Ref } from '@stacksjs/stx';
2
+ export declare function isGeneralError(error: ResponseError): error is { error: string };
3
+ export declare interface ValidationError {
4
+ [key: string]: {
5
+ message: string
6
+ }[]
7
+ }
8
+ export declare interface RegisterError {
9
+ errors: ResponseError
10
+ }
11
+ export declare interface RegisterResponse {
12
+ data: {
13
+ token: string
14
+ user: {
15
+ id: number
16
+ email: string
17
+ name: string
18
+ }
19
+ }
20
+ }
21
+ export declare interface Response<T> {
22
+ errors: ResponseError
23
+ data: T
24
+ }
25
+ export declare interface AuthUser {
26
+ email: string
27
+ password: string
28
+ }
29
+ export declare interface ErrorResponse {
30
+ message: string
31
+ }
32
+ export declare interface UserData {
33
+ id: number
34
+ email: string
35
+ name: string
36
+ }
37
+ export declare interface MeResponse {
38
+ user: UserData
39
+ }
40
+ export declare interface AuthComposable {
41
+ isAuthenticated: Ref<boolean>
42
+ user: Ref<UserData | null>
43
+ login: (user: AuthUser) => Promise<LoginResponse | LoginError>
44
+ register: (user: AuthUser) => Promise<RegisterResponse | RegisterError>
45
+ fetchAuthUser: () => Promise<UserData | null>
46
+ checkAuthentication: () => Promise<boolean>
47
+ logout: () => void
48
+ getToken: () => string | null
49
+ token: Ref<string | null>
50
+ }
51
+ export type ResponseError = {
52
+ error: string
53
+ } | ValidationError;
54
+ export type LoginError = RegisterError;
55
+ export type LoginResponse = RegisterResponse;
@@ -1,3 +1,25 @@
1
+ declare function get(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
2
+ declare function post(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
3
+ declare function patch(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
4
+ declare function put(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
5
+ declare function destroy(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
6
+ declare function setToken(authToken: string): void;
7
+ declare const baseURL: '/';
8
+ export declare const Fetch: ApiFetch;
9
+ declare interface Params {
10
+ [key: string]: Primitive | Primitive[] | Params | Params[]
11
+ }
12
+ declare interface ApiFetch {
13
+ get: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
14
+ post: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
15
+ destroy: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
16
+ patch: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
17
+ put: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
18
+ setToken: (authToken: string) => void
19
+ baseURL: '/' | string
20
+ loading: boolean
21
+ token: string
22
+ }
1
23
  /**
2
24
  * Loose payload type for `Fetch.{get,post,patch,put,destroy}`.
3
25
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/browser",
3
3
  "type": "module",
4
- "version": "0.70.36",
4
+ "version": "0.70.42",
5
5
  "description": "Stacks core frontend/browser functionalities.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -47,7 +47,7 @@
47
47
  "prepublishOnly": "bun run build"
48
48
  },
49
49
  "dependencies": {
50
- "@stacksjs/composables": "0.70.30",
50
+ "@stacksjs/composables": "^0.70.42",
51
51
  "@stacksjs/stx": "^0.2.40",
52
52
  "@stripe/stripe-js": "^9.0.0",
53
53
  "bun-query-builder": "^0.1.21",
@@ -55,6 +55,6 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "better-dx": "^0.2.12",
58
- "@stacksjs/utils": "0.70.30"
58
+ "@stacksjs/utils": "^0.70.42"
59
59
  }
60
60
  }