@mframework/core 0.0.3 → 0.0.4

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/dist/index.d.ts CHANGED
@@ -65,6 +65,7 @@ export * from './src/types/sdk/endpoint';
65
65
  export * from './src/types/sdk/request';
66
66
  export * from './src/types/sdk/response';
67
67
  export * from './src/types/sdk/adapter';
68
+ export { sdk } from './src/client';
68
69
  export * from './src/normalizers/factories';
69
70
  export * from './src/normalizers/factories/apiClientFactory';
70
71
  export * from './src/normalizers/utils/context';
@@ -75,3 +76,5 @@ export * from './src/normalizers/utils/logger';
75
76
  export * from './src/normalizers/utils/shared';
76
77
  export * from './src/normalizers/utils/ssr';
77
78
  export * from './src/normalizers/utils/wrap';
79
+ export * from './src/client';
80
+ export * from './src/registry';
package/dist/index.js CHANGED
@@ -76,6 +76,8 @@ export * from './src/types/sdk/endpoint';
76
76
  export * from './src/types/sdk/request';
77
77
  export * from './src/types/sdk/response';
78
78
  export * from './src/types/sdk/adapter';
79
+ // Explicit SDK runtime export
80
+ export { sdk } from './src/client';
79
81
  // Normalizers
80
82
  export * from './src/normalizers/factories';
81
83
  export * from './src/normalizers/factories/apiClientFactory';
@@ -87,3 +89,9 @@ export * from './src/normalizers/utils/logger';
87
89
  export * from './src/normalizers/utils/shared';
88
90
  export * from './src/normalizers/utils/ssr';
89
91
  export * from './src/normalizers/utils/wrap';
92
+ export * from './src/client';
93
+ // Note: adapters re-exports may cause type name collisions with dedicated types
94
+ // (e.g. CommerceAdapter). Avoid re-exporting the entire adapters folder here;
95
+ // import specific adapter helpers from `@mframework/core/src/adapters` when
96
+ // needed instead.
97
+ export * from './src/registry';
@@ -1,9 +1,13 @@
1
1
  import { BaseAdapterConfig } from './common';
2
+ import type { LoginInput, RegisterInput, Result, Session, User } from '../types';
2
3
  export interface AuthAdapterConfig extends BaseAdapterConfig {
3
4
  provider: 'custom' | 'auth0' | 'cognito' | string;
4
5
  }
5
6
  export interface AuthAdapter {
6
- login(payload: unknown): Promise<unknown>;
7
- logout(): Promise<void>;
8
- getSession(): Promise<unknown | null>;
7
+ login(input: LoginInput): Promise<Result<Session>>;
8
+ register?(input: RegisterInput): Promise<Result<Session>>;
9
+ logout(): Promise<Result<true>>;
10
+ getSession(): Promise<Result<Session | null>>;
11
+ refresh?(): Promise<Result<Session>>;
12
+ getUser?(): Promise<Result<User>>;
9
13
  }
@@ -0,0 +1,19 @@
1
+ import type { Result } from '../types';
2
+ import type { CommerceProduct } from '../types/commerce/product';
3
+ import type { CommerceCart } from '../types/commerce/cart';
4
+ type Product = CommerceProduct;
5
+ type Cart = CommerceCart;
6
+ export interface CommerceAdapter {
7
+ getProduct(id: string): Promise<Result<Product>>;
8
+ listProducts(): Promise<Result<Product[]>>;
9
+ getCart(): Promise<Result<Cart>>;
10
+ addToCart(item: {
11
+ productId: string;
12
+ variantId?: string;
13
+ quantity: number;
14
+ }): Promise<Result<Cart>>;
15
+ updateCartItem(itemId: string, quantity: number): Promise<Result<Cart>>;
16
+ removeCartItem(itemId: string): Promise<Result<Cart>>;
17
+ clearCart(): Promise<Result<Cart>>;
18
+ }
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export * from './transport';
2
+ export * from './auth';
3
+ export * from './commerce';
4
+ export * from './search';
5
+ export * from './cart';
6
+ export * from './catalog';
7
+ export * from './common';
8
+ export * from './lists';
@@ -0,0 +1,8 @@
1
+ export * from './transport';
2
+ export * from './auth';
3
+ export * from './commerce';
4
+ export * from './search';
5
+ export * from './cart';
6
+ export * from './catalog';
7
+ export * from './common';
8
+ export * from './lists';
@@ -1,21 +1,11 @@
1
1
  import { BaseAdapter, BaseAdapterConfig } from './common';
2
+ import type { Result, Facet, SearchQuery, SearchResult } from '../types';
2
3
  export interface SearchAdapterConfig extends BaseAdapterConfig {
3
4
  provider: string;
4
5
  }
