forked from Wroclaw/WorkshopTasker
update cuz presentation
This commit is contained in:
parent
7a9e451739
commit
4e67cc4e19
29 changed files with 1065 additions and 88 deletions
51
utils/snowflake.ts
Normal file
51
utils/snowflake.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
export default class Snowflake {
|
||||
static current_increment = 0n;
|
||||
|
||||
public static increment() {
|
||||
this.current_increment = BigInt.asUintN(12, this.current_increment + 1n);
|
||||
return this.current_increment;
|
||||
}
|
||||
|
||||
state = 0n;
|
||||
public set_timestamp(value: number | bigint) {
|
||||
value = BigInt.asUintN(64 - 22, BigInt(value));
|
||||
const state = BigInt.asUintN(22, this.state);
|
||||
this.state = state + (value << 22n);
|
||||
}
|
||||
|
||||
public set_machineid(value: number | bigint) {
|
||||
value = BigInt.asUintN(12 - 17, BigInt(value));
|
||||
const state = BigInt.asUintN(17, this.state) + (this.state >> 22n) << 22n;
|
||||
this.state = state + (value << 12n);
|
||||
}
|
||||
|
||||
public set_processid(value: number | bigint) {
|
||||
value = BigInt.asUintN(17 - 12, BigInt(value));
|
||||
const state = BigInt.asUintN(12, this.state) + (this.state >> 17n) << 17n;
|
||||
this.state = state + (value << 12n);
|
||||
}
|
||||
|
||||
public set_increment(value: number | bigint) {
|
||||
value = BigInt.asUintN(12 - 0, BigInt(value));
|
||||
const state = (this.state >> 12n) << 12n;
|
||||
this.state = state + (value << 0n);
|
||||
}
|
||||
|
||||
constructor(value?: bigint) {
|
||||
if (value) {
|
||||
this.state = BigInt.asUintN(64, value);
|
||||
return;
|
||||
}
|
||||
this.set_timestamp(Date.now());
|
||||
this.set_processid(1);
|
||||
this.set_increment(Snowflake.increment());
|
||||
}
|
||||
|
||||
public toString() {
|
||||
return this.state.toString();
|
||||
}
|
||||
|
||||
public get timestamp() {
|
||||
return BigInt.asUintN(64 - 22, this.state >> 22n);
|
||||
}
|
||||
}
|
|
@ -1,68 +1,99 @@
|
|||
export interface client {
|
||||
id: string,
|
||||
name: string | null,
|
||||
address: string | null,
|
||||
phone: string | null,
|
||||
email: string | null,
|
||||
id: string;
|
||||
name: string | null;
|
||||
address: string | null;
|
||||
phone: string | null;
|
||||
email: string | null;
|
||||
}
|
||||
|
||||
export interface user {
|
||||
id: string,
|
||||
username: string,
|
||||
email: string,
|
||||
display_name?: string,
|
||||
id: string;
|
||||
username: string;
|
||||
email: string;
|
||||
display_name?: string;
|
||||
}
|
||||
|
||||
export interface session {
|
||||
id: string,
|
||||
user: string,
|
||||
expiry_date: string,
|
||||
id: string;
|
||||
user: string;
|
||||
expiry_date: string;
|
||||
}
|
||||
|
||||
export interface imported_product {
|
||||
id: string,
|
||||
id: string;
|
||||
// order: string,
|
||||
name?: string,
|
||||
link: string,
|
||||
price_imported: string,
|
||||
price: string,
|
||||
name?: string;
|
||||
link: string;
|
||||
price_imported: string;
|
||||
price: string;
|
||||
}
|
||||
|
||||
export interface offer {
|
||||
id: string,
|
||||
name: string,
|
||||
description?: string,
|
||||
recommended_price?: string,
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
recommended_price?: string;
|
||||
}
|
||||
|
||||
export interface work {
|
||||
id: string,
|
||||
id: string;
|
||||
// order: string,
|
||||
offer: string|offer,
|
||||
price: string,
|
||||
notes: string,
|
||||
is_fulfilled: boolean,
|
||||
offer: string | offer;
|
||||
price: string;
|
||||
notes: string;
|
||||
is_fulfilled: boolean;
|
||||
}
|
||||
|
||||
export interface order {
|
||||
id: string,
|
||||
client: client|string,
|
||||
user: user|string,
|
||||
is_draft: boolean,
|
||||
imported_products: imported_product[],
|
||||
work: work[],
|
||||
imported_products: Array<{
|
||||
id: string;
|
||||
name: string | null;
|
||||
link: string;
|
||||
price: string;
|
||||
price_imported: string;
|
||||
}>;
|
||||
work: {
|
||||
id: string;
|
||||
offer: offer;
|
||||
price: number;
|
||||
notes: string | null;
|
||||
is_fulfilled: 0 | 1;
|
||||
}[];
|
||||
id: string;
|
||||
client: string;
|
||||
user: string;
|
||||
is_draft: 0 | 1;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface orderSummary {
|
||||
id: string;
|
||||
client: string;
|
||||
user: string;
|
||||
is_draft: 0 | 1;
|
||||
value: string;
|
||||
imported_products_count: number;
|
||||
work_count: number;
|
||||
}
|
||||
|
||||
export interface work_template {
|
||||
id: string,
|
||||
id: string;
|
||||
// order_template: string,
|
||||
offer: string|offer,
|
||||
price: string,
|
||||
notes?: string,
|
||||
offer: string | offer;
|
||||
price: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface order_template {
|
||||
id: string,
|
||||
name: string,
|
||||
description?: string,
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
// 1 is true, 0 is false
|
||||
export type Dboolean =
|
||||
| boolean
|
||||
| 0 // false
|
||||
| 1; // true
|
||||
|
||||
export type Dnumber = number | `${number}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue