@marteye/studiojs 1.0.0 → 1.1.1

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/package.json CHANGED
@@ -1,35 +1,36 @@
1
1
  {
2
2
  "name": "@marteye/studiojs",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
+ "description": "MartEye Studio JavaScript SDK",
4
5
  "license": "MIT",
5
- "source": "src/studio.ts",
6
- "main": "dist/main.js",
7
- "module": "dist/module.js",
8
- "types": "dist/types.d.ts",
6
+ "source": "src/index.ts",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.esm.js",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
9
13
  "scripts": {
10
- "watch": "parcel watch",
11
- "build": "parcel build",
14
+ "build": "rollup -c",
15
+ "watch": "rollup -c -w",
12
16
  "test": "jest --coverage",
17
+ "build:types": "tsc --emitDeclarationOnly",
13
18
  "publish": "npm run build && npm publish --access public"
14
19
  },
15
- "dependencies": {},
16
20
  "devDependencies": {
17
- "@parcel/packager-ts": "2.8.3",
18
- "@parcel/transformer-typescript-types": "2.8.3",
21
+ "@rollup/plugin-commonjs": "^25.0.0",
22
+ "@rollup/plugin-node-resolve": "^15.0.0",
23
+ "@rollup/plugin-typescript": "^11.0.0",
19
24
  "@types/jest": "^29.4.0",
20
25
  "@types/node": "^18.14.0",
26
+ "dotenv": "^16.4.7",
21
27
  "jest": "^29.4.3",
22
- "parcel": "latest",
28
+ "rollup": "^4.0.0",
29
+ "rollup-plugin-dts": "^6.0.0",
23
30
  "ts-jest": "^29.0.5",
31
+ "tslib": "^2.6.0",
24
32
  "typescript": ">=3.0.0"
25
33
  },
26
- "targets": {
27
- "main": {
28
- "context": "node",
29
- "isLibrary": true,
30
- "outputFormat": "commonjs"
31
- }
32
- },
33
34
  "jest": {
34
35
  "preset": "ts-jest"
35
36
  }
package/dist/main.js DELETED
@@ -1,97 +0,0 @@
1
- function $parcel$defineInteropFlag(a) {
2
- Object.defineProperty(a, '__esModule', {value: true, configurable: true});
3
- }
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
-
8
- $parcel$defineInteropFlag(module.exports);
9
-
10
- $parcel$export(module.exports, "default", () => $3c93c9c319e9a70c$export$2e2bcd8739ae039);
11
- function $8e3eb8e0c79c5481$export$2e2bcd8739ae039() {
12
- if (typeof fetch === "undefined") throw new Error("fetch is not defined. Please use a polyfill.");
13
- return fetch;
14
- }
15
-
16
-
17
- function $9a498e161c618486$export$2e2bcd8739ae039(baseUrl, apiKey, fetch, defaultTimeout) {
18
- async function request(method, path, body) {
19
- let controller = new AbortController();
20
- let t = setTimeout(()=>{
21
- controller.abort();
22
- }, defaultTimeout);
23
- let requestInit = {
24
- method: method,
25
- headers: {
26
- "Content-Type": "application/json",
27
- Authorization: `Bearer ${apiKey}`
28
- },
29
- signal: controller.signal
30
- };
31
- if (body) requestInit.body = typeof body === "string" ? body : JSON.stringify(body);
32
- let response = await fetch(`${baseUrl}${path}`, requestInit);
33
- clearTimeout(t);
34
- if (response.ok) return response.json();
35
- if (response.status === 404) throw new Error(`${baseUrl}${path} not found`);
36
- throw new Error(`Request failed with status ${response.status}: ${await response.text()}}`);
37
- }
38
- return {
39
- get: async (path)=>{
40
- return request("GET", path);
41
- },
42
- post: async (path, body)=>{
43
- return request("GET", path, body);
44
- }
45
- };
46
- }
47
-
48
-
49
- function $90674427dab4539a$export$2e2bcd8739ae039(httpClient) {
50
- return {
51
- get: async (marketId, saleId, lotId)=>{
52
- return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
53
- }
54
- };
55
- }
56
-
57
-
58
- // Path: studiojs/src/resources/markets.ts
59
- function $cc646c3e83d242b2$export$2e2bcd8739ae039(httpClient) {
60
- const markets = {
61
- get: async (marketId)=>{
62
- return httpClient.get(`/${marketId}`);
63
- }
64
- };
65
- return markets;
66
- }
67
-
68
-
69
- function $e4c9332355025a8d$export$2e2bcd8739ae039(httpClient) {
70
- return {
71
- get: async (marketId, saleId)=>{
72
- return httpClient.get(`/${marketId}/sales/${saleId}`);
73
- }
74
- };
75
- }
76
-
77
-
78
- function $82b9f9d7f5269d17$export$2e2bcd8739ae039(httpClient) {
79
- return {
80
- markets: (0, $cc646c3e83d242b2$export$2e2bcd8739ae039)(httpClient),
81
- sales: (0, $e4c9332355025a8d$export$2e2bcd8739ae039)(httpClient),
82
- lots: (0, $90674427dab4539a$export$2e2bcd8739ae039)(httpClient)
83
- };
84
- }
85
-
86
-
87
- const $3c93c9c319e9a70c$var$BaseUrl = "https://marteyestudio.com/api";
88
- const $3c93c9c319e9a70c$var$DefaultTimeout = 10000;
89
- function $3c93c9c319e9a70c$export$2e2bcd8739ae039(apiKey, baseUrl = $3c93c9c319e9a70c$var$BaseUrl, defaultTimeout = $3c93c9c319e9a70c$var$DefaultTimeout) {
90
- let httpClient = (0, $9a498e161c618486$export$2e2bcd8739ae039)(baseUrl, apiKey, (0, $8e3eb8e0c79c5481$export$2e2bcd8739ae039)(), defaultTimeout);
91
- return {
92
- ...(0, $82b9f9d7f5269d17$export$2e2bcd8739ae039)(httpClient)
93
- };
94
- }
95
-
96
-
97
- //# sourceMappingURL=main.js.map
package/dist/main.js.map DELETED
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;ACAe,oDAAoB;IACjC,IAAI,OAAO,UAAU,aACnB,MAAM,IAAI,MAAM,gDAAgD;IAElE,OAAO;AACT;;ADLA;AEAe,kDACb,OAAe,EACf,MAAc,EACd,KAAU,EACV,cAAsB,EACtB;IACA,eAAe,QAAW,MAAc,EAAE,IAAY,EAAE,IAAU,EAAE;QAClE,IAAI,aAAa,IAAI;QAErB,IAAI,IAAI,WAAW,IAAM;YACvB,WAAW,KAAK;QAClB,GAAG;QAEH,IAAI,cAAmB;oBACrB;YACA,SAAS;gBACP,gBAAgB;gBAChB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC;YACnC;YACA,QAAQ,WAAW,MAAM;QAC3B;QAEA,IAAI,MACF,YAAY,IAAI,GAAG,OAAO,SAAS,WAAW,OAAO,KAAK,SAAS,CAAC,KAAK;QAG3E,IAAI,WAAW,MAAM,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE;QAChD,aAAa;QAEb,IAAI,SAAS,EAAE,EACb,OAAO,SAAS,IAAI;QAGtB,IAAI,SAAS,MAAM,KAAK,KACtB,MAAM,IAAI,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,UAAU,CAAC,EAAE;QAGjD,MAAM,IAAI,MACR,CAAC,2BAA2B,EAAE,SAAS,MAAM,CAAC,EAAE,EAAE,MAAM,SAAS,IAAI,GAAG,CAAC,CAAC,EAC1E;IACJ;IAEA,OAAO;QACL,KAAK,OAAU,OAAiB;YAC9B,OAAO,QAAW,OAAO;QAC3B;QACA,MAAM,OAAU,MAAc,OAAc;YAC1C,OAAO,QAAW,OAAO,MAAM;QACjC;IACF;AACF;;;AE/Ce,kDAAgB,UAAsB,EAAE;IACrD,OAAO;QACL,KAAK,OAAO,UAAkB,QAAgB,QAAkB;YAC9D,OAAO,WAAW,GAAG,CAAM,CAAC,CAAC,EAAE,SAAS,OAAO,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC;QACzE;IACF;AACF;;ADTA;AEAA,0CAA0C;AAK3B,kDAAgB,UAAsB,EAAE;IACrD,MAAM,UAAU;QACd,KAAK,OAAO,WAAqB;YAC/B,OAAO,WAAW,GAAG,CAAS,CAAC,CAAC,EAAE,SAAS,CAAC;QAC9C;IACF;IAEA,OAAO;AACT;;;ACVe,kDAAgB,UAAsB,EAAE;IACrD,OAAO;QACL,KAAK,OAAO,UAAkB,SAAmB;YAC/C,OAAO,WAAW,GAAG,CAAO,CAAC,CAAC,EAAE,SAAS,OAAO,EAAE,OAAO,CAAC;QAC5D;IACF;AACF;;;AHHe,kDAAmB,UAAsB,EAAE;IACxD,OAAO;QACL,SAAS,CAAA,GAAA,wCAAM,EAAE;QACjB,OAAO,CAAA,GAAA,wCAAI,EAAE;QACb,MAAM,CAAA,GAAA,wCAAG,EAAE;IACb;AACF;;;AHRA,MAAM,gCAAU;AAChB,MAAM,uCAAiB;AAER,kDACb,MAAc,EACd,UAAkB,6BAAO,EACzB,iBAAyB,oCAAc,EACvC;IACA,IAAI,aAAa,CAAA,GAAA,wCAAU,AAAD,EAAE,SAAS,QAAQ,CAAA,GAAA,wCAAO,KAAK;IAEzD,OAAO;QACL,GAAG,CAAA,GAAA,wCAAS,AAAD,EAAE,WAAW;IAC1B;AACF","sources":["src/studio.ts","src/net/fetch.ts","src/net/http.ts","src/resources.ts","src/resources/lots.ts","src/resources/markets.ts","src/resources/sales.ts"],"sourcesContent":["import getFetch from \"./net/fetch\";\nimport HttpClient from \"./net/http\";\nimport Resources from \"./resources\";\n\nconst BaseUrl = \"https://marteyestudio.com/api\";\nconst DefaultTimeout = 10000;\n\nexport default function Studio(\n apiKey: string,\n baseUrl: string = BaseUrl,\n defaultTimeout: number = DefaultTimeout\n) {\n let httpClient = HttpClient(baseUrl, apiKey, getFetch(), defaultTimeout);\n\n return {\n ...Resources(httpClient),\n };\n}\n","export default function getFetch() {\n if (typeof fetch === \"undefined\") {\n throw new Error(\"fetch is not defined. Please use a polyfill.\");\n }\n return fetch;\n}\n","export default function SimpleHttpClient(\n baseUrl: string,\n apiKey: string,\n fetch: any,\n defaultTimeout: number\n) {\n async function request<T>(method: string, path: string, body?: any) {\n let controller = new AbortController();\n\n let t = setTimeout(() => {\n controller.abort();\n }, defaultTimeout);\n\n let requestInit: any = {\n method,\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n signal: controller.signal,\n };\n\n if (body) {\n requestInit.body = typeof body === \"string\" ? body : JSON.stringify(body);\n }\n\n let response = await fetch(`${baseUrl}${path}`, requestInit);\n clearTimeout(t);\n\n if (response.ok) {\n return response.json() as T;\n }\n\n if (response.status === 404) {\n throw new Error(`${baseUrl}${path} not found`);\n }\n\n throw new Error(\n `Request failed with status ${response.status}: ${await response.text()}}`\n );\n }\n\n return {\n get: async <T>(path: string) => {\n return request<T>(\"GET\", path);\n },\n post: async <T>(path: string, body: any) => {\n return request<T>(\"GET\", path, body);\n },\n };\n}\n\nexport type HttpClient = ReturnType<typeof SimpleHttpClient>;\n","import { HttpClient } from \"./net/http\";\n\nimport lots from \"./resources/lots\";\nimport markets from \"./resources/markets\";\nimport sales from \"./resources/sales\";\n\nexport default function resources(httpClient: HttpClient) {\n return {\n markets: markets(httpClient),\n sales: sales(httpClient),\n lots: lots(httpClient),\n };\n}\n","import { Lot } from \"../all-types\";\nimport { HttpClient } from \"../net/http\";\n\nexport default function create(httpClient: HttpClient) {\n return {\n get: async (marketId: string, saleId: string, lotId: string) => {\n return httpClient.get<Lot>(`/${marketId}/sales/${saleId}/lots/${lotId}`);\n },\n };\n}\n","// Path: studiojs/src/resources/markets.ts\n\nimport { Market } from \"../all-types\";\nimport { HttpClient } from \"../net/http\";\n\nexport default function create(httpClient: HttpClient) {\n const markets = {\n get: async (marketId: string) => {\n return httpClient.get<Market>(`/${marketId}`);\n },\n };\n\n return markets;\n}\n","import { Sale } from \"../all-types\";\nimport { HttpClient } from \"../net/http\";\n\nexport default function create(httpClient: HttpClient) {\n return {\n get: async (marketId: string, saleId: string) => {\n return httpClient.get<Sale>(`/${marketId}/sales/${saleId}`);\n },\n };\n}\n"],"names":[],"version":3,"file":"main.js.map","sourceRoot":"../"}
package/dist/module.js DELETED
@@ -1,88 +0,0 @@
1
- function $4c86cdd3cc913dee$export$2e2bcd8739ae039() {
2
- if (typeof fetch === "undefined") throw new Error("fetch is not defined. Please use a polyfill.");
3
- return fetch;
4
- }
5
-
6
-
7
- function $c5abda17a6bd4e32$export$2e2bcd8739ae039(baseUrl, apiKey, fetch, defaultTimeout) {
8
- async function request(method, path, body) {
9
- let controller = new AbortController();
10
- let t = setTimeout(()=>{
11
- controller.abort();
12
- }, defaultTimeout);
13
- let requestInit = {
14
- method: method,
15
- headers: {
16
- "Content-Type": "application/json",
17
- Authorization: `Bearer ${apiKey}`
18
- },
19
- signal: controller.signal
20
- };
21
- if (body) requestInit.body = typeof body === "string" ? body : JSON.stringify(body);
22
- let response = await fetch(`${baseUrl}${path}`, requestInit);
23
- clearTimeout(t);
24
- if (response.ok) return response.json();
25
- if (response.status === 404) throw new Error(`${baseUrl}${path} not found`);
26
- throw new Error(`Request failed with status ${response.status}: ${await response.text()}}`);
27
- }
28
- return {
29
- get: async (path)=>{
30
- return request("GET", path);
31
- },
32
- post: async (path, body)=>{
33
- return request("GET", path, body);
34
- }
35
- };
36
- }
37
-
38
-
39
- function $e2a62c5f05559132$export$2e2bcd8739ae039(httpClient) {
40
- return {
41
- get: async (marketId, saleId, lotId)=>{
42
- return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
43
- }
44
- };
45
- }
46
-
47
-
48
- // Path: studiojs/src/resources/markets.ts
49
- function $abaf70a6c9885685$export$2e2bcd8739ae039(httpClient) {
50
- const markets = {
51
- get: async (marketId)=>{
52
- return httpClient.get(`/${marketId}`);
53
- }
54
- };
55
- return markets;
56
- }
57
-
58
-
59
- function $3fc233e19dbb5a0d$export$2e2bcd8739ae039(httpClient) {
60
- return {
61
- get: async (marketId, saleId)=>{
62
- return httpClient.get(`/${marketId}/sales/${saleId}`);
63
- }
64
- };
65
- }
66
-
67
-
68
- function $4c2cf4c2b45f610a$export$2e2bcd8739ae039(httpClient) {
69
- return {
70
- markets: (0, $abaf70a6c9885685$export$2e2bcd8739ae039)(httpClient),
71
- sales: (0, $3fc233e19dbb5a0d$export$2e2bcd8739ae039)(httpClient),
72
- lots: (0, $e2a62c5f05559132$export$2e2bcd8739ae039)(httpClient)
73
- };
74
- }
75
-
76
-
77
- const $ae75deffebf5b774$var$BaseUrl = "https://marteyestudio.com/api";
78
- const $ae75deffebf5b774$var$DefaultTimeout = 10000;
79
- function $ae75deffebf5b774$export$2e2bcd8739ae039(apiKey, baseUrl = $ae75deffebf5b774$var$BaseUrl, defaultTimeout = $ae75deffebf5b774$var$DefaultTimeout) {
80
- let httpClient = (0, $c5abda17a6bd4e32$export$2e2bcd8739ae039)(baseUrl, apiKey, (0, $4c86cdd3cc913dee$export$2e2bcd8739ae039)(), defaultTimeout);
81
- return {
82
- ...(0, $4c2cf4c2b45f610a$export$2e2bcd8739ae039)(httpClient)
83
- };
84
- }
85
-
86
-
87
- export {$ae75deffebf5b774$export$2e2bcd8739ae039 as default};
88
- //# sourceMappingURL=module.js.map
@@ -1 +0,0 @@
1
- {"mappings":"ACAe,oDAAoB;IACjC,IAAI,OAAO,UAAU,aACnB,MAAM,IAAI,MAAM,gDAAgD;IAElE,OAAO;AACT;;ADLA;AEAe,kDACb,OAAe,EACf,MAAc,EACd,KAAU,EACV,cAAsB,EACtB;IACA,eAAe,QAAW,MAAc,EAAE,IAAY,EAAE,IAAU,EAAE;QAClE,IAAI,aAAa,IAAI;QAErB,IAAI,IAAI,WAAW,IAAM;YACvB,WAAW,KAAK;QAClB,GAAG;QAEH,IAAI,cAAmB;oBACrB;YACA,SAAS;gBACP,gBAAgB;gBAChB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC;YACnC;YACA,QAAQ,WAAW,MAAM;QAC3B;QAEA,IAAI,MACF,YAAY,IAAI,GAAG,OAAO,SAAS,WAAW,OAAO,KAAK,SAAS,CAAC,KAAK;QAG3E,IAAI,WAAW,MAAM,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE;QAChD,aAAa;QAEb,IAAI,SAAS,EAAE,EACb,OAAO,SAAS,IAAI;QAGtB,IAAI,SAAS,MAAM,KAAK,KACtB,MAAM,IAAI,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,UAAU,CAAC,EAAE;QAGjD,MAAM,IAAI,MACR,CAAC,2BAA2B,EAAE,SAAS,MAAM,CAAC,EAAE,EAAE,MAAM,SAAS,IAAI,GAAG,CAAC,CAAC,EAC1E;IACJ;IAEA,OAAO;QACL,KAAK,OAAU,OAAiB;YAC9B,OAAO,QAAW,OAAO;QAC3B;QACA,MAAM,OAAU,MAAc,OAAc;YAC1C,OAAO,QAAW,OAAO,MAAM;QACjC;IACF;AACF;;;AE/Ce,kDAAgB,UAAsB,EAAE;IACrD,OAAO;QACL,KAAK,OAAO,UAAkB,QAAgB,QAAkB;YAC9D,OAAO,WAAW,GAAG,CAAM,CAAC,CAAC,EAAE,SAAS,OAAO,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC;QACzE;IACF;AACF;;ADTA;AEAA,0CAA0C;AAK3B,kDAAgB,UAAsB,EAAE;IACrD,MAAM,UAAU;QACd,KAAK,OAAO,WAAqB;YAC/B,OAAO,WAAW,GAAG,CAAS,CAAC,CAAC,EAAE,SAAS,CAAC;QAC9C;IACF;IAEA,OAAO;AACT;;;ACVe,kDAAgB,UAAsB,EAAE;IACrD,OAAO;QACL,KAAK,OAAO,UAAkB,SAAmB;YAC/C,OAAO,WAAW,GAAG,CAAO,CAAC,CAAC,EAAE,SAAS,OAAO,EAAE,OAAO,CAAC;QAC5D;IACF;AACF;;;AHHe,kDAAmB,UAAsB,EAAE;IACxD,OAAO;QACL,SAAS,CAAA,GAAA,wCAAM,EAAE;QACjB,OAAO,CAAA,GAAA,wCAAI,EAAE;QACb,MAAM,CAAA,GAAA,wCAAG,EAAE;IACb;AACF;;;AHRA,MAAM,gCAAU;AAChB,MAAM,uCAAiB;AAER,kDACb,MAAc,EACd,UAAkB,6BAAO,EACzB,iBAAyB,oCAAc,EACvC;IACA,IAAI,aAAa,CAAA,GAAA,wCAAU,AAAD,EAAE,SAAS,QAAQ,CAAA,GAAA,wCAAO,KAAK;IAEzD,OAAO;QACL,GAAG,CAAA,GAAA,wCAAS,AAAD,EAAE,WAAW;IAC1B;AACF","sources":["src/studio.ts","src/net/fetch.ts","src/net/http.ts","src/resources.ts","src/resources/lots.ts","src/resources/markets.ts","src/resources/sales.ts"],"sourcesContent":["import getFetch from \"./net/fetch\";\nimport HttpClient from \"./net/http\";\nimport Resources from \"./resources\";\n\nconst BaseUrl = \"https://marteyestudio.com/api\";\nconst DefaultTimeout = 10000;\n\nexport default function Studio(\n apiKey: string,\n baseUrl: string = BaseUrl,\n defaultTimeout: number = DefaultTimeout\n) {\n let httpClient = HttpClient(baseUrl, apiKey, getFetch(), defaultTimeout);\n\n return {\n ...Resources(httpClient),\n };\n}\n","export default function getFetch() {\n if (typeof fetch === \"undefined\") {\n throw new Error(\"fetch is not defined. Please use a polyfill.\");\n }\n return fetch;\n}\n","export default function SimpleHttpClient(\n baseUrl: string,\n apiKey: string,\n fetch: any,\n defaultTimeout: number\n) {\n async function request<T>(method: string, path: string, body?: any) {\n let controller = new AbortController();\n\n let t = setTimeout(() => {\n controller.abort();\n }, defaultTimeout);\n\n let requestInit: any = {\n method,\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n signal: controller.signal,\n };\n\n if (body) {\n requestInit.body = typeof body === \"string\" ? body : JSON.stringify(body);\n }\n\n let response = await fetch(`${baseUrl}${path}`, requestInit);\n clearTimeout(t);\n\n if (response.ok) {\n return response.json() as T;\n }\n\n if (response.status === 404) {\n throw new Error(`${baseUrl}${path} not found`);\n }\n\n throw new Error(\n `Request failed with status ${response.status}: ${await response.text()}}`\n );\n }\n\n return {\n get: async <T>(path: string) => {\n return request<T>(\"GET\", path);\n },\n post: async <T>(path: string, body: any) => {\n return request<T>(\"GET\", path, body);\n },\n };\n}\n\nexport type HttpClient = ReturnType<typeof SimpleHttpClient>;\n","import { HttpClient } from \"./net/http\";\n\nimport lots from \"./resources/lots\";\nimport markets from \"./resources/markets\";\nimport sales from \"./resources/sales\";\n\nexport default function resources(httpClient: HttpClient) {\n return {\n markets: markets(httpClient),\n sales: sales(httpClient),\n lots: lots(httpClient),\n };\n}\n","import { Lot } from \"../all-types\";\nimport { HttpClient } from \"../net/http\";\n\nexport default function create(httpClient: HttpClient) {\n return {\n get: async (marketId: string, saleId: string, lotId: string) => {\n return httpClient.get<Lot>(`/${marketId}/sales/${saleId}/lots/${lotId}`);\n },\n };\n}\n","// Path: studiojs/src/resources/markets.ts\n\nimport { Market } from \"../all-types\";\nimport { HttpClient } from \"../net/http\";\n\nexport default function create(httpClient: HttpClient) {\n const markets = {\n get: async (marketId: string) => {\n return httpClient.get<Market>(`/${marketId}`);\n },\n };\n\n return markets;\n}\n","import { Sale } from \"../all-types\";\nimport { HttpClient } from \"../net/http\";\n\nexport default function create(httpClient: HttpClient) {\n return {\n get: async (marketId: string, saleId: string) => {\n return httpClient.get<Sale>(`/${marketId}/sales/${saleId}`);\n },\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":"AOOA,+BACE,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,MAAgB,EACzB,cAAc,GAAE,MAAuB;;;;;;;;;;EAOxC","sources":["src/src/net/fetch.ts","src/src/net/http.ts","src/src/all-types.ts","src/src/resources/lots.ts","src/src/resources/markets.ts","src/src/resources/sales.ts","src/src/resources.ts","src/src/studio.ts","src/studio.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"import getFetch from \"./net/fetch\";\nimport HttpClient from \"./net/http\";\nimport Resources from \"./resources\";\n\nconst BaseUrl = \"https://marteyestudio.com/api\";\nconst DefaultTimeout = 10000;\n\nexport default function Studio(\n apiKey: string,\n baseUrl: string = BaseUrl,\n defaultTimeout: number = DefaultTimeout\n) {\n let httpClient = HttpClient(baseUrl, apiKey, getFetch(), defaultTimeout);\n\n return {\n ...Resources(httpClient),\n };\n}\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/src/all-types.ts DELETED
@@ -1,396 +0,0 @@
1
- type Timestamp = string; // ISO 8601
2
-
3
- // dicates vat and commission applicatble to the line item
4
- export type ClientType = "Seller" | "Buyer";
5
-
6
- export type SuperType =
7
- | "Sheep"
8
- | "Goats"
9
- | "Cattle"
10
- | "Pigs"
11
- | "Machinery"
12
- | "Antiques"
13
- | "Other";
14
-
15
- export type Currency = "GBP" | "EUR" | "USD";
16
- export type SupportedCountryCode =
17
- | "GB-ENG"
18
- | "GB-SCT"
19
- | "GB-WLS"
20
- | "GB-NIR"
21
- | "IE";
22
- export type CurrenciesWithGuinnea = Currency | "GUINNEA-GBP";
23
- export type UnitOfSale =
24
- | "Per KG"
25
- | "Per Item" /* aka 'per head'*/
26
- | "Per Lot"
27
- | "Per 1000KG";
28
- export type PaymentMethods = "BACS" | "Cheque" | "ETF" | "CASH" | "Card";
29
-
30
- export type AttributeDefinitionId =
31
- | "@weightKg"
32
- | "@avgWeightKg"
33
- | "@eartag"
34
- | "@breedOfSheep";
35
-
36
- export interface Market {
37
- id: string;
38
- createdAt: Timestamp;
39
- updatedAt: Timestamp;
40
-
41
- name: string;
42
- description: string;
43
-
44
- logo: string;
45
- primaryColour: string;
46
- secondaryColour: string;
47
-
48
- countryCode: SupportedCountryCode;
49
-
50
- // -- settings
51
- defaultPayoutPreference: PaymentMethods;
52
- defaultCurrency: CurrenciesWithGuinnea;
53
- defaultUnitOfSale: UnitOfSale;
54
-
55
- address: Address;
56
-
57
- movementTracingNumbers?: {
58
- number: string;
59
- type: "CPH" | "Herd Number" | "Flock Number" | "Other";
60
- // the issuing country that the holding number is valid for
61
- countryCode: SupportedCountryCode;
62
- // There should only be one primary for each country / type combination
63
- isPrimary: boolean;
64
- createdAt: Timestamp;
65
- }[];
66
-
67
- // The part to identify which applications are enable for this market. e.g. BCMS / LIS / APHIS / SAGE etc
68
- // Theses market integrations configs will only be used if the sale doesn't provide it's own
69
- integrations: Integrations;
70
-
71
- // --/ settings
72
- }
73
-
74
- export interface Integrations {
75
- [integrationId: string]: {
76
- enabled: boolean;
77
- config: {
78
- [key: string]: any;
79
- };
80
- };
81
- }
82
-
83
- export interface Lot {
84
- id: string; // unique for the sale? Could be saleId + lotNumber
85
- saleId: string;
86
- marketId: string;
87
-
88
- createdAt: Timestamp;
89
- updatedAt: Timestamp;
90
- updatedBy?: string | null;
91
-
92
- // the item code of the lot. This is used to determine the commission rate and the display board
93
- // a lot can only contain items with the same product code (you can think of it as a product type)
94
- productCode: string;
95
-
96
- itemMap: {
97
- [itemId: string]: LotItem;
98
- };
99
-
100
- sellerCustomerId: string | null;
101
- seller?: ShortCustomerDetails;
102
-
103
- lotNumber?: string | null;
104
- // The sort order of the lot within the sale
105
- index: number;
106
- // More than one lot can be sold in the ring at once. This groups the lots. Convention to use the earliest lot number in the group as the group ID
107
- group?: string;
108
-
109
- // Free text description of the lot
110
- remarks?: string;
111
-
112
- // This is the expected quantity of items in the lot used to validate that the correct number of items are inputted.
113
- expectedQuantity?: number;
114
-
115
- // Sale config
116
- currency: CurrenciesWithGuinnea;
117
-
118
- unitOfSale: UnitOfSale;
119
-
120
- //VAT configuration
121
- // We need to for IE as it is assumed the hammer price includes VAT
122
- // default false
123
- unitPriceIncludesVat?: boolean;
124
-
125
- // --- Sale record
126
-
127
- unitPriceInCents?: number;
128
-
129
- // This could be any free text that the clerk input on the rostrum. It can be thought of as a note for someone to look up the actual buyer later
130
- buyerCasual?: string | null;
131
- buyerCustomerId: string | null;
132
- buyer?: ShortCustomerDetails | null;
133
-
134
- // The time the lot entered and left the ring
135
- startedAt?: Timestamp;
136
- endedAt?: Timestamp;
137
-
138
- // must be set, the null used to find records that have not been invoiced
139
- sellerInvoiceId: string | null;
140
- // must be set, used to find records that have not been invoiced
141
- buyerInvoiceId: string | null;
142
-
143
- saleStatus?: "Sold" | "Unsold";
144
- // ignore the result of this lot. Likely because it was a demo or was rerun
145
- void?: boolean;
146
- // if this lot was rerun, this is the ID of the lot that re-ran
147
- rerun?: string;
148
-
149
- // -- /Sale record
150
-
151
- metadata: {
152
- [key: string]: string | number | boolean | Timestamp | Media;
153
- };
154
-
155
- // These are controlled by a cloud function
156
- generated?: LotGeneratedValues;
157
-
158
- // Issues with a lot can be raised asyncronously and resolved later.
159
- issues?: {
160
- code: string;
161
- // The issue description
162
- description: string;
163
- // The issue severity
164
- severity: "error" | "warning" | "info";
165
- }[];
166
- }
167
-
168
- export interface LotGeneratedValues {
169
- // The total value of the lot in cents
170
- totalValueInCents?: number;
171
- }
172
-
173
- // To save a lookup to the customer document we store a copy of the customer details in the lot taken at the time it was added
174
- // Whilst the customer may change their details later it's actually a useful feature not to go back and update the lot with the change
175
- export interface ShortCustomerDetails {
176
- // true if the customer record has been found and copied in
177
- // false if the customer could not be found
178
- isSet: boolean;
179
-
180
- id?: string;
181
- copiedInAt?: Timestamp;
182
- accountNumber?: string;
183
- displayName?: string;
184
- }
185
-
186
- // note the item does not have it's own document in firestore. It exists inside the Lot
187
- export interface LotItem {
188
- id: string; // unique ID but it wont be created by firestore
189
-
190
- createdAt: Timestamp;
191
- updatedAt: Timestamp;
192
- updatedBy?: string | null;
193
- index: number;
194
-
195
- // this carries through to how commission is applied, the display board and what movements are reported
196
- // it should be only in Lot Type
197
- productCode: string;
198
-
199
- attributes: {
200
- [key: string]: string | number | boolean | Timestamp | Media;
201
- };
202
-
203
- notes: { note: string; createdAt: Timestamp }[];
204
-
205
- metadata: {
206
- // Interesting things to add here could be:
207
- // - time the item was scanned in
208
- // - photos of the entry forms
209
- // - links to clips generated
210
- [key: string]: string | number | boolean | Timestamp | Media;
211
- };
212
-
213
- // The seller may have more than one holding number. Specify which to use here (if relevant)
214
- originMovementTracingNumber?: string;
215
-
216
- destinationMovementTracingNumber?: string;
217
-
218
- issues?: {
219
- code: string;
220
- // The issue description
221
- description: string;
222
- // The issue severity.
223
- severity: "error" | "warning" | "info";
224
- }[];
225
- }
226
-
227
- export interface MovementRecord {
228
- id: string;
229
- createdAt: Timestamp;
230
- updatedAt: Timestamp;
231
- marketId: string;
232
-
233
- // The item this movement record is for
234
- itemId: string;
235
-
236
- // Usually now but may be in the future (up to 2-3 days depending on the service)
237
- dateOfMovement: Timestamp;
238
-
239
- // The seller may have more than one holding number. Specify which to use here (if relevant)
240
- // Note the customer ID could be null if the market is the origin
241
- fromCustomerId?: string;
242
- originMovementTracingNumber?: string;
243
-
244
- // Where the item is going
245
- toCustomerId?: string;
246
- destinationMovementTracingNumber?: string;
247
-
248
- // May not be best to delete so we have a record of what was sent to BCMS etc.
249
- isVoided?: boolean;
250
-
251
- // The integration that processed this movement
252
- integrationId?: string;
253
- // True if the movement record was successfully sent to the external processing service (LIS / BCMS etc)
254
- integrationSyncSuccessful?: boolean;
255
-
256
- metadata: {
257
- [key: string]: string | number | boolean | Timestamp | Media;
258
- };
259
-
260
- // The movement record can be written to firebase but the actual movements are sent to the 3rd party in an async fashion. We need a way to track problems with that movement here.
261
- issues?: {
262
- code: string;
263
- // The issue description
264
- description: string;
265
- // The issue severity
266
- severity: "error" | "warning" | "info";
267
- }[];
268
- }
269
-
270
- /***
271
- * Items have codes. And those codes are used to apply the correct commission rates, report movements etc.
272
- */
273
- export interface ProductCodeConfiguration {
274
- // Unique for the market, is the ID for the document
275
- code: string;
276
-
277
- // Integrations will use this for determining if this item needs to have movements reported etc
278
- superType: SuperType;
279
-
280
- description: string;
281
-
282
- // Name for the icon to use in the UI
283
- icon?: string;
284
-
285
- // A set of expected attributes needed for the catalogue
286
- // TODO need to loop in the existing @attributes
287
- attributes?: {
288
- name: string;
289
- type: "string" | "boolean" | "date" | "number" | "image";
290
- optional: boolean;
291
- }[];
292
-
293
- metadata: {
294
- [key: string]: string | number | boolean | Timestamp | Media;
295
- };
296
-
297
- // -- invoices
298
- // - the following generate line items for the invoice.
299
- // - They can be removed or changed manually by the user
300
-
301
- // id for a TaxRate record
302
- // Users shoudl be able to override this on the invoice later
303
- // e.g. people may have different tax rates if they live in another country
304
- buyerTaxRateId: string;
305
- sellerTaxRateId: string;
306
-
307
- // groups up on the subtotal lines on the invoice
308
- // leave null if grouping isn't needed
309
- subtotalGroup?: SubtotalGroups | null;
310
-
311
- // extra charges to apply on the invoice (e.g. commission, levies etc)
312
- // IDs for AdjustmentsConfiguration records
313
- adjustmentIds: string[];
314
- }
315
-
316
- export type SubtotalGroups = "Commission" | string;
317
-
318
- export interface Address {
319
- company?: string;
320
- firstName?: string;
321
- lastName?: string;
322
- address1: string;
323
- address2?: string;
324
- city: string;
325
- province?: string;
326
- zip: string;
327
- // ISO Country Code
328
- country?: string;
329
- phone?: string;
330
- }
331
-
332
- interface ImageThumbnail {
333
- url: string;
334
- width: number;
335
- height: number;
336
- }
337
-
338
- export interface Media {
339
- id: string;
340
-
341
- url: string;
342
- type: "image/jpeg" | "image/png" | "video/mp4" | "application/pdf";
343
- filename: string;
344
- thumbnails?: {
345
- small?: ImageThumbnail;
346
- medium?: ImageThumbnail;
347
- large?: ImageThumbnail;
348
- };
349
- }
350
-
351
- export interface Sale {
352
- id: string;
353
- createdAt: Timestamp;
354
- updatedAt: Timestamp;
355
- updatedBy?: string | null;
356
-
357
- startsAt: Timestamp;
358
-
359
- closedAt?: Timestamp;
360
-
361
- // The owner of the sale
362
- marketId: string;
363
-
364
- // "Weekly Dairy Sale" / "Fat Lambs, Hoggets & Fat Ewes" etc
365
- name: string;
366
-
367
- // Ring 1 / Ring 2 / Farm Address etc
368
- location: string;
369
-
370
- // These carry over to the lots
371
- defaultCurrency: CurrenciesWithGuinnea;
372
- defaultUnitOfSale: UnitOfSale;
373
- defaultProductCode: string;
374
-
375
- // the codes that are allowed for the sale
376
- availableProductCodes: string[];
377
-
378
- // Either the string ID for a known item attibute (begins with an @) or a custom attribute
379
- attributes: (
380
- | string
381
- | {
382
- // NOTE - not supported yet... could make these as AdditionalColumn...
383
- id: string;
384
- name: string;
385
- type: "string" | "number";
386
- }
387
- )[];
388
-
389
- // Default false. If true when a lot is created an empty item is created for it
390
- createItemWithLot?: boolean;
391
-
392
- // The ID of the group of lots that are currently being sold (for a live sale)
393
- currentLotGroup?: string | null;
394
- // The ID of the group the clerk has queued up next
395
- nextLotGroup?: string | null;
396
- }
package/src/net/fetch.ts DELETED
@@ -1,6 +0,0 @@
1
- export default function getFetch() {
2
- if (typeof fetch === "undefined") {
3
- throw new Error("fetch is not defined. Please use a polyfill.");
4
- }
5
- return fetch;
6
- }