@gesagro/jaspion-sdk 1.0.0 → 1.0.2
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/README.md +7 -0
- package/dist/index.d.mts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +28 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -5
package/README.md
ADDED
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
declare class HttpClient {
|
|
2
|
+
private readonly baseUrl;
|
|
3
|
+
private readonly headers;
|
|
4
|
+
constructor(baseUrl: string);
|
|
5
|
+
setHeader(key: string, value: string): void;
|
|
6
|
+
post(path: string, body: unknown): Promise<void>;
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
type ContentType = 'application/pdf' | 'text/csv';
|
|
4
10
|
interface Parameter {
|
|
@@ -19,9 +25,9 @@ interface RequestReportInput {
|
|
|
19
25
|
resources: Resource[];
|
|
20
26
|
}
|
|
21
27
|
declare abstract class Report {
|
|
22
|
-
protected readonly http:
|
|
28
|
+
protected readonly http: HttpClient;
|
|
23
29
|
protected readonly config: ReportConfig;
|
|
24
|
-
constructor(http:
|
|
30
|
+
constructor(http: HttpClient, config: ReportConfig);
|
|
25
31
|
protected request({ contentType, parameters, resources, }: RequestReportInput): Promise<void>;
|
|
26
32
|
}
|
|
27
33
|
|
|
@@ -32,22 +38,22 @@ interface OriginListInput {
|
|
|
32
38
|
language: LanguageCode;
|
|
33
39
|
}
|
|
34
40
|
declare class OriginList extends Report {
|
|
35
|
-
constructor(http:
|
|
41
|
+
constructor(http: HttpClient);
|
|
36
42
|
pdf(input: OriginListInput): Promise<void>;
|
|
37
43
|
csv(input: OriginListInput): Promise<void>;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
declare class PigMasterNamespace {
|
|
41
47
|
readonly originList: OriginList;
|
|
42
|
-
constructor(http:
|
|
48
|
+
constructor(http: HttpClient);
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
declare class JaspionClient {
|
|
46
52
|
private readonly http;
|
|
47
53
|
readonly pigMaster: PigMasterNamespace;
|
|
48
|
-
constructor(http:
|
|
54
|
+
constructor(http: HttpClient);
|
|
49
55
|
setAccessToken(token: string): void;
|
|
50
56
|
}
|
|
51
|
-
declare function jaspion(
|
|
57
|
+
declare function jaspion(baseUrl: string): JaspionClient;
|
|
52
58
|
|
|
53
59
|
export { jaspion };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
declare class HttpClient {
|
|
2
|
+
private readonly baseUrl;
|
|
3
|
+
private readonly headers;
|
|
4
|
+
constructor(baseUrl: string);
|
|
5
|
+
setHeader(key: string, value: string): void;
|
|
6
|
+
post(path: string, body: unknown): Promise<void>;
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
type ContentType = 'application/pdf' | 'text/csv';
|
|
4
10
|
interface Parameter {
|
|
@@ -19,9 +25,9 @@ interface RequestReportInput {
|
|
|
19
25
|
resources: Resource[];
|
|
20
26
|
}
|
|
21
27
|
declare abstract class Report {
|
|
22
|
-
protected readonly http:
|
|
28
|
+
protected readonly http: HttpClient;
|
|
23
29
|
protected readonly config: ReportConfig;
|
|
24
|
-
constructor(http:
|
|
30
|
+
constructor(http: HttpClient, config: ReportConfig);
|
|
25
31
|
protected request({ contentType, parameters, resources, }: RequestReportInput): Promise<void>;
|
|
26
32
|
}
|
|
27
33
|
|
|
@@ -32,22 +38,22 @@ interface OriginListInput {
|
|
|
32
38
|
language: LanguageCode;
|
|
33
39
|
}
|
|
34
40
|
declare class OriginList extends Report {
|
|
35
|
-
constructor(http:
|
|
41
|
+
constructor(http: HttpClient);
|
|
36
42
|
pdf(input: OriginListInput): Promise<void>;
|
|
37
43
|
csv(input: OriginListInput): Promise<void>;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
declare class PigMasterNamespace {
|
|
41
47
|
readonly originList: OriginList;
|
|
42
|
-
constructor(http:
|
|
48
|
+
constructor(http: HttpClient);
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
declare class JaspionClient {
|
|
46
52
|
private readonly http;
|
|
47
53
|
readonly pigMaster: PigMasterNamespace;
|
|
48
|
-
constructor(http:
|
|
54
|
+
constructor(http: HttpClient);
|
|
49
55
|
setAccessToken(token: string): void;
|
|
50
56
|
}
|
|
51
|
-
declare function jaspion(
|
|
57
|
+
declare function jaspion(baseUrl: string): JaspionClient;
|
|
52
58
|
|
|
53
59
|
export { jaspion };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -34,8 +24,28 @@ __export(index_exports, {
|
|
|
34
24
|
});
|
|
35
25
|
module.exports = __toCommonJS(index_exports);
|
|
36
26
|
|
|
37
|
-
// src/client.ts
|
|
38
|
-
var
|
|
27
|
+
// src/core/http-client.ts
|
|
28
|
+
var HttpClient = class {
|
|
29
|
+
constructor(baseUrl) {
|
|
30
|
+
this.baseUrl = baseUrl;
|
|
31
|
+
this.headers = {
|
|
32
|
+
"Content-Type": "application/json"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
setHeader(key, value) {
|
|
36
|
+
this.headers[key] = value;
|
|
37
|
+
}
|
|
38
|
+
async post(path, body) {
|
|
39
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
40
|
+
method: "POST",
|
|
41
|
+
headers: this.headers,
|
|
42
|
+
body: JSON.stringify(body)
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
throw new Error(`Request failed with status ${response.status}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
39
49
|
|
|
40
50
|
// src/core/report.ts
|
|
41
51
|
var Report = class {
|
|
@@ -72,7 +82,7 @@ var OriginList = class extends Report {
|
|
|
72
82
|
async pdf(input) {
|
|
73
83
|
return await this.request({
|
|
74
84
|
contentType: "application/pdf",
|
|
75
|
-
resources: [{ key: "
|
|
85
|
+
resources: [{ key: "FARM_ID", value: input.farmId }],
|
|
76
86
|
parameters: [
|
|
77
87
|
{ key: "DATA_ONLY", value: false },
|
|
78
88
|
{ key: "LOCATE", value: input.language.replace("-", "_") }
|
|
@@ -82,9 +92,9 @@ var OriginList = class extends Report {
|
|
|
82
92
|
async csv(input) {
|
|
83
93
|
return await this.request({
|
|
84
94
|
contentType: "text/csv",
|
|
85
|
-
resources: [{ key: "
|
|
95
|
+
resources: [{ key: "FARM_ID", value: input.farmId }],
|
|
86
96
|
parameters: [
|
|
87
|
-
{ key: "DATA_ONLY", value:
|
|
97
|
+
{ key: "DATA_ONLY", value: true },
|
|
88
98
|
{ key: "LOCATE", value: input.language.replace("-", "_") }
|
|
89
99
|
]
|
|
90
100
|
});
|
|
@@ -105,11 +115,11 @@ var JaspionClient = class {
|
|
|
105
115
|
this.pigMaster = new PigMasterNamespace(http);
|
|
106
116
|
}
|
|
107
117
|
setAccessToken(token) {
|
|
108
|
-
this.http.
|
|
118
|
+
this.http.setHeader("Authorization", `Bearer ${token}`);
|
|
109
119
|
}
|
|
110
120
|
};
|
|
111
|
-
function jaspion(
|
|
112
|
-
const http =
|
|
121
|
+
function jaspion(baseUrl) {
|
|
122
|
+
const http = new HttpClient(baseUrl);
|
|
113
123
|
return new JaspionClient(http);
|
|
114
124
|
}
|
|
115
125
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/core/report.ts","../src/namespaces/pig-master/reports/origin-list.ts","../src/namespaces/pig-master/index.ts"],"sourcesContent":["export { jaspion } from './client'\n","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/core/http-client.ts","../src/core/report.ts","../src/namespaces/pig-master/reports/origin-list.ts","../src/namespaces/pig-master/index.ts","../src/client.ts"],"sourcesContent":["export { jaspion } from './client'\n","export class HttpClient {\n private readonly headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n }\n\n constructor(private readonly baseUrl: string) {}\n\n setHeader(key: string, value: string) {\n this.headers[key] = value\n }\n\n async post(path: string, body: unknown) {\n const response = await fetch(`${this.baseUrl}${path}`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(body),\n })\n\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`)\n }\n }\n}\n","import type { HttpClient } from './http-client'\n\ntype ContentType = 'application/pdf' | 'text/csv'\n\nexport interface Parameter {\n key: string\n value: string | number | boolean | null\n}\n\nexport interface Resource {\n key: string\n value: string\n}\n\ninterface ReportConfig {\n template: string\n fileName: string\n}\n\ninterface RequestReportInput {\n contentType: ContentType\n parameters: Parameter[]\n resources: Resource[]\n}\n\nexport abstract class Report {\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ReportConfig,\n ) {}\n\n protected async request({\n contentType,\n parameters,\n resources,\n }: RequestReportInput) {\n const extension = contentType === 'application/pdf' ? '.pdf' : '.csv'\n const fileName = `${this.config.fileName}${extension}`\n\n await this.http.post('/reports', {\n template: this.config.template,\n fileName,\n parameters,\n resources,\n contentType,\n type: 'jasper-reports',\n })\n }\n}\n","import type { HttpClient } from '../../../core/http-client'\nimport { Report } from '../../../core/report'\nimport { LanguageCode } from '../../../core/types'\n\ninterface OriginListInput {\n farmId: string\n language: LanguageCode\n}\n\nexport class OriginList extends Report {\n constructor(http: HttpClient) {\n super(http, {\n template: '@pig-master/origin-list',\n fileName: 'Listagem de origens',\n })\n }\n\n async pdf(input: OriginListInput) {\n return await this.request({\n contentType: 'application/pdf',\n resources: [{ key: 'FARM_ID', value: input.farmId }],\n parameters: [\n { key: 'DATA_ONLY', value: false },\n { key: 'LOCATE', value: input.language.replace('-', '_') },\n ],\n })\n }\n\n async csv(input: OriginListInput) {\n return await this.request({\n contentType: 'text/csv',\n resources: [{ key: 'FARM_ID', value: input.farmId }],\n parameters: [\n { key: 'DATA_ONLY', value: true },\n { key: 'LOCATE', value: input.language.replace('-', '_') },\n ],\n })\n }\n}\n","import type { HttpClient } from '../../core/http-client'\nimport { OriginList } from './reports/origin-list'\n\nexport class PigMasterNamespace {\n public readonly originList: OriginList\n\n constructor(http: HttpClient) {\n this.originList = new OriginList(http)\n }\n}\n","import { HttpClient } from './core/http-client'\nimport { PigMasterNamespace } from './namespaces/pig-master'\n\nexport class JaspionClient {\n public readonly pigMaster: PigMasterNamespace\n\n constructor(private readonly http: HttpClient) {\n this.pigMaster = new PigMasterNamespace(http)\n }\n\n setAccessToken(token: string) {\n this.http.setHeader('Authorization', `Bearer ${token}`)\n }\n}\n\nexport function jaspion(baseUrl: string) {\n const http = new HttpClient(baseUrl)\n\n return new JaspionClient(http)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAA6B,SAAiB;AAAjB;AAJ7B,SAAiB,UAAkC;AAAA,MACjD,gBAAgB;AAAA,IAClB;AAAA,EAE+C;AAAA,EAE/C,UAAU,KAAa,OAAe;AACpC,SAAK,QAAQ,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,MAAM,KAAK,MAAc,MAAe;AACtC,UAAM,WAAW,MAAM,MAAM,GAAG,KAAK,OAAO,GAAG,IAAI,IAAI;AAAA,MACrD,QAAQ;AAAA,MACR,SAAS,KAAK;AAAA,MACd,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,8BAA8B,SAAS,MAAM,EAAE;AAAA,IACjE;AAAA,EACF;AACF;;;ACGO,IAAe,SAAf,MAAsB;AAAA,EAC3B,YACqB,MACA,QACnB;AAFmB;AACA;AAAA,EAClB;AAAA,EAEH,MAAgB,QAAQ;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAuB;AACrB,UAAM,YAAY,gBAAgB,oBAAoB,SAAS;AAC/D,UAAM,WAAW,GAAG,KAAK,OAAO,QAAQ,GAAG,SAAS;AAEpD,UAAM,KAAK,KAAK,KAAK,YAAY;AAAA,MAC/B,UAAU,KAAK,OAAO;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AACF;;;ACvCO,IAAM,aAAN,cAAyB,OAAO;AAAA,EACrC,YAAY,MAAkB;AAC5B,UAAM,MAAM;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,O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;
|
|
5
|
+
this.headers = {
|
|
6
|
+
"Content-Type": "application/json"
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
setHeader(key, value) {
|
|
10
|
+
this.headers[key] = value;
|
|
11
|
+
}
|
|
12
|
+
async post(path, body) {
|
|
13
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: this.headers,
|
|
16
|
+
body: JSON.stringify(body)
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error(`Request failed with status ${response.status}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
3
23
|
|
|
4
24
|
// src/core/report.ts
|
|
5
25
|
var Report = class {
|
|
@@ -36,7 +56,7 @@ var OriginList = class extends Report {
|
|
|
36
56
|
async pdf(input) {
|
|
37
57
|
return await this.request({
|
|
38
58
|
contentType: "application/pdf",
|
|
39
|
-
resources: [{ key: "
|
|
59
|
+
resources: [{ key: "FARM_ID", value: input.farmId }],
|
|
40
60
|
parameters: [
|
|
41
61
|
{ key: "DATA_ONLY", value: false },
|
|
42
62
|
{ key: "LOCATE", value: input.language.replace("-", "_") }
|
|
@@ -46,9 +66,9 @@ var OriginList = class extends Report {
|
|
|
46
66
|
async csv(input) {
|
|
47
67
|
return await this.request({
|
|
48
68
|
contentType: "text/csv",
|
|
49
|
-
resources: [{ key: "
|
|
69
|
+
resources: [{ key: "FARM_ID", value: input.farmId }],
|
|
50
70
|
parameters: [
|
|
51
|
-
{ key: "DATA_ONLY", value:
|
|
71
|
+
{ key: "DATA_ONLY", value: true },
|
|
52
72
|
{ key: "LOCATE", value: input.language.replace("-", "_") }
|
|
53
73
|
]
|
|
54
74
|
});
|
|
@@ -69,11 +89,11 @@ var JaspionClient = class {
|
|
|
69
89
|
this.pigMaster = new PigMasterNamespace(http);
|
|
70
90
|
}
|
|
71
91
|
setAccessToken(token) {
|
|
72
|
-
this.http.
|
|
92
|
+
this.http.setHeader("Authorization", `Bearer ${token}`);
|
|
73
93
|
}
|
|
74
94
|
};
|
|
75
|
-
function jaspion(
|
|
76
|
-
const http =
|
|
95
|
+
function jaspion(baseUrl) {
|
|
96
|
+
const http = new HttpClient(baseUrl);
|
|
77
97
|
return new JaspionClient(http);
|
|
78
98
|
}
|
|
79
99
|
export {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/core/report.ts","../src/namespaces/pig-master/reports/origin-list.ts","../src/namespaces/pig-master/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/core/http-client.ts","../src/core/report.ts","../src/namespaces/pig-master/reports/origin-list.ts","../src/namespaces/pig-master/index.ts","../src/client.ts"],"sourcesContent":["export class HttpClient {\n private readonly headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n }\n\n constructor(private readonly baseUrl: string) {}\n\n setHeader(key: string, value: string) {\n this.headers[key] = value\n }\n\n async post(path: string, body: unknown) {\n const response = await fetch(`${this.baseUrl}${path}`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(body),\n })\n\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`)\n }\n }\n}\n","import type { HttpClient } from './http-client'\n\ntype ContentType = 'application/pdf' | 'text/csv'\n\nexport interface Parameter {\n key: string\n value: string | number | boolean | null\n}\n\nexport interface Resource {\n key: string\n value: string\n}\n\ninterface ReportConfig {\n template: string\n fileName: string\n}\n\ninterface RequestReportInput {\n contentType: ContentType\n parameters: Parameter[]\n resources: Resource[]\n}\n\nexport abstract class Report {\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ReportConfig,\n ) {}\n\n protected async request({\n contentType,\n parameters,\n resources,\n }: RequestReportInput) {\n const extension = contentType === 'application/pdf' ? '.pdf' : '.csv'\n const fileName = `${this.config.fileName}${extension}`\n\n await this.http.post('/reports', {\n template: this.config.template,\n fileName,\n parameters,\n resources,\n contentType,\n type: 'jasper-reports',\n })\n }\n}\n","import type { HttpClient } from '../../../core/http-client'\nimport { Report } from '../../../core/report'\nimport { LanguageCode } from '../../../core/types'\n\ninterface OriginListInput {\n farmId: string\n language: LanguageCode\n}\n\nexport class OriginList extends Report {\n constructor(http: HttpClient) {\n super(http, {\n template: '@pig-master/origin-list',\n fileName: 'Listagem de origens',\n })\n }\n\n async pdf(input: OriginListInput) {\n return await this.request({\n contentType: 'application/pdf',\n resources: [{ key: 'FARM_ID', value: input.farmId }],\n parameters: [\n { key: 'DATA_ONLY', value: false },\n { key: 'LOCATE', value: input.language.replace('-', '_') },\n ],\n })\n }\n\n async csv(input: OriginListInput) {\n return await this.request({\n contentType: 'text/csv',\n resources: [{ key: 'FARM_ID', value: input.farmId }],\n parameters: [\n { key: 'DATA_ONLY', value: true },\n { key: 'LOCATE', value: input.language.replace('-', '_') },\n ],\n })\n }\n}\n","import type { HttpClient } from '../../core/http-client'\nimport { OriginList } from './reports/origin-list'\n\nexport class PigMasterNamespace {\n public readonly originList: OriginList\n\n constructor(http: HttpClient) {\n this.originList = new OriginList(http)\n }\n}\n","import { HttpClient } from './core/http-client'\nimport { PigMasterNamespace } from './namespaces/pig-master'\n\nexport class JaspionClient {\n public readonly pigMaster: PigMasterNamespace\n\n constructor(private readonly http: HttpClient) {\n this.pigMaster = new PigMasterNamespace(http)\n }\n\n setAccessToken(token: string) {\n this.http.setHeader('Authorization', `Bearer ${token}`)\n }\n}\n\nexport function jaspion(baseUrl: string) {\n const http = new HttpClient(baseUrl)\n\n return new JaspionClient(http)\n}\n"],"mappings":";AAAO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAA6B,SAAiB;AAAjB;AAJ7B,SAAiB,UAAkC;AAAA,MACjD,gBAAgB;AAAA,IAClB;AAAA,EAE+C;AAAA,EAE/C,UAAU,KAAa,OAAe;AACpC,SAAK,QAAQ,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,MAAM,KAAK,MAAc,MAAe;AACtC,UAAM,WAAW,MAAM,MAAM,GA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,WAAW,OAAO,MAAM,OAAO,CAAC;AAAA,MACnD,YAAY;AAAA,QACV,EAAE,KAAK,aAAa,OAAO,KAAK;AAAA,QAChC,EAAE,KAAK,UAAU,OAAO,MAAM,SAAS,QAAQ,KAAK,GAAG,EAAE;AAAA,MAC3D;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;ACnCO,IAAM,qBAAN,MAAyB;AAAA,EAG9B,YAAY,MAAkB;AAC5B,SAAK,aAAa,IAAI,WAAW,IAAI;AAAA,EACvC;AACF;;;ACNO,IAAM,gBAAN,MAAoB;AAAA,EAGzB,YAA6B,MAAkB;AAAlB;AAC3B,SAAK,YAAY,IAAI,mBAAmB,IAAI;AAAA,EAC9C;AAAA,EAEA,eAAe,OAAe;AAC5B,SAAK,KAAK,UAAU,iBAAiB,UAAU,KAAK,EAAE;AAAA,EACxD;AACF;AAEO,SAAS,QAAQ,SAAiB;AACvC,QAAM,OAAO,IAAI,WAAW,OAAO;AAEnC,SAAO,IAAI,cAAc,IAAI;AAC/B;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesagro/jaspion-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "SDK for Jaspion",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,9 +26,6 @@
|
|
|
26
26
|
"typecheck": "tsc --noEmit",
|
|
27
27
|
"prepublishOnly": "npm run build"
|
|
28
28
|
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"axios": "^1.15.2"
|
|
31
|
-
},
|
|
32
29
|
"devDependencies": {
|
|
33
30
|
"@biomejs/biome": "^2.4.13",
|
|
34
31
|
"@types/node": "^25.6.0",
|
|
@@ -36,4 +33,4 @@
|
|
|
36
33
|
"tsup": "^8.5.1",
|
|
37
34
|
"typescript": "^6.0.3"
|
|
38
35
|
}
|
|
39
|
-
}
|
|
36
|
+
}
|