-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 22a1224
Showing
57 changed files
with
1,437 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Bootstrap scripts folder | ||
.bootstrap | ||
|
||
# npm | ||
node_modules | ||
package-lock.json | ||
|
||
# env | ||
.env* | ||
!.env.example | ||
|
||
# temp | ||
/__temp* | ||
|
||
# build | ||
/build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"bracketSpacing": true, | ||
"htmlWhitespaceSensitivity": "css", | ||
"insertPragma": false, | ||
"parser": "typescript", | ||
"printWidth": 80, | ||
"proseWrap": "preserve", | ||
"requirePragma": false, | ||
"semi": false, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch TS", | ||
"program": "${file}", | ||
"preLaunchTask": "tsc: build - tsconfig.json", | ||
"envFile": "${workspaceFolder}/.env", | ||
"outFiles": [ | ||
"${workspaceFolder}/dist/**/*.js" | ||
], | ||
"internalConsoleOptions": "openOnSessionStart" | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch JS", | ||
"program": "${file}", | ||
"envFile": "${workspaceFolder}/.env", | ||
"internalConsoleOptions": "openOnSessionStart" | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Makeev Vitaliy | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# moysklad-api-model | ||
|
||
> Объектная модель сервиса МойСклад для TypeScript проектов | ||
Экспериментальная версия |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "moysklad-api-model", | ||
"version": "0.1.0", | ||
"description": "Объектная модель API МойСклад для TypeScript проектов", | ||
"main": "build/src/index.js", | ||
"types": "build/src/index.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"compile": "tsc --build tsconfig.prod.json", | ||
"build": "rm -rf build/ && npm run compile" | ||
}, | ||
"keywords": [ | ||
"moysklad", | ||
"model", | ||
"api", | ||
"typescript" | ||
], | ||
"author": { | ||
"name": "Vitaliy V. Makeev", | ||
"email": "w.makeev@gmail.com" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"moysklad": "^0.9.2", | ||
"moysklad-extension-queue": "^0.2.1", | ||
"prettier": "^2.2.1", | ||
"typescript": "^4.1.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// @ts-nocheck | ||
|
||
import type { EntityByMetaType, MetaType } from './model/MetaType' | ||
import type { PositionTypeByDocument } from './model/Position' | ||
|
||
type EntityCollectionEndpoint<T extends MetaType> = `entity/${T}` | ||
// type EntityCollectionEndpoint2 = `entity/${MetaType}` | ||
|
||
type EntityEndpoint = `entity/${MetaType}/${string}` | ||
|
||
type PositionsEndpoint = `entity/${keyof PositionTypeByDocument}/${string}/positions` | ||
type CounterpartyContactPersonsEndpoint = `entity/${MetaType.Counterparty}/${string}/contactpersons` | ||
|
||
export type EntityByEndpoint<T extends string> = string extends T | ||
? 'unknown1' | ||
: T extends `entity/${infer M}` | ||
? M extends keyof EntityByMetaType | ||
? EntityByMetaType[M] | ||
: M | ||
: 'never3' | ||
|
||
type Test1 = EntityByEndpoint<'entity/account'> | ||
type Test2 = EntityByMetaType['bonusprogram'] | ||
|
||
type Keys = keyof EntityByMetaType // MetaType | ||
type Keys2 = `${MetaType}` | ||
type Keys3 = keyof typeof MetaType | ||
|
||
type Test3 = 'account' extends keyof EntityByMetaType ? true : false | ||
type Test4 = 'account' extends Keys2 ? true : false | ||
type Test5 = 'account' extends keyof typeof MetaType ? true : false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './model' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { Entity } from './Entity' | ||
import type { HasUpdated } from './HasUpdated' | ||
import type { MetaType } from './MetaType' | ||
|
||
export interface Account extends Entity<MetaType.Account>, HasUpdated { | ||
/** Является ли счет основным счетом Контрагента */ | ||
isDefault: boolean | ||
|
||
/** Номер счета */ | ||
accountNumber: string | ||
|
||
/** Наименование банка */ | ||
bankName?: string | ||
|
||
/** Адрес банка */ | ||
bankLocation?: string | ||
|
||
/** Кор. счет */ | ||
correspondentAccount?: string | ||
|
||
/** БИК */ | ||
bic?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { EntityRef } from './EntityRef' | ||
import type { MetaType } from './MetaType' | ||
|
||
export interface Address { | ||
postalCode?: string | ||
|
||
country?: EntityRef<MetaType.Country> | ||
|
||
region?: EntityRef<MetaType.Region> | ||
|
||
city?: string | ||
|
||
street?: string | ||
|
||
house?: string | ||
|
||
apartment?: string | ||
|
||
addInfo?: string | ||
|
||
comment?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { Entity } from './Entity' | ||
import type { HasAttributes } from './HasAttributes' | ||
import type { HasCreated } from './HasCreated' | ||
import type { HasUpdated } from './HasUpdated' | ||
import type { MetaType } from './MetaType' | ||
import type { Owned } from './Owned' | ||
|
||
export type AgentMetaType = | ||
| MetaType.Employee | ||
| MetaType.Counterparty | ||
| MetaType.Organization | ||
|
||
export interface Agent<T extends AgentMetaType> | ||
extends Entity<T>, | ||
Owned, | ||
HasCreated, | ||
HasUpdated, | ||
HasAttributes { | ||
/** Наименование */ | ||
name: string | ||
|
||
/** Комментарий */ | ||
description?: string | ||
|
||
/** Внешний код */ | ||
externalCode: string | ||
|
||
/** Архивирован */ | ||
archived: boolean | ||
|
||
/** ИНН */ | ||
inn?: string | ||
|
||
/** Email */ | ||
email?: string | ||
|
||
/** Номер телефона */ | ||
phone?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { Entity } from './Entity' | ||
import type { EntityRef } from './EntityRef' | ||
import type { HasCreated } from './HasCreated' | ||
import type { MetaType } from './MetaType' | ||
|
||
export interface AgentNote extends Entity<MetaType.Note>, HasCreated { | ||
description?: string | ||
|
||
agent: EntityRef<MetaType.Counterparty> | ||
|
||
author: EntityRef<MetaType.Employee> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { Entity } from './Entity' | ||
import type { EntityRef } from './EntityRef' | ||
import type { MediaType } from './MediaType' | ||
import type { MetaType } from './MetaType' | ||
|
||
export enum AttributeType { | ||
// Base type | ||
String = 'string', | ||
Long = 'long', | ||
Time = 'time', | ||
File = 'file', | ||
Double = 'double', | ||
Boolean = 'boolean', | ||
Text = 'text', | ||
Link = 'link', | ||
|
||
// Embedded entity | ||
Organization = 'organization', | ||
Counterparty = 'counterparty', | ||
Employee = 'employee', | ||
Contract = 'contract', | ||
Product = 'product', | ||
Project = 'project', | ||
Store = 'store', | ||
|
||
// Custom entity | ||
CustomEntity = 'customentity' | ||
} | ||
|
||
export type AttributeJsTypeMap = { | ||
// Base type | ||
[AttributeType.String]: string | ||
[AttributeType.Long]: number | ||
[AttributeType.Time]: string | ||
[AttributeType.File]: object // TODO AttributeType.File | ||
[AttributeType.Double]: number | ||
[AttributeType.Boolean]: boolean | ||
[AttributeType.Text]: string | ||
[AttributeType.Link]: string | ||
|
||
// Embedded entity | ||
[AttributeType.Organization]: EntityRef<MetaType.Organization> | ||
[AttributeType.Counterparty]: EntityRef<MetaType.Counterparty> | ||
[AttributeType.Employee]: EntityRef<MetaType.Employee> | ||
[AttributeType.Contract]: EntityRef<MetaType.Contract> | ||
[AttributeType.Product]: EntityRef<MetaType.Product> | ||
[AttributeType.Project]: EntityRef<MetaType.Project> | ||
[AttributeType.Store]: EntityRef<MetaType.Store> | ||
|
||
// Custom entity | ||
[AttributeType.CustomEntity]: EntityRef<MetaType.CustomEntity> & { | ||
name: string | ||
} | ||
} | ||
|
||
interface AttributeBase<T extends AttributeType = AttributeType> | ||
extends Entity<MetaType.AttributeMetadata> { | ||
/** Наименование пользовательского поля */ | ||
name: string | ||
|
||
/** Тип значения пользовательского поля */ | ||
type: T | ||
|
||
value: AttributeJsTypeMap[T] | ||
} | ||
|
||
export type Attribute< | ||
T extends AttributeType = AttributeType | ||
> = T extends AttributeType.File | ||
? AttributeBase<T> & { | ||
download: { | ||
href: string | ||
mediaType: MediaType | ||
} | ||
} | ||
: AttributeBase<T> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { CollectionRef } from './CollectionRef' | ||
import type { EntityByMetaType, MetaType } from './MetaType' | ||
|
||
export interface Collection<T extends MetaType = MetaType> | ||
extends CollectionRef<T> { | ||
rows: EntityByMetaType[T][] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { EntityRef } from './EntityRef' | ||
import type { MetaType } from './MetaType' | ||
|
||
export interface CollectionRef<T extends MetaType = MetaType> | ||
extends EntityRef<T> { | ||
meta: EntityRef<T>['meta'] & { | ||
size: number | ||
limit: number | ||
offset: number | ||
} | ||
} |
Oops, something went wrong.