Skip to content

Commit bf4d58c

Browse files
feat: Assign default value to fields and args of type enum with only one value (box/box-codegen#465) (#131)
1 parent 57ccdac commit bf4d58c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+9236
-566
lines changed

.codegen.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "fd9728e", "specHash": "1698c95", "version": "0.5.2" }
1+
{ "engineHash": "7b699f4", "specHash": "1698c95", "version": "0.5.2" }

docs/classifications.md

+4-10
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ See the endpoint docs at
5858

5959
```ts
6060
await client.classifications.addClassification([
61-
{
62-
op: 'addEnumOption' as AddClassificationRequestBodyOpField,
63-
fieldKey:
64-
'Box__Security__Classification__Key' as AddClassificationRequestBodyFieldKeyField,
61+
new AddClassificationRequestBody({
6562
data: {
6663
key: getUuid(),
6764
staticConfig: {
@@ -71,7 +68,7 @@ await client.classifications.addClassification([
7168
} satisfies AddClassificationRequestBodyDataStaticConfigClassificationField,
7269
} satisfies AddClassificationRequestBodyDataStaticConfigField,
7370
} satisfies AddClassificationRequestBodyDataField,
74-
} satisfies AddClassificationRequestBody,
71+
}),
7572
]);
7673
```
7774

@@ -110,10 +107,7 @@ See the endpoint docs at
110107

111108
```ts
112109
await client.classifications.updateClassification([
113-
{
114-
op: 'editEnumOption' as UpdateClassificationRequestBodyOpField,
115-
fieldKey:
116-
'Box__Security__Classification__Key' as UpdateClassificationRequestBodyFieldKeyField,
110+
new UpdateClassificationRequestBody({
117111
enumOptionKey: classification.key,
118112
data: {
119113
key: updatedClassificationName,
@@ -124,7 +118,7 @@ await client.classifications.updateClassification([
124118
} satisfies UpdateClassificationRequestBodyDataStaticConfigClassificationField,
125119
} satisfies UpdateClassificationRequestBodyDataStaticConfigField,
126120
} satisfies UpdateClassificationRequestBodyDataField,
127-
} satisfies UpdateClassificationRequestBody,
121+
}),
128122
]);
129123
```
130124

docs/fileClassifications.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ See the endpoint docs at
100100

101101
```ts
102102
await client.fileClassifications.updateClassificationOnFile(file.id, [
103-
{
104-
op: 'replace' as UpdateClassificationOnFileRequestBodyOpField,
105-
path: '/Box__Security__Classification__Key' as UpdateClassificationOnFileRequestBodyPathField,
103+
new UpdateClassificationOnFileRequestBody({
106104
value: secondClassification.key,
107-
} satisfies UpdateClassificationOnFileRequestBody,
105+
}),
108106
]);
109107
```
110108

docs/fileWatermarks.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ See the endpoint docs at
4848

4949
```ts
5050
await client.fileWatermarks.updateFileWatermark(file.id, {
51-
watermark: {
51+
watermark: new UpdateFileWatermarkRequestBodyWatermarkField({
5252
imprint: 'default' as UpdateFileWatermarkRequestBodyWatermarkImprintField,
53-
} satisfies UpdateFileWatermarkRequestBodyWatermarkField,
53+
}),
5454
} satisfies UpdateFileWatermarkRequestBody);
5555
```
5656

docs/folderClassifications.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ See the endpoint docs at
100100

101101
```ts
102102
await client.folderClassifications.updateClassificationOnFolder(folder.id, [
103-
{
104-
op: 'replace' as UpdateClassificationOnFolderRequestBodyOpField,
105-
path: '/Box__Security__Classification__Key' as UpdateClassificationOnFolderRequestBodyPathField,
103+
new UpdateClassificationOnFolderRequestBody({
106104
value: secondClassification.key,
107-
} satisfies UpdateClassificationOnFolderRequestBody,
105+
}),
108106
]);
109107
```
110108

docs/folderWatermarks.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ See the endpoint docs at
4848

4949
```ts
5050
await client.folderWatermarks.updateFolderWatermark(folder.id, {
51-
watermark: {
51+
watermark: new UpdateFolderWatermarkRequestBodyWatermarkField({
5252
imprint: 'default' as UpdateFolderWatermarkRequestBodyWatermarkImprintField,
53-
} satisfies UpdateFolderWatermarkRequestBodyWatermarkField,
53+
}),
5454
} satisfies UpdateFolderWatermarkRequestBody);
5555
```
5656

docs/integrationMappings.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,11 @@ See the endpoint docs at
5555

