Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

restomax-deliverect

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restomax-deliverect - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

7

lib/src/intfs/account.d.ts

@@ -12,2 +12,7 @@ import { ILocation } from './location';

}
/**
* Just convert to Descr
* @param id
*/
export declare function getAccountTypeDescr(id: IAccountType | number): string;
/** Every restaurant has an account.

@@ -18,3 +23,2 @@ * When such an account is linked to your integrator account, it will show up when doing this call.

export interface IAccount {
_id: string;
name: string;

@@ -30,3 +34,4 @@ accountType: IAccountType | number;

_etag: string;
_id: string;
_links: IAnswerLinks;
}

@@ -13,2 +13,16 @@ "use strict";

})(IAccountType = exports.IAccountType || (exports.IAccountType = {}));
/**
* Just convert to Descr
* @param id
*/
function getAccountTypeDescr(id) {
switch (id) {
case IAccountType.CUSTOMER: return 'Customer Account';
case IAccountType.PARTNER: return 'Partner Account';
case IAccountType.CHAIN: return 'Chain Account';
case IAccountType.SUPERADMIN: return 'SuperAdmin Account';
}
return 'Account Type ' + id.toString();
}
exports.getAccountTypeDescr = getAccountTypeDescr;
//# sourceMappingURL=account.js.map

13

lib/src/intfs/answer.d.ts

@@ -5,4 +5,7 @@ import { IAccount } from './account';

