Skip to content

Commit 4a13a90

Browse files
committed
Merge branch 'main' into add-scheme-work-order-templates
2 parents 4ff2736 + daed257 commit 4a13a90

File tree

11 files changed

+30
-43
lines changed

11 files changed

+30
-43
lines changed

dist/Client.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export declare class Client {
6868
vehicleCategories(): VehicleCategoriesService;
6969
vehicleModels(): VehicleModelsService;
7070
equipment(): EquipmentService;
71-
equipmentExposures(): EquipmentExposureService;
71+
equipmentExposures(equipmentId?: string): EquipmentExposureService;
7272
equipmentManufacturers(): EquipmentManufacturersService;
7373
equipmentModels(): EquipmentModelsService;
7474
equipmentCategories(): EquipmentCategoriesService;

dist/Client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export class Client {
143143
equipment() {
144144
return new EquipmentService(this);
145145
}
146-
equipmentExposures() {
147-
return new EquipmentExposureService(this);
146+
equipmentExposures(equipmentId) {
147+
return new EquipmentExposureService(this, equipmentId);
148148
}
149149
equipmentManufacturers() {
150150
return new EquipmentManufacturersService(this);
@@ -239,7 +239,7 @@ export class Client {
239239
try {
240240
// @todo switch on cookie, "X-Session-Token" or client_credentials
241241
const fetchResponse = await fetch(url, {
242-
credentials: 'include', // @todo only required for cookie based auth,
242+
credentials: 'include',
243243
headers: headers,
244244
});
245245
let json = await fetchResponse.json();

dist/index.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,15 +1561,13 @@ class BaseService extends RequestBuilder {
15611561
};
15621562
}
15631563
async create(model, params) {
1564-
if (params) {
1565-
}
1564+
if (params) {}
15661565
const jsonApiSerializer = new JsonApiSerializer(this.hydrator.getModelMap());
15671566
const payload = jsonApiSerializer.buildCreatePayload(model);
15681567
return await this.client.makePostRequest(this.endpoint, payload);
15691568
}
15701569
async update(id, model, params) {
1571-
if (params) {
1572-
}
1570+
if (params) {}
15731571
const jsonApiSerializer = new JsonApiSerializer(this.hydrator.getModelMap());
15741572
const payload = jsonApiSerializer.buildUpdatePayload(model);
15751573
return await this.client.makePatchRequest(`${this.endpoint}/${id}`, payload);
@@ -1767,8 +1765,9 @@ class EquipmentService extends BaseService {
17671765

17681766
// src/services/EquipmentExposureService.ts
17691767
class EquipmentExposureService extends BaseService {
1770-
constructor(client) {
1771-
super(client, "/v3/orgs/:orgId/assets/equipment/exposures");
1768+
constructor(client, equipmentId) {
1769+
const endpoint = equipmentId ? `/v3/orgs/:orgId/assets/equipment/${equipmentId}/exposures` : `/v3/orgs/:orgId/assets/equipment/exposures`;
1770+
super(client, endpoint);
17721771
}
17731772
}
17741773

@@ -2109,8 +2108,8 @@ class Client {
21092108
equipment() {
21102109
return new EquipmentService(this);
21112110
}
2112-
equipmentExposures() {
2113-
return new EquipmentExposureService(this);
2111+
equipmentExposures(equipmentId) {
2112+
return new EquipmentExposureService(this, equipmentId);
21142113
}
21152114
equipmentManufacturers() {
21162115
return new EquipmentManufacturersService(this);
@@ -2252,9 +2251,6 @@ class ClientConfig {
22522251
}
22532252
// src/models/Organisation.ts
22542253
class Organisation extends BaseModel {
2255-
constructor() {
2256-
super(...arguments);
2257-
}
22582254
type = "organisations";
22592255
static relationships = [];
22602256
}

dist/services/BaseService.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ export declare class BaseService<T extends Model> extends RequestBuilder {
1313
constructor(client: Client, endpoint: string);
1414
convertToJsonApi(model: Model): {
1515
data: {
16-
id?: string;
16+
id?: string | undefined;
1717
type: string;
1818
attributes: Record<string, any>;
1919
relationships?: Record<string, {
2020
data: {
2121
type: string;
2222
id: string;
2323
};
24-
}>;
24+
}> | undefined;
2525
};
2626
};
2727
get(): Promise<InternalResponse<T[]>>;

dist/services/EquipmentExposureService.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { Client } from "../Client";
22
import { BaseService } from "./BaseService";
33
import { EquipmentExposure } from "../models/EquipmentExposure";
44
export declare class EquipmentExposureService extends BaseService<EquipmentExposure> {
5-
constructor(client: Client);
5+
constructor(client: Client, equipmentId?: string);
66
}

dist/services/EquipmentExposureService.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { Client } from "../Client";
22
import { BaseService } from "./BaseService";
33
import { EquipmentExposure } from "../models/EquipmentExposure";
44
export class EquipmentExposureService extends BaseService {
5-
constructor(client) {
6-
super(client, "/v3/orgs/:orgId/assets/equipment/exposures");
5+
constructor(client, equipmentId) {
6+
const endpoint = equipmentId ? `/v3/orgs/:orgId/assets/equipment/${equipmentId}/exposures` : `/v3/orgs/:orgId/assets/equipment/exposures`;
7+
super(client, endpoint);
78
}
89
}

dist/utils/Requests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class Requests {
1212
}
1313
static buildInternalResponse(fetchResponse, json) {
1414
return {
15-
ok: fetchResponse.ok, // @todo convert to own version
15+
ok: fetchResponse.ok,
1616
statusCode: fetchResponse.status,
1717
headers: fetchResponse.headers,
1818
meta: json?.meta || null,
@@ -29,7 +29,7 @@ export class Requests {
2929
static buildInternalErrorResponse(error) {
3030
return {
3131
ok: false,
32-
statusCode: error.statusCode || 0, // If there's no response, status code is 0
32+
statusCode: error.statusCode || 0,
3333
headers: error.headers,
3434
data: null,
3535
errors: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "git",
55
"url": "https://github.com/ctrl-hub/sdk.ts"
66
},
7-
"version": "0.1.137",
7+
"version": "0.1.138",
88
"main": "dist/index.js",
99
"types": "dist/index.d.ts",
1010
"type": "module",

src/Client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ export class Client {
179179
return new EquipmentService(this);
180180
}
181181

182-
public equipmentExposures(): EquipmentExposureService {
183-
return new EquipmentExposureService(this);
182+
public equipmentExposures(equipmentId?: string): EquipmentExposureService {
183+
return new EquipmentExposureService(this, equipmentId);
184184
}
185185

186186
public equipmentManufacturers(): EquipmentManufacturersService {

src/models/EquipmentExposure.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class EquipmentExposure extends BaseModel implements Partial<JsonApiMappi
5050

5151
constructor(data?: any) {
5252
super(data);
53-
this.start_time = data?.attributes?.start_time?.id ?? data?.start_time ?? '';
53+
this.start_time = data?.attributes?.start_time ?? data?.start_time ?? '';
5454
this.end_time = data?.attributes?.end_time ?? data?.end_time ?? '';
5555

5656
if (data?.attributes?.location) {
@@ -70,22 +70,11 @@ export class EquipmentExposure extends BaseModel implements Partial<JsonApiMappi
7070
}
7171
}
7272

73-
if (data?.attributes?.ppe) {
74-
const ppeData = data.attributes?.ppe;
73+
const ppe = data?.ppe ?? data?.attributes?.ppe
7574

76-
this.ppe = {
77-
mask: ppeData.ppe?.mask ?? false,
78-
ear_defenders: ppeData.ppe?.ear_defenders ?? false
79-
}
80-
}
81-
82-
if (data?.ppe) {
83-
const ppeData = data.ppe;
84-
85-
this.ppe = {
86-
mask: ppeData.mask ?? false,
87-
ear_defenders: ppeData.ear_defenders ?? false
88-
}
75+
this.ppe = {
76+
mask: ppe?.mask ?? false,
77+
ear_defenders: ppe?.ear_defenders ?? false
8978
}
9079
}
9180
}

0 commit comments

Comments
 (0)