5656
```ts
5757
await userClient.integrationMappings.createSlackIntegrationMapping({
58-
partnerItem: {
59-
type: 'channel' as IntegrationMappingPartnerItemSlackTypeField,
58+
partnerItem: new IntegrationMappingPartnerItemSlack({
6059
id: partnerItemId,
6160
slackOrgId: slackOrgId,
62-
} satisfies IntegrationMappingPartnerItemSlack,
63-
boxItem: {
64-
id: folder.id,
65-
type: 'folder' as IntegrationMappingBoxItemSlackTypeField,
66-
} satisfies IntegrationMappingBoxItemSlack,
61+
}),
62+
boxItem: new IntegrationMappingBoxItemSlack({ id: folder.id }),
6763
} satisfies IntegrationMappingSlackCreateRequest);
6864
```
6965

docs/shieldInformationBarrierSegmentMembers.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,7 @@ await client.shieldInformationBarrierSegmentMembers.createShieldInformationBarri
126126
id: segment.id!,
127127
type: 'shield_information_barrier_segment' as CreateShieldInformationBarrierSegmentMemberRequestBodyShieldInformationBarrierSegmentTypeField,
128128
} satisfies CreateShieldInformationBarrierSegmentMemberRequestBodyShieldInformationBarrierSegmentField,
129-
user: {
130-
id: getEnvVar('USER_ID'),
131-
type: 'user' as UserBaseTypeField,
132-
} satisfies UserBase,
129+
user: new UserBase({ id: getEnvVar('USER_ID') }),
133130
} satisfies CreateShieldInformationBarrierSegmentMemberRequestBody
134131
);
135132
```

docs/shieldInformationBarrierSegmentRestrictions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ See the endpoint docs at
122122

123123
```ts
124124
await client.shieldInformationBarrierSegmentRestrictions.createShieldInformationBarrierSegmentRestriction(
125-
{
125+
new CreateShieldInformationBarrierSegmentRestrictionRequestBody({
126126
restrictedSegment: {
127127
id: segmentToRestrictId,
128128
type: 'shield_information_barrier_segment' as CreateShieldInformationBarrierSegmentRestrictionRequestBodyRestrictedSegmentTypeField,
@@ -132,7 +132,7 @@ await client.shieldInformationBarrierSegmentRestrictions.createShieldInformation
132132
type: 'shield_information_barrier_segment' as CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField,
133133
} satisfies CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentField,
134134
type: 'shield_information_barrier_segment_restriction' as CreateShieldInformationBarrierSegmentRestrictionRequestBodyTypeField,
135-
} satisfies CreateShieldInformationBarrierSegmentRestrictionRequestBody
135+
})
136136
);
137137
```
138138

docs/shieldInformationBarriers.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ See the endpoint docs at
119119

120120
```ts
121121
await client.shieldInformationBarriers.createShieldInformationBarrier({
122-
enterprise: {
123-
id: enterpriseId,
124-
type: 'enterprise' as EnterpriseBaseTypeField,
125-
} satisfies EnterpriseBase,
122+
enterprise: { id: enterpriseId } satisfies EnterpriseBase,
126123
} satisfies CreateShieldInformationBarrierRequestBody);
127124
```
128125

docs/signRequests.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,8 @@ await client.signRequests.createSignRequest({
148148
signerGroupId: 'user',
149149
} satisfies SignRequestCreateSigner,
150150
],
151-
parentFolder: {
152-
id: destinationFolder.id,
153-
type: 'folder' as FolderBaseTypeField,
154-
} satisfies FolderMini,
155-
sourceFiles: [
156-
{ id: fileToSign.id, type: 'file' as FileBaseTypeField } satisfies FileBase,
157-
],
151+
parentFolder: new FolderMini({ id: destinationFolder.id }),
152+
sourceFiles: [new FileBase({ id: fileToSign.id })],
158153
} satisfies SignRequestCreateRequest);
159154
```
160155

docs/skills.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ await client.skills.createBoxSkillCardsOnFile(file.id, {
6060
code: 'license-plates',
6161
message: titleMessage,
6262
} satisfies KeywordSkillCardSkillCardTitleField,
63-
skill: {
63+
skill: new KeywordSkillCardSkillField({
6464
id: skillId,
6565
type: 'service' as KeywordSkillCardSkillTypeField,
66-
} satisfies KeywordSkillCardSkillField,
67-
invocation: {
66+
}),
67+
invocation: new KeywordSkillCardInvocationField({
6868
id: invocationId,
6969
type: 'skill_invocation' as KeywordSkillCardInvocationTypeField,
70-
} satisfies KeywordSkillCardInvocationField,
70+
}),
7171
entries: [{ text: 'DN86 BOX' } satisfies KeywordSkillCardEntriesField],
7272
} satisfies KeywordSkillCardOrStatusSkillCardOrTimelineSkillCardOrTranscriptSkillCard,
7373
],
@@ -108,23 +108,23 @@ await client.skills.updateBoxSkillCardsOnFile(file.id, [
108108
{
109109
op: 'replace' as UpdateBoxSkillCardsOnFileRequestBodyOpField,
110110
path: '/cards/0',
111-
value: {
111+
value: new KeywordSkillCard({
112112
type: 'skill_card' as KeywordSkillCardTypeField,
113113
skillCardType: 'keyword' as KeywordSkillCardSkillCardTypeField,
114114
skillCardTitle: {
115115
code: 'license-plates',
116116
message: updatedTitleMessage,
117117
} satisfies KeywordSkillCardSkillCardTitleField,
118-
skill: {
118+
skill: new KeywordSkillCardSkillField({
119119
id: skillId,
120120
type: 'service' as KeywordSkillCardSkillTypeField,
121-
} satisfies KeywordSkillCardSkillField,
122-
invocation: {
121+
}),
122+
invocation: new KeywordSkillCardInvocationField({
123123
id: invocationId,
124124
type: 'skill_invocation' as KeywordSkillCardInvocationTypeField,
125-
} satisfies KeywordSkillCardInvocationField,
125+
}),
126126
entries: [{ text: 'DN86 BOX' } satisfies KeywordSkillCardEntriesField],
127-
} satisfies KeywordSkillCard,
127+
}),
128128
} satisfies UpdateBoxSkillCardsOnFileRequestBody,
129129
]);
130130
```

docs/storagePolicyAssignments.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ See the endpoint docs at
5454

5555
```ts
5656
await client.storagePolicyAssignments.createStoragePolicyAssignment({
57-
storagePolicy: {
58-
id: policyId,
59-
type: 'storage_policy' as CreateStoragePolicyAssignmentRequestBodyStoragePolicyTypeField,
60-
} satisfies CreateStoragePolicyAssignmentRequestBodyStoragePolicyField,
57+
storagePolicy: new CreateStoragePolicyAssignmentRequestBodyStoragePolicyField(
58+
{ id: policyId }
59+
),
6160
assignedTo: {
6261
id: userId,
6362
type: 'user' as CreateStoragePolicyAssignmentRequestBodyAssignedToTypeField,
@@ -127,10 +126,10 @@ See the endpoint docs at
127126
await client.storagePolicyAssignments.updateStoragePolicyAssignmentById(
128127
storagePolicyAssignment.id,
129128
{
130-
storagePolicy: {
131-
id: storagePolicy2.id,
132-
type: 'storage_policy' as UpdateStoragePolicyAssignmentByIdRequestBodyStoragePolicyTypeField,
133-
} satisfies UpdateStoragePolicyAssignmentByIdRequestBodyStoragePolicyField,
129+
storagePolicy:
130+
new UpdateStoragePolicyAssignmentByIdRequestBodyStoragePolicyField({
131+
id: storagePolicy2.id,
132+
}),
134133
} satisfies UpdateStoragePolicyAssignmentByIdRequestBody
135134
);
136135
```

docs/taskAssignments.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ See the endpoint docs at
5353

5454
```ts
5555
await client.taskAssignments.createTaskAssignment({
56-
task: {
56+
task: new CreateTaskAssignmentRequestBodyTaskField({
5757
type: 'task' as CreateTaskAssignmentRequestBodyTaskTypeField,
5858
id: task.id!,
59-
} satisfies CreateTaskAssignmentRequestBodyTaskField,
59+
}),
6060
assignTo: {
6161
id: currentUser.id,
6262
} satisfies CreateTaskAssignmentRequestBodyAssignToField,

docs/termsOfServiceUserStatuses.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,10 @@ See the endpoint docs at
5252

5353
```ts
5454
await client.termsOfServiceUserStatuses.createTermsOfServiceStatusForUser({
55-
tos: {
56-
type: 'terms_of_service' as CreateTermsOfServiceStatusForUserRequestBodyTosTypeField,
57-
id: tos.id,
58-
} satisfies CreateTermsOfServiceStatusForUserRequestBodyTosField,
59-
user: {
60-
type: 'user' as CreateTermsOfServiceStatusForUserRequestBodyUserTypeField,
55+
tos: new CreateTermsOfServiceStatusForUserRequestBodyTosField({ id: tos.id }),
56+
user: new CreateTermsOfServiceStatusForUserRequestBodyUserField({
6157
id: user.id,
62-
} satisfies CreateTermsOfServiceStatusForUserRequestBodyUserField,
58+
}),
6359
isAccepted: false,
6460
} satisfies CreateTermsOfServiceStatusForUserRequestBody);
6561
```

0 commit comments

Comments
 (0)