5
- export interface SearchQuery {
6
- term: string;
7
- filters?: Record<string, unknown>;
8
- page?: number;
9
- pageSize?: number;
10
- }
11
- export interface SearchResult<TItem = unknown> {
12
- items: TItem[];
13
- total: number;
14
- page: number;
15
- pageSize: number;
16
- }
17
6
  export interface SearchAdapter<TItem = unknown> extends BaseAdapter<SearchAdapterConfig> {
18
7
  type: 'search';
19
8
  search(query: SearchQuery): Promise<SearchResult<TItem>>;
20
9
  suggest?(term: string): Promise<string[]>;
10
+ facets(query: SearchQuery): Promise<Result<Facet[]>>;
21
11
  }
@@ -0,0 +1,4 @@
1
+ import type { RequestOptions, APIResponse } from '../types';
2
+ export interface TransportAdapter {
3
+ request<T = unknown>(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string, options?: RequestOptions): Promise<APIResponse<T>>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ export declare const sdk: {
2
+ auth: {
3
+ login: (input: {
4
+ email: string;
5
+ password: string;
6
+ }) => Promise<import("../types").Result<import("../types").Session>> | undefined;
7
+ register: (input: {
8
+ email: string;
9
+ password: string;
10
+ confirmPassword: string;
11
+ }) => Promise<import("../types").Result<import("../types").Session>> | undefined;
12
+ logout: () => Promise<import("../types").Result<true>> | undefined;
13
+ getSession: () => Promise<import("../types").Result<import("../types").Session | null>> | undefined;
14
+ refresh: () => Promise<import("../types").Result<import("../types").Session>> | undefined;
15
+ getUser: () => Promise<import("../types").Result<import("../types").User>> | undefined;
16
+ };
17
+ commerce: {
18
+ getProduct: (id: string) => Promise<import("../types").Result<import("../types").CommerceProduct>> | undefined;
19
+ listProducts: () => Promise<import("../types").Result<import("../types").CommerceProduct[]>> | undefined;
20
+ getCart: () => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
21
+ addToCart: (item: {
22
+ productId: string;
23
+ variantId?: string;
24
+ quantity: number;
25
+ }) => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
26
+ updateCartItem: (id: string, qty: number) => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
27
+ removeCartItem: (id: string) => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
28
+ clearCart: () => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
29
+ };
30
+ search: {
31
+ search: (query: import("../types").SearchQuery) => Promise<import("../types").SearchResult<unknown>> | undefined;
32
+ facets: (query: import("../types").SearchQuery) => Promise<import("../types").Result<import("../types").Facet[]>> | undefined;
33
+ };
34
+ readonly transport: import("../adapters").TransportAdapter;
35
+ };
@@ -0,0 +1,12 @@
1
+ import { auth } from '../registry/auth';
2
+ import { commerce } from '../registry/commerce';
3
+ import { search } from '../registry/search';
4
+ import { getRegistry } from '../registry';
5
+ export const sdk = {
6
+ auth,
7
+ commerce,
8
+ search,
9
+ get transport() {
10
+ return getRegistry().transport;
11
+ }
12
+ };
@@ -0,0 +1,15 @@
1
+ export declare const auth: {
2
+ login: (input: {
3
+ email: string;
4
+ password: string;
5
+ }) => Promise<import("../types").Result<import("../types").Session>> | undefined;
6
+ register: (input: {
7
+ email: string;
8
+ password: string;
9
+ confirmPassword: string;
10
+ }) => Promise<import("../types").Result<import("../types").Session>> | undefined;
11
+ logout: () => Promise<import("../types").Result<true>> | undefined;
12
+ getSession: () => Promise<import("../types").Result<import("../types").Session | null>> | undefined;
13
+ refresh: () => Promise<import("../types").Result<import("../types").Session>> | undefined;
14
+ getUser: () => Promise<import("../types").Result<import("../types").User>> | undefined;
15
+ };
@@ -0,0 +1,9 @@
1
+ import { getRegistry } from './index';
2
+ export const auth = {
3
+ login: (input) => getRegistry().auth?.login?.(input),
4
+ register: (input) => getRegistry().auth?.register?.(input),
5
+ logout: () => getRegistry().auth?.logout?.(),
6
+ getSession: () => getRegistry().auth?.getSession?.(),
7
+ refresh: () => getRegistry().auth?.refresh?.(),
8
+ getUser: () => getRegistry().auth?.getUser?.()
9
+ };
@@ -0,0 +1,13 @@
1
+ export declare const commerce: {
2
+ getProduct: (id: string) => Promise<import("../types").Result<import("../types").CommerceProduct>> | undefined;
3
+ listProducts: () => Promise<import("../types").Result<import("../types").CommerceProduct[]>> | undefined;
4
+ getCart: () => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
5
+ addToCart: (item: {
6
+ productId: string;
7
+ variantId?: string;
8
+ quantity: number;
9
+ }) => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
10
+ updateCartItem: (id: string, qty: number) => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
11
+ removeCartItem: (id: string) => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
12
+ clearCart: () => Promise<import("../types").Result<import("../types").CommerceCart>> | undefined;
13
+ };
@@ -0,0 +1,10 @@
1
+ import { getRegistry } from './index';
2
+ export const commerce = {
3
+ getProduct: (id) => getRegistry().commerce?.getProduct(id),
4
+ listProducts: () => getRegistry().commerce?.listProducts(),
5
+ getCart: () => getRegistry().commerce?.getCart(),
6
+ addToCart: (item) => getRegistry().commerce?.addToCart(item),
7
+ updateCartItem: (id, qty) => getRegistry().commerce?.updateCartItem(id, qty),
8
+ removeCartItem: (id) => getRegistry().commerce?.removeCartItem(id),
9
+ clearCart: () => getRegistry().commerce?.clearCart()
10
+ };
@@ -0,0 +1,12 @@
1
+ import type { TransportAdapter, AuthAdapter, CommerceAdapter, SearchAdapter } from '../adapters';
2
+ export interface SDKRegistry {
3
+ transport: TransportAdapter;
4
+ auth?: AuthAdapter;
5
+ commerce?: CommerceAdapter;
6
+ search?: SearchAdapter;
7
+ }
8
+ export declare const setTransport: (adapter: TransportAdapter) => void;
9
+ export declare const setAuthAdapter: (adapter: AuthAdapter) => void;
10
+ export declare const setCommerceAdapter: (adapter: CommerceAdapter) => void;
11
+ export declare const setSearchAdapter: (adapter: SearchAdapter) => void;
12
+ export declare const getRegistry: () => SDKRegistry;
@@ -0,0 +1,19 @@
1
+ const registry = {};
2
+ export const setTransport = (adapter) => {
3
+ registry.transport = adapter;
4
+ };
5
+ export const setAuthAdapter = (adapter) => {
6
+ registry.auth = adapter;
7
+ };
8
+ export const setCommerceAdapter = (adapter) => {
9
+ registry.commerce = adapter;
10
+ };
11
+ export const setSearchAdapter = (adapter) => {
12
+ registry.search = adapter;
13
+ };
14
+ export const getRegistry = () => {
15
+ if (!registry.transport) {
16
+ throw new Error('Transport adapter not set');
17
+ }
18
+ return registry;
19
+ };
@@ -0,0 +1,5 @@
1
+ import type { SearchQuery } from '../types';
2
+ export declare const search: {
3
+ search: (query: SearchQuery) => Promise<import("../types").SearchResult<unknown>> | undefined;
4
+ facets: (query: SearchQuery) => Promise<import("../types").Result<import("../types").Facet[]>> | undefined;
5
+ };
@@ -0,0 +1,5 @@
1
+ import { getRegistry } from './index';
2
+ export const search = {
3
+ search: (query) => getRegistry().search?.search(query),
4
+ facets: (query) => getRegistry().search?.facets(query)
5
+ };
@@ -9,6 +9,7 @@ export * from './auth/session';
9
9
  export * from './auth/providers';
10
10
  export * from './auth/inputs';
11
11
  export * from './auth/adapter';
12
+ export { AuthSession as Session } from './auth/session';
12
13
  export * from './commerce/product';
13
14
  export * from './commerce/cart';
14
15
  export * from './commerce/order';
package/index.ts CHANGED
@@ -104,6 +104,8 @@ export * from './src/types/sdk/endpoint'
104
104
  export * from './src/types/sdk/request'
105
105
  export * from './src/types/sdk/response'
106
106
  export * from './src/types/sdk/adapter'
107
+ // Explicit SDK runtime export
108
+ export { sdk } from './src/client'
107
109
 
108
110
  // Normalizers
109
111
  export * from './src/normalizers/factories'
@@ -118,5 +120,8 @@ export * from './src/normalizers/utils/ssr'
118
120
  export * from './src/normalizers/utils/wrap'
119
121
 
120
122
  export * from './src/client';
121
- export * from './src/adapters';
123
+ // Note: adapters re-exports may cause type name collisions with dedicated types
124
+ // (e.g. CommerceAdapter). Avoid re-exporting the entire adapters folder here;
125
+ // import specific adapter helpers from `@mframework/core/src/adapters` when
126
+ // needed instead.
122
127
  export * from './src/registry';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mframework/core",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "The core and robust API module serving as a wrapper around Prisma for the M Framework.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -1,4 +1,5 @@
1
1
  import { BaseAdapterConfig } from './common'
2
+ import type { LoginInput, RegisterInput, Result, Session, User } from '../types'
2
3
 
3
4
  export interface AuthAdapterConfig extends BaseAdapterConfig {
4
5
  provider: 'custom' | 'auth0' | 'cognito' | string
@@ -6,9 +7,9 @@ export interface AuthAdapterConfig extends BaseAdapterConfig {
6
7
 
7
8
  export interface AuthAdapter {
8
9
  login(input: LoginInput): Promise<Result<Session>>
9
- register(input: RegisterInput): Promise<Result<Session>>
10
+ register?(input: RegisterInput): Promise<Result<Session>>
10
11
  logout(): Promise<Result<true>>
11
- getSession(): Promise<Result<Session>>
12
- refresh(): Promise<Result<Session>>
13
- getUser(): Promise<Result<User>>
12
+ getSession(): Promise<Result<Session | null>>
13
+ refresh?(): Promise<Result<Session>>
14
+ getUser?(): Promise<Result<User>>
14
15
  }
@@ -1,3 +1,10 @@
1
+ import type { Result } from '../types'
2
+ import type { CommerceProduct, CommerceVariant } from '../types/commerce/product'
3
+ import type { CommerceCart } from '../types/commerce/cart'
4
+
5
+ type Product = CommerceProduct
6
+ type Cart = CommerceCart
7
+
1
8
  export interface CommerceAdapter {
2
9
  getProduct(id: string): Promise<Result<Product>>
3
10
  listProducts(): Promise<Result<Product[]>>
@@ -2,7 +2,6 @@ export * from './transport'
2
2
  export * from './auth'
3
3
  export * from './commerce'
4
4
  export * from './search'
5
- export * from './registry'
6
5
  export * from './cart'
7
6
  export * from './catalog'
8
7
  export * from './common'
@@ -1,23 +1,10 @@
1
1
  import { BaseAdapter, BaseAdapterConfig } from './common'
2
+ import type { Result, Facet, SearchQuery, SearchResult } from '../types'
2
3
 
3
4
  export interface SearchAdapterConfig extends BaseAdapterConfig {
4
5
  provider: string
5
6
  }
6
7
 
7
- export interface SearchQuery {
8
- term: string
9
- filters?: Record<string, unknown>
10
- page?: number
11
- pageSize?: number
12
- }
13
-
14
- export interface SearchResult<TItem = unknown> {
15
- items: TItem[]
16
- total: number
17
- page: number
18
- pageSize: number
19
- }
20
-
21
8
  export interface SearchAdapter<TItem = unknown>
22
9
  extends BaseAdapter<SearchAdapterConfig> {
23
10
  type: 'search'
@@ -1,3 +1,5 @@
1
+ import type { RequestOptions, APIResponse } from '../types'
2
+
1
3
  export interface TransportAdapter {
2
4
  request<T = unknown>(
3
5
  method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
@@ -1,10 +1,10 @@
1
1
  import { getRegistry } from './index'
2
2
 
3
3
  export const auth = {
4
- login: (input: { email: string; password: string }) => getRegistry().auth?.login(input),
5
- register: (input: { email: string; password: string; confirmPassword: string }) => getRegistry().auth?.register(input),
6
- logout: () => getRegistry().auth?.logout(),
7
- getSession: () => getRegistry().auth?.getSession(),
8
- refresh: () => getRegistry().auth?.refresh(),
9
- getUser: () => getRegistry().auth?.getUser()
4
+ login: (input: { email: string; password: string }) => getRegistry().auth?.login?.(input),
5
+ register: (input: { email: string; password: string; confirmPassword: string }) => getRegistry().auth?.register?.(input),
6
+ logout: () => getRegistry().auth?.logout?.(),
7
+ getSession: () => getRegistry().auth?.getSession?.(),
8
+ refresh: () => getRegistry().auth?.refresh?.(),
9
+ getUser: () => getRegistry().auth?.getUser?.()
10
10
  }
@@ -1,4 +1,5 @@
1
1
  import { getRegistry } from './index'
2
+ import type { SearchQuery } from '../types'
2
3
 
3
4
  export const search = {
4
5
  search: (query: SearchQuery) => getRegistry().search?.search(query),
@@ -12,6 +12,8 @@ export * from './auth/session'
12
12
  export * from './auth/providers'
13
13
  export * from './auth/inputs'
14
14
  export * from './auth/adapter'
15
+ // Compatibility alias: expose `Session` name expected by adapters
16
+ export { AuthSession as Session } from './auth/session'
15
17
 
16
18
  // Commerce
17
19
  export * from './commerce/product'