Skip to content

docs: Improve code samples in docs (box/box-codegen#661) #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "cb61d82", "specHash": "59747aa", "version": "1.12.0" }
{ "engineHash": "2c730de", "specHash": "59747aa", "version": "1.12.0" }
60 changes: 46 additions & 14 deletions docs/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@ See the endpoint docs at

```ts
await client.ai.createAiAsk({
mode: 'multiple_item_qa' as AiAskModeField,
prompt: 'Which direction sun rises?',
mode: 'single_item_qa' as AiAskModeField,
prompt: 'which direction sun rises',
items: [
{
id: fileToAsk1.id,
type: 'file' as AiItemAskTypeField,
content: 'Earth goes around the sun',
} satisfies AiItemAsk,
{
id: fileToAsk2.id,
id: fileToAsk.id,
type: 'file' as AiItemAskTypeField,
content: 'Sun rises in the East in the morning',
content: 'Sun rises in the East',
} satisfies AiItemAsk,
],
} satisfies AiAsk);
Expand Down Expand Up @@ -112,7 +107,7 @@ See the endpoint docs at

```ts
await client.ai.getAiAgentDefaultConfig({
mode: 'text_gen' as GetAiAgentDefaultConfigQueryParamsModeField,
mode: 'ask' as GetAiAgentDefaultConfigQueryParamsModeField,
language: 'en-US',
} satisfies GetAiAgentDefaultConfigQueryParams);
```
Expand Down Expand Up @@ -187,10 +182,47 @@ See the endpoint docs at

```ts
await client.ai.createAiExtractStructured({
metadataTemplate: {
templateKey: templateKey,
scope: 'enterprise',
} satisfies AiExtractStructuredMetadataTemplateField,
fields: [
{
key: 'firstName',
displayName: 'First name',
description: 'Person first name',
prompt: 'What is the your first name?',
type: 'string',
} satisfies AiExtractStructuredFieldsField,
{
key: 'lastName',
displayName: 'Last name',
description: 'Person last name',
prompt: 'What is the your last name?',
type: 'string',
} satisfies AiExtractStructuredFieldsField,
{
key: 'dateOfBirth',
displayName: 'Birth date',
description: 'Person date of birth',
prompt: 'What is the date of your birth?',
type: 'date',
} satisfies AiExtractStructuredFieldsField,
{
key: 'age',
displayName: 'Age',
description: 'Person age',
prompt: 'How old are you?',
type: 'float',
} satisfies AiExtractStructuredFieldsField,
{
key: 'hobby',
displayName: 'Hobby',
description: 'Person hobby',
prompt: 'What is your hobby?',
type: 'multiSelect',
options: [
{ key: 'guitar' } satisfies AiExtractStructuredFieldsOptionsField,
{ key: 'books' } satisfies AiExtractStructuredFieldsOptionsField,
],
} satisfies AiExtractStructuredFieldsField,
],
items: [new AiItemBase({ id: file.id })],
} satisfies AiExtractStructured);
```
Expand Down
2 changes: 1 addition & 1 deletion docs/collaborationAllowlistEntries.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ See the endpoint docs at

```ts
await client.collaborationAllowlistEntries.getCollaborationWhitelistEntryById(
entry.id!,
newEntry.id!,
);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/collaborationAllowlistExemptTargets.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ See the endpoint docs at

```ts
await client.collaborationAllowlistExemptTargets.getCollaborationWhitelistExemptTargetById(
exemptTarget.id!,
newExemptTarget.id!,
);
```

Expand Down
4 changes: 2 additions & 2 deletions docs/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ See the endpoint docs at
await client.comments.createComment({
message: message,
item: {
id: newComment.id!,
type: 'comment' as CreateCommentRequestBodyItemTypeField,
id: fileId,
type: 'file' as CreateCommentRequestBodyItemTypeField,
} satisfies CreateCommentRequestBodyItemField,
} satisfies CreateCommentRequestBody);
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docgenTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ See the endpoint docs at

```ts
await client.docgenTemplate.createDocgenTemplateV2025R0({
file: new FileReferenceV2025R0({ id: uploadedFile.id }),
file: new FileReferenceV2025R0({ id: file.id }),
} satisfies DocGenTemplateCreateRequestV2025R0);
```

Expand Down
7 changes: 1 addition & 6 deletions docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ See the endpoint docs at
<!-- sample get_events -->

```ts
await client.events.getEvents({
streamType: 'admin_logs' as GetEventsQueryParamsStreamTypeField,
limit: 1,
createdAfter: createdAfterDate,
createdBefore: createdBeforeDate,
} satisfies GetEventsQueryParams);
await client.events.getEvents();
```

### Arguments
Expand Down
16 changes: 5 additions & 11 deletions docs/fileMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,9 @@ See the endpoint docs at
```ts
await client.fileMetadata.createFileMetadataById(
file.id,
'enterprise' as CreateFileMetadataByIdScope,
templateKey,
{
['name']: 'John',
['age']: 23,
['birthDate']: '2001-01-03T02:20:50.520Z',
['countryCode']: 'US',
['sports']: ['basketball', 'tennis'],
},
'global' as CreateFileMetadataByIdScope,
'properties',
{ ['abc']: 'xyz' },
);
```

Expand Down Expand Up @@ -193,8 +187,8 @@ See the endpoint docs at
```ts
await client.fileMetadata.deleteFileMetadataById(
file.id,
'enterprise' as DeleteFileMetadataByIdScope,
templateKey,
'global' as DeleteFileMetadataByIdScope,
'properties',
);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/fileRequests.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ See the endpoint docs at
<!-- sample get_file_requests_id -->

```ts
await client.fileRequests.getFileRequestById(updatedFileRequest.id);
await client.fileRequests.getFileRequestById(fileRequestId);
```

### Arguments
Expand Down
10 changes: 0 additions & 10 deletions docs/fileVersions.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ See the endpoint docs at
await client.fileVersions.getFileVersionById(
file.id,
fileVersions.entries![0].id,
{
queryParams: {
fields: [
'trashed_at' as string,
'trashed_by' as string,
'restored_at' as string,
'restored_by' as string,
],
} satisfies GetFileVersionByIdQueryParams,
} satisfies GetFileVersionByIdOptionalsInput,
);
```

Expand Down
13 changes: 8 additions & 5 deletions docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ See the endpoint docs at
<!-- sample get_files_id -->

```ts
await client.files.getFileById(fileId, {
await client.files.getFileById(uploadedFile.id, {
queryParams: {
fields: ['is_associated_with_app_item' as string],
fields: ['is_externally_owned' as string, 'has_collaborations' as string],
} satisfies GetFileByIdQueryParams,
} satisfies GetFileByIdOptionalsInput);
```
Expand Down Expand Up @@ -56,8 +56,11 @@ See the endpoint docs at
<!-- sample put_files_id -->

```ts
await downscopedClient.files.updateFileById(file.id, {
requestBody: { name: getUuid() } satisfies UpdateFileByIdRequestBody,
await client.files.updateFileById(fileToUpdate.id, {
requestBody: {
name: updatedName,
description: 'Updated description',
} satisfies UpdateFileByIdRequestBody,
} satisfies UpdateFileByIdOptionalsInput);
```

Expand Down Expand Up @@ -94,7 +97,7 @@ See the endpoint docs at
<!-- sample delete_files_id -->

```ts
await parentClient.files.deleteFileById(file.id);
await client.files.deleteFileById(thumbnailFile.id);
```

### Arguments
Expand Down
16 changes: 5 additions & 11 deletions docs/folderMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,9 @@ See the endpoint docs at
```ts
await client.folderMetadata.createFolderMetadataById(
folder.id,
'enterprise' as CreateFolderMetadataByIdScope,
templateKey,
{
['name']: 'John',
['age']: 23,
['birthDate']: '2001-01-03T02:20:50.520Z',
['countryCode']: 'US',
['sports']: ['basketball', 'tennis'],
},
'global' as CreateFolderMetadataByIdScope,
'properties',
{ ['abc']: 'xyz' },
);
```

Expand Down Expand Up @@ -198,8 +192,8 @@ See the endpoint docs at
```ts
await client.folderMetadata.deleteFolderMetadataById(
folder.id,
'enterprise' as DeleteFolderMetadataByIdScope,
templateKey,
'global' as DeleteFolderMetadataByIdScope,
'properties',
);
```

Expand Down
19 changes: 9 additions & 10 deletions docs/folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ See the endpoint docs at
<!-- sample get_folders_id -->

```ts
await client.folders.getFolderById(folderId, {
queryParams: {
fields: ['is_associated_with_app_item' as string],
} satisfies GetFolderByIdQueryParams,
} satisfies GetFolderByIdOptionalsInput);
await client.folders.getFolderById('0');
```

### Arguments
Expand Down Expand Up @@ -71,8 +67,11 @@ See the endpoint docs at
<!-- sample put_folders_id -->

```ts
await downscopedClient.folders.updateFolderById(folder.id, {
requestBody: { name: getUuid() } satisfies UpdateFolderByIdRequestBody,
await client.folders.updateFolderById(folderToUpdate.id, {
requestBody: {
name: updatedName,
description: 'Updated description',
} satisfies UpdateFolderByIdRequestBody,
} satisfies UpdateFolderByIdOptionalsInput);
```

Expand Down Expand Up @@ -111,7 +110,7 @@ See the endpoint docs at
<!-- sample delete_folders_id -->

```ts
await parentClient.folders.deleteFolderById(folder.id);
await client.folders.deleteFolderById(newFolder.id);
```

### Arguments
Expand Down Expand Up @@ -172,8 +171,8 @@ See the endpoint docs at
<!-- sample post_folders -->

```ts
await parentClient.folders.createFolder({
name: getUuid(),
await client.folders.createFolder({
name: newFolderName,
parent: { id: '0' } satisfies CreateFolderRequestBodyParentField,
} satisfies CreateFolderRequestBody);
```
Expand Down
11 changes: 10 additions & 1 deletion docs/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@ See the endpoint docs at
<!-- sample get_groups_id -->

```ts
await client.groups.getGroupById(group.id);
await client.groups.getGroupById(group.id, {
queryParams: {
fields: [
'id' as string,
'name' as string,
'description' as string,
'group_type' as string,
],
} satisfies GetGroupByIdQueryParams,
} satisfies GetGroupByIdOptionalsInput);
```

### Arguments
Expand Down
6 changes: 2 additions & 4 deletions docs/legalHoldPolicies.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ See the endpoint docs at
await client.legalHoldPolicies.createLegalHoldPolicy({
policyName: legalHoldPolicyName,
description: legalHoldDescription,
isOngoing: false,
filterStartedAt: filterStartedAt,
filterEndedAt: filterEndedAt,
isOngoing: true,
} satisfies CreateLegalHoldPolicyRequestBody);
```

Expand Down Expand Up @@ -146,7 +144,7 @@ See the endpoint docs at
<!-- sample delete_legal_hold_policies_id -->

```ts
await client.legalHoldPolicies.deleteLegalHoldPolicyById(legalHoldPolicy.id);
await client.legalHoldPolicies.deleteLegalHoldPolicyById(legalHoldPolicyId);
```

### Arguments
Expand Down
37 changes: 2 additions & 35 deletions docs/metadataTemplates.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,42 +273,9 @@ await client.metadataTemplates.createMetadataTemplate({
templateKey: templateKey,
fields: [
{
key: 'firstName',
displayName: 'First name',
description: 'Person first name',
type: 'string' as CreateMetadataTemplateRequestBodyFieldsTypeField,
} satisfies CreateMetadataTemplateRequestBodyFieldsField,
{
key: 'lastName',
displayName: 'Last name',
description: 'Person last name',
type: 'string' as CreateMetadataTemplateRequestBodyFieldsTypeField,
} satisfies CreateMetadataTemplateRequestBodyFieldsField,
{
key: 'dateOfBirth',
displayName: 'Birth date',
description: 'Person date of birth',
type: 'date' as CreateMetadataTemplateRequestBodyFieldsTypeField,
} satisfies CreateMetadataTemplateRequestBodyFieldsField,
{
key: 'age',
displayName: 'Age',
description: 'Person age',
type: 'float' as CreateMetadataTemplateRequestBodyFieldsTypeField,
} satisfies CreateMetadataTemplateRequestBodyFieldsField,
{
key: 'hobby',
displayName: 'Hobby',
description: 'Person hobby',
type: 'multiSelect' as CreateMetadataTemplateRequestBodyFieldsTypeField,
options: [
{
key: 'guitar',
} satisfies CreateMetadataTemplateRequestBodyFieldsOptionsField,
{
key: 'books',
} satisfies CreateMetadataTemplateRequestBodyFieldsOptionsField,
],
key: 'testName',
displayName: 'testName',
} satisfies CreateMetadataTemplateRequestBodyFieldsField,
],
} satisfies CreateMetadataTemplateRequestBody);
Expand Down
Loading