@blob-solutions/vcr-am-sdk 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +6 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.global.js +5 -5
- package/lib/index.global.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
package/lib/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var m=(a,e)=>{for(var s in e)p(a,s,{get:e[s],enumerable:!0})},f=(a,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of d(e))!g.call(a,n)&&n!==s&&p(a,n,{get:()=>e[n],enumerable:!(o=y(e,n))||o.enumerable});return a};var A=a=>f(p({},"__esModule",{value:!0}),a);var I={};m(I,{AVAILABLE_LANGUAGES:()=>b,VCRClient:()=>r,unitsKeys:()=>D});module.exports=A(I);var i=require("simple-typed-fetch"),t=require("zod"),u="https://vcr.am/api/v1",h=t.z.object({urlId:t.z.string(),saleId:t.z.number(),crn:t.z.string(),srcReceiptId:t.z.number().int(),fiscal:t.z.string()}),l=t.z.object({error:t.z.string()}),r=class{constructor(e){this.apiKey=e}async registerSale(e){return await(0,i.simpleFetch)(async()=>await(0,i.fetchWithValidation)(`${u}/sales`,h,{method:"POST",headers:{"x-api-key":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)},l))()}async searchClassifierCategory(e,s,o){let n=new URL(`${u}/searchClassifier`);return n.searchParams.append("query",e),n.searchParams.append("type",s),n.searchParams.append("language",o),await(0,i.simpleFetch)(async()=>await(0,i.fetchWithValidation)(n.toString(),t.z.array(t.z.object({code:t.z.string(),title:t.z.string()})),{method:"GET",headers:{"x-api-key":this.apiKey,"Content-Type":"application/json"}},l))()}};var D=["pc","unit","set","box","pack","case","hr","sess","proj","sub","kg","l","m","g","ml","cm","bottle","can","jar","bag","m2","dozen","pair","mm","roll","tube","km","ton","m3","pallet","other"],b=["hy","ru","en"];
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/VCRClient.ts","../src/constants.ts"],"sourcesContent":["export { default as VCRClient } from \"./VCRClient\";\nexport * from \"./types\";\nexport * from \"./constants\";\n","import { fetchWithValidation, simpleFetch } from \"simple-typed-fetch\";\nimport { z } from \"zod\";\n\nimport type { SaleData } from \"./types\";\n\nconst API_URL = \"https://vcr.am/api/v1\";\n\nconst saleResponseSchema = z.object({\n saleId: z.number(),\n crn: z.string(),\n srcReceiptId: z.number().int(),\n fiscal: z.string(),\n});\n\nexport default class VCRClient {\n constructor(private readonly apiKey: string) {}\n\n async registerSale(data: SaleData) {\n const responseData = await simpleFetch(\n async () =>\n await fetchWithValidation(\n `${API_URL}/sales`,\n saleResponseSchema,\n {\n method: \"POST\",\n headers: {\n \"x-api-key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n z.object({
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/VCRClient.ts","../src/constants.ts"],"sourcesContent":["export { default as VCRClient } from \"./VCRClient\";\nexport * from \"./types\";\nexport * from \"./constants\";\n","import { fetchWithValidation, simpleFetch } from \"simple-typed-fetch\";\nimport { z } from \"zod\";\n\nimport type { Language, SaleData } from \"./types\";\n\nconst API_URL = \"https://vcr.am/api/v1\";\n\nconst saleResponseSchema = z.object({\n urlId: z.string(),\n saleId: z.number(),\n crn: z.string(),\n srcReceiptId: z.number().int(),\n fiscal: z.string(),\n});\n\nconst errorResponseSchema = z.object({\n error: z.string(),\n});\n\nexport default class VCRClient {\n constructor(private readonly apiKey: string) {}\n\n async registerSale(data: SaleData) {\n const responseData = await simpleFetch(\n async () =>\n await fetchWithValidation(\n `${API_URL}/sales`,\n saleResponseSchema,\n {\n method: \"POST\",\n headers: {\n \"x-api-key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n errorResponseSchema\n )\n )();\n\n return responseData;\n }\n\n async searchClassifierCategory(\n query: string,\n type: \"product\" | \"service\",\n language: Language\n ) {\n const url = new URL(`${API_URL}/searchClassifier`);\n url.searchParams.append(\"query\", query);\n url.searchParams.append(\"type\", type);\n url.searchParams.append(\"language\", language);\n\n return await simpleFetch(\n async () =>\n await fetchWithValidation(\n url.toString(),\n z.array(z.object({ code: z.string(), title: z.string() })),\n {\n method: \"GET\",\n headers: {\n \"x-api-key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n },\n },\n errorResponseSchema\n )\n )();\n }\n}\n","export const unitsKeys = [\n \"pc\",\n \"unit\",\n \"set\",\n \"box\",\n \"pack\",\n \"case\",\n \"hr\",\n \"sess\",\n \"proj\",\n \"sub\",\n \"kg\",\n \"l\",\n \"m\",\n \"g\",\n \"ml\",\n \"cm\",\n \"bottle\",\n \"can\",\n \"jar\",\n \"bag\",\n \"m2\",\n \"dozen\",\n \"pair\",\n \"mm\",\n \"roll\",\n \"tube\",\n \"km\",\n \"ton\",\n \"m3\",\n \"pallet\",\n \"other\",\n] as const;\n\nexport const AVAILABLE_LANGUAGES = [\"hy\", \"ru\", \"en\"] as const;\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,cAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAL,GCAA,IAAAM,EAAiD,8BACjDC,EAAkB,eAIZC,EAAU,wBAEVC,EAAqB,IAAE,OAAO,CAClC,MAAO,IAAE,OAAO,EAChB,OAAQ,IAAE,OAAO,EACjB,IAAK,IAAE,OAAO,EACd,aAAc,IAAE,OAAO,EAAE,IAAI,EAC7B,OAAQ,IAAE,OAAO,CACnB,CAAC,EAEKC,EAAsB,IAAE,OAAO,CACnC,MAAO,IAAE,OAAO,CAClB,CAAC,EAEoBC,EAArB,KAA+B,CAC7B,YAA6BC,EAAgB,CAAhB,YAAAA,CAAiB,CAE9C,MAAM,aAAaC,EAAgB,CAkBjC,OAjBqB,QAAM,eACzB,SACE,QAAM,uBACJ,GAAGL,CAAO,SACVC,EACA,CACE,OAAQ,OACR,QAAS,CACP,YAAa,KAAK,OAClB,eAAgB,kBAClB,EACA,KAAM,KAAK,UAAUI,CAAI,CAC3B,EACAH,CACF,CACJ,EAAE,CAGJ,CAEA,MAAM,yBACJI,EACAC,EACAC,EACA,CACA,IAAMC,EAAM,IAAI,IAAI,GAAGT,CAAO,mBAAmB,EACjD,OAAAS,EAAI,aAAa,OAAO,QAASH,CAAK,EACtCG,EAAI,aAAa,OAAO,OAAQF,CAAI,EACpCE,EAAI,aAAa,OAAO,WAAYD,CAAQ,EAErC,QAAM,eACX,SACE,QAAM,uBACJC,EAAI,SAAS,EACb,IAAE,MAAM,IAAE,OAAO,CAAE,KAAM,IAAE,OAAO,EAAG,MAAO,IAAE,OAAO,CAAE,CAAC,CAAC,EACzD,CACE,OAAQ,MACR,QAAS,CACP,YAAa,KAAK,OAClB,eAAgB,kBAClB,CACF,EACAP,CACF,CACJ,EAAE,CACJ,CACF,ECrEO,IAAMQ,EAAY,CACvB,KACA,OACA,MACA,MACA,OACA,OACA,KACA,OACA,OACA,MACA,KACA,IACA,IACA,IACA,KACA,KACA,SACA,MACA,MACA,MACA,KACA,QACA,OACA,KACA,OACA,OACA,KACA,MACA,KACA,SACA,OACF,EAEaC,EAAsB,CAAC,KAAM,KAAM,IAAI","names":["src_exports","__export","AVAILABLE_LANGUAGES","VCRClient","unitsKeys","__toCommonJS","import_simple_typed_fetch","import_zod","API_URL","saleResponseSchema","errorResponseSchema","VCRClient","apiKey","data","query","type","language","url","unitsKeys","AVAILABLE_LANGUAGES"]}
|
package/lib/index.d.cts
CHANGED
|
@@ -103,11 +103,16 @@ declare class VCRClient {
|
|
|
103
103
|
private readonly apiKey;
|
|
104
104
|
constructor(apiKey: string);
|
|
105
105
|
registerSale(data: SaleData): Promise<{
|
|
106
|
+
urlId: string;
|
|
106
107
|
saleId: number;
|
|
107
108
|
crn: string;
|
|
108
109
|
srcReceiptId: number;
|
|
109
110
|
fiscal: string;
|
|
110
111
|
}>;
|
|
112
|
+
searchClassifierCategory(query: string, type: "product" | "service", language: Language): Promise<{
|
|
113
|
+
code: string;
|
|
114
|
+
title: string;
|
|
115
|
+
}[]>;
|
|
111
116
|
}
|
|
112
117
|
|
|
113
|
-
export { AVAILABLE_LANGUAGES, type SaleData, type SaleItem, type Unit, VCRClient, unitsKeys };
|
|
118
|
+
export { AVAILABLE_LANGUAGES, type Language, type SaleData, type SaleItem, type Unit, VCRClient, unitsKeys };
|
package/lib/index.d.ts
CHANGED
|
@@ -103,11 +103,16 @@ declare class VCRClient {
|
|
|
103
103
|
private readonly apiKey;
|
|
104
104
|
constructor(apiKey: string);
|
|
105
105
|
registerSale(data: SaleData): Promise<{
|
|
106
|
+
urlId: string;
|
|
106
107
|
saleId: number;
|
|
107
108
|
crn: string;
|
|
108
109
|
srcReceiptId: number;
|
|
109
110
|
fiscal: string;
|
|
110
111
|
}>;
|
|
112
|
+
searchClassifierCategory(query: string, type: "product" | "service", language: Language): Promise<{
|
|
113
|
+
code: string;
|
|
114
|
+
title: string;
|
|
115
|
+
}[]>;
|
|
111
116
|
}
|
|
112
117
|
|
|
113
|
-
export { AVAILABLE_LANGUAGES, type SaleData, type SaleItem, type Unit, VCRClient, unitsKeys };
|
|
118
|
+
export { AVAILABLE_LANGUAGES, type Language, type SaleData, type SaleItem, type Unit, VCRClient, unitsKeys };
|