Skip to content

Commit dd195dd

Browse files
committed
add operation template requirements
1 parent 1432ae8 commit dd195dd

File tree

9 files changed

+48
-6
lines changed

9 files changed

+48
-6
lines changed

dist/Client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ export class Client {
205205
headers['Authorization'] = `Bearer ${this.bearerToken}`;
206206
}
207207
try {
208+
console.log('body', body);
209+
console.log(JSON.stringify(body, null, 2));
208210
const fetchResponse = await fetch(url, {
209211
method: 'POST',
210212
headers: headers,

dist/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class BaseModel {
149149
}
150150
toJSON() {
151151
const obj = {};
152+
console.log(this);
152153
if (this.id)
153154
obj.id = this.id;
154155
if (this.type)
@@ -1170,15 +1171,17 @@ class OperationTemplate extends BaseModel {
11701171
type = "operation-templates";
11711172
name = "";
11721173
labels = [];
1174+
requirements = { forms: [] };
11731175
static relationships = [];
11741176
constructor(data) {
11751177
super(data);
11761178
this.name = data?.attributes?.name ?? data?.name ?? "";
11771179
this.labels = data?.attributes?.labels ?? data?.labels ?? [];
1180+
this.requirements = data?.attributes?.requirements ?? data?.requirements ?? { forms: [] };
11781181
}
11791182
jsonApiMapping() {
11801183
return {
1181-
attributes: ["name", "labels"]
1184+
attributes: ["name", "labels", "requirements"]
11821185
};
11831186
}
11841187
}
@@ -1516,13 +1519,15 @@ class BaseService extends RequestBuilder {
15161519
};
15171520
}
15181521
async create(model, params) {
1519-
if (params) {}
1522+
if (params) {
1523+
}
15201524
const jsonApiSerializer = new JsonApiSerializer(this.hydrator.getModelMap());
15211525
const payload = jsonApiSerializer.buildCreatePayload(model);
15221526
return await this.client.makePostRequest(this.endpoint, payload);
15231527
}
15241528
async update(id, model, params) {
1525-
if (params) {}
1529+
if (params) {
1530+
}
15261531
const jsonApiSerializer = new JsonApiSerializer(this.hydrator.getModelMap());
15271532
const payload = jsonApiSerializer.buildUpdatePayload(model);
15281533
return await this.client.makePatchRequest(`${this.endpoint}/${id}`, payload);
@@ -2111,6 +2116,8 @@ class Client {
21112116
headers["Authorization"] = `Bearer ${this.bearerToken}`;
21122117
}
21132118
try {
2119+
console.log("body", body);
2120+
console.log(JSON.stringify(body, null, 2));
21142121
const fetchResponse = await fetch(url, {
21152122
method: "POST",
21162123
headers,
@@ -2185,6 +2192,9 @@ class ClientConfig {
21852192
}
21862193
// src/models/Organisation.ts
21872194
class Organisation extends BaseModel {
2195+
constructor() {
2196+
super(...arguments);
2197+
}
21882198
type = "organisations";
21892199
static relationships = [];
21902200
}

dist/models/BaseModel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class BaseModel {
2525
}
2626
toJSON() {
2727
const obj = {};
28+
console.log(this);
2829
if (this.id)
2930
obj.id = this.id;
3031
if (this.type)

dist/models/OperationTemplate.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import type { RelationshipDefinition } from '../types/RelationshipDefinition';
22
import { BaseModel } from './BaseModel';
33
import type { Label } from './Label';
4+
type Requirements = {
5+
forms: FormRequirement[];
6+
};
7+
declare class FormRequirement {
8+
id: string;
9+
required: boolean;
10+
}
411
export declare class OperationTemplate extends BaseModel {
512
type: string;
613
name: string;
714
labels: Label[];
15+
requirements: Requirements;
816
static relationships: RelationshipDefinition[];
917
constructor(data?: any);
1018
jsonApiMapping(): {
1119
attributes: string[];
1220
};
1321
}
22+
export {};

dist/models/OperationTemplate.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import { BaseModel } from './BaseModel';
2+
class FormRequirement {
3+
id = '';
4+
required = false;
5+
}
26
export class OperationTemplate extends BaseModel {
37
type = 'operation-templates';
48
name = '';
59
labels = [];
10+
requirements = { forms: [] };
611
static relationships = [];
712
constructor(data) {
813
super(data);
914
this.name = data?.attributes?.name ?? data?.name ?? '';
1015
this.labels = data?.attributes?.labels ?? data?.labels ?? [];
16+
this.requirements = data?.attributes?.requirements ?? data?.requirements ?? { forms: [] };
1117
}
1218
jsonApiMapping() {
1319
return {
14-
attributes: ['name', 'labels'],
20+
attributes: ['name', 'labels', 'requirements'],
1521
};
1622
}
1723
}

src/Client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ export class Client {
260260
}
261261

262262
try {
263+
console.log('body', body);
264+
console.log(JSON.stringify(body, null, 2));
263265
const fetchResponse = await fetch(url, {
264266
method: 'POST',
265267
headers: headers,

src/models/BaseModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export abstract class BaseModel implements Model {
3636

3737
toJSON() {
3838
const obj: Record<string, any> = {};
39+
console.log(this)
3940

4041
if (this.id) obj.id = this.id;
4142
if (this.type) obj.type = this.type;

src/models/OperationTemplate.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,34 @@ import type { RelationshipDefinition } from '../types/RelationshipDefinition';
22
import { BaseModel } from '@models/BaseModel';
33
import type { Label } from './Label';
44

5+
type Requirements = {
6+
forms: FormRequirement[]
7+
}
8+
9+
class FormRequirement {
10+
public id: string = '';
11+
public required: boolean = false;
12+
}
13+
514
export class OperationTemplate extends BaseModel {
615
public type: string = 'operation-templates';
716

817
public name: string = '';
918
public labels: Label[] = [];
19+
public requirements: Requirements = { forms: [] };
1020

1121
static relationships: RelationshipDefinition[] = [];
1222

1323
constructor(data?: any) {
1424
super(data);
1525
this.name = data?.attributes?.name ?? data?.name ?? '';
1626
this.labels = data?.attributes?.labels ?? data?.labels ?? [];
27+
this.requirements = data?.attributes?.requirements ?? data?.requirements ?? { forms: [] };
1728
}
1829

1930
jsonApiMapping() {
2031
return {
21-
attributes: ['name', 'labels'],
32+
attributes: ['name', 'labels', 'requirements'],
2233
};
2334
}
2435
}

src/utils/JsonSerializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,4 @@ export class JsonApiSerializer {
156156

157157
return payload;
158158
}
159-
}
159+
}

0 commit comments

Comments
 (0)