@meeovi/sdk 1.0.0

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,9 @@
1
+ import type { User, Session, Result, LoginInput, RegisterInput } from '@meeovi/types';
2
+ export interface AuthAdapter {
3
+ login(input: LoginInput): Promise<Result<Session>>;
4
+ register(input: RegisterInput): Promise<Result<Session>>;
5
+ logout(): Promise<Result<true>>;
6
+ getSession(): Promise<Result<Session>>;
7
+ refresh(): Promise<Result<Session>>;
8
+ getUser(): Promise<Result<User>>;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Product, Cart, Result } from '@meeovi/types';
2
+ export interface CommerceAdapter {
3
+ getProduct(id: string): Promise<Result<Product>>;
4
+ listProducts(): Promise<Result<Product[]>>;
5
+ getCart(): Promise<Result<Cart>>;
6
+ addToCart(item: {
7
+ productId: string;
8
+ variantId?: string;
9
+ quantity: number;
10
+ }): Promise<Result<Cart>>;
11
+ updateCartItem(itemId: string, quantity: number): Promise<Result<Cart>>;
12
+ removeCartItem(itemId: string): Promise<Result<Cart>>;
13
+ clearCart(): Promise<Result<Cart>>;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './transport';
2
+ export * from './auth';
3
+ export * from './commerce';
4
+ export * from './search';
@@ -0,0 +1,4 @@
1
+ export * from './transport';
2
+ export * from './auth';
3
+ export * from './commerce';
4
+ export * from './search';
@@ -0,0 +1,5 @@
1
+ import type { SearchQuery, SearchResult, Facet, Result } from '@meeovi/types';
2
+ export interface SearchAdapter {
3
+ search<T = unknown>(query: SearchQuery): Promise<Result<SearchResult<T>>>;
4
+ facets(query: SearchQuery): Promise<Result<Facet[]>>;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { RequestOptions, APIResponse } from '@meeovi/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("@meeovi/types").Result<import("@meeovi/types").Session>> | undefined;
7
+ register: (input: {
8
+ email: string;
9
+ password: string;
10
+ confirmPassword: string;
11
+ }) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Session>> | undefined;
12
+ logout: () => Promise<import("@meeovi/types").Result<true>> | undefined;
13
+ getSession: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Session>> | undefined;
14
+ refresh: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Session>> | undefined;
15
+ getUser: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").User>> | undefined;
16
+ };
17
+ commerce: {
18
+ getProduct: (id: string) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Product>> | undefined;
19
+ listProducts: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Product[]>> | undefined;
20
+ getCart: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
21
+ addToCart: (item: {
22
+ productId: string;
23
+ variantId?: string;
24
+ quantity: number;
25
+ }) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
26
+ updateCartItem: (id: string, qty: number) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
27
+ removeCartItem: (id: string) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
28
+ clearCart: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
29
+ };
30
+ search: {
31
+ search: (query: import("@meeovi/types").SearchQuery) => Promise<import("@meeovi/types").Result<import("@meeovi/types").SearchResult<unknown>>> | undefined;
32
+ facets: (query: import("@meeovi/types").SearchQuery) => Promise<import("@meeovi/types").Result<import("@meeovi/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("@meeovi/types").Result<import("@meeovi/types").Session>> | undefined;
6
+ register: (input: {
7
+ email: string;
8
+ password: string;
9
+ confirmPassword: string;
10
+ }) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Session>> | undefined;
11
+ logout: () => Promise<import("@meeovi/types").Result<true>> | undefined;
12
+ getSession: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Session>> | undefined;
13
+ refresh: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Session>> | undefined;
14
+ getUser: () => Promise<import("@meeovi/types").Result<import("@meeovi/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("@meeovi/types").Result<import("@meeovi/types").Product>> | undefined;
3
+ listProducts: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Product[]>> | undefined;
4
+ getCart: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
5
+ addToCart: (item: {
6
+ productId: string;
7
+ variantId?: string;
8
+ quantity: number;
9
+ }) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
10
+ updateCartItem: (id: string, qty: number) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
11
+ removeCartItem: (id: string) => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | undefined;
12
+ clearCart: () => Promise<import("@meeovi/types").Result<import("@meeovi/types").Cart>> | 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 { SearchQuery } from '@meeovi/types';
2
+ export declare const search: {
3
+ search: (query: SearchQuery) => Promise<import("@meeovi/types").Result<import("@meeovi/types").SearchResult<unknown>>> | undefined;
4
+ facets: (query: SearchQuery) => Promise<import("@meeovi/types").Result<import("@meeovi/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
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@meeovi/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Official SDK for the Alternate Framework.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "test": "echo \"Error: no test specified\" && exit 1",
16
+ "build": "tsc -p tsconfig.json"
17
+ },
18
+ "keywords": [
19
+ "directus",
20
+ "directus-sdk",
21
+ "directus-types",
22
+ "directus-visual-editing",
23
+ "directus-client",
24
+ "vue",
25
+ "react",
26
+ "typescript"
27
+ ],
28
+ "author": "Meeovi",
29
+ "license": "MIT",
30
+ "type": "module",
31
+ "dependencies": {
32
+ "@meeovi/types": "^1.0.1",
33
+ "typescript": "^5.9.3"
34
+ }
35
+ }
@@ -0,0 +1,16 @@
1
+ import type {
2
+ User,
3
+ Session,
4
+ Result,
5
+ LoginInput,
6
+ RegisterInput
7
+ } from '@meeovi/types'
8
+
9
+ export interface AuthAdapter {
10
+ login(input: LoginInput): Promise<Result<Session>>
11
+ register(input: RegisterInput): Promise<Result<Session>>
12
+ logout(): Promise<Result<true>>
13
+ getSession(): Promise<Result<Session>>
14
+ refresh(): Promise<Result<Session>>
15
+ getUser(): Promise<Result<User>>
16
+ }
@@ -0,0 +1,17 @@
1
+ import type {
2
+ Product,
3
+ Cart,
4
+ CartItem,
5
+ Result
6
+ } from '@meeovi/types'
7
+
8
+ export interface CommerceAdapter {
9
+ getProduct(id: string): Promise<Result<Product>>
10
+ listProducts(): Promise<Result<Product[]>>
11
+
12
+ getCart(): Promise<Result<Cart>>
13
+ addToCart(item: { productId: string; variantId?: string; quantity: number }): Promise<Result<Cart>>
14
+ updateCartItem(itemId: string, quantity: number): Promise<Result<Cart>>
15
+ removeCartItem(itemId: string): Promise<Result<Cart>>
16
+ clearCart(): Promise<Result<Cart>>
17
+ }
@@ -0,0 +1,4 @@
1
+ export * from './transport'
2
+ export * from './auth'
3
+ export * from './commerce'
4
+ export * from './search'
@@ -0,0 +1,11 @@
1
+ import type {
2
+ SearchQuery,
3
+ SearchResult,
4
+ Facet,
5
+ Result
6
+ } from '@meeovi/types'
7
+
8
+ export interface SearchAdapter {
9
+ search<T = unknown>(query: SearchQuery): Promise<Result<SearchResult<T>>>
10
+ facets(query: SearchQuery): Promise<Result<Facet[]>>
11
+ }
@@ -0,0 +1,9 @@
1
+ import type { RequestOptions, APIResponse } from '@meeovi/types'
2
+
3
+ export interface TransportAdapter {
4
+ request<T = unknown>(
5
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
6
+ path: string,
7
+ options?: RequestOptions
8
+ ): Promise<APIResponse<T>>
9
+ }
@@ -0,0 +1,13 @@
1
+ import { auth } from '../registry/auth'
2
+ import { commerce } from '../registry/commerce'
3
+ import { search } from '../registry/search'
4
+ import { getRegistry } from '../registry'
5
+
6
+ export const sdk = {
7
+ auth,
8
+ commerce,
9
+ search,
10
+ get transport() {
11
+ return getRegistry().transport
12
+ }
13
+ }
@@ -0,0 +1,10 @@
1
+ import { getRegistry } from './index'
2
+
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()
10
+ }
@@ -0,0 +1,11 @@
1
+ import { getRegistry } from './index'
2
+
3
+ export const commerce = {
4
+ getProduct: (id: string) => getRegistry().commerce?.getProduct(id),
5
+ listProducts: () => getRegistry().commerce?.listProducts(),
6
+ getCart: () => getRegistry().commerce?.getCart(),
7
+ addToCart: (item: { productId: string; variantId?: string; quantity: number }) => getRegistry().commerce?.addToCart(item),
8
+ updateCartItem: (id: string, qty: number) => getRegistry().commerce?.updateCartItem(id, qty),
9
+ removeCartItem: (id: string) => getRegistry().commerce?.removeCartItem(id),
10
+ clearCart: () => getRegistry().commerce?.clearCart()
11
+ }
@@ -0,0 +1,38 @@
1
+ import type {
2
+ TransportAdapter,
3
+ AuthAdapter,
4
+ CommerceAdapter,
5
+ SearchAdapter
6
+ } from '../adapters/'
7
+
8
+ export interface SDKRegistry {
9
+ transport: TransportAdapter
10
+ auth?: AuthAdapter
11
+ commerce?: CommerceAdapter
12
+ search?: SearchAdapter
13
+ }
14
+
15
+ const registry: Partial<SDKRegistry> = {}
16
+
17
+ export const setTransport = (adapter: TransportAdapter) => {
18
+ registry.transport = adapter
19
+ }
20
+
21
+ export const setAuthAdapter = (adapter: AuthAdapter) => {
22
+ registry.auth = adapter
23
+ }
24
+
25
+ export const setCommerceAdapter = (adapter: CommerceAdapter) => {
26
+ registry.commerce = adapter
27
+ }
28
+
29
+ export const setSearchAdapter = (adapter: SearchAdapter) => {
30
+ registry.search = adapter
31
+ }
32
+
33
+ export const getRegistry = (): SDKRegistry => {
34
+ if (!registry.transport) {
35
+ throw new Error('Transport adapter not set')
36
+ }
37
+ return registry as SDKRegistry
38
+ }
@@ -0,0 +1,7 @@
1
+ import { SearchQuery } from '@meeovi/types'
2
+ import { getRegistry } from './index'
3
+
4
+ export const search = {
5
+ search: (query: SearchQuery) => getRegistry().search?.search(query),
6
+ facets: (query: SearchQuery) => getRegistry().search?.facets(query)
7
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "emitDeclarationOnly": false,
5
+ "outDir": "dist",
6
+ "moduleResolution": "bundler",
7
+ "module": "ESNext",
8
+ "target": "ESNext",
9
+ "strict": true,
10
+ "jsx": "react-jsx",
11
+ "skipLibCheck": true,
12
+ "noEmitOnError": false
13
+ },
14
+ "include": ["src"]
15
+ }