Skip to content

Commit

Permalink
feat(model): mark readonly fields
Browse files Browse the repository at this point in the history
- fix: fields overlap
- add: HasDeleted
  • Loading branch information
wmakeev committed Jul 4, 2021
1 parent b6254e7 commit bd43680
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 35 deletions.
12 changes: 6 additions & 6 deletions src/model/Attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ export type AttributeJsTypeMap = {

// Custom entity
[AttributeType.CustomEntity]: EntityRef<MetaType.CustomEntity> & {
name: string
readonly name: string
}
}

export interface AttributeBase<T extends AttributeType = AttributeType>
extends Entity<MetaType.AttributeMetadata> {
/** Наименование пользовательского поля */
name: string
readonly name: string

/** Тип значения пользовательского поля */
type: T
readonly type: T

value: AttributeJsTypeMap[T]
}
Expand All @@ -68,9 +68,9 @@ export type Attribute<
T extends AttributeType = AttributeType
> = T extends AttributeType.File
? AttributeBase<T> & {
download: {
href: string
mediaType: MediaType
readonly download: {
readonly href: string
readonly mediaType: MediaType
}
}
: AttributeBase<T>
8 changes: 4 additions & 4 deletions src/model/CollectionRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import type { EntityRef } from './EntityRef'
import type { MetaType } from './MetaType'

export type CollectionPageInfo = {
size: number
limit: number
offset: number
hextHref?: string
readonly size: number
readonly limit: number
readonly offset: number
readonly hextHref?: string
}

export interface CollectionRef<T extends MetaType = MetaType>
Expand Down
8 changes: 4 additions & 4 deletions src/model/CustomerOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ export type CustomerOrder = Order<MetaType.CustomerOrder> &
HasVat & {
taxSystem?: TaxSystem

reservedSum: number
readonly reservedSum: number

purchaseOrders?: EntityRef<MetaType.PurchaseOrder>[]

// TODO Проверить связи (нет в документации?)

shippedSum: number
readonly shippedSum: number
demands?: EntityRef<MetaType.Demand>[]

invoicedSum: number
readonly invoicedSum: number
invoicesOut?: EntityRef<MetaType.InvoiceOut>[]

payedSum: number
readonly payedSum: number
payments?: EntityRef<MetaType.PaymentOut | MetaType.PaymentIn>[]
}

Expand Down
2 changes: 0 additions & 2 deletions src/model/Discount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import type { EntityRef } from './EntityRef'
import type { MetaType } from './MetaType'

export interface Discount extends Entity<MetaType.Discount> {
accountId: string

name: string

active: boolean
Expand Down
7 changes: 3 additions & 4 deletions src/model/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Entity } from './Entity'
import type { EntityRef } from './EntityRef'
import type { HasAttributes } from './HasAttributes'
import type { HasCreated } from './HasCreated'
import type { HasDeleted } from './HasDeleted'
import type { HasFiles } from './HasFiles'
import type { HasProject } from './HasProject'
import type { HasRate } from './HasRate'
Expand All @@ -23,6 +24,7 @@ export interface Document<T extends DocumentMetaType>
extends Entity<T>,
HasCreated,
HasUpdated,
HasDeleted,
HasState,
HasProject,
HasRate,
Expand All @@ -44,16 +46,13 @@ export interface Document<T extends DocumentMetaType>
/** Дата документа */
moment: string

/** Дата последнего удаления документа в корзину */
deleted?: string

readonly syncId?: string

/** Договор */
contract?: EntityRef<MetaType.Contract>

/** Сумма документа */
sum: number
readonly sum: number

// TODO agent: общий тип можно экспандить только по пересечению

Expand Down
2 changes: 1 addition & 1 deletion src/model/Employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { MetaType } from './MetaType'

export interface Employee extends Agent<MetaType.Employee> {
/** Логин Сотрудника */
uid: string
readonly uid: string

/** Краткое ФИО */
shortFio: string
Expand Down
2 changes: 1 addition & 1 deletion src/model/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { EntityRef } from './EntityRef'

export interface Entity<T extends MetaType = MetaType> extends EntityRef<T> {
/** Идентификатор сущности */
id: string
readonly id: string

/** ID учетной записи */
readonly accountId: string
Expand Down
2 changes: 1 addition & 1 deletion src/model/EntityRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import type { MetaType } from './MetaType'

export interface EntityRef<T extends MetaType = MetaType>
extends MoyskladObject {
meta: Meta<T>
readonly meta: Meta<T>
}
2 changes: 1 addition & 1 deletion src/model/HasCreated.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface HasCreated {
/** Дата создания сущности */
created: string
readonly created: string
}
4 changes: 4 additions & 0 deletions src/model/HasDeleted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface HasDeleted {
/** Момент последнего удаления (помещения в корзину) */
readonly deleted?: string
}
1 change: 1 addition & 0 deletions src/model/HasRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import type { MetaType } from './MetaType'

export interface HasRate {
currency: EntityRef<MetaType.Currency>

// TODO поля
}
5 changes: 1 addition & 4 deletions src/model/HasUpdated.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export interface HasUpdated {
/** Момент последнего обновления */
updated: string

/** Момент последнего удаления (помещения в корзину) */
deleted?: string
readonly updated: string
}
10 changes: 5 additions & 5 deletions src/model/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export interface Organization extends Company<MetaType.Organization> {
chiefAccountant: string

/** Идентификатор в ФСРАР */
fsrarId?: string
readonly fsrarId?: string

/** IP-адрес УТМ */
utmUrl?: string
readonly utmUrl?: string

trackingContractNumber?: string
readonly trackingContractNumber?: string

trackingContractDate?: Date
readonly trackingContractDate?: Date

/** Бонусная программа (meta) */
bonusProgram?: EntityRef<MetaType.BonusProgram>
readonly bonusProgram?: EntityRef<MetaType.BonusProgram>
}
5 changes: 3 additions & 2 deletions src/model/RetailDemand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { DocumentWithPositions, MetaType } from '.'

export interface RetailDemand
extends DocumentWithPositions<MetaType.RetailDemand> {
cashSum: number
noCashSum: number
readonly cashSum: number

readonly noCashSum: number
}

0 comments on commit bd43680

Please sign in to comment.