@go-avro/avro-js 0.0.4-beta.3 → 0.0.4-beta.31
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/auth/AuthManager.d.ts +2 -2
- package/dist/client/QueryClient.d.ts +55 -2
- package/dist/client/QueryClient.js +29 -7
- package/dist/client/hooks/catalog_items.js +8 -1
- package/dist/client/hooks/jobs.js +7 -3
- package/dist/client/hooks/prepayments.js +60 -1
- package/dist/client/hooks/proposal.js +8 -1
- package/dist/client/hooks/routes.js +13 -8
- package/dist/client/hooks/users.js +15 -1
- package/dist/client/hooks/waivers.d.ts +1 -0
- package/dist/client/hooks/waivers.js +123 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/api/AdditionalCharge.d.ts +5 -0
- package/dist/types/api/AdditionalCharge.js +1 -0
- package/dist/types/api/Avro.d.ts +11 -0
- package/dist/types/api/Avro.js +1 -0
- package/dist/types/api/Bill.d.ts +27 -0
- package/dist/types/api/Bill.js +1 -0
- package/dist/types/api/BillPayment.d.ts +13 -0
- package/dist/types/api/BillPayment.js +1 -0
- package/dist/types/api/BillUser.d.ts +11 -0
- package/dist/types/api/BillUser.js +1 -0
- package/dist/types/api/Break.d.ts +7 -0
- package/dist/types/api/Break.js +1 -0
- package/dist/types/api/CatalogItem.d.ts +16 -0
- package/dist/types/api/CatalogItem.js +1 -0
- package/dist/types/api/Chat.d.ts +12 -0
- package/dist/types/api/Chat.js +1 -0
- package/dist/types/api/Company.d.ts +58 -0
- package/dist/types/api/Company.js +1 -0
- package/dist/types/api/CustomLineItem.d.ts +4 -0
- package/dist/types/api/CustomLineItem.js +1 -0
- package/dist/types/api/Email.d.ts +21 -0
- package/dist/types/api/Email.js +1 -0
- package/dist/types/api/Friendship.d.ts +2 -0
- package/dist/types/api/Friendship.js +1 -0
- package/dist/types/api/Group.d.ts +12 -0
- package/dist/types/api/Group.js +1 -0
- package/dist/types/api/Job.d.ts +36 -0
- package/dist/types/api/Job.js +22 -0
- package/dist/types/api/Label.d.ts +7 -0
- package/dist/types/api/Label.js +1 -0
- package/dist/types/api/LineItem.d.ts +41 -0
- package/dist/types/api/LineItem.js +30 -0
- package/dist/types/api/MemberState.d.ts +7 -0
- package/dist/types/api/MemberState.js +1 -0
- package/dist/types/api/Message.d.ts +13 -0
- package/dist/types/api/Message.js +1 -0
- package/dist/types/api/PaymentMethod.d.ts +51 -0
- package/dist/types/api/PaymentMethod.js +1 -0
- package/dist/types/api/PaymentOption.d.ts +9 -0
- package/dist/types/api/PaymentOption.js +1 -0
- package/dist/types/api/PaymentType.d.ts +5 -0
- package/dist/types/api/PaymentType.js +5 -0
- package/dist/types/api/Plan.d.ts +13 -0
- package/dist/types/api/Plan.js +1 -0
- package/dist/types/api/PlanPayment.d.ts +10 -0
- package/dist/types/api/PlanPayment.js +1 -0
- package/dist/types/api/Prepayment.d.ts +15 -0
- package/dist/types/api/Prepayment.js +7 -0
- package/dist/types/api/Reaction.d.ts +8 -0
- package/dist/types/api/Reaction.js +1 -0
- package/dist/types/api/Route.d.ts +37 -0
- package/dist/types/api/Route.js +82 -0
- package/dist/types/api/RouteJob.d.ts +15 -0
- package/dist/types/api/RouteJob.js +5 -0
- package/dist/types/api/ServiceMonth.d.ts +7 -0
- package/dist/types/api/ServiceMonth.js +1 -0
- package/dist/types/api/Session.d.ts +13 -0
- package/dist/types/api/Session.js +1 -0
- package/dist/types/api/Skill.d.ts +7 -0
- package/dist/types/api/Skill.js +1 -0
- package/dist/types/api/Subscription.d.ts +8 -0
- package/dist/types/api/Subscription.js +1 -0
- package/dist/types/api/Task.d.ts +57 -0
- package/dist/types/api/Task.js +74 -0
- package/dist/types/api/User.d.ts +23 -0
- package/dist/types/api/User.js +1 -0
- package/dist/types/api/UserCompanyAssociation.d.ts +71 -0
- package/dist/types/api/UserCompanyAssociation.js +53 -0
- package/dist/types/api/UserEvent.d.ts +13 -0
- package/dist/types/api/UserEvent.js +1 -0
- package/dist/types/api/Waiver.d.ts +9 -0
- package/dist/types/api/Waiver.js +1 -0
- package/dist/types/api/_Event.d.ts +19 -0
- package/dist/types/api/_Event.js +1 -0
- package/dist/types/api.d.ts +43 -587
- package/dist/types/api.js +37 -74
- package/dist/types/cache.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface BillPayment {
|
|
2
|
+
id: string;
|
|
3
|
+
amount: number;
|
|
4
|
+
avro_fees: number;
|
|
5
|
+
stripe_fees: number;
|
|
6
|
+
stripe_pi_id: string;
|
|
7
|
+
bill_user_id: string;
|
|
8
|
+
status: "created" | "processing" | "succeeded" | "failed" | "canceled" | "requires_action";
|
|
9
|
+
type: "us_bank_account" | "card";
|
|
10
|
+
action_required_at: number;
|
|
11
|
+
time_created: number;
|
|
12
|
+
time_updated: number | null;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BillPayment } from "../../types/api/BillPayment";
|
|
2
|
+
export interface BillUser {
|
|
3
|
+
id: string;
|
|
4
|
+
user_id: string;
|
|
5
|
+
bill_id: string;
|
|
6
|
+
invoice_id: string;
|
|
7
|
+
payment_attempts: BillPayment[];
|
|
8
|
+
time_created: number;
|
|
9
|
+
time_updated: number | null;
|
|
10
|
+
amount: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PaymentOption } from "../../types/api/PaymentOption";
|
|
2
|
+
export interface CatalogItem {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
company_id: string;
|
|
6
|
+
description: string;
|
|
7
|
+
industry: string;
|
|
8
|
+
price_format: string;
|
|
9
|
+
payment_options: PaymentOption[];
|
|
10
|
+
recommended_frequency?: number | null;
|
|
11
|
+
recommended_activate_on?: number | null;
|
|
12
|
+
recommended_expire_on?: number | null;
|
|
13
|
+
time_created: number;
|
|
14
|
+
time_updated: number | null;
|
|
15
|
+
skills: string[];
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Message } from "../../types/api/Message";
|
|
2
|
+
import { MemberState } from "../../types/api/MemberState";
|
|
3
|
+
export interface Chat {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
company_id: string;
|
|
7
|
+
time_created: number;
|
|
8
|
+
time_updated: number;
|
|
9
|
+
last_message: Message;
|
|
10
|
+
user_state: MemberState[];
|
|
11
|
+
messages: Message[];
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Bill } from "../../types/api/Bill";
|
|
2
|
+
import { Email } from "../../types/api/Email";
|
|
3
|
+
import { Group } from "../../types/api/Group";
|
|
4
|
+
import { Label } from "../../types/api/Label";
|
|
5
|
+
import { PaymentMethod } from "../../types/api/PaymentMethod";
|
|
6
|
+
import { PaymentType } from "../../types/api/PaymentType";
|
|
7
|
+
import { Plan } from "../../types/api/Plan";
|
|
8
|
+
import { PlanPayment } from "../../types/api/PlanPayment";
|
|
9
|
+
import { Session } from "../../types/api/Session";
|
|
10
|
+
import { Skill } from "../../types/api/Skill";
|
|
11
|
+
import { UserCompanyAssociation } from "../../types/api/UserCompanyAssociation";
|
|
12
|
+
import { CatalogItem } from "../../types/api/CatalogItem";
|
|
13
|
+
export interface Company {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
email: string;
|
|
17
|
+
emails: Email[];
|
|
18
|
+
skills: Skill[];
|
|
19
|
+
catalog_items: CatalogItem[];
|
|
20
|
+
time_created: number;
|
|
21
|
+
time_updated: number | null;
|
|
22
|
+
users: UserCompanyAssociation[];
|
|
23
|
+
use_client_side_customer_start_billing: boolean;
|
|
24
|
+
use_client_side_customer_stop_billing: boolean;
|
|
25
|
+
use_client_side_employee_start_billing: boolean;
|
|
26
|
+
use_client_side_employee_stop_billing: boolean;
|
|
27
|
+
logo_url: string;
|
|
28
|
+
delay_scalar: number;
|
|
29
|
+
payments: PlanPayment[];
|
|
30
|
+
overdue_threshold: number;
|
|
31
|
+
stripe_account_id: string;
|
|
32
|
+
is_restricted: boolean;
|
|
33
|
+
disabled_reason: string;
|
|
34
|
+
completed_onboarding: boolean;
|
|
35
|
+
restricted_soon: boolean;
|
|
36
|
+
service_email_id: string;
|
|
37
|
+
billing_email_id: string;
|
|
38
|
+
num_events: number;
|
|
39
|
+
num_jobs: number;
|
|
40
|
+
num_routes: number;
|
|
41
|
+
num_teams: number;
|
|
42
|
+
num_skills: number;
|
|
43
|
+
bills: Bill[];
|
|
44
|
+
enabled_payment_methods: PaymentType[];
|
|
45
|
+
sessions: Session[];
|
|
46
|
+
num_sessions: number;
|
|
47
|
+
labels: Label[];
|
|
48
|
+
groups: Group[];
|
|
49
|
+
indicator_lifetime: number;
|
|
50
|
+
available_plans: Plan[];
|
|
51
|
+
last_payment: number;
|
|
52
|
+
last_charged: number;
|
|
53
|
+
balance: number;
|
|
54
|
+
plan_id: string;
|
|
55
|
+
payment_methods: PaymentMethod[];
|
|
56
|
+
intuit_connected: boolean;
|
|
57
|
+
next_payment_due: number | null;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { User } from "../../types/api/User";
|
|
2
|
+
export interface Email {
|
|
3
|
+
id: string;
|
|
4
|
+
company_id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
mail_server: string;
|
|
7
|
+
mail_port: number;
|
|
8
|
+
mail_username: string;
|
|
9
|
+
mail_password: string | null;
|
|
10
|
+
mail_default_sender: string;
|
|
11
|
+
mail_use_tls: boolean;
|
|
12
|
+
mail_use_ssl: boolean;
|
|
13
|
+
mail_api_key: string;
|
|
14
|
+
is_company_wide: boolean;
|
|
15
|
+
users: User[];
|
|
16
|
+
type: "OUTLOOK" | "SMTP" | "GMAIL";
|
|
17
|
+
access_token?: string;
|
|
18
|
+
access_token_expiry?: number;
|
|
19
|
+
refresh_token?: string;
|
|
20
|
+
refresh_token_expiry?: number;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Permission } from "../../types/api/UserCompanyAssociation";
|
|
2
|
+
export interface Group {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
is_active: boolean;
|
|
6
|
+
is_user_type: boolean;
|
|
7
|
+
users: string[];
|
|
8
|
+
permissions: Permission[];
|
|
9
|
+
company_id: string;
|
|
10
|
+
time_created: number;
|
|
11
|
+
time_updated: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Task } from "../../types/api/Task";
|
|
2
|
+
import { _Event } from "../../types/api/_Event";
|
|
3
|
+
import { RouteJob } from "../../types/api/RouteJob";
|
|
4
|
+
import { Subscription } from "../../types/api/Subscription";
|
|
5
|
+
declare module '../../types/api/Job' {
|
|
6
|
+
interface Job {
|
|
7
|
+
address: string;
|
|
8
|
+
company: string;
|
|
9
|
+
description: string;
|
|
10
|
+
id: string;
|
|
11
|
+
is_one_time: boolean;
|
|
12
|
+
autostart_radius: number;
|
|
13
|
+
latitude: number;
|
|
14
|
+
longitude: number;
|
|
15
|
+
name: string;
|
|
16
|
+
internal_notes: string;
|
|
17
|
+
external_notes: string;
|
|
18
|
+
priority: number;
|
|
19
|
+
tasks: Partial<Task>[];
|
|
20
|
+
time_created: number;
|
|
21
|
+
time_updated: number | null;
|
|
22
|
+
routes: RouteJob[];
|
|
23
|
+
subscribers: Subscription[];
|
|
24
|
+
manual_emails: string[][];
|
|
25
|
+
overdue_time: number;
|
|
26
|
+
last_completed_event: _Event | null;
|
|
27
|
+
current_event: _Event | null;
|
|
28
|
+
labels: string[];
|
|
29
|
+
owner: string;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export declare class Job {
|
|
33
|
+
constructor(init?: Partial<Job>);
|
|
34
|
+
portionDone: (fallback?: Date | null, routeJob?: RouteJob) => number;
|
|
35
|
+
isDone: (fallback?: Date | null, routeJob?: RouteJob) => boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Task } from "../../types/api/Task";
|
|
2
|
+
import { RouteJob } from "../../types/api/RouteJob";
|
|
3
|
+
export class Job {
|
|
4
|
+
constructor(init) {
|
|
5
|
+
this.portionDone = (fallback, routeJob) => {
|
|
6
|
+
if (!this.tasks || this.tasks.length === 0) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
return this.tasks.filter(t => t.isDone?.(fallback) && (!routeJob || !t.id || routeJob.tasks.includes(t.id))).length / this.tasks.length;
|
|
10
|
+
};
|
|
11
|
+
this.isDone = (fallback, routeJob) => {
|
|
12
|
+
return this.portionDone(fallback, routeJob) === 1;
|
|
13
|
+
};
|
|
14
|
+
Object.assign(this, init);
|
|
15
|
+
if (init?.tasks) {
|
|
16
|
+
this.tasks = init.tasks.map(t => new Task(t));
|
|
17
|
+
}
|
|
18
|
+
if (init?.routes) {
|
|
19
|
+
this.routes = init.routes.map(r => new RouteJob(r));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const LineItemStatus: {
|
|
2
|
+
readonly CREATED: "CREATED";
|
|
3
|
+
readonly EXTERNALLY_BILLED: "EXTERNALLY_BILLED";
|
|
4
|
+
readonly BILLED: "BILLED";
|
|
5
|
+
readonly PROCESSING: "PROCESSING";
|
|
6
|
+
readonly EXTERNALLY_PAID: "EXTERNALLY_PAID";
|
|
7
|
+
readonly PREPAID: "PREPAID";
|
|
8
|
+
readonly PAID: "PAID";
|
|
9
|
+
};
|
|
10
|
+
export type LineItemStatus = typeof LineItemStatus[keyof typeof LineItemStatus];
|
|
11
|
+
export declare const LineItemType: {
|
|
12
|
+
readonly CUSTOM: "CUSTOM";
|
|
13
|
+
readonly ADDITIONAL_CHARGE: "ADDITIONAL_CHARGE";
|
|
14
|
+
readonly EVENT: "EVENT";
|
|
15
|
+
readonly SERVICE_MONTH: "SERVICE_MONTH";
|
|
16
|
+
readonly PREPAYMENT: "PREPAYMENT";
|
|
17
|
+
};
|
|
18
|
+
export type LineItemType = typeof LineItemType[keyof typeof LineItemType];
|
|
19
|
+
declare module '../../types/api/LineItem' {
|
|
20
|
+
interface LineItem {
|
|
21
|
+
id: string;
|
|
22
|
+
line_item_type: LineItemType;
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
cost: number;
|
|
26
|
+
amount: number;
|
|
27
|
+
status: LineItemStatus;
|
|
28
|
+
job_id: string;
|
|
29
|
+
job_name: string;
|
|
30
|
+
job_address: string;
|
|
31
|
+
job_labels: string[];
|
|
32
|
+
company_id: string;
|
|
33
|
+
time_created: number;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export declare class LineItem {
|
|
37
|
+
constructor(init?: Partial<LineItem>);
|
|
38
|
+
isPaid: () => boolean;
|
|
39
|
+
isBilled: () => boolean;
|
|
40
|
+
isUnbilled: () => boolean;
|
|
41
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const LineItemStatus = {
|
|
2
|
+
CREATED: "CREATED",
|
|
3
|
+
EXTERNALLY_BILLED: "EXTERNALLY_BILLED",
|
|
4
|
+
BILLED: "BILLED",
|
|
5
|
+
PROCESSING: "PROCESSING",
|
|
6
|
+
EXTERNALLY_PAID: "EXTERNALLY_PAID",
|
|
7
|
+
PREPAID: "PREPAID",
|
|
8
|
+
PAID: "PAID",
|
|
9
|
+
};
|
|
10
|
+
export const LineItemType = {
|
|
11
|
+
CUSTOM: "CUSTOM",
|
|
12
|
+
ADDITIONAL_CHARGE: "ADDITIONAL_CHARGE",
|
|
13
|
+
EVENT: "EVENT",
|
|
14
|
+
SERVICE_MONTH: "SERVICE_MONTH",
|
|
15
|
+
PREPAYMENT: "PREPAYMENT",
|
|
16
|
+
};
|
|
17
|
+
export class LineItem {
|
|
18
|
+
constructor(init) {
|
|
19
|
+
this.isPaid = () => {
|
|
20
|
+
return this.status === LineItemStatus.PAID || this.status === LineItemStatus.PREPAID || this.status === LineItemStatus.EXTERNALLY_PAID;
|
|
21
|
+
};
|
|
22
|
+
this.isBilled = () => {
|
|
23
|
+
return this.status === LineItemStatus.BILLED || this.status === LineItemStatus.EXTERNALLY_BILLED;
|
|
24
|
+
};
|
|
25
|
+
this.isUnbilled = () => {
|
|
26
|
+
return !this.isBilled() && !this.isPaid();
|
|
27
|
+
};
|
|
28
|
+
Object.assign(this, init);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Reaction } from "../../types/api/Reaction";
|
|
2
|
+
export interface Message {
|
|
3
|
+
id: string;
|
|
4
|
+
chat_id: string;
|
|
5
|
+
sender_id: string;
|
|
6
|
+
reply_to_id: string;
|
|
7
|
+
content: string;
|
|
8
|
+
reactions: Reaction[];
|
|
9
|
+
time_created: number;
|
|
10
|
+
time_updated: number;
|
|
11
|
+
time_sent: number;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PaymentType } from "../../types/api/PaymentType";
|
|
2
|
+
export interface PaymentMethod {
|
|
3
|
+
allow_redisplay: string;
|
|
4
|
+
autopay: boolean;
|
|
5
|
+
billing_details: {
|
|
6
|
+
email: string;
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
created: number;
|
|
10
|
+
customer: string;
|
|
11
|
+
id: string;
|
|
12
|
+
type: PaymentType;
|
|
13
|
+
us_bank_account: {
|
|
14
|
+
account_holder_type: string;
|
|
15
|
+
account_type: string;
|
|
16
|
+
bank_name: string;
|
|
17
|
+
financial_connections_account: string;
|
|
18
|
+
fingerprint: string;
|
|
19
|
+
last4: string;
|
|
20
|
+
networks: {
|
|
21
|
+
preferred: string;
|
|
22
|
+
supported: string[];
|
|
23
|
+
};
|
|
24
|
+
routing_number: string;
|
|
25
|
+
status_details: object;
|
|
26
|
+
} | null;
|
|
27
|
+
card: {
|
|
28
|
+
brand: string;
|
|
29
|
+
checks: {
|
|
30
|
+
address_line1_check: string;
|
|
31
|
+
address_postal_code_check: string;
|
|
32
|
+
cvc_check: string;
|
|
33
|
+
};
|
|
34
|
+
country: string;
|
|
35
|
+
exp_month: number;
|
|
36
|
+
exp_year: number;
|
|
37
|
+
fingerprint: string;
|
|
38
|
+
funding: string;
|
|
39
|
+
last4: string;
|
|
40
|
+
networks: {
|
|
41
|
+
preferred: string;
|
|
42
|
+
supported: string[];
|
|
43
|
+
};
|
|
44
|
+
three_d_secure_usage: {
|
|
45
|
+
supported: boolean;
|
|
46
|
+
};
|
|
47
|
+
wallet: {
|
|
48
|
+
type: string;
|
|
49
|
+
} | null;
|
|
50
|
+
} | null;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Plan {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
base_rate: number;
|
|
5
|
+
price_per_job: number;
|
|
6
|
+
description: string;
|
|
7
|
+
referral_codes: string[];
|
|
8
|
+
trial_period_days: number;
|
|
9
|
+
time_created: number;
|
|
10
|
+
time_updated: number;
|
|
11
|
+
available_to_new_companies?: boolean;
|
|
12
|
+
available_to?: string[];
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LineItem } from "../../types/api/LineItem";
|
|
2
|
+
declare module '../../types/api/Prepayment' {
|
|
3
|
+
interface Prepayment extends LineItem {
|
|
4
|
+
id: string;
|
|
5
|
+
task_id: string | null;
|
|
6
|
+
line_item_type: "PREPAYMENT";
|
|
7
|
+
type: "SERVICE" | "MONTH";
|
|
8
|
+
time_updated: number | null;
|
|
9
|
+
num_events: number;
|
|
10
|
+
num_service_months: number;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare class Prepayment extends LineItem {
|
|
14
|
+
constructor(init?: Partial<Prepayment>);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RouteJob } from "../../types/api/RouteJob";
|
|
2
|
+
export declare const FrequencyType: {
|
|
3
|
+
readonly ONCE: "ONCE";
|
|
4
|
+
readonly DAILY: "DAILY";
|
|
5
|
+
readonly WEEKLY: "WEEKLY";
|
|
6
|
+
readonly BIWEEKLY: "BIWEEKLY";
|
|
7
|
+
readonly MONTHLY: "MONTHLY";
|
|
8
|
+
readonly YEARLY: "YEARLY";
|
|
9
|
+
};
|
|
10
|
+
export type FrequencyType = typeof FrequencyType[keyof typeof FrequencyType];
|
|
11
|
+
declare module '../../types/api/Route' {
|
|
12
|
+
interface Route {
|
|
13
|
+
company: string;
|
|
14
|
+
id: string;
|
|
15
|
+
is_internal: boolean;
|
|
16
|
+
jobs: RouteJob[];
|
|
17
|
+
name: string;
|
|
18
|
+
time_created: number;
|
|
19
|
+
time_updated: number | null;
|
|
20
|
+
teams: string[];
|
|
21
|
+
polyline: string;
|
|
22
|
+
is_optimized: boolean;
|
|
23
|
+
start_time: number;
|
|
24
|
+
end_time: number;
|
|
25
|
+
start_latitude: number;
|
|
26
|
+
start_longitude: number;
|
|
27
|
+
end_latitude: number;
|
|
28
|
+
end_longitude: number;
|
|
29
|
+
frequency: typeof FrequencyType[keyof typeof FrequencyType];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export declare class Route {
|
|
33
|
+
constructor(init?: Partial<Route>);
|
|
34
|
+
getNextOccurrences: (count?: number) => (Date | null)[];
|
|
35
|
+
getNextOccurrence: (after?: Date) => Date | null;
|
|
36
|
+
getIndicatorExpiration: () => Date;
|
|
37
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { RouteJob } from "../../types/api/RouteJob";
|
|
2
|
+
export const FrequencyType = {
|
|
3
|
+
ONCE: "ONCE",
|
|
4
|
+
DAILY: "DAILY",
|
|
5
|
+
WEEKLY: "WEEKLY",
|
|
6
|
+
BIWEEKLY: "BIWEEKLY",
|
|
7
|
+
MONTHLY: "MONTHLY",
|
|
8
|
+
YEARLY: "YEARLY",
|
|
9
|
+
};
|
|
10
|
+
export class Route {
|
|
11
|
+
constructor(init) {
|
|
12
|
+
this.getNextOccurrences = (count = 1) => {
|
|
13
|
+
let next_occurrences = [];
|
|
14
|
+
for (let i = 0; i < count; i++) {
|
|
15
|
+
next_occurrences.push(this.getNextOccurrence(next_occurrences.length > 0 ? next_occurrences[next_occurrences.length - 1] ?? new Date() : new Date()));
|
|
16
|
+
}
|
|
17
|
+
return next_occurrences;
|
|
18
|
+
};
|
|
19
|
+
this.getNextOccurrence = (after = new Date()) => {
|
|
20
|
+
let next_occurrence = new Date(this.start_time * 1000);
|
|
21
|
+
while (next_occurrence <= after) {
|
|
22
|
+
switch (this.frequency) {
|
|
23
|
+
case FrequencyType.ONCE:
|
|
24
|
+
return null;
|
|
25
|
+
case FrequencyType.DAILY:
|
|
26
|
+
next_occurrence.setDate(next_occurrence.getDate() + 1);
|
|
27
|
+
break;
|
|
28
|
+
case FrequencyType.WEEKLY:
|
|
29
|
+
next_occurrence.setDate(next_occurrence.getDate() + 7);
|
|
30
|
+
break;
|
|
31
|
+
case FrequencyType.BIWEEKLY:
|
|
32
|
+
next_occurrence.setDate(next_occurrence.getDate() + 14);
|
|
33
|
+
break;
|
|
34
|
+
case FrequencyType.MONTHLY:
|
|
35
|
+
next_occurrence.setMonth(next_occurrence.getMonth() + 1);
|
|
36
|
+
break;
|
|
37
|
+
case FrequencyType.YEARLY:
|
|
38
|
+
next_occurrence.setFullYear(next_occurrence.getFullYear() + 1);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return next_occurrence;
|
|
43
|
+
};
|
|
44
|
+
this.getIndicatorExpiration = () => {
|
|
45
|
+
const start_time = new Date(this.start_time * 1000);
|
|
46
|
+
if (this.frequency === FrequencyType.ONCE) {
|
|
47
|
+
return start_time;
|
|
48
|
+
}
|
|
49
|
+
// if the route is currently active, return the start time as the indicator expiration
|
|
50
|
+
if (Date.now() > start_time.getTime()) {
|
|
51
|
+
return start_time;
|
|
52
|
+
}
|
|
53
|
+
// else compute the previous occurrence and return that as the indicator expiration
|
|
54
|
+
const prev = new Date(start_time);
|
|
55
|
+
switch (this.frequency) {
|
|
56
|
+
case FrequencyType.DAILY:
|
|
57
|
+
prev.setHours(prev.getHours() - 4);
|
|
58
|
+
prev.setDate(prev.getDate() - 1);
|
|
59
|
+
break;
|
|
60
|
+
case FrequencyType.WEEKLY:
|
|
61
|
+
prev.setDate(prev.getDate() - 8);
|
|
62
|
+
break;
|
|
63
|
+
case FrequencyType.BIWEEKLY:
|
|
64
|
+
prev.setDate(prev.getDate() - 15);
|
|
65
|
+
break;
|
|
66
|
+
case FrequencyType.MONTHLY:
|
|
67
|
+
prev.setDate(prev.getDate() - 1);
|
|
68
|
+
prev.setMonth(prev.getMonth() - 1);
|
|
69
|
+
break;
|
|
70
|
+
case FrequencyType.YEARLY:
|
|
71
|
+
prev.setDate(prev.getDate() - 1);
|
|
72
|
+
prev.setFullYear(prev.getFullYear() - 1);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return prev;
|
|
76
|
+
};
|
|
77
|
+
Object.assign(this, init);
|
|
78
|
+
if (init?.jobs) {
|
|
79
|
+
this.jobs = init.jobs.map(j => new RouteJob(j));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|