feeef 0.0.7 → 0.0.9

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/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "feeef",
3
3
  "description": "FeeeF sdk",
4
- "main": "src/index.ts",
5
- "version": "0.0.7",
4
+ "version": "0.0.9",
6
5
  "type": "module",
6
+ "main": "build/index.js",
7
+ "files": [
8
+ "build",
9
+ "!build/bin",
10
+ "!build/tests",
11
+ "!build/factories"
12
+ ],
13
+ "exports": {
14
+ ".": "./build/index.js"
15
+ },
7
16
  "scripts": {
8
17
  "dev": "vite --host",
9
18
  "build": "tsc && vite build",
@@ -25,5 +34,16 @@
25
34
  "eslint-plugin-react-refresh": "^0.4.3",
26
35
  "typescript": "^5.0.2",
27
36
  "vite": "^4.4.5"
37
+ },
38
+ "tsup": {
39
+ "entry": [
40
+ "./index.ts"
41
+ ],
42
+ "outDir": "./build",
43
+ "clean": true,
44
+ "format": "esm",
45
+ "dts": false,
46
+ "sourcemap": true,
47
+ "target": "esnext"
28
48
  }
29
49
  }
package/.eslintrc.cjs DELETED
@@ -1,19 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- env: { browser: true, es2020: true },
4
- extends: [
5
- "eslint:recommended",
6
- "plugin:@typescript-eslint/recommended",
7
- "plugin:react-hooks/recommended",
8
- ],
9
- ignorePatterns: ["dist", ".eslintrc.cjs"],
10
- parser: "@typescript-eslint/parser",
11
- plugins: ["react-refresh"],
12
- rules: {
13
- "react-refresh/only-export-components": [
14
- "warn",
15
- { allowConstantExport: true },
16
- ],
17
- "@typescript-eslint/no-explicit-any": "off",
18
- },
19
- };
package/src/core/core.ts DELETED
@@ -1,10 +0,0 @@
1
- // entities
2
- export * from './entities/order.js'
3
- export * from './entities/store.js'
4
- export * from './entities/product.js'
5
- export * from './entities/user.js'
6
- export * from './entities/shipping_method.js'
7
- // embaddeds
8
- export * from './embadded/address.js'
9
- export * from './embadded/category.js'
10
- export * from './embadded/contact.js'
@@ -1,13 +0,0 @@
1
- export interface EmbaddedAddress {
2
- city: string
3
- state: string
4
- country?: string
5
- street?: string
6
- zip?: string
7
- location?: {
8
- geohash?: string
9
- lat: number
10
- long: number
11
- }
12
- metadata?: Record<string, any>
13
- }
@@ -1,7 +0,0 @@
1
- export interface EmbaddedCategory {
2
- name: string
3
- description: string | null
4
- photoUrl: string | null
5
- ondarkPhotoUrl?: string | null
6
- metadata?: Record<string, any>
7
- }
@@ -1,24 +0,0 @@
1
- export enum EmbaddedContactType {
2
- phone = 'phone',
3
- email = 'email',
4
- facebook = 'facebook',
5
- twitter = 'twitter',
6
- instagram = 'instagram',
7
- linkedin = 'linkedin',
8
- website = 'website',
9
- whatsapp = 'whatsapp',
10
- telegram = 'telegram',
11
- signal = 'signal',
12
- viber = 'viber',
13
- skype = 'skype',
14
- zoom = 'zoom',
15
- other = 'other',
16
- }
17
-
18
- // EmbaddedContactType is not enum but can only be: "phone" | "email" | "facebook" | "twitter" | "instagram" | "linkedin" | "website" | "whatsapp" | "telegram" | "signal" | "viber" | "skype" | "zoom" | "other
19
-
20
- export interface EmbaddedContact {
21
- type: EmbaddedContactType
22
- value: string
23
- metadata?: Record<string, any>
24
- }
@@ -1,52 +0,0 @@
1
- export enum OrderStatus {
2
- draft = "draft",
3
- pending = "pending",
4
- processing = "processing",
5
- completed = "completed",
6
- cancelled = "cancelled",
7
- }
8
-
9
- // PaymentStatus
10
- export enum PaymentStatus {
11
- unpaid = "unpaid",
12
- paid = "paid",
13
- received = "received",
14
- }
15
- export enum DeliveryStatus {
16
- pending = "pending",
17
- delivering = "delivering",
18
- delivered = "delivered",
19
- returned = "returned",
20
- }
21
-
22
- export interface OrderEntity {
23
- id: string;
24
- customerName: string | null;
25
- customerPhone: string;
26
- customerIp: string | null;
27
- shippingAddress: string | null;
28
- shippingCity: string | null;
29
- shippingState: string | null;
30
- shippingMethodId: string | null;
31
- paymentMethodId: string | null;
32
- items: OrderItem[];
33
- subtotal: number;
34
- shippingPrice: number;
35
- total: number;
36
- discount: number;
37
- coupon: string | null;
38
- storeId: string;
39
- metadata: any;
40
- status: OrderStatus;
41
- paymentStatus: PaymentStatus;
42
- deliveryStatus: DeliveryStatus;
43
- createdAt: any;
44
- updatedAt: any;
45
- }
46
- export interface OrderItem {
47
- productId: string;
48
- productName: string;
49
- variantPath?: string;
50
- quantity: number;
51
- price: number;
52
- }
@@ -1,99 +0,0 @@
1
- import { EmbaddedCategory } from "../embadded/category.js";
2
-
3
- export interface ProductEntity {
4
- id: string;
5
-
6
- slug: string;
7
-
8
- decoration: ProductDecoration | null;
9
-
10
- name: string | null;
11
-
12
- photoUrl: string | null;
13
-
14
- media: string[];
15
-
16
- storeId: string;
17
-
18
- category: EmbaddedCategory;
19
-
20
- title: string | null;
21
-
22
- description: string | null;
23
-
24
- body: string | null;
25
-
26
- // sku
27
- sku: string | null;
28
-
29
- price: number;
30
-
31
- discount: number | null;
32
-
33
- stock: number;
34
-
35
- sold: number;
36
-
37
- views: number;
38
-
39
- likes: number;
40
-
41
- dislikes: number;
42
-
43
- variant?: ProductVariant | null;
44
-
45
- metadata: Record<string, any>;
46
-
47
- status: ProductStatus;
48
-
49
- type: ProductType;
50
-
51
- verifiedAt: any | null;
52
-
53
- blockedAt: any | null;
54
-
55
- createdAt: any;
56
-
57
- updatedAt: any;
58
- }
59
-
60
- export enum ProductStatus {
61
- draft = "draft",
62
- published = "published",
63
- archived = "archived",
64
- deleted = "deleted",
65
- }
66
-
67
- export interface ProductDecoration {
68
- metadata: Record<string, any>;
69
- }
70
-
71
- export interface ProductVariant {
72
- name: string;
73
- options: ProductVariantOption[];
74
- }
75
-
76
- export interface ProductVariantOption {
77
- name: string;
78
- sku?: string | null;
79
- price?: number | null;
80
- discount?: number | null;
81
- stock?: number | null;
82
- sold?: number | null;
83
- type?: VariantOptionType;
84
- child?: ProductVariant | null;
85
- mediaIndex?: number | null;
86
- hint?: string | null;
87
- }
88
-
89
- export enum VariantOptionType {
90
- color = "color",
91
- image = "image",
92
- text = "text",
93
- }
94
-
95
- export enum ProductType {
96
- physical = "physical",
97
- digital = "digital",
98
- service = "service",
99
- }
@@ -1,32 +0,0 @@
1
- import { OrderEntity } from "./order.js";
2
-
3
- export interface ShippingMethodEntity {
4
- id: string;
5
- name: string;
6
- description: string | null;
7
- logoUrl: string | null;
8
- ondarkLogoUrl: string | null;
9
- price: number;
10
- forks: number;
11
- sourceId: string;
12
- storeId: string;
13
- rates: (number | null)[];
14
- status: ShippingMethodStatus;
15
- policy: ShippingMethodPolicy;
16
- verifiedAt: any;
17
- createdAt: any;
18
- updatedAt: any;
19
- orders: OrderEntity[];
20
- source: ShippingMethodEntity | null;
21
- }
22
-
23
- export enum ShippingMethodStatus {
24
- draft = "draft",
25
- published = "published",
26
- archived = "archived",
27
- }
28
-
29
- export enum ShippingMethodPolicy {
30
- private = "private",
31
- public = "public",
32
- }
@@ -1,84 +0,0 @@
1
- import { EmbaddedAddress } from '../embadded/address.js'
2
- import { EmbaddedCategory } from '../embadded/category.js'
3
- import { EmbaddedContact } from '../embadded/contact.js'
4
- // import { OrderEntity } from "./order.js";
5
- // import { ShippingMethodEntity } from "./shipping_method.js";
6
- import { UserEntity } from './user.js'
7
-
8
- export interface StoreEntity {
9
- id: string
10
- slug: string
11
- banner: StoreBanner | null
12
- action: StoreAction | null
13
- domain: StoreDomain | null
14
- decoration: StoreDecoration | null
15
- name: string
16
- logoUrl: string | null
17
- ondarkLogoUrl: string | null
18
- userId: string
19
- categories: EmbaddedCategory[]
20
- title: string | null
21
- description: string | null
22
- addresses: EmbaddedAddress[]
23
- metadata: Record<string, any>
24
- contacts: EmbaddedContact[]
25
- integrations: StoreIntegration[]
26
- verifiedAt: any | null
27
- blockedAt: any | null
28
- createdAt: any
29
- updatedAt: any
30
- // products: ProductEntity[];
31
- user: UserEntity
32
- // orders: OrderEntity[];
33
- // shippingMethods: ShippingMethodEntity[];
34
- defaultShippingRates: (number | null)[][] | null
35
- }
36
-
37
- export interface StoreDomain {
38
- name: string
39
- verifiedAt: any | null
40
- metadata: Record<string, any>
41
- }
42
- export interface StoreBanner {
43
- title: string
44
- url?: string | null
45
- enabled: boolean
46
- metadata: Record<string, any>
47
- }
48
-
49
- export interface StoreDecoration {
50
- primary: number
51
- onPrimary?: number
52
- showStoreLogoInHeader?: boolean
53
- logoFullHeight?: boolean
54
- showStoreNameInHeader?: boolean
55
- metadata?: Record<string, any>
56
- }
57
-
58
- export interface StoreIntegration {
59
- type: StoreIntegrations
60
- // any
61
- [key: string]: any
62
- metadata: Record<string, any>
63
- }
64
-
65
- export enum StoreIntegrations {
66
- telegram = 'telegram',
67
- facebookPixel = 'facebook_pixel',
68
- googleAnalytics = 'google_analytics',
69
- googleSheet = 'google_sheet',
70
- sms = 'sms',
71
- }
72
-
73
- export interface StoreAction {
74
- label: string
75
- url: string
76
- type: StoreActionType
77
- }
78
-
79
- export enum StoreActionType {
80
- link = 'link',
81
- whatsapp = 'whatsapp',
82
- telegram = 'telegram',
83
- phone = 'phone',
84
- }
@@ -1,24 +0,0 @@
1
- export interface UserEntity {
2
- id: string
3
- name: string | null
4
- email: string
5
- phone: string
6
- password: string
7
- photoUrl: string | null
8
- emailVerifiedAt: any | null
9
- phoneVerifiedAt: any | null
10
- verifiedAt: any | null
11
- blockedAt: any | null
12
- createdAt: any
13
- updatedAt: any | null
14
- metadata: Record<string, any>
15
- }
16
-
17
- export interface AuthToken {
18
- type: string
19
- name: string | null
20
- token: string
21
- abilities: string[]
22
- lastUsedAt: any
23
- expiresAt: any
24
- }
@@ -1,3 +0,0 @@
1
- abstract class FifStoreSdk {
2
- constructor(parameters) {}
3
- }
@@ -1,94 +0,0 @@
1
- import axios, { AxiosInstance } from "axios";
2
- import { buildWebStorage, setupCache } from "axios-cache-interceptor";
3
- import { OrderRepository } from "./repositories/orders";
4
- import { ProductRepository } from "./repositories/products";
5
- import { StoreRepository } from "./repositories/stores";
6
- import { UserRepository } from "./repositories/users";
7
-
8
- /**
9
- * Configuration options for the FeeeF module.
10
- */
11
- export interface FeeeFConfig {
12
- /**
13
- * The API key to be used for authentication.
14
- */
15
- apiKey: string;
16
-
17
- /**
18
- * An optional Axios instance to be used for making HTTP requests.
19
- */
20
- client?: AxiosInstance;
21
-
22
- /**
23
- * Specifies whether caching should be enabled or disabled.
24
- * If set to a number, it represents the maximum number of seconds to cache the responses.
25
- * If set to `false`, caching will be disabled (5s).
26
- * cannot be less than 5 seconds
27
- */
28
- cache?: false | number;
29
- }
30
-
31
- /**
32
- * Represents the FeeeF class.
33
- */
34
- export class FeeeF {
35
- /**
36
- * The API key used for authentication.
37
- */
38
- apiKey: string;
39
-
40
- /**
41
- * The Axios instance used for making HTTP requests.
42
- */
43
- client: AxiosInstance;
44
-
45
- /**
46
- * The repository for managing stores.
47
- */
48
- stores: StoreRepository;
49
-
50
- /**
51
- * The repository for managing products.
52
- */
53
- products: ProductRepository;
54
-
55
- /**
56
- * The repository for managing users.
57
- */
58
- users: UserRepository;
59
-
60
- /**
61
- * The repository for managing orders.
62
- */
63
- orders: OrderRepository;
64
-
65
- /**
66
- * Constructs a new instance of the FeeeF class.
67
- * @param {FeeeFConfig} config - The configuration object.
68
- * @param {string} config.apiKey - The API key used for authentication.
69
- * @param {AxiosInstance} config.client - The Axios instance used for making HTTP requests.
70
- * @param {boolean | number} config.cache - The caching configuration. Set to `false` to disable caching, or provide a number to set the cache TTL in milliseconds.
71
- */
72
- constructor({ apiKey, client, cache }: FeeeFConfig) {
73
- this.apiKey = apiKey;
74
- // get th "cache" search param
75
- const urlParams = new URLSearchParams(window.location.search);
76
- const cacheParam = urlParams.get("cache");
77
- // if is 0 or false, disable cache
78
- if (cacheParam == '0') {
79
- this.client = client || axios;
80
- } else {
81
- this.client = setupCache(client || axios, {
82
- ttl: cache === false ? 5 : Math.max(cache!, 5) || 1 * 60 * 1000, // 1 minute by default
83
- // for persistent cache use buildWebStorage
84
- storage: buildWebStorage(localStorage, "ff:"),
85
- });
86
- }
87
- // set base url
88
- this.client.defaults.baseURL = "http://localhost:3333/api/v1";
89
- this.stores = new StoreRepository(this.client);
90
- this.products = new ProductRepository(this.client);
91
- this.users = new UserRepository(this.client);
92
- this.orders = new OrderRepository(this.client);
93
- }
94
- }
@@ -1,37 +0,0 @@
1
- import vine from "@vinejs/vine";
2
- import { InferInput } from "@vinejs/vine/types";
3
- import { AxiosInstance } from "axios";
4
- import { OrderEntity } from "../../core/core";
5
- import { CreateOrderSchema, SendOrderSchema } from "../validators/order";
6
- import { ModelRepository } from "./repository";
7
-
8
- /**
9
- * Represents a repository for managing orders.
10
- */
11
- export class OrderRepository extends ModelRepository<
12
- OrderEntity,
13
- InferInput<typeof CreateOrderSchema>,
14
- InferInput<typeof CreateOrderSchema>
15
- > {
16
- /**
17
- * Constructs a new OrderRepository instance.
18
- * @param client - The AxiosInstance used for making HTTP requests.
19
- */
20
- constructor(client: AxiosInstance) {
21
- super("orders", client);
22
- }
23
-
24
- /**
25
- * Sends an order from an anonymous user.
26
- * @param data - The data representing the order to be sent.
27
- * @returns A Promise that resolves to the sent OrderEntity.
28
- */
29
- async send(data: InferInput<typeof SendOrderSchema>): Promise<OrderEntity> {
30
- const validator = vine.compile(SendOrderSchema);
31
- const output = await validator.validate(data);
32
- const res = await this.client.post(`/${this.resource}/send`, output);
33
-
34
- // Return the sent OrderEntity
35
- return res.data;
36
- }
37
- }
@@ -1,25 +0,0 @@
1
- import { InferInput } from "@vinejs/vine/types";
2
- import { AxiosInstance } from "axios";
3
- import { ProductEntity } from "../../core/core";
4
- import {
5
- CreateProductSchema,
6
- UpdateProductSchema,
7
- } from "../validators/product";
8
- import { ModelRepository } from "./repository";
9
-
10
- /**
11
- * Represents a repository for managing products.
12
- */
13
- export class ProductRepository extends ModelRepository<
14
- ProductEntity,
15
- InferInput<typeof CreateProductSchema>,
16
- InferInput<typeof UpdateProductSchema>
17
- > {
18
- /**
19
- * Creates a new instance of the ProductRepository class.
20
- * @param client - The AxiosInstance used for making HTTP requests.
21
- */
22
- constructor(client: AxiosInstance) {
23
- super("products", client);
24
- }
25
- }