/** Answer Meta
* The _meta field provides pagination data and will only be there if Pagination has been enabled (it is by default) and there is at least one document being returned.
* When a consumer requests a resource, the first N items matching the query are served, and links to subsequent/previous pages are provided with the response.
* ex: ?max_results=20&page=2
*/
export interface IAnswerMeta {
export interface IPagination {
page: number;

@@ -15,5 +18,7 @@ max_results: number;

export interface IAnswerEnvelope {
_items: IAccount[] | ILocation[];
_links: IAnswerLinks;
_meta: IAnswerMeta;
_status?: string;
_error?: string;
_items?: IAccount[] | ILocation[] | any[];
_meta?: IPagination;
_links?: IAnswerLinks;
}

@@ -27,29 +27,12 @@ /** Auth Request Body to ask a access Token

required: boolean;
type?: undefined;
};
fieldGroupClassName?: undefined;
fieldGroup?: undefined;
} | {
fieldGroupClassName: string;
fieldGroup: ({
key: string;
key: string;
type: string;
templateOptions: {
label: string;
type: string;
className: string;
templateOptions: {
label: string;
required: boolean;
type?: undefined;
};
} | {
key: string;
type: string;
className: string;
templateOptions: {
label: string;
type: string;
required?: undefined;
};
})[];
key?: undefined;
type?: undefined;
templateOptions?: undefined;
required?: undefined;
};
})[];

@@ -56,0 +39,0 @@ export declare const InitialDeliverectConfig: IDeliverectConfig;

@@ -22,25 +22,18 @@ "use strict";

{
fieldGroupClassName: 'display-flex',
fieldGroup: [
{
key: 'apiUri',
type: 'input',
className: 'flex-3',
templateOptions: {
label: 'serverUri',
required: true
}
},
{
key: 'timeout',
type: 'input',
className: 'flex-1',
templateOptions: {
label: 'timeout',
type: 'number',
}
}
]
key: 'apiUri',
type: 'input',
templateOptions: {
label: 'serverUri',
required: true
}
},
{
key: 'timeout',
type: 'input',
templateOptions: {
label: 'timeout',
type: 'number',
}
},
{
key: 'backofficeUrl',

@@ -63,2 +56,3 @@ type: 'input',

apiUri: 'https://api.staging.deliverect.com/',
timeout: 1000,
backofficeUrl: 'https://frontend.staging.deliverect.com/'

@@ -65,0 +59,0 @@ };

@@ -5,3 +5,2 @@ /** ProductCategories are the groups of the Deliverect platform.

export interface ICategory {
_id: string;
location?: string;

@@ -18,2 +17,3 @@ account: string;

posLocationId: string;
_id: string;
}

@@ -24,3 +24,2 @@ /**

export interface IChannelStatus {
_id: string;
orderStatus: number;

@@ -33,2 +32,3 @@ response: string;

_etag: string;
_id: string;
}

@@ -39,4 +39,25 @@ /**

export interface IChannelLink {
account: string;
location: string;
name: string;
channel: IChannel | number;
status: number;
defaultPreparationTime: number;
averageDeliveryTime: number;
sendDeliveryFee: boolean;
sendServiceCharge: boolean;
anonymizeCustomer: boolean;
application: string;
serviceChargePLU: string;
discountPLU: string;
deliveryPLU: string;
posSystemId: number;
posSystem: string;
posLocationId: string;
posOrdersAreAlwaysPaid: boolean;
_created: string;
_updated: string;
_deleted: boolean;
_etag: string;
_id: string;
}

@@ -7,7 +7,14 @@ /** Answer Links

}
/** Answer Links
/** Answer Links.
* From https://docs.python-eve.org/en/stable/features.html
* The _links list provides HATEOAS directives.
* Hypermedia as the Engine of Application State (HATEOAS)
* A GET request to the API home page (the API entry point) will be served with a list of links to accessible resources.
*/
export interface IAnswerLinks {
self: IAnswerLink;
parent?: IAnswerLink;
self: IAnswerLink;
child?: IAnswerLink[];
next?: IAnswerLink;
last?: IAnswerLink;
}
import { IAnswerLinks } from './links';
import { IChannelLink } from './channel';
/**

@@ -52,7 +53,6 @@ *

export interface ILocation {
_id: string;
name: string;
status: ILocationStatus | string;
account: string;
channelLinks: string[];
channelLinks: string[] | IChannelLink[];
ignorePOSOrderStatuses?: boolean;

@@ -68,3 +68,4 @@ address: ILocationAddress;

_etag: string;
_id: string;
_links: IAnswerLinks;
}

@@ -18,3 +18,2 @@ import { IAnswerLinks } from './links';

export interface IOrderItem {
_id: string;
plu: string;

@@ -29,2 +28,3 @@ name: string;

_etag: string;
_id: string;
}

@@ -41,3 +41,2 @@ /** An order represents what a customer ordered using a channel.

export interface IOrder {
_id: string;
status: IOrderStatus | number;

@@ -44,0 +43,0 @@ statusHistory: IOrderHistoryStatus[];

@@ -19,3 +19,2 @@ /** We currently support 3 types of products, Products, ModifierGroups and Modifiers

export interface IProduct {
_id: string;
uniqueKey: string;

@@ -43,2 +42,3 @@ location?: string;

posCategoryIds: string;
_id: string;
}
{
"name": "restomax-deliverect",
"version": "0.0.6",
"version": "0.0.7",
"description": "Restomax Deliverect Link",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -14,2 +14,15 @@ import {ILocation} from './location';

/**
* Just convert to Descr
* @param id
*/
export function getAccountTypeDescr( id:IAccountType | number): string {
switch (id) {
case IAccountType.CUSTOMER:return 'Customer Account';
case IAccountType.PARTNER:return 'Partner Account';
case IAccountType.CHAIN:return 'Chain Account';
case IAccountType.SUPERADMIN:return 'SuperAdmin Account';
}
return 'Account Type ' + id.toString();
}

@@ -23,4 +36,2 @@ // --------------------------------------------------------------------------------

// "_id": "5d948ab5c87d8a000183c437",
_id: string;
// "name": "Restomax test customer",

@@ -50,3 +61,6 @@ name: string;

// "_etag": "18bce2c91751422371b1f654f11073d734ca9ffd",
// ETag, to be used for concurrency control and conditional requests.
_etag: string,
// "_id": "5d948ab5c87d8a000183c437",
_id: string;

@@ -53,0 +67,0 @@ _links: IAnswerLinks;

@@ -7,4 +7,7 @@ import {IAccount} from './account';

/** Answer Meta
* The _meta field provides pagination data and will only be there if Pagination has been enabled (it is by default) and there is at least one document being returned.
* When a consumer requests a resource, the first N items matching the query are served, and links to subsequent/previous pages are provided with the response.
* ex: ?max_results=20&page=2
*/
export interface IAnswerMeta {
export interface IPagination {
page : number;

@@ -19,5 +22,7 @@ max_results: number;

export interface IAnswerEnvelope {
_items : IAccount[] | ILocation[];
_links : IAnswerLinks;
_meta : IAnswerMeta;
_status ?: string;
_error ?: string;
_items ?: IAccount[] | ILocation[] | any[];
_meta ?: IPagination;
_links ?: IAnswerLinks;
}

@@ -53,9 +53,5 @@ // --------------------------------------------------------------------------------

},
{
fieldGroupClassName: 'display-flex',
fieldGroup: [
{
key: 'apiUri',
type: 'input',
className: 'flex-3',
templateOptions: {

@@ -69,3 +65,2 @@ label: 'serverUri',

type: 'input',
className: 'flex-1',
templateOptions: {

@@ -75,3 +70,2 @@ label: 'timeout',

}
}]
},

@@ -96,2 +90,3 @@ {

apiUri: 'https://api.staging.deliverect.com/',
timeout: 1000,
backofficeUrl: 'https://frontend.staging.deliverect.com/'

@@ -98,0 +93,0 @@ };

@@ -7,5 +7,2 @@ /** ProductCategories are the groups of the Deliverect platform.

// string($objectid)
_id : string,
// string($objectid)
location ?: string,

@@ -32,2 +29,6 @@

posLocationId : string,
// string($objectid)
_id : string,
}

@@ -26,4 +26,2 @@ /**

export interface IChannelStatus {
// "_id": "5c6d830a0182d6000e******",
_id: string;
// "orderStatus": 2,

@@ -44,2 +42,4 @@ orderStatus: number,

_etag: string,
// "_id": "5c6d830a0182d6000e******",
_id: string;
}

@@ -51,15 +51,38 @@

export interface IChannelLink {
// account
// location
// locationId
account: string,
location: string,
name: string,
channel: IChannel | number,
// deliverySystem : string,
// status
// application
// statusValidUntill
// bufferInsertOrder
// dia
status : number;
defaultPreparationTime : number;
averageDeliveryTime : number;
sendDeliveryFee: boolean;
sendServiceCharge: boolean;
anonymizeCustomer: boolean;
application: string,
serviceChargePLU: string,
discountPLU: string,
deliveryPLU: string,
posSystemId: number,
posSystem: string,
posLocationId: string,
posOrdersAreAlwaysPaid: boolean,
// "_created": "2019-10-02T11:32:05.000000Z",
_created : string,
// "_updated": "2019-10-02T11:41:21.000000Z",
_updated : string,
// "_deleted": false,
_deleted: boolean,
// "_etag": "18bce2c91751422371b1f654f11073d734ca9ffd",
_etag : string,
// "_id": "5bf02f38c6489f002c******",
_id : string;
}

@@ -10,8 +10,15 @@ // --------------------------------------------------------------------------------

// --------------------------------------------------------------------------------
/** Answer Links
/** Answer Links.
* From https://docs.python-eve.org/en/stable/features.html
* The _links list provides HATEOAS directives.
* Hypermedia as the Engine of Application State (HATEOAS)
* A GET request to the API home page (the API entry point) will be served with a list of links to accessible resources.
*/
export interface IAnswerLinks {
self : IAnswerLink;
parent ?: IAnswerLink;
self : IAnswerLink;
child ?: IAnswerLink[];
next ?: IAnswerLink;
last ?: IAnswerLink;
}
import {IAnswerLinks} from './links';
import {IChannelLink} from './channel';

@@ -59,4 +60,2 @@ /**

// "_id": "5bf02f38c6489f002c******",
_id : string;
// "name": "Test location 1",

@@ -71,3 +70,3 @@ name : string,

// "channelLinks": ["5bf02f38c6489f002******1","5bf02f38c6489f002******2"]
channelLinks : string[],
channelLinks : string[] | IChannelLink[],

@@ -99,2 +98,4 @@ // Indicates whether to ignore POS order statuses and use our mobile app statuses instead.

_etag : string,
// "_id": "5bf02f38c6489f002c******",
_id : string;

@@ -101,0 +102,0 @@ _links : IAnswerLinks;

@@ -20,4 +20,2 @@ import {IAnswerLinks} from './links';

export interface IOrderItem {
// "_id": "5c6d830a0182d6000e******",
_id : string;

@@ -43,2 +41,4 @@ // "plu": "P2",

_etag : string,
// "_id": "5c6d830a0182d6000e******",
_id : string;
}

@@ -58,5 +58,2 @@

// "_id": "5c6d830a0182d6000e******",
_id : string;
// "status": 1,

@@ -128,3 +125,2 @@ status : IOrderStatus | number,

_updated : string,
// "_etag": "33a7f3f6c7c5f8e82fc97116220b8c23094db14f",

@@ -131,0 +127,0 @@ _etag : string,

@@ -25,5 +25,2 @@ /** We currently support 3 types of products, Products, ModifierGroups and Modifiers

// string($objectid)
_id : string,
// "uniqueKey": "",

@@ -75,2 +72,5 @@ uniqueKey : string,

posCategoryIds : string,
// string($objectid)
_id : string,
}
import {createAction, props, union} from '@ngrx/store';
import {IAccount} from '../intfs/account';

@@ -7,4 +8,4 @@ export const DeliverectLogIn = createAction('[Deliverect] LogIn');

export const DeliverectLogInError = createAction('[Deliverect] LogIn Error', props<{ error: any }>());
export const DeliverectLoadAll = createAction('[Deliverect] Load All');
export const DeliverectLoaded = createAction('[Deliverect] Loaded');
export const DeliverectLoadAccounts = createAction('[Deliverect] Load Accounts');
export const DeliverectAccountsLoaded = createAction('[Deliverect] Accounts Loaded', props<{accounts: Array<IAccount>}>());
export const DeliverectLoadError = createAction('[Deliverect] Load Error', props<{ error: any }>());

@@ -17,4 +18,4 @@

DeliverectLogInError,
DeliverectLoadAll,
DeliverectLoaded,
DeliverectLoadAccounts,
DeliverectAccountsLoaded,
DeliverectLoadError

@@ -21,0 +22,0 @@ });

@@ -1,2 +0,2 @@

import {map, withLatestFrom} from 'rxjs/operators';
import {map, tap} from 'rxjs/operators';
import {Injectable} from '@angular/core';

@@ -8,3 +8,3 @@ import {Store} from '@ngrx/store';

import {DeliverectService} from './deliverect.service';
import {DeliverectActions, DeliverectLoadAll, DeliverectLogIn, DeliverectLogOut} from './deliverect.actions';
import {DeliverectActions, DeliverectLoadAccounts, DeliverectLogIn, DeliverectLogOut} from './deliverect.actions';

@@ -37,3 +37,3 @@ // .......................................................................................................................................

this.logger.debugOperator('DeliverectEffects', LogLevel.INFO),
map( () => {
tap( () => {
this.deliverectService.LogOut();

@@ -44,7 +44,7 @@ })

@Effect({dispatch: false})
DeliverectLoadAll$ = this.actions$.pipe(
ofType(DeliverectLoadAll.type),
DeliverectLoadAccounts$ = this.actions$.pipe(
ofType(DeliverectLoadAccounts.type),
this.logger.debugOperator('DeliverectEffects', LogLevel.INFO),
map( () => {
return this.deliverectService.LoadAll();
return this.deliverectService.LoadAccounts();
})

@@ -51,0 +51,0 @@ );

@@ -1,11 +0,22 @@

import {forkJoin} from 'rxjs';
import {map, timeout} from 'rxjs/operators';
import {timeout} from 'rxjs/operators';
import {Injectable} from '@angular/core';
import {HttpBackend, HttpClient, HttpHeaders} from '@angular/common/http';
import {Store} from '@ngrx/store';
import * as moment from 'moment';
import {Moment} from 'moment';
import * as moment from 'moment';
import {CompleteDeliverectConfig, DeliverectConfigIsEmpty, IAuthAnswerBody, IDeliverectConfig} from '../intfs/auth';
import {DeliverectLoaded, DeliverectLoadError, DeliverectLoggedIn, DeliverectLogInError} from './deliverect.actions';
import {
DeliverectAccountsLoaded,
DeliverectLoadError,
DeliverectLoggedIn,
DeliverectLogInError
} from './deliverect.actions';
import {IAnswerEnvelope} from '../intfs/answer';
import {IAccount} from '../intfs/account';
import {Observable, of} from 'rxjs';
import {ILocation} from '../intfs/location';
import {IChannelLink} from '../intfs/channel';
import {ICategory} from '../intfs/category';
import {IProduct} from '../intfs/product';

@@ -33,4 +44,3 @@ @Injectable({

) {
// By Pass Global Interceptor
// https://medium.com/mikes-fullstack-ladder/how-to-skip-http-interceptor-dee136e54a5f
// By Pass Global Interceptor https://medium.com/mikes-fullstack-ladder/how-to-skip-http-interceptor-dee136e54a5f
this.http = new HttpClient(handler);

@@ -141,5 +151,24 @@ }

* Load All [Accounts,Locations,...]
* Load all using embedded syntax
*/
public LoadAll() {
private static ParseAccounts(account: IAccount[]): IAccount[] {
if (!account || account.length === 0)
return [];
const res : IAccount[] = [];
account.forEach((item) => {
if (item.locations && item.locations.length > 0) {
res.push(item);
}
});
return res
}
// ................... ................................................................................................
/**
* Load All [Accounts,Locations,...]
* Load all using embedded syntax.
*/
public LoadAccounts() {
if (!this.tokenValid) {

@@ -152,18 +181,92 @@ // Missing Valid Token

this.PrepareHttpOptions();
const accounts = this.http.get(this.config.apiUri + 'accounts', this.httpOptions).pipe(
let url = this.config.apiUri + 'accounts?';
url += 'embedded={"locations": 1, "locations.channelLinks": 1 }';
url += '&max_results=500';
return this.http.get(url, this.httpOptions).pipe(
// delay(5000),
timeout(timeoutMSec),
map((res) => {
console.log(res);
})
);
return forkJoin([accounts]).subscribe(
() => this.store$.dispatch(DeliverectLoaded()),
timeout(timeoutMSec)
).subscribe(
(res:any) => {
let answer = <IAnswerEnvelope>res;
if (!answer?._meta)
return this.store$.dispatch(DeliverectLoadError({error:'Missing Meta Info'}));
if (answer?._meta.total>=answer?._meta.max_results)
return this.store$.dispatch(DeliverectLoadError({error:'Too many pages'}));
const accounts = DeliverectService.ParseAccounts(<IAccount[]>answer?._items);
if (accounts.length ===0) {
return this.store$.dispatch(DeliverectLoadError({error:'No Account Found'}));
}
// OK Got Data, update the store
return this.store$.dispatch(DeliverectAccountsLoaded({accounts:accounts}));
},
error => this.store$.dispatch(DeliverectLoadError(error))
);
}
// ...................................................................................................................
/**
* Upload Categories and Products
*/
public UploadProducts(account: IAccount, location: ILocation, categories: Partial<ICategory>[], products: Partial<IProduct>[]) : Observable<any> {
const timeoutMSec = 2000;
const body = {
accountId : account ? account._id : '',
locationId : location ? location._id : '',
categories: categories,
products: products
}
this.PrepareHttpOptions();
let url = this.config.apiUri + 'productAndCategories';
return this.http.post(url, body, this.httpOptions).pipe(
timeout(timeoutMSec)
)
}
// ...................................................................................................................
/**
* SyncProduct insertUpdateDeletePOSProducts
*/
public SyncProduct(account: IAccount, location: ILocation) : Observable<any> {
const timeoutMSec = 2000;
this.PrepareHttpOptions();
let url = this.config.apiUri + 'insertUpdateDeletePOSProducts/' + location._id;
return this.http.get(url, this.httpOptions).pipe(
timeout(timeoutMSec)
)
}
// ...................................................................................................................
/**
* BusyMode
*/
public BusyMode(_account: IAccount, _location: ILocation) : Observable<any> {
return of('Not Implemented');
}
// ...................................................................................................................
/**
* Open Resto activateChannelLink
*/
OpenResto(account: IAccount, location: ILocation, channel: IChannelLink) : Observable<any> {
const timeoutMSec = 2000;
this.PrepareHttpOptions();
let url = this.config.apiUri + 'activateChannelLink/' + channel._id;
return this.http.post(url, undefined, this.httpOptions).pipe(
timeout(timeoutMSec)
)
}
// ...................................................................................................................
/**
* Close Resto disableChannelLink
*/
CloseResto(account: IAccount, location: ILocation, channel: IChannelLink) : Observable<any> {
const timeoutMSec = 2000;
this.PrepareHttpOptions();
let url = this.config.apiUri + 'disableChannelLink/' + channel._id;
return this.http.post(url, undefined, this.httpOptions).pipe(
timeout(timeoutMSec)
)
}
}
import {createReducer, on} from '@ngrx/store';
import {IAccount} from '../intfs/account';
import {
DeliverectLoadAll, DeliverectLoaded, DeliverectLoadError,
DeliverectLoadAccounts, DeliverectAccountsLoaded, DeliverectLoadError,
DeliverectLoggedIn,

@@ -15,2 +16,3 @@ DeliverectLogIn,

isLoaded: boolean;
accounts?: IAccount[];
}

@@ -22,2 +24,4 @@

export const getDeliverectIsLogIn = (deliverect: AppDeliverectState) => deliverect.isLogIn;
export const getDeliverectIsLoaded = (deliverect: AppDeliverectState) => deliverect.isLoaded;
export const getDeliverectAccounts = (deliverect: AppDeliverectState) => deliverect.accounts;

@@ -32,5 +36,5 @@ // .......................................................................................................................................

on(DeliverectLoadAll, (state) => ({...state, LoadError: '', Loading: true, isLoaded: false})),
on(DeliverectLoaded, (state) => ({...state, LoadError: '', Loading: false, isLoaded: true})),
on(DeliverectLoadAccounts, (state) => ({...state, LoadError: '', Loading: true, isLoaded: false})),
on(DeliverectAccountsLoaded, (state, accounts) => ({...state, accounts:accounts.accounts, LoadError: '', Loading: false, isLoaded: true})),
on(DeliverectLoadError, (state, error: any) => ({...state, LoadError: JSON.stringify(error?.error || error?.message || error), Loading: false, isLoaded: false})),
)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc