diff --git a/package.json b/package.json index 0264a58..a56505d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" }, @@ -40,6 +40,6 @@ "typescript": "^4.3.5" }, "dependencies": { - "moysklad-api-model": "^0.4.4" + "moysklad-api-model": "^0.5.4" } } diff --git a/src/helpers/getHelpers.ts b/src/helpers/getHelpers.ts index a0d4e0a..1a05916 100644 --- a/src/helpers/getHelpers.ts +++ b/src/helpers/getHelpers.ts @@ -58,7 +58,7 @@ export function getHelpers(ms: { buildUrl: (path: string) => string }) { return { meta: { - type: 'attributemetadata', + type: 'attributemetadata' as const, href: href(path) }, value diff --git a/tests/index.ts b/tests/index.ts new file mode 100644 index 0000000..806a03e --- /dev/null +++ b/tests/index.ts @@ -0,0 +1 @@ +import './index.test' diff --git a/tests/types/HrefMetaType.test.ts b/tests/types/HrefMetaType.ts similarity index 100% rename from tests/types/HrefMetaType.test.ts rename to tests/types/HrefMetaType.ts diff --git a/tests/types/attr.ts b/tests/types/attr.ts new file mode 100644 index 0000000..7cc3de0 --- /dev/null +++ b/tests/types/attr.ts @@ -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 diff --git a/tests/types/commom.test.ts b/tests/types/commom.ts similarity index 100% rename from tests/types/commom.test.ts rename to tests/types/commom.ts diff --git a/tests/types/ref.test.ts b/tests/types/ref.ts similarity index 100% rename from tests/types/ref.test.ts rename to tests/types/ref.ts