dalux-build-api 2.2.0 → 2.4.0
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 +31 -11
- package/src/api/CompaniesApi.js +0 -67
- package/src/api/CompanyCatalogApi.js +0 -129
- package/src/api/FileAreasApi.js +0 -57
- package/src/api/FileRevisionsApi.js +0 -33
- package/src/api/FileUploadApi.js +0 -64
- package/src/api/FilesApi.js +0 -721
- package/src/api/FoldersApi.js +0 -283
- package/src/api/FormsApi.js +0 -53
- package/src/api/InspectionPlansApi.js +0 -140
- package/src/api/ProjectTemplatesApi.js +0 -25
- package/src/api/ProjectsApi.js +0 -127
- package/src/api/TasksApi.js +0 -193
- package/src/api/TestPlansApi.js +0 -137
- package/src/api/UsersApi.js +0 -52
- package/src/api/VersionSetsApi.js +0 -75
- package/src/api/WorkPackagesApi.js +0 -30
- package/src/apiClient.js +0 -143
- package/src/browser.js +0 -84
- package/src/configuration.js +0 -39
- package/src/index.js +0 -133
- package/src/models/common.js +0 -22
- package/src/models/companies/index.js +0 -14
- package/src/models/companyCatalog/index.js +0 -19
- package/src/models/convert.js +0 -44
- package/src/models/fileAreas/index.js +0 -20
- package/src/models/fileRevisions/index.js +0 -12
- package/src/models/fileUpload/index.js +0 -12
- package/src/models/files/index.js +0 -97
- package/src/models/folders/index.js +0 -20
- package/src/models/forms/index.js +0 -19
- package/src/models/helpers.js +0 -62
- package/src/models/index.js +0 -178
- package/src/models/inspectionPlans/index.js +0 -61
- package/src/models/projectTemplates/index.js +0 -11
- package/src/models/projects/index.js +0 -57
- package/src/models/tasks/index.js +0 -105
- package/src/models/testPlans/index.js +0 -61
- package/src/models/users/index.js +0 -29
- package/src/models/versionSets/index.js +0 -22
- package/src/models/workPackages/index.js +0 -19
- package/src/next.js +0 -89
- package/src/utils/errors.js +0 -45
- package/src/utils/index.js +0 -26
- package/src/utils/pagination.js +0 -82
- package/src/utils/pathResolver.js +0 -124
- package/src/utils/search.js +0 -61
- package/src/utils/validation.js +0 -36
package/src/models/index.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Zod schemas for Dalux Build API responses. Mirrors the public surface of
|
|
5
|
-
* python/dalux_build/models/__init__.py, with a `Schema` suffix on every
|
|
6
|
-
* export name (these are zod schema objects, not constructible classes).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const { LinkSchema, MetadataSchema } = require('./common');
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
ProjectSchema,
|
|
13
|
-
ProjectModuleSchema,
|
|
14
|
-
ProjectMetadataSchema,
|
|
15
|
-
ProjectTemplateSchema,
|
|
16
|
-
ProjectCompanySchema,
|
|
17
|
-
ProjectsListResponseSchema,
|
|
18
|
-
ProjectResponseSchema,
|
|
19
|
-
} = require('./projects');
|
|
20
|
-
|
|
21
|
-
const { FileAreaSchema, FileAreasListResponseSchema, FileAreaResponseSchema } = require('./fileAreas');
|
|
22
|
-
|
|
23
|
-
const { FolderSchema, FoldersListResponseSchema, FolderResponseSchema } = require('./folders');
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
FileSchema,
|
|
27
|
-
ReferenceSchema,
|
|
28
|
-
FileNameFilterSchema,
|
|
29
|
-
FileIntegerPropertySchema,
|
|
30
|
-
FileDatePropertySchema,
|
|
31
|
-
FileTextPropertySchema,
|
|
32
|
-
FileReferencePropertySchema,
|
|
33
|
-
FilePropertyFieldSchema,
|
|
34
|
-
FilesListResponseSchema,
|
|
35
|
-
FileResponseSchema,
|
|
36
|
-
} = require('./files');
|
|
37
|
-
|
|
38
|
-
const { VersionSetSchema, VersionSetsListResponseSchema, VersionSetResponseSchema } = require('./versionSets');
|
|
39
|
-
|
|
40
|
-
const { UserSchema, ProjectUserSchema, UsersListResponseSchema, UserResponseSchema } = require('./users');
|
|
41
|
-
|
|
42
|
-
const { CompaniesListResponseSchema, CompanyResponseSchema } = require('./companies');
|
|
43
|
-
|
|
44
|
-
const { CompanyCatalogListResponseSchema, CompanyCatalogResponseSchema } = require('./companyCatalog');
|
|
45
|
-
|
|
46
|
-
const {
|
|
47
|
-
InspectionPlanSchema,
|
|
48
|
-
InspectionPlanItemSchema,
|
|
49
|
-
InspectionPlanItemZoneSchema,
|
|
50
|
-
InspectionPlanRegistrationSchema,
|
|
51
|
-
InspectionPlansListResponseSchema,
|
|
52
|
-
InspectionPlanItemsListResponseSchema,
|
|
53
|
-
InspectionPlanItemZonesListResponseSchema,
|
|
54
|
-
InspectionPlanRegistrationsListResponseSchema,
|
|
55
|
-
} = require('./inspectionPlans');
|
|
56
|
-
|
|
57
|
-
const {
|
|
58
|
-
TestPlanSchema,
|
|
59
|
-
TestPlanItemSchema,
|
|
60
|
-
TestPlanItemZoneSchema,
|
|
61
|
-
TestPlanRegistrationSchema,
|
|
62
|
-
TestPlansListResponseSchema,
|
|
63
|
-
TestPlanItemsListResponseSchema,
|
|
64
|
-
TestPlanItemZonesListResponseSchema,
|
|
65
|
-
TestPlanRegistrationsListResponseSchema,
|
|
66
|
-
} = require('./testPlans');
|
|
67
|
-
|
|
68
|
-
const { FormSchema, FormsListResponseSchema, FormResponseSchema } = require('./forms');
|
|
69
|
-
|
|
70
|
-
const {
|
|
71
|
-
TaskSchema,
|
|
72
|
-
TaskAttachmentSchema,
|
|
73
|
-
TaskChangeSchema,
|
|
74
|
-
TaskChangeActorSchema,
|
|
75
|
-
TaskChangeFieldsSchema,
|
|
76
|
-
TaskChangeLocationSchema,
|
|
77
|
-
TaskListParamsSchema,
|
|
78
|
-
TasksListResponseSchema,
|
|
79
|
-
TaskResponseSchema,
|
|
80
|
-
TaskChangeResponseSchema,
|
|
81
|
-
TaskChangesSchema,
|
|
82
|
-
TaskAttachmentsListResponseSchema,
|
|
83
|
-
} = require('./tasks');
|
|
84
|
-
|
|
85
|
-
const { FileRevisionSchema } = require('./fileRevisions');
|
|
86
|
-
const { FileUploadSchema } = require('./fileUpload');
|
|
87
|
-
const { WorkPackageSchema, WorkPackagesListResponseSchema } = require('./workPackages');
|
|
88
|
-
|
|
89
|
-
module.exports = {
|
|
90
|
-
// Base
|
|
91
|
-
LinkSchema,
|
|
92
|
-
MetadataSchema,
|
|
93
|
-
// Projects
|
|
94
|
-
ProjectSchema,
|
|
95
|
-
ProjectModuleSchema,
|
|
96
|
-
ProjectMetadataSchema,
|
|
97
|
-
ProjectTemplateSchema,
|
|
98
|
-
ProjectCompanySchema,
|
|
99
|
-
ProjectsListResponseSchema,
|
|
100
|
-
ProjectResponseSchema,
|
|
101
|
-
// File Areas
|
|
102
|
-
FileAreaSchema,
|
|
103
|
-
FileAreasListResponseSchema,
|
|
104
|
-
FileAreaResponseSchema,
|
|
105
|
-
// Folders
|
|
106
|
-
FolderSchema,
|
|
107
|
-
FoldersListResponseSchema,
|
|
108
|
-
FolderResponseSchema,
|
|
109
|
-
// Files
|
|
110
|
-
FileSchema,
|
|
111
|
-
ReferenceSchema,
|
|
112
|
-
FileNameFilterSchema,
|
|
113
|
-
FileIntegerPropertySchema,
|
|
114
|
-
FileDatePropertySchema,
|
|
115
|
-
FileTextPropertySchema,
|
|
116
|
-
FileReferencePropertySchema,
|
|
117
|
-
FilePropertyFieldSchema,
|
|
118
|
-
FilesListResponseSchema,
|
|
119
|
-
FileResponseSchema,
|
|
120
|
-
// Version Sets
|
|
121
|
-
VersionSetSchema,
|
|
122
|
-
VersionSetsListResponseSchema,
|
|
123
|
-
VersionSetResponseSchema,
|
|
124
|
-
// Users
|
|
125
|
-
UserSchema,
|
|
126
|
-
ProjectUserSchema,
|
|
127
|
-
UsersListResponseSchema,
|
|
128
|
-
UserResponseSchema,
|
|
129
|
-
// Companies
|
|
130
|
-
CompaniesListResponseSchema,
|
|
131
|
-
CompanyResponseSchema,
|
|
132
|
-
// Company Catalog
|
|
133
|
-
CompanyCatalogListResponseSchema,
|
|
134
|
-
CompanyCatalogResponseSchema,
|
|
135
|
-
// Inspection Plans
|
|
136
|
-
InspectionPlanSchema,
|
|
137
|
-
InspectionPlanItemSchema,
|
|
138
|
-
InspectionPlanItemZoneSchema,
|
|
139
|
-
InspectionPlanRegistrationSchema,
|
|
140
|
-
InspectionPlansListResponseSchema,
|
|
141
|
-
InspectionPlanItemsListResponseSchema,
|
|
142
|
-
InspectionPlanItemZonesListResponseSchema,
|
|
143
|
-
InspectionPlanRegistrationsListResponseSchema,
|
|
144
|
-
// Test Plans
|
|
145
|
-
TestPlanSchema,
|
|
146
|
-
TestPlanItemSchema,
|
|
147
|
-
TestPlanItemZoneSchema,
|
|
148
|
-
TestPlanRegistrationSchema,
|
|
149
|
-
TestPlansListResponseSchema,
|
|
150
|
-
TestPlanItemsListResponseSchema,
|
|
151
|
-
TestPlanItemZonesListResponseSchema,
|
|
152
|
-
TestPlanRegistrationsListResponseSchema,
|
|
153
|
-
// Forms
|
|
154
|
-
FormSchema,
|
|
155
|
-
FormsListResponseSchema,
|
|
156
|
-
FormResponseSchema,
|
|
157
|
-
// Tasks
|
|
158
|
-
TaskSchema,
|
|
159
|
-
TaskAttachmentSchema,
|
|
160
|
-
TaskChangeSchema,
|
|
161
|
-
TaskChangeActorSchema,
|
|
162
|
-
TaskChangeFieldsSchema,
|
|
163
|
-
TaskChangeLocationSchema,
|
|
164
|
-
TaskListParamsSchema,
|
|
165
|
-
TasksListResponseSchema,
|
|
166
|
-
TaskResponseSchema,
|
|
167
|
-
TaskChangeResponseSchema,
|
|
168
|
-
TaskChangesSchema,
|
|
169
|
-
TaskAttachmentsListResponseSchema,
|
|
170
|
-
// Project Templates (same ProjectTemplateSchema as Projects, re-exported above)
|
|
171
|
-
// File Revisions
|
|
172
|
-
FileRevisionSchema,
|
|
173
|
-
// File Upload
|
|
174
|
-
FileUploadSchema,
|
|
175
|
-
// Work Packages
|
|
176
|
-
WorkPackageSchema,
|
|
177
|
-
WorkPackagesListResponseSchema,
|
|
178
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { z } = require('zod');
|
|
4
|
-
const { listResponseSchema } = require('../helpers');
|
|
5
|
-
|
|
6
|
-
const optionalString = z.string().nullish();
|
|
7
|
-
const optionalInteger = z.number().int().nullish();
|
|
8
|
-
|
|
9
|
-
const InspectionPlanSchema = z.object({
|
|
10
|
-
inspectionPlanId: optionalString,
|
|
11
|
-
name: optionalString,
|
|
12
|
-
workpackageId: optionalString,
|
|
13
|
-
}).passthrough();
|
|
14
|
-
|
|
15
|
-
const InspectionPlanItemSchema = z.object({
|
|
16
|
-
inspectionPlanItemId: optionalString,
|
|
17
|
-
inspectionPlanId: optionalString,
|
|
18
|
-
number: optionalString,
|
|
19
|
-
subject: optionalString,
|
|
20
|
-
heading: optionalString,
|
|
21
|
-
subHeading: optionalString,
|
|
22
|
-
extentType: optionalString,
|
|
23
|
-
planned: optionalInteger,
|
|
24
|
-
ongoing: optionalInteger,
|
|
25
|
-
completed: optionalInteger,
|
|
26
|
-
nonPlannedOngoing: optionalInteger,
|
|
27
|
-
nonPlannedCompleted: optionalInteger,
|
|
28
|
-
}).passthrough();
|
|
29
|
-
|
|
30
|
-
const InspectionPlanItemZoneSchema = z.object({
|
|
31
|
-
inspectionPlanItemId: optionalString,
|
|
32
|
-
inspectionPlanItemZoneId: optionalString,
|
|
33
|
-
name: optionalString,
|
|
34
|
-
planned: optionalInteger,
|
|
35
|
-
ongoing: optionalInteger,
|
|
36
|
-
completed: optionalInteger,
|
|
37
|
-
}).passthrough();
|
|
38
|
-
|
|
39
|
-
const InspectionPlanRegistrationSchema = z.object({
|
|
40
|
-
status: optionalString,
|
|
41
|
-
formId: optionalString,
|
|
42
|
-
taskId: optionalString,
|
|
43
|
-
inspectionPlanItemId: optionalString,
|
|
44
|
-
inspectionPlanItemZoneId: optionalString,
|
|
45
|
-
}).passthrough();
|
|
46
|
-
|
|
47
|
-
const InspectionPlansListResponseSchema = listResponseSchema(InspectionPlanSchema);
|
|
48
|
-
const InspectionPlanItemsListResponseSchema = listResponseSchema(InspectionPlanItemSchema);
|
|
49
|
-
const InspectionPlanItemZonesListResponseSchema = listResponseSchema(InspectionPlanItemZoneSchema);
|
|
50
|
-
const InspectionPlanRegistrationsListResponseSchema = listResponseSchema(InspectionPlanRegistrationSchema);
|
|
51
|
-
|
|
52
|
-
module.exports = {
|
|
53
|
-
InspectionPlanSchema,
|
|
54
|
-
InspectionPlanItemSchema,
|
|
55
|
-
InspectionPlanItemZoneSchema,
|
|
56
|
-
InspectionPlanRegistrationSchema,
|
|
57
|
-
InspectionPlansListResponseSchema,
|
|
58
|
-
InspectionPlanItemsListResponseSchema,
|
|
59
|
-
InspectionPlanItemZonesListResponseSchema,
|
|
60
|
-
InspectionPlanRegistrationsListResponseSchema,
|
|
61
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { ProjectTemplateSchema } = require('../projects');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Mirrors models/project_templates/models.py::ProjectTemplate — identical
|
|
7
|
-
* shape to projects/models.py::ProjectTemplate, so it's reused rather than
|
|
8
|
-
* duplicated. listProjectTemplates returns raw/unmodeled data in Python too
|
|
9
|
-
* (company-wide endpoint), so no response wrapper is defined here.
|
|
10
|
-
*/
|
|
11
|
-
module.exports = { ProjectTemplateSchema };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { z } = require('zod');
|
|
4
|
-
const { listResponseSchema, singleResponseSchema } = require('../helpers');
|
|
5
|
-
|
|
6
|
-
/** Mirrors models/projects/models.py::ProjectModule (empty placeholder, passthrough). */
|
|
7
|
-
const ProjectModuleSchema = z.object({}).passthrough();
|
|
8
|
-
|
|
9
|
-
/** Mirrors models/projects/models.py::Project. Note: `type` is the real JSON key (Python aliases project_type -> "type"). */
|
|
10
|
-
const ProjectSchema = z.object({
|
|
11
|
-
projectId: z.string(),
|
|
12
|
-
projectName: z.string(),
|
|
13
|
-
type: z.string().nullish(),
|
|
14
|
-
projectTemplateId: z.string().nullish(),
|
|
15
|
-
address: z.string().nullish(),
|
|
16
|
-
number: z.string().nullish(),
|
|
17
|
-
created: z.string().nullish(),
|
|
18
|
-
closing: z.string().nullish(),
|
|
19
|
-
modules: z.array(ProjectModuleSchema).nullish(),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
/** Mirrors models/projects/models.py::ProjectMetadata. */
|
|
23
|
-
const ProjectMetadataSchema = z.object({
|
|
24
|
-
key: z.string(),
|
|
25
|
-
value: z.string().nullish(),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
/** Mirrors models/projects/models.py::ProjectTemplate (also duplicated in project_templates/models.py — same shape). */
|
|
29
|
-
const ProjectTemplateSchema = z.object({
|
|
30
|
-
projectTemplateId: z.string(),
|
|
31
|
-
name: z.string(),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
/** Mirrors models/projects/models.py::ProjectCompany. */
|
|
35
|
-
const ProjectCompanySchema = z.object({
|
|
36
|
-
companyId: z.string().nullish(),
|
|
37
|
-
name: z.string().nullish(),
|
|
38
|
-
vatNumber: z.string().nullish(),
|
|
39
|
-
address: z.string().nullish(),
|
|
40
|
-
city: z.string().nullish(),
|
|
41
|
-
postalCode: z.string().nullish(),
|
|
42
|
-
country: z.string().nullish(),
|
|
43
|
-
catalogCompanyId: z.string().nullish(),
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const ProjectsListResponseSchema = listResponseSchema(ProjectSchema);
|
|
47
|
-
const ProjectResponseSchema = singleResponseSchema(ProjectSchema);
|
|
48
|
-
|
|
49
|
-
module.exports = {
|
|
50
|
-
ProjectModuleSchema,
|
|
51
|
-
ProjectSchema,
|
|
52
|
-
ProjectMetadataSchema,
|
|
53
|
-
ProjectTemplateSchema,
|
|
54
|
-
ProjectCompanySchema,
|
|
55
|
-
ProjectsListResponseSchema,
|
|
56
|
-
ProjectResponseSchema,
|
|
57
|
-
};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { z } = require('zod');
|
|
4
|
-
const { listResponseSchema, singleResponseSchema } = require('../helpers');
|
|
5
|
-
|
|
6
|
-
/** Mirrors models/tasks/models.py::Task (extra="allow" -> passthrough; only taskId is typed). */
|
|
7
|
-
const TaskSchema = z.object({
|
|
8
|
-
taskId: z.string().nullish(),
|
|
9
|
-
}).passthrough();
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Mirrors models/tasks/models.py::TaskListParams. Field names are the
|
|
13
|
-
* actual OData query keys (matches what src/api/TasksApi.js's
|
|
14
|
-
* normalizeTaskParams reads/writes) rather than Python's snake_case
|
|
15
|
-
* attribute names, since JS has no alias layer to bridge the two. These are
|
|
16
|
-
* developer-supplied query params (not API responses), so plain `.optional()`
|
|
17
|
-
* is fine.
|
|
18
|
-
*/
|
|
19
|
-
const TaskListParamsSchema = z.object({
|
|
20
|
-
typeId: z.string().optional(),
|
|
21
|
-
$filter: z.string().optional(),
|
|
22
|
-
$select: z.string().optional(),
|
|
23
|
-
$orderby: z.string().optional(),
|
|
24
|
-
$top: z.number().optional(),
|
|
25
|
-
$skip: z.number().optional(),
|
|
26
|
-
bookmark: z.string().optional(),
|
|
27
|
-
}).passthrough();
|
|
28
|
-
|
|
29
|
-
/** Mirrors models/tasks/models.py::TaskChangeActor. */
|
|
30
|
-
const TaskChangeActorSchema = z.object({
|
|
31
|
-
userId: z.string().nullish(),
|
|
32
|
-
roleId: z.string().nullish(),
|
|
33
|
-
roleName: z.string().nullish(),
|
|
34
|
-
userName: z.string().nullish(),
|
|
35
|
-
name: z.string().nullish(),
|
|
36
|
-
}).passthrough();
|
|
37
|
-
|
|
38
|
-
/** Mirrors models/tasks/models.py::TaskChangeLocation (empty passthrough). */
|
|
39
|
-
const TaskChangeLocationSchema = z.object({}).passthrough();
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Preprocesses the deadline field the same way Python's
|
|
43
|
-
* `normalize_deadline` field_validator does: unwraps API payloads where
|
|
44
|
-
* deadline is returned as an object instead of a bare string.
|
|
45
|
-
*/
|
|
46
|
-
const deadlineSchema = z.preprocess((value) => {
|
|
47
|
-
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
48
|
-
if (value.empty === true) return undefined;
|
|
49
|
-
if ('value' in value) return value.value;
|
|
50
|
-
if ('date' in value) return value.date;
|
|
51
|
-
if ('datetime' in value) return value.datetime;
|
|
52
|
-
}
|
|
53
|
-
return value;
|
|
54
|
-
}, z.string().nullish());
|
|
55
|
-
|
|
56
|
-
/** Mirrors models/tasks/models.py::TaskChangeFields. */
|
|
57
|
-
const TaskChangeFieldsSchema = z.object({
|
|
58
|
-
currentResponsible: TaskChangeActorSchema.nullish(),
|
|
59
|
-
assignedTo: TaskChangeActorSchema.nullish(),
|
|
60
|
-
title: z.string().nullish(),
|
|
61
|
-
deadline: deadlineSchema,
|
|
62
|
-
status: z.string().nullish(),
|
|
63
|
-
modifiedBy: TaskChangeActorSchema.nullish(),
|
|
64
|
-
userDefinedFields: z.record(z.any()).nullish(),
|
|
65
|
-
workpackageId: z.string().nullish(),
|
|
66
|
-
location: TaskChangeLocationSchema.nullish(),
|
|
67
|
-
}).passthrough();
|
|
68
|
-
|
|
69
|
-
/** Mirrors models/tasks/models.py::TaskChange. */
|
|
70
|
-
const TaskChangeSchema = z.object({
|
|
71
|
-
taskId: z.string(),
|
|
72
|
-
description: z.string().nullish(),
|
|
73
|
-
timestamp: z.string(),
|
|
74
|
-
action: z.string(),
|
|
75
|
-
fields: TaskChangeFieldsSchema.nullish(),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
/** Mirrors models/tasks/models.py::TaskAttachment. */
|
|
79
|
-
const TaskAttachmentSchema = z.object({
|
|
80
|
-
attachmentId: z.string().nullish(),
|
|
81
|
-
taskId: z.string().nullish(),
|
|
82
|
-
fileId: z.string().nullish(),
|
|
83
|
-
}).passthrough();
|
|
84
|
-
|
|
85
|
-
const TasksListResponseSchema = listResponseSchema(TaskSchema);
|
|
86
|
-
const TaskResponseSchema = singleResponseSchema(TaskSchema);
|
|
87
|
-
const TaskChangeResponseSchema = singleResponseSchema(TaskChangeSchema);
|
|
88
|
-
/** Bare-list payloads (`[...]` instead of `{items: [...]}`) are handled by listResponseSchema's preprocessor. */
|
|
89
|
-
const TaskChangesSchema = listResponseSchema(TaskChangeSchema);
|
|
90
|
-
const TaskAttachmentsListResponseSchema = listResponseSchema(TaskAttachmentSchema);
|
|
91
|
-
|
|
92
|
-
module.exports = {
|
|
93
|
-
TaskSchema,
|
|
94
|
-
TaskListParamsSchema,
|
|
95
|
-
TaskChangeActorSchema,
|
|
96
|
-
TaskChangeLocationSchema,
|
|
97
|
-
TaskChangeFieldsSchema,
|
|
98
|
-
TaskChangeSchema,
|
|
99
|
-
TaskAttachmentSchema,
|
|
100
|
-
TasksListResponseSchema,
|
|
101
|
-
TaskResponseSchema,
|
|
102
|
-
TaskChangeResponseSchema,
|
|
103
|
-
TaskChangesSchema,
|
|
104
|
-
TaskAttachmentsListResponseSchema,
|
|
105
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { z } = require('zod');
|
|
4
|
-
const { listResponseSchema } = require('../helpers');
|
|
5
|
-
|
|
6
|
-
const optionalString = z.string().nullish();
|
|
7
|
-
const optionalInteger = z.number().int().nullish();
|
|
8
|
-
|
|
9
|
-
const TestPlanSchema = z.object({
|
|
10
|
-
testPlanId: optionalString,
|
|
11
|
-
name: optionalString,
|
|
12
|
-
workpackageId: optionalString,
|
|
13
|
-
}).passthrough();
|
|
14
|
-
|
|
15
|
-
const TestPlanItemSchema = z.object({
|
|
16
|
-
testPlanItemId: optionalString,
|
|
17
|
-
testPlanId: optionalString,
|
|
18
|
-
number: optionalString,
|
|
19
|
-
subject: optionalString,
|
|
20
|
-
heading: optionalString,
|
|
21
|
-
subHeading: optionalString,
|
|
22
|
-
extentType: optionalString,
|
|
23
|
-
planned: optionalInteger,
|
|
24
|
-
ongoing: optionalInteger,
|
|
25
|
-
completed: optionalInteger,
|
|
26
|
-
nonPlannedOngoing: optionalInteger,
|
|
27
|
-
nonPlannedCompleted: optionalInteger,
|
|
28
|
-
}).passthrough();
|
|
29
|
-
|
|
30
|
-
const TestPlanItemZoneSchema = z.object({
|
|
31
|
-
testPlanItemId: optionalString,
|
|
32
|
-
testPlanItemZoneId: optionalString,
|
|
33
|
-
name: optionalString,
|
|
34
|
-
planned: optionalInteger,
|
|
35
|
-
ongoing: optionalInteger,
|
|
36
|
-
completed: optionalInteger,
|
|
37
|
-
}).passthrough();
|
|
38
|
-
|
|
39
|
-
const TestPlanRegistrationSchema = z.object({
|
|
40
|
-
status: optionalString,
|
|
41
|
-
formId: optionalString,
|
|
42
|
-
taskId: optionalString,
|
|
43
|
-
testPlanItemId: optionalString,
|
|
44
|
-
testPlanItemZoneId: optionalString,
|
|
45
|
-
}).passthrough();
|
|
46
|
-
|
|
47
|
-
const TestPlansListResponseSchema = listResponseSchema(TestPlanSchema);
|
|
48
|
-
const TestPlanItemsListResponseSchema = listResponseSchema(TestPlanItemSchema);
|
|
49
|
-
const TestPlanItemZonesListResponseSchema = listResponseSchema(TestPlanItemZoneSchema);
|
|
50
|
-
const TestPlanRegistrationsListResponseSchema = listResponseSchema(TestPlanRegistrationSchema);
|
|
51
|
-
|
|
52
|
-
module.exports = {
|
|
53
|
-
TestPlanSchema,
|
|
54
|
-
TestPlanItemSchema,
|
|
55
|
-
TestPlanItemZoneSchema,
|
|
56
|
-
TestPlanRegistrationSchema,
|
|
57
|
-
TestPlansListResponseSchema,
|
|
58
|
-
TestPlanItemsListResponseSchema,
|
|
59
|
-
TestPlanItemZonesListResponseSchema,
|
|
60
|
-
TestPlanRegistrationsListResponseSchema,
|
|
61
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { z } = require('zod');
|
|
4
|
-
const { listResponseSchema, singleResponseSchema } = require('../helpers');
|
|
5
|
-
|
|
6
|
-
/** Mirrors models/users/models.py::User. */
|
|
7
|
-
const UserSchema = z.object({
|
|
8
|
-
userId: z.string(),
|
|
9
|
-
userType: z.string(),
|
|
10
|
-
email: z.string().email(),
|
|
11
|
-
firstName: z.string().nullish(),
|
|
12
|
-
lastName: z.string().nullish(),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
/** Mirrors models/users/models.py::ProjectUser (User + companyId). */
|
|
16
|
-
const ProjectUserSchema = UserSchema.extend({
|
|
17
|
-
companyId: z.string().nullish(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const UsersListResponseSchema = listResponseSchema(ProjectUserSchema);
|
|
21
|
-
/** Single-user response wraps User, not ProjectUser — matches Python. */
|
|
22
|
-
const UserResponseSchema = singleResponseSchema(UserSchema);
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
UserSchema,
|
|
26
|
-
ProjectUserSchema,
|
|
27
|
-
UsersListResponseSchema,
|
|
28
|
-
UserResponseSchema,
|
|
29
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { z } = require('zod');
|
|
4
|
-
const { listResponseSchema, singleResponseSchema } = require('../helpers');
|
|
5
|
-
|
|
6
|
-
/** Mirrors models/version_sets/models.py::VersionSet. */
|
|
7
|
-
const VersionSetSchema = z.object({
|
|
8
|
-
versionSetId: z.string(),
|
|
9
|
-
name: z.string(),
|
|
10
|
-
description: z.string().nullish(),
|
|
11
|
-
status: z.string().nullish(),
|
|
12
|
-
fileAreaId: z.string(),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const VersionSetsListResponseSchema = listResponseSchema(VersionSetSchema);
|
|
16
|
-
const VersionSetResponseSchema = singleResponseSchema(VersionSetSchema);
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
VersionSetSchema,
|
|
20
|
-
VersionSetsListResponseSchema,
|
|
21
|
-
VersionSetResponseSchema,
|
|
22
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { z } = require('zod');
|
|
4
|
-
const { listResponseSchema } = require('../helpers');
|
|
5
|
-
|
|
6
|
-
/** Mirrors models/work_packages/models.py::WorkPackage (extra="allow" -> passthrough). */
|
|
7
|
-
const WorkPackageSchema = z.object({
|
|
8
|
-
workpackageId: z.string().nullish(),
|
|
9
|
-
companyId: z.string().nullish(),
|
|
10
|
-
name: z.string().nullish(),
|
|
11
|
-
}).passthrough();
|
|
12
|
-
|
|
13
|
-
/** No single-item response class in Python. */
|
|
14
|
-
const WorkPackagesListResponseSchema = listResponseSchema(WorkPackageSchema);
|
|
15
|
-
|
|
16
|
-
module.exports = {
|
|
17
|
-
WorkPackageSchema,
|
|
18
|
-
WorkPackagesListResponseSchema,
|
|
19
|
-
};
|
package/src/next.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function normalizeAllowedMethods(allowedMethods) {
|
|
4
|
-
const normalized = new Set();
|
|
5
|
-
if (Array.isArray(allowedMethods)) {
|
|
6
|
-
for (const method of allowedMethods) normalized.add(method);
|
|
7
|
-
} else if (allowedMethods && typeof allowedMethods === 'object') {
|
|
8
|
-
for (const [resource, methods] of Object.entries(allowedMethods)) {
|
|
9
|
-
for (const method of methods) normalized.add(`${resource}.${method}`);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
if (normalized.size === 0) {
|
|
13
|
-
throw new Error('allowedMethods must explicitly expose at least one Dalux client method');
|
|
14
|
-
}
|
|
15
|
-
return normalized;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function json(body, status = 200) {
|
|
19
|
-
return Response.json(body, { status });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function errorStatus(error) {
|
|
23
|
-
if (error?.name === 'AuthenticationError') return 401;
|
|
24
|
-
if (error?.name === 'NotFoundError') return 404;
|
|
25
|
-
if (error?.name === 'RateLimitError') return 429;
|
|
26
|
-
if (error?.name === 'ValidationError') return 422;
|
|
27
|
-
return 502;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Create a Next.js App Router POST handler for a browser Dalux client.
|
|
32
|
-
*
|
|
33
|
-
* @param {object} options
|
|
34
|
-
* @param {object} options.client A server-side client from createClient().
|
|
35
|
-
* @param {string[]|Record<string, string[]>} options.allowedMethods Explicit RPC allow-list.
|
|
36
|
-
* @param {(request: Request) => boolean|Response|Promise<boolean|Response>} [options.authorize]
|
|
37
|
-
* @returns {(request: Request) => Promise<Response>}
|
|
38
|
-
*/
|
|
39
|
-
function createDaluxRouteHandler({ client, allowedMethods, authorize } = {}) {
|
|
40
|
-
if (!client || typeof client !== 'object') {
|
|
41
|
-
throw new Error('A server-side Dalux client is required');
|
|
42
|
-
}
|
|
43
|
-
const allowed = normalizeAllowedMethods(allowedMethods);
|
|
44
|
-
|
|
45
|
-
return async function POST(request) {
|
|
46
|
-
if (authorize) {
|
|
47
|
-
const authorization = await authorize(request);
|
|
48
|
-
if (authorization instanceof Response) return authorization;
|
|
49
|
-
if (!authorization) return json({ ok: false, error: { name: 'AuthenticationError', message: 'Unauthorized' } }, 401);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let payload;
|
|
53
|
-
try {
|
|
54
|
-
payload = await request.json();
|
|
55
|
-
} catch {
|
|
56
|
-
return json({ ok: false, error: { name: 'ValidationError', message: 'Request body must be JSON' } }, 400);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const { resource, method, args = [] } = payload || {};
|
|
60
|
-
const qualifiedMethod = `${resource}.${method}`;
|
|
61
|
-
if (!allowed.has(qualifiedMethod)) {
|
|
62
|
-
return json({ ok: false, error: { name: 'NotFoundError', message: `Method ${qualifiedMethod} is not exposed` } }, 404);
|
|
63
|
-
}
|
|
64
|
-
if (!Array.isArray(args)) {
|
|
65
|
-
return json({ ok: false, error: { name: 'ValidationError', message: 'args must be an array' } }, 400);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const target = client[resource];
|
|
69
|
-
const operation = target?.[method];
|
|
70
|
-
if (typeof operation !== 'function') {
|
|
71
|
-
return json({ ok: false, error: { name: 'NotFoundError', message: `Unknown method ${qualifiedMethod}` } }, 404);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const data = await operation.apply(target, args);
|
|
76
|
-
return json({ ok: true, data: data === undefined ? null : data });
|
|
77
|
-
} catch (error) {
|
|
78
|
-
return json({
|
|
79
|
-
ok: false,
|
|
80
|
-
error: {
|
|
81
|
-
name: error?.name || 'ApiError',
|
|
82
|
-
message: error?.message || String(error),
|
|
83
|
-
},
|
|
84
|
-
}, errorStatus(error));
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
module.exports = { createDaluxRouteHandler };
|
package/src/utils/errors.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Base exception for all Dalux API errors.
|
|
5
|
-
*/
|
|
6
|
-
class DaluxError extends Error {
|
|
7
|
-
constructor(message) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.name = this.constructor.name;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Resource not found (HTTP 404).
|
|
15
|
-
*/
|
|
16
|
-
class NotFoundError extends DaluxError {}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* API request failed (4xx / 5xx other than 401, 404, 429).
|
|
20
|
-
*/
|
|
21
|
-
class ApiError extends DaluxError {}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Input validation failed.
|
|
25
|
-
*/
|
|
26
|
-
class ValidationError extends DaluxError {}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Authentication failed (HTTP 401).
|
|
30
|
-
*/
|
|
31
|
-
class AuthenticationError extends DaluxError {}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Rate limit exceeded (HTTP 429).
|
|
35
|
-
*/
|
|
36
|
-
class RateLimitError extends DaluxError {}
|
|
37
|
-
|
|
38
|
-
module.exports = {
|
|
39
|
-
DaluxError,
|
|
40
|
-
NotFoundError,
|
|
41
|
-
ApiError,
|
|
42
|
-
ValidationError,
|
|
43
|
-
AuthenticationError,
|
|
44
|
-
RateLimitError,
|
|
45
|
-
};
|