Skip to content

Commit

Permalink
fix(attr): moysklad model Patch helper support
Browse files Browse the repository at this point in the history
update model version
  • Loading branch information
wmakeev committed Dec 4, 2021
1 parent 1a055ff commit 993d9cf
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moysklad-helpers",
"version": "3.0.0-beta.11",
"version": "3.0.1",
"description": "Вспомогательные функции для работы с библиотекой moysklad",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand All @@ -11,7 +11,7 @@
"update": "npm i moysklad-api-model@latest",
"format": "prettier --write \"src/**/*.ts\"",
"build": "npm run format && rm -rf dist/* && tsc --build tsconfig.deploy.json",
"test": "npm run build && node dist/tests/index.test.js | tap-spec",
"test": "npm run build && node dist/tests | tap-spec",
"git:tag": "git tag \"v$(cat package.json | json version)\"",
"npm:publish": "npm run test && npm publish && npm run git:tag && git push"
},
Expand Down Expand Up @@ -40,6 +40,6 @@
"typescript": "^4.3.5"
},
"dependencies": {
"moysklad-api-model": "^0.4.4"
"moysklad-api-model": "^0.5.4"
}
}
2 changes: 1 addition & 1 deletion src/helpers/getHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function getHelpers(ms: { buildUrl: (path: string) => string }) {

return {
meta: {
type: 'attributemetadata',
type: 'attributemetadata' as const,
href: href(path)
},
value
Expand Down
1 change: 1 addition & 0 deletions tests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './index.test'
File renamed without changes.
26 changes: 26 additions & 0 deletions tests/types/attr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { PatchCollection } from 'moysklad-api-model'
import Moysklad from 'moysklad'

import { getHelpers } from '../../src'

const ms = Moysklad({ apiVersion: '1.2' })
const { attr } = getHelpers(ms)

const ATTR_ID = 'id'

const productPatch1: PatchCollection<'product'> = [
{
meta: { type: 'product', href: '' },
attributes: [attr(`entity/product/metadata/attributes/${ATTR_ID}`, 'value')]
}
]
productPatch1

// TODO Test entity type and href?
const productPatch2: PatchCollection<'product'> = [
{
meta: { type: 'product', href: '' },
attributes: [attr(`foo/bar/${ATTR_ID}`, 'value')]
}
]
productPatch2
File renamed without changes.
File renamed without changes.

0 comments on commit 993d9cf

Please sign in to comment.