Skip to content

Commit

Permalink
feat(DocumentWithPositions): add store field
Browse files Browse the repository at this point in the history
  • Loading branch information
wmakeev committed Jul 19, 2021
1 parent 1c19dab commit c2c9338
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moysklad-api-model",
"version": "0.2.6",
"version": "0.2.7",
"description": "Объектная модель API МойСклад для TypeScript проектов",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
17 changes: 11 additions & 6 deletions src/model/DocumentWithPositions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CollectionRef } from './CollectionRef'
import type { Document, DocumentExpand, DocumentPatch } from './Document'
import type { EntityRef } from './EntityRef'
import type { DocumentPositionType, PositionPatch } from './Position'
import type { Patch } from './utils'

Expand All @@ -8,6 +9,7 @@ export type DocumentWithPositionsMetaType = keyof DocumentPositionType
export type DocumentWithPositionsFields<
T extends DocumentWithPositionsMetaType
> = {
store: EntityRef<'store'>
positions: CollectionRef<DocumentPositionType[T]>
}

Expand All @@ -17,13 +19,16 @@ export type DocumentWithPositions<

export type DocumentWithPositionsExpand<
T extends DocumentWithPositionsMetaType
> = Pick<DocumentWithPositionsFields<T>, 'positions'> & DocumentExpand<T>
> = Pick<DocumentWithPositionsFields<T>, 'positions' | 'store'> &
DocumentExpand<T>

export type DocumentWithPositionsPatch<
T extends DocumentWithPositionsMetaType
> = DocumentPatch &
Partial<{
// TODO Добавить вариант с коллекцией?
// TODO Для каждого типа документа будет свой PositionPatch (брать из type map)
positions: Patch<DocumentPositionType[T]>[]
}>
Partial<
{
// TODO Добавить вариант с коллекцией?
// TODO Для каждого типа документа будет свой PositionPatch (брать из type map)
positions: Patch<DocumentPositionType[T]>[]
} & Pick<DocumentWithPositionsFields<T>, 'store'>
>
1 change: 1 addition & 0 deletions test/model/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const invoiceOut: Patch<'invoiceout'> = {}

invoiceOut.positions?.[0].price
invoiceOut.customerOrder
invoiceOut.store

const invoiceOutTemplate = {} as Template<InvoiceOut>

Expand Down

0 comments on commit c2c9338

Please sign in to comment.