apirocket 0.4.2 → 0.5.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,31 @@
1
+ declare const cartIn: (_node: HTMLElement) => {
2
+ duration: number;
3
+ easing: (t: number) => number;
4
+ css: (_t: number, u: number) => string;
5
+ };
6
+ declare const cartOut: (_node: HTMLElement) => {
7
+ duration: number;
8
+ easing: (t: number) => number;
9
+ css: (_t: number, u: number) => string;
10
+ };
11
+ declare const checkoutIn: (_node: HTMLElement) => {
12
+ duration: number;
13
+ easing: (t: number) => number;
14
+ css: (_t: number, u: number) => string;
15
+ };
16
+ declare const checkoutOut: (_node: HTMLElement) => {
17
+ duration: number;
18
+ easing: (t: number) => number;
19
+ css: (_t: number, u: number) => string;
20
+ };
21
+ declare const summaryIn: (_node: HTMLElement) => {
22
+ duration: number;
23
+ easing: (t: number) => number;
24
+ css: (_t: number, u: number) => string;
25
+ };
26
+ declare const summaryOut: (_node: HTMLElement) => {
27
+ duration: number;
28
+ easing: (t: number) => number;
29
+ css: (_t: number, u: number) => string;
30
+ };
31
+ export { cartIn, cartOut, checkoutIn, checkoutOut, summaryIn, summaryOut };
@@ -0,0 +1,7 @@
1
+ export declare const ADDRESS = "{\n address\n address2\n city\n country {\n id\n name\n }\n firstName\n lastName\n postalCode\n province {\n id\n name\n }\n}";
2
+ export declare const BILLING_ADDRESS = "{\n address\n address2\n city\n country {\n id\n name\n }\n name\n postalCode\n province {\n id\n name\n }\n taxCode\n}\n";
3
+ export declare const CART_RESPONSE: string;
4
+ export declare const ORDER_CUSTOMER = "\n{\n email\n id\n phone\n}\n";
5
+ export declare const ORDER_ITEM: string;
6
+ export declare const ORDER_PAYMENT = "{\n authorization\n method {\n id\n name\n }\n}";
7
+ export declare const ORDER_SHIPPING = "{\n description,\n id\n name\n taxBase\n taxAmount\n total\n}";
@@ -0,0 +1,18 @@
1
+ import type { CartType, InputCartAddItem, InputCartRemoveItem, InputCartToOrderType, InputCartUpdate, InputCartUpdateItem } from '@src/types/types';
2
+ import type { OrderType } from '@src/types/order';
3
+ import type { CustomerService } from '@src/services/customer.service';
4
+ import { type Observable } from 'rxjs';
5
+ declare const ID_ESPANA = 199;
6
+ declare const cartToOrder: (input: InputCartToOrderType, customer: CustomerService) => Observable<OrderType>;
7
+ declare const paymentInfo: (id: number, hash: string) => Observable<PaymentInfoType>;
8
+ declare const cartAddItem: (input: InputCartAddItem, customer: CustomerService) => Observable<CartType>;
9
+ declare const cartRemoveItem: (input: InputCartRemoveItem, customer: CustomerService) => Observable<CartType>;
10
+ declare const cartUpdate: (input: InputCartUpdate, customer: CustomerService) => Observable<CartType>;
11
+ declare const cartUpdateItem: (input: InputCartUpdateItem, customer: CustomerService) => Observable<CartType>;
12
+ declare const countries: (customer: CustomerService) => Observable<Array<CountryType>>;
13
+ declare const provinces: (country: number, customer: CustomerService) => Observable<Array<ProvinceType>>;
14
+ export { cartAddItem, cartRemoveItem, cartToOrder, cartUpdate, cartUpdateItem, countries, myAccount, orderSummary, paymentMethods, paymentInfo, provinces, shippingMethods, ID_ESPANA };
15
+ declare const orderSummary: (id: number, hash: string, customer: CustomerService) => Observable<OrderType>;
16
+ declare const shippingMethods: (customer: CustomerService) => Observable<Array<ShippingMethodType>>;
17
+ declare const paymentMethods: (customer: CustomerService) => Observable<Array<PaymentMethodOption>>;
18
+ declare const myAccount: (customer: CustomerService) => Observable<CustomerAccount>;
@@ -0,0 +1 @@
1
+ export declare const SHIPPING_METHOD: ShippingMethodType;
@@ -0,0 +1,19 @@
1
+ import { AjaxResponse } from 'rxjs/ajax';
2
+ import { Observable } from 'rxjs/internal/Observable';
3
+ import type { CustomerService } from '@src/services/customer.service';
4
+ export type QueryErrors = {
5
+ __errors?: Array<string>;
6
+ };
7
+ export type QueryVariables = {
8
+ [index: string]: any;
9
+ };
10
+ export type QueryOptions = {
11
+ debug?: boolean;
12
+ retry?: number;
13
+ };
14
+ export declare const post: <T>(url: string, data: any, customer?: CustomerService) => Observable<{
15
+ __errors: any;
16
+ status: number;
17
+ } & T>;
18
+ export declare const get: (url: string, data: any, customer: CustomerService) => Observable<AjaxResponse<any>>;
19
+ export declare const query: <T>(query: string, variables: QueryVariables, customer?: CustomerService) => Observable<T>;
@@ -0,0 +1,16 @@
1
+ declare const dataset: (element: HTMLElement, property: string) => any;
2
+ declare const millares: (valor: number, decimales: number, cero?: boolean) => string;
3
+ declare const asFloat: (value: string | number | Array<string> | undefined, decimales?: number) => number;
4
+ declare const asInteger: (value: string | number | Array<string> | boolean | undefined) => number;
5
+ declare const round: (num: number, precision: number) => number;
6
+ declare const storageAvailable: (type: "sessionStorage" | "localStorage") => boolean;
7
+ declare const backToShopping: () => void;
8
+ declare const cart: (fullScreen?: boolean) => void;
9
+ declare const signIn: () => void;
10
+ declare const checkout: () => void;
11
+ declare const rememberPassword: () => void;
12
+ declare const orderError: () => void;
13
+ declare const orderSummary: () => void;
14
+ declare const payment: () => void;
15
+ declare const account: () => void;
16
+ export { account, asFloat, asInteger, backToShopping, cart, checkout, dataset, millares, orderError, orderSummary, payment, rememberPassword, round, signIn, storageAvailable };
@@ -0,0 +1,7 @@
1
+ import { CheckoutAddress } from "./checkout-address.model";
2
+ export declare class BillingAddress extends CheckoutAddress implements BillingAddressType {
3
+ taxCode?: string;
4
+ name?: string;
5
+ protected constructor(values: BillingAddressType);
6
+ static create(values: BillingAddressType): BillingAddress;
7
+ }
@@ -0,0 +1,13 @@
1
+ declare class CheckoutAddress implements AddressType {
2
+ get fullAddress(): string;
3
+ address?: string;
4
+ address2?: string;
5
+ city?: string;
6
+ country?: CountryType;
7
+ id: number;
8
+ province?: ProvinceType;
9
+ postalCode?: string;
10
+ protected constructor(values: AddressType);
11
+ private getFullAddress;
12
+ }
13
+ export { CheckoutAddress };
@@ -0,0 +1,7 @@
1
+ import { CheckoutAddress } from "./checkout-address.model";
2
+ export declare class ShippingAddress extends CheckoutAddress implements ShippingAddressType {
3
+ firstName?: string;
4
+ lastName?: string;
5
+ protected constructor(values: ShippingAddressType);
6
+ static create(values: ShippingAddressType): ShippingAddress;
7
+ }
@@ -0,0 +1,11 @@
1
+ import { Observable } from "rxjs";
2
+ import { type FormControl } from "@e-xisto/form-control";
3
+ import type { CustomerService } from "./customer.service";
4
+ export declare class AccountService {
5
+ #private;
6
+ get myAccount$(): Observable<CustomerAccount>;
7
+ constructor();
8
+ setCustomerService(customer: CustomerService): void;
9
+ personalForm(formElement: HTMLFormElement, accountService: AccountService, customerService: CustomerService): FormControl;
10
+ private myAccountData;
11
+ }
@@ -0,0 +1,39 @@
1
+ import { Observable } from "rxjs";
2
+ import type { CustomerService } from './customer.service';
3
+ import type { CheckoutService } from "./checkout.service";
4
+ import type { CartItemType, CartStatus, LastOrder } from "@src/types/types";
5
+ import type { OrderType } from "@src/types/order";
6
+ export declare class CartService {
7
+ #private;
8
+ readonly change$: Observable<CartService>;
9
+ get count(): number;
10
+ get items(): Array<CartItemType>;
11
+ get lastOrder(): LastOrder;
12
+ get numItems(): number;
13
+ get status(): CartStatus;
14
+ get taxBase(): number;
15
+ get total(): number;
16
+ get units(): number;
17
+ get uuid(): string;
18
+ constructor();
19
+ private getItems;
20
+ remove(item: CartItemType): Promise<void>;
21
+ private restoreStorage;
22
+ private saveStorage;
23
+ setCustomerService(customer: CustomerService): void;
24
+ subscribe(cb: (cart: CartService) => void): () => void;
25
+ update(): Promise<void>;
26
+ updateItem(item: CartItemType, quantity: number): Promise<void>;
27
+ private changeCart;
28
+ add(data: CartItemType): void;
29
+ close(): void;
30
+ open(fullScreen: boolean): void;
31
+ private updateCart;
32
+ setPayment(lastOrderId: number, lastOrderHash: string): void;
33
+ orderSummary(id: number, hash: string): Observable<OrderType>;
34
+ addFromTarget(target: HTMLElement): void;
35
+ private setStatus;
36
+ clear(): void;
37
+ cartToOrder(customerService: CustomerService, checkoutService: CheckoutService): Observable<PaymentInfoType>;
38
+ private addItemCart;
39
+ }
@@ -0,0 +1,43 @@
1
+ import { Observable } from 'rxjs/internal/Observable';
2
+ import type { FormControl } from "@e-xisto/form-control";
3
+ import type { CartService } from '@src/services/cart.service';
4
+ import type { AccountService } from './account.service';
5
+ import type { CustomerService } from './customer.service';
6
+ import { CheckoutStatus } from '@src/types/checkout.type';
7
+ import { ShippingAddress } from "@src/models/shipping-address.model";
8
+ import { BillingAddress } from '@src/models/billing-address.model';
9
+ export declare class CheckoutService {
10
+ #private;
11
+ readonly change$: Observable<CheckoutService>;
12
+ get billingAddress(): BillingAddress;
13
+ get paymentAddress(): boolean;
14
+ get paymentMethod(): PaymentMethodType;
15
+ get status(): CheckoutStatus;
16
+ get shippingAddress(): ShippingAddress;
17
+ get shippingMethod(): ShippingMethodType;
18
+ get steps(): Set<CheckoutStatus>;
19
+ get total(): number;
20
+ constructor(cartService: CartService, customer: CustomerService);
21
+ private saveStorage;
22
+ setStatus(newStatus: CheckoutStatus): void;
23
+ formSignIn(form: HTMLFormElement): FormControl;
24
+ signInSubmit(_form: FormControl): void;
25
+ close(): void;
26
+ open(): void;
27
+ private initCountryControl;
28
+ paymentForm(formElement: HTMLFormElement, paymentMethods: Array<PaymentMethodOption>): FormControl;
29
+ shippingMethodForm(formElement: HTMLFormElement, shippingMethods: Array<ShippingMethodType>): FormControl;
30
+ shippingMethodSet(form: FormControl, methods: Array<ShippingMethodType>, cartService: CartService, gotoPayment: boolean): void;
31
+ private restoreStorage;
32
+ shippingMethods(): Observable<Array<ShippingMethodType>>;
33
+ updateTotal(cartService: CartService): void;
34
+ paymentSet(form: FormControl, payments: Array<PaymentMethodOption>): void;
35
+ resetPassword(form: FormControl): void;
36
+ private shippingAddressSelect;
37
+ shippingAddressForm(formElement: HTMLFormElement, customerService: CustomerService, account: AccountService): Observable<{
38
+ form: FormControl;
39
+ addresses: Array<AccountShippingAddress>;
40
+ }>;
41
+ shippingAddressSet(form: FormControl, customerService: CustomerService): void;
42
+ private otherShippingAddress;
43
+ }
@@ -0,0 +1,34 @@
1
+ import type { Observable } from 'rxjs/internal/Observable';
2
+ import type { FormControl } from "@e-xisto/form-control";
3
+ import type { CartService } from "./cart.service";
4
+ import type { CustomerType } from "@src/types/types";
5
+ export declare class CustomerService {
6
+ #private;
7
+ readonly change$: Observable<CustomerService>;
8
+ get acceptEmailMarketing(): boolean;
9
+ get email(): string;
10
+ get firstName(): string;
11
+ get id(): number;
12
+ get lastName(): string;
13
+ get phone(): string;
14
+ get refreshToken(): string;
15
+ get token(): string;
16
+ get type(): CustomerType;
17
+ constructor();
18
+ private changeCustomer;
19
+ rememberPassword(form: FormControl): Promise<any>;
20
+ private restoreState;
21
+ private saveState;
22
+ setCartService(cart: CartService): void;
23
+ subscribe(cb: (customer: CustomerService) => void): () => void;
24
+ price(productId: number): Promise<any>;
25
+ logout(): Promise<{
26
+ status: number;
27
+ }>;
28
+ setData(email: string, phone: string, acceptEmailMarketing: boolean): void;
29
+ login(form: FormControl): Promise<{
30
+ status: number;
31
+ }>;
32
+ private updateState;
33
+ updateToken(data: LoginData): void;
34
+ }
@@ -0,0 +1,8 @@
1
+ import type { SvelteComponent } from "svelte";
2
+ import type { EcommerceService } from "./ecommerce.service";
3
+ type Route = {
4
+ component: typeof SvelteComponent;
5
+ canActivate?: (ecommerceService: EcommerceService) => boolean;
6
+ };
7
+ export declare const ROUTES: Map<String, Route>;
8
+ export {};
@@ -0,0 +1,24 @@
1
+ import { EcommerceStatus } from "@src/types/ecommerce.type";
2
+ import { CartService } from "@src/services/cart.service";
3
+ import { CheckoutService } from "@src/services/checkout.service";
4
+ import { CustomerService } from "./customer.service";
5
+ import { AccountService } from './account.service';
6
+ export declare class EcommerceService {
7
+ #private;
8
+ get account(): AccountService;
9
+ get cart(): CartService;
10
+ get checkout(): CheckoutService;
11
+ get customer(): CustomerService;
12
+ get logo(): string;
13
+ get status(): EcommerceStatus;
14
+ constructor();
15
+ private changeStatus;
16
+ private initStatusChange;
17
+ private init;
18
+ signIn(): void;
19
+ close(): void;
20
+ rememberPassword(): void;
21
+ config(value: EcommerceConfig): void;
22
+ updateEvents(): void;
23
+ private ready;
24
+ }
@@ -0,0 +1,11 @@
1
+ import type { ModalConfig, ModalInstance, ModalOpen, ModalService } from "@src/types/modal-service.type";
2
+ declare class ModalServiceClass implements ModalService {
3
+ #private;
4
+ constructor();
5
+ close(instance?: ModalInstance): void;
6
+ private closeInstance;
7
+ private destroyInstance;
8
+ open(modalComponent: ModalOpen, modalConfig?: ModalConfig): ModalInstance;
9
+ }
10
+ export declare const modalService: Readonly<ModalServiceClass>;
11
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare enum AccountStatus {
2
+ PERSONAL = "personal",
3
+ SHIPPING = "shipping",
4
+ BILLING = "billing",
5
+ ORDERS = "orders"
6
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum CheckoutStatus {
2
+ INFO = "info",
3
+ SHIPPING = "shipping",
4
+ PAYMENT = "payment"
5
+ }
@@ -0,0 +1,24 @@
1
+ import type { InputControl } from "@e-xisto/form-control";
2
+ import type { PublicEcommerceService } from "./types";
3
+ export declare enum EcommerceStatus {
4
+ ACCOUNT = "#/my-account",
5
+ CART = "#/cart",
6
+ CARTLEFT = "#/cart-left",
7
+ CHECKOUT = "#/checkout",
8
+ NONE = "",
9
+ PAYMENT = "#/payment",
10
+ SIGNIN = "#/signin",
11
+ ORDER_SUMMARY = "#/order-summary",
12
+ ORDER_ERROR = "#/order-error",
13
+ REMEMBER_PASSWORD = "#/remember-password",
14
+ REGISTER = "#/register",
15
+ RESET_PASSWORD = "#/reset-password"
16
+ }
17
+ export declare class EcommerceReadyEvent extends Event {
18
+ readonly ecommerce: PublicEcommerceService;
19
+ constructor(type: string, ecommerce: PublicEcommerceService);
20
+ }
21
+ export declare class InputControlChangeEvent extends Event {
22
+ readonly control: InputControl;
23
+ constructor(type: string, control: InputControl);
24
+ }
@@ -0,0 +1,21 @@
1
+ import type { SvelteComponent } from "svelte";
2
+ export interface ModalConfig {
3
+ afterClosed?: () => void;
4
+ beforeClosed?: () => void;
5
+ closeAll?: boolean;
6
+ fullscreen?: boolean;
7
+ width?: 'sm' | 'md' | 'lg' | 'fluid';
8
+ }
9
+ export interface ModalInstance {
10
+ afterClosed?: () => void;
11
+ index: number;
12
+ modal: SvelteComponent;
13
+ }
14
+ export interface ModalOpen {
15
+ component: typeof SvelteComponent;
16
+ props?: any;
17
+ }
18
+ export interface ModalService {
19
+ close(instance?: ModalInstance): void;
20
+ open(modalComponent: ModalOpen, config?: ModalConfig): void;
21
+ }
@@ -0,0 +1,25 @@
1
+ export interface OrderType {
2
+ billingAddress: BillingAddressType;
3
+ customer: OrderCustomer;
4
+ date: Date;
5
+ hash: string;
6
+ id: number;
7
+ items: any;
8
+ notes: string;
9
+ number: string;
10
+ payment: OrderPaymentType;
11
+ shippingAddress: ShippingAddressType;
12
+ shippingMethod: ShippingMethodType;
13
+ total: number;
14
+ }
15
+ export interface OrderPaymentType {
16
+ authorization: string;
17
+ method: {
18
+ id: number;
19
+ name: string;
20
+ };
21
+ }
22
+ export type OrderPaymentMethodType = {
23
+ id: number;
24
+ name: string;
25
+ };
@@ -0,0 +1,85 @@
1
+ import type { OrderPaymentMethodType } from './order';
2
+ export interface InputCartToOrderType {
3
+ billingAddress?: BillingAddressType;
4
+ cartUuid: string;
5
+ customer: OrderCustomer;
6
+ customerId?: number;
7
+ email?: string;
8
+ notes: string;
9
+ numItems: number;
10
+ paymentMethod: OrderPaymentMethodType;
11
+ shippingAddress: AddressType;
12
+ shippingMethod: InputShippingMethodType;
13
+ units: number;
14
+ total: number;
15
+ }
16
+ export type CartItemType = {
17
+ price: number;
18
+ product: {
19
+ barcode: string;
20
+ category: {
21
+ id: number;
22
+ name: string;
23
+ };
24
+ description: string;
25
+ id: number;
26
+ image: string;
27
+ name: string;
28
+ noShippingCost: boolean;
29
+ sku: string;
30
+ stockManagement: boolean;
31
+ url: string;
32
+ weight: number;
33
+ };
34
+ itemPrice: {
35
+ comparePrice: number;
36
+ price: number;
37
+ taxAmount: number;
38
+ };
39
+ quantity: number;
40
+ uuid: string;
41
+ };
42
+ export type CartType = {
43
+ items: Array<CartItemType>;
44
+ taxBase: number;
45
+ total: number;
46
+ uuid: string;
47
+ };
48
+ export type CartStatus = 'loaded' | 'loading';
49
+ export type CustomerType = 'B2C' | 'B2B';
50
+ export type LastOrder = {
51
+ id: number;
52
+ hash: string;
53
+ };
54
+ export type InputCartAddItem = {
55
+ cartUuid: string;
56
+ customerId?: number;
57
+ email?: string;
58
+ productId: number;
59
+ quantity: number;
60
+ url?: string;
61
+ };
62
+ export type InputCartRemoveItem = {
63
+ cartUuid: string;
64
+ customerId?: number;
65
+ email?: string;
66
+ itemUuid: string;
67
+ };
68
+ export type InputCartUpdateItem = {
69
+ cartUuid: string;
70
+ customerId?: number;
71
+ email?: string;
72
+ itemUuid: string;
73
+ quantity: number;
74
+ };
75
+ export type InputCartUpdate = {
76
+ cartUuid: string;
77
+ customerId?: number;
78
+ email?: string;
79
+ };
80
+ export type PublicEcommerceService = {
81
+ customer: any;
82
+ cart: any;
83
+ config: (value: EcommerceConfig) => void;
84
+ updateEvents: () => void;
85
+ };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "apirocket",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": " ",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "type": "module",
7
8
  "scripts": {
8
9
  "prepublish": "rm -Rf dist && npm run build && npm run check",
9
10
  "build": "rollup -c",
@@ -15,28 +16,28 @@
15
16
  "author": "",
16
17
  "license": "ISC",
17
18
  "devDependencies": {
18
- "@rollup/plugin-commonjs": "^22.0.0",
19
- "@rollup/plugin-node-resolve": "^13.0.4",
20
- "@rollup/plugin-typescript": "^8.2.5",
19
+ "@rollup/plugin-commonjs": "^24.0.1",
20
+ "@rollup/plugin-node-resolve": "^15.0.1",
21
+ "@rollup/plugin-typescript": "^11.0.0",
21
22
  "@tsconfig/svelte": "^3.0.0",
22
- "@types/dompurify": "^2.3.3",
23
- "@types/node": "^17.0.31",
24
- "rollup": "^2.56.3",
23
+ "@types/dompurify": "^2.4.0",
24
+ "@types/node": "^18.14.4",
25
+ "rollup": "^3.18.0",
25
26
  "rollup-plugin-copy": "^3.4.0",
26
- "rollup-plugin-css-only": "^3.1.0",
27
- "rollup-plugin-livereload": "^2.0.0",
28
- "rollup-plugin-svelte": "^7.1.0",
29
- "rollup-plugin-terser": "^7.0.2",
27
+ "rollup-plugin-css-only": "^4.3.0",
28
+ "rollup-plugin-livereload": "^2.0.5",
29
+ "rollup-plugin-minification": "^0.2.0",
30
+ "rollup-plugin-svelte": "^7.1.4",
30
31
  "sirv-cli": "^2.0.2",
31
- "svelte": "^3.42.4",
32
- "svelte-check": "^2.7.0",
33
- "svelte-preprocess": "^4.10.6",
34
- "tslib": "^2.3.1",
35
- "typescript": "^4.6.4"
32
+ "svelte": "^3.55.1",
33
+ "svelte-check": "^3.0.4",
34
+ "svelte-preprocess": "^5.0.1",
35
+ "tslib": "^2.5.0",
36
+ "typescript": "^4.9.5"
36
37
  },
37
38
  "dependencies": {
38
39
  "@e-xisto/form-control": "^0.1.6",
39
- "dompurify": "^2.3.6",
40
- "rxjs": "^7.4.0"
40
+ "dompurify": "^3.0.1",
41
+ "rxjs": "^7.8.0"
41
42
  }
42
43
  }