@vulog/aima-config 1.1.49 → 1.1.50

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/dist/index.d.mts CHANGED
@@ -51,4 +51,13 @@ type FleetConf = {
51
51
  };
52
52
  declare const getFleetConf: (client: Client) => Promise<FleetConf>;
53
53
 
54
- export { type City, type FleetConf, type Service, getCities, getCitiesAllFranchises, getFleetConf, getServices, getServicesAllFranchises };
54
+ type Label = {
55
+ id: number;
56
+ name: string;
57
+ createDate: string;
58
+ };
59
+ declare const getLabels: (client: Client) => Promise<Label[]>;
60
+ declare const addLabel: (client: Client, name: string) => Promise<void>;
61
+ declare const removeLabel: (client: Client, labelId: number, cascade?: boolean) => Promise<void>;
62
+
63
+ export { type City, type FleetConf, type Label, type Service, addLabel, getCities, getCitiesAllFranchises, getFleetConf, getLabels, getServices, getServicesAllFranchises, removeLabel };
package/dist/index.d.ts CHANGED
@@ -51,4 +51,13 @@ type FleetConf = {
51
51
  };
52
52
  declare const getFleetConf: (client: Client) => Promise<FleetConf>;
53
53
 
54
- export { type City, type FleetConf, type Service, getCities, getCitiesAllFranchises, getFleetConf, getServices, getServicesAllFranchises };
54
+ type Label = {
55
+ id: number;
56
+ name: string;
57
+ createDate: string;
58
+ };
59
+ declare const getLabels: (client: Client) => Promise<Label[]>;
60
+ declare const addLabel: (client: Client, name: string) => Promise<void>;
61
+ declare const removeLabel: (client: Client, labelId: number, cascade?: boolean) => Promise<void>;
62
+
63
+ export { type City, type FleetConf, type Label, type Service, addLabel, getCities, getCitiesAllFranchises, getFleetConf, getLabels, getServices, getServicesAllFranchises, removeLabel };
package/dist/index.js CHANGED
@@ -20,11 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ addLabel: () => addLabel,
23
24
  getCities: () => getCities,
24
25
  getCitiesAllFranchises: () => getCitiesAllFranchises,
25
26
  getFleetConf: () => getFleetConf,
27
+ getLabels: () => getLabels,
26
28
  getServices: () => getServices,
27
- getServicesAllFranchises: () => getServicesAllFranchises
29
+ getServicesAllFranchises: () => getServicesAllFranchises,
30
+ removeLabel: () => removeLabel
28
31
  });
29
32
  module.exports = __toCommonJS(index_exports);
30
33
 
@@ -52,11 +55,47 @@ var getServicesAllFranchises = async (client) => {
52
55
  var getFleetConf = async (client) => {
53
56
  return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/conf`).then(({ data }) => data);
54
57
  };
58
+
59
+ // src/label.ts
60
+ var import_zod = require("zod");
61
+ var getLabels = async (client) => {
62
+ return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels`).then(({ data }) => data);
63
+ };
64
+ var schemaData = import_zod.z.object({
65
+ name: import_zod.z.string().nonempty()
66
+ });
67
+ var addLabel = async (client, name) => {
68
+ const result = schemaData.safeParse({ name });
69
+ if (!result.success) {
70
+ throw new TypeError("Invalid args", {
71
+ cause: result.error.issues
72
+ });
73
+ }
74
+ await client.post(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels`, {
75
+ name
76
+ });
77
+ };
78
+ var schemaRemove = import_zod.z.object({
79
+ labelId: import_zod.z.number().positive(),
80
+ cascade: import_zod.z.boolean().optional()
81
+ });
82
+ var removeLabel = async (client, labelId, cascade = false) => {
83
+ const result = schemaRemove.safeParse({ labelId, cascade });
84
+ if (!result.success) {
85
+ throw new TypeError("Invalid args", {
86
+ cause: result.error.issues
87
+ });
88
+ }
89
+ await client.delete(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels/${labelId}?cascade=${cascade}`);
90
+ };
55
91
  // Annotate the CommonJS export names for ESM import in node:
56
92
  0 && (module.exports = {
93
+ addLabel,
57
94
  getCities,
58
95
  getCitiesAllFranchises,
59
96
  getFleetConf,
97
+ getLabels,
60
98
  getServices,
61
- getServicesAllFranchises
99
+ getServicesAllFranchises,
100
+ removeLabel
62
101
  });
package/dist/index.mjs CHANGED
@@ -22,10 +22,46 @@ var getServicesAllFranchises = async (client) => {
22
22
  var getFleetConf = async (client) => {
23
23
  return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/conf`).then(({ data }) => data);
24
24
  };
25
+
26
+ // src/label.ts
27
+ import { z } from "zod";
28
+ var getLabels = async (client) => {
29
+ return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels`).then(({ data }) => data);
30
+ };
31
+ var schemaData = z.object({
32
+ name: z.string().nonempty()
33
+ });
34
+ var addLabel = async (client, name) => {
35
+ const result = schemaData.safeParse({ name });
36
+ if (!result.success) {
37
+ throw new TypeError("Invalid args", {
38
+ cause: result.error.issues
39
+ });
40
+ }
41
+ await client.post(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels`, {
42
+ name
43
+ });
44
+ };
45
+ var schemaRemove = z.object({
46
+ labelId: z.number().positive(),
47
+ cascade: z.boolean().optional()
48
+ });
49
+ var removeLabel = async (client, labelId, cascade = false) => {
50
+ const result = schemaRemove.safeParse({ labelId, cascade });
51
+ if (!result.success) {
52
+ throw new TypeError("Invalid args", {
53
+ cause: result.error.issues
54
+ });
55
+ }
56
+ await client.delete(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels/${labelId}?cascade=${cascade}`);
57
+ };
25
58
  export {
59
+ addLabel,
26
60
  getCities,
27
61
  getCitiesAllFranchises,
28
62
  getFleetConf,
63
+ getLabels,
29
64
  getServices,
30
- getServicesAllFranchises
65
+ getServicesAllFranchises,
66
+ removeLabel
31
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulog/aima-config",
3
- "version": "1.1.49",
3
+ "version": "1.1.50",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "author": "Vulog",
20
20
  "license": "ISC",
21
21
  "dependencies": {
22
- "@vulog/aima-client": "1.1.49",
23
- "@vulog/aima-core": "1.1.49"
22
+ "@vulog/aima-client": "1.1.50",
23
+ "@vulog/aima-core": "1.1.50"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "zod": "^3.24.2"
package/src/index.ts CHANGED
@@ -1,6 +1,4 @@
1
- export { getCities, getCitiesAllFranchises } from './getCities';
2
- export type { City } from './getCities';
3
- export { getServices, getServicesAllFranchises } from './getServices';
4
- export type { Service } from './getServices';
5
- export { getFleetConf } from './getFleetConf';
6
- export type { FleetConf } from './getFleetConf';
1
+ export * from './getCities';
2
+ export * from './getServices';
3
+ export * from './getFleetConf';
4
+ export * from './label';
package/src/label.ts ADDED
@@ -0,0 +1,47 @@
1
+ import { Client } from '@vulog/aima-client';
2
+ import { z } from 'zod';
3
+
4
+ export type Label = {
5
+ id: number;
6
+ name: string;
7
+ createDate: string;
8
+ };
9
+
10
+ export const getLabels = async (client: Client) => {
11
+ return client
12
+ .get<Label[]>(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels`)
13
+ .then(({ data }) => data);
14
+ };
15
+
16
+ const schemaData = z.object({
17
+ name: z.string().nonempty(),
18
+ });
19
+
20
+ export const addLabel = async (client: Client, name: string) => {
21
+ const result = schemaData.safeParse({ name });
22
+ if (!result.success) {
23
+ throw new TypeError('Invalid args', {
24
+ cause: result.error.issues,
25
+ });
26
+ }
27
+
28
+ await client.post(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels`, {
29
+ name,
30
+ });
31
+ };
32
+
33
+ const schemaRemove = z.object({
34
+ labelId: z.number().positive(),
35
+ cascade: z.boolean().optional(),
36
+ });
37
+
38
+ export const removeLabel = async (client: Client, labelId: number, cascade = false) => {
39
+ const result = schemaRemove.safeParse({ labelId, cascade });
40
+ if (!result.success) {
41
+ throw new TypeError('Invalid args', {
42
+ cause: result.error.issues,
43
+ });
44
+ }
45
+
46
+ await client.delete(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/labels/${labelId}?cascade=${cascade}`);
47
+ };