Skip to content
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": "f0bd1ce", "specHash": "1698c95", "version": "0.5.3" }
{ "engineHash": "267eec8", "specHash": "1698c95", "version": "0.5.3" }
2 changes: 1 addition & 1 deletion docs/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ await client.tasks.createTask({
id: file.id,
} satisfies CreateTaskRequestBodyItemField,
message: 'test message',
dueAt: date,
dueAt: dateTime,
action: 'review' as CreateTaskRequestBodyActionField,
completionRule: 'all_assignees' as CreateTaskRequestBodyCompletionRuleField,
} satisfies CreateTaskRequestBody);
Expand Down
38 changes: 38 additions & 0 deletions src/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,44 @@ export type Iterator<T = any> = AsyncIterator<T>;
export type AgentOptions = any;
export type Agent = any;

// using wrappers for date/datetime because of inability to export built-in Date types
class DateWrapper {
constructor(public readonly value: Date) {}
}

class DateTimeWrapper {
constructor(public readonly value: Date) {}
}

export { DateWrapper as Date, DateTimeWrapper as DateTime };

export function dateFromString(value: string): DateWrapper {
return new DateWrapper(new Date(value));
}

export function dateToString(date: DateWrapper): string {
return date.value.toISOString().match(/^\d{4}-\d{2}-\d{2}/)![0];
}

export function dateTimeFromString(value: string): DateTimeWrapper {
return new DateTimeWrapper(new Date(value));
}

export function dateTimeToString(dateTime: DateTimeWrapper): string {
return (
dateTime.value
.toISOString()
.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)![0] + '+00:00'
);
}

export {
dateToString as serializeDate,
dateFromString as deserializeDate,
dateTimeToString as serializeDateTime,
dateTimeFromString as deserializeDateTime,
};

// Function to convert a hexadecimal string to base64
export function hexStrToBase64(hex: string) {
const hexString = hex.toString(); // Ensure the input is a string
Expand Down
19 changes: 15 additions & 4 deletions src/managers/events.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { serializeClientError } from '../schemas.generated.js';
import { deserializeClientError } from '../schemas.generated.js';
import { serializeRealtimeServers } from '../schemas.generated.js';
import { deserializeRealtimeServers } from '../schemas.generated.js';
import { serializeDateTime } from '../internal/utils.js';
import { deserializeDateTime } from '../internal/utils.js';
import { Events } from '../schemas.generated.js';
import { ClientError } from '../schemas.generated.js';
import { RealtimeServers } from '../schemas.generated.js';
Expand All @@ -13,6 +15,7 @@ import { prepareParams } from '../internal/utils.js';
import { toString } from '../internal/utils.js';
import { ByteStream } from '../internal/utils.js';
import { CancellationToken } from '../internal/utils.js';
import { DateTime } from '../internal/utils.js';
import { sdToJson } from '../serialization/json.js';
import { FetchOptions } from '../networking/fetch.js';
import { FetchResponse } from '../networking/fetch.js';
Expand Down Expand Up @@ -148,8 +151,8 @@ export interface GetEventsQueryParams {
readonly streamPosition?: string;
readonly limit?: number;
readonly eventType?: readonly GetEventsQueryParamsEventTypeField[];
readonly createdAfter?: string;
readonly createdBefore?: string;
readonly createdAfter?: DateTime;
readonly createdBefore?: DateTime;
}
export class GetEventsHeaders {
readonly extraHeaders?: {
Expand Down Expand Up @@ -219,8 +222,16 @@ export class EventsManager {
['event_type']: queryParams.eventType
? queryParams.eventType.map(toString).join(',')
: undefined,
['created_after']: toString(queryParams.createdAfter) as string,
['created_before']: toString(queryParams.createdBefore) as string,
['created_after']: sdToJson(
queryParams.createdAfter
? serializeDateTime(queryParams.createdAfter)
: undefined
) as string,
['created_before']: sdToJson(
queryParams.createdBefore
? serializeDateTime(queryParams.createdBefore)
: undefined
) as string,
});
const headersMap: {
readonly [key: string]: string;
Expand Down
33 changes: 21 additions & 12 deletions src/managers/files.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { serializeFileFull } from '../schemas.generated.js';
import { deserializeFileFull } from '../schemas.generated.js';
import { serializeClientError } from '../schemas.generated.js';
import { deserializeClientError } from '../schemas.generated.js';
import { serializeDateTime } from '../internal/utils.js';
import { deserializeDateTime } from '../internal/utils.js';
import { FileFull } from '../schemas.generated.js';
import { ClientError } from '../schemas.generated.js';
import { Authentication } from '../networking/auth.generated.js';
Expand All @@ -15,6 +17,7 @@ import { FetchOptions } from '../networking/fetch.js';
import { FetchResponse } from '../networking/fetch.js';
import { fetch } from '../networking/fetch.js';
import { SerializedData } from '../serialization/json.js';
import { DateTime } from '../internal/utils.js';
import { BoxSdkError } from '../box/errors.js';
import { sdIsEmpty } from '../serialization/json.js';
import { sdIsBoolean } from '../serialization/json.js';
Expand Down Expand Up @@ -64,13 +67,13 @@ export interface UpdateFileByIdRequestBodySharedLinkField {
readonly access?: UpdateFileByIdRequestBodySharedLinkAccessField;
readonly password?: string;
readonly vanityName?: string;
readonly unsharedAt?: string;
readonly unsharedAt?: DateTime;
readonly permissions?: UpdateFileByIdRequestBodySharedLinkPermissionsField;
}
export type UpdateFileByIdRequestBodyLockAccessField = 'lock';
export interface UpdateFileByIdRequestBodyLockField {
readonly access?: UpdateFileByIdRequestBodyLockAccessField;
readonly expiresAt?: string;
readonly expiresAt?: DateTime;
readonly isDownloadPrevented?: boolean;
}
export type UpdateFileByIdRequestBodyPermissionsCanDownloadField =
Expand All @@ -89,7 +92,7 @@ export interface UpdateFileByIdRequestBody {
readonly parent?: UpdateFileByIdRequestBodyParentField;
readonly sharedLink?: UpdateFileByIdRequestBodySharedLinkField;
readonly lock?: UpdateFileByIdRequestBodyLockField;
readonly dispositionAt?: string;
readonly dispositionAt?: DateTime;
readonly permissions?: UpdateFileByIdRequestBodyPermissionsField;
readonly collections?: readonly UpdateFileByIdRequestBodyCollectionsField[];
readonly tags?: readonly string[];
Expand Down Expand Up @@ -489,7 +492,8 @@ export function serializeUpdateFileByIdRequestBodySharedLinkField(
: serializeUpdateFileByIdRequestBodySharedLinkAccessField(val.access),
['password']: val.password == void 0 ? void 0 : val.password,
['vanity_name']: val.vanityName == void 0 ? void 0 : val.vanityName,
['unshared_at']: val.unsharedAt == void 0 ? void 0 : val.unsharedAt,
['unshared_at']:
val.unsharedAt == void 0 ? void 0 : serializeDateTime(val.unsharedAt),
['permissions']:
val.permissions == void 0
? void 0
Expand All @@ -509,8 +513,8 @@ export function deserializeUpdateFileByIdRequestBodySharedLinkField(
val.password == void 0 ? void 0 : val.password;
const vanityName: undefined | string =
val.vanity_name == void 0 ? void 0 : val.vanity_name;
const unsharedAt: undefined | string =
val.unshared_at == void 0 ? void 0 : val.unshared_at;
const unsharedAt: undefined | DateTime =
val.unshared_at == void 0 ? void 0 : deserializeDateTime(val.unshared_at);
const permissions:
| undefined
| UpdateFileByIdRequestBodySharedLinkPermissionsField =
Expand Down Expand Up @@ -556,7 +560,8 @@ export function serializeUpdateFileByIdRequestBodyLockField(
val.access == void 0
? void 0
: serializeUpdateFileByIdRequestBodyLockAccessField(val.access),
['expires_at']: val.expiresAt == void 0 ? void 0 : val.expiresAt,
['expires_at']:
val.expiresAt == void 0 ? void 0 : serializeDateTime(val.expiresAt),
['is_download_prevented']:
val.isDownloadPrevented == void 0 ? void 0 : val.isDownloadPrevented,
};
Expand All @@ -568,8 +573,8 @@ export function deserializeUpdateFileByIdRequestBodyLockField(
val.access == void 0
? void 0
: deserializeUpdateFileByIdRequestBodyLockAccessField(val.access);
const expiresAt: undefined | string =
val.expires_at == void 0 ? void 0 : val.expires_at;
const expiresAt: undefined | DateTime =
val.expires_at == void 0 ? void 0 : deserializeDateTime(val.expires_at);
const isDownloadPrevented: undefined | boolean =
val.is_download_prevented == void 0 ? void 0 : val.is_download_prevented;
return {
Expand Down Expand Up @@ -664,7 +669,9 @@ export function serializeUpdateFileByIdRequestBody(val: any): SerializedData {
? void 0
: serializeUpdateFileByIdRequestBodyLockField(val.lock),
['disposition_at']:
val.dispositionAt == void 0 ? void 0 : val.dispositionAt,
val.dispositionAt == void 0
? void 0
: serializeDateTime(val.dispositionAt),
['permissions']:
val.permissions == void 0
? void 0
Expand Down Expand Up @@ -703,8 +710,10 @@ export function deserializeUpdateFileByIdRequestBody(
val.lock == void 0
? void 0
: deserializeUpdateFileByIdRequestBodyLockField(val.lock);
const dispositionAt: undefined | string =
val.disposition_at == void 0 ? void 0 : val.disposition_at;
const dispositionAt: undefined | DateTime =
val.disposition_at == void 0
? void 0
: deserializeDateTime(val.disposition_at);
const permissions: undefined | UpdateFileByIdRequestBodyPermissionsField =
val.permissions == void 0
? void 0
Expand Down
12 changes: 8 additions & 4 deletions src/managers/folders.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { serializeClientError } from '../schemas.generated.js';
import { deserializeClientError } from '../schemas.generated.js';
import { serializeItems } from '../schemas.generated.js';
import { deserializeItems } from '../schemas.generated.js';
import { serializeDateTime } from '../internal/utils.js';
import { deserializeDateTime } from '../internal/utils.js';
import { FolderFull } from '../schemas.generated.js';
import { ClientError } from '../schemas.generated.js';
import { Items } from '../schemas.generated.js';
Expand All @@ -18,6 +20,7 @@ import { FetchOptions } from '../networking/fetch.js';
import { FetchResponse } from '../networking/fetch.js';
import { fetch } from '../networking/fetch.js';
import { SerializedData } from '../serialization/json.js';
import { DateTime } from '../internal/utils.js';
import { BoxSdkError } from '../box/errors.js';
import { sdIsEmpty } from '../serialization/json.js';
import { sdIsBoolean } from '../serialization/json.js';
Expand Down Expand Up @@ -75,7 +78,7 @@ export interface UpdateFolderByIdRequestBodySharedLinkField {
readonly access?: UpdateFolderByIdRequestBodySharedLinkAccessField;
readonly password?: string;
readonly vanityName?: string;
readonly unsharedAt?: string;
readonly unsharedAt?: DateTime;
readonly permissions?: UpdateFolderByIdRequestBodySharedLinkPermissionsField;
}
export type UpdateFolderByIdRequestBodyFolderUploadEmailAccessField =
Expand Down Expand Up @@ -683,7 +686,8 @@ export function serializeUpdateFolderByIdRequestBodySharedLinkField(
: serializeUpdateFolderByIdRequestBodySharedLinkAccessField(val.access),
['password']: val.password == void 0 ? void 0 : val.password,
['vanity_name']: val.vanityName == void 0 ? void 0 : val.vanityName,
['unshared_at']: val.unsharedAt == void 0 ? void 0 : val.unsharedAt,
['unshared_at']:
val.unsharedAt == void 0 ? void 0 : serializeDateTime(val.unsharedAt),
['permissions']:
val.permissions == void 0
? void 0
Expand All @@ -703,8 +707,8 @@ export function deserializeUpdateFolderByIdRequestBodySharedLinkField(
val.password == void 0 ? void 0 : val.password;
const vanityName: undefined | string =
val.vanity_name == void 0 ? void 0 : val.vanity_name;
const unsharedAt: undefined | string =
val.unshared_at == void 0 ? void 0 : val.unshared_at;
const unsharedAt: undefined | DateTime =
val.unshared_at == void 0 ? void 0 : deserializeDateTime(val.unshared_at);
const permissions:
| undefined
| UpdateFolderByIdRequestBodySharedLinkPermissionsField =
Expand Down
27 changes: 19 additions & 8 deletions src/managers/legalHoldPolicies.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { serializeClientError } from '../schemas.generated.js';
import { deserializeClientError } from '../schemas.generated.js';
import { serializeLegalHoldPolicy } from '../schemas.generated.js';
import { deserializeLegalHoldPolicy } from '../schemas.generated.js';
import { serializeDateTime } from '../internal/utils.js';
import { deserializeDateTime } from '../internal/utils.js';
import { LegalHoldPolicies } from '../schemas.generated.js';
import { ClientError } from '../schemas.generated.js';
import { LegalHoldPolicy } from '../schemas.generated.js';
Expand All @@ -18,6 +20,7 @@ import { FetchOptions } from '../networking/fetch.js';
import { FetchResponse } from '../networking/fetch.js';
import { fetch } from '../networking/fetch.js';
import { SerializedData } from '../serialization/json.js';
import { DateTime } from '../internal/utils.js';
import { sdIsEmpty } from '../serialization/json.js';
import { sdIsBoolean } from '../serialization/json.js';
import { sdIsNumber } from '../serialization/json.js';
Expand Down Expand Up @@ -52,8 +55,8 @@ export interface GetLegalHoldPoliciesHeadersInput {
export interface CreateLegalHoldPolicyRequestBody {
readonly policyName: string;
readonly description?: string;
readonly filterStartedAt?: string;
readonly filterEndedAt?: string;
readonly filterStartedAt?: DateTime;
readonly filterEndedAt?: DateTime;
readonly isOngoing?: boolean;
}
export class CreateLegalHoldPolicyHeaders {
Expand Down Expand Up @@ -331,9 +334,13 @@ export function serializeCreateLegalHoldPolicyRequestBody(
['policy_name']: val.policyName,
['description']: val.description == void 0 ? void 0 : val.description,
['filter_started_at']:
val.filterStartedAt == void 0 ? void 0 : val.filterStartedAt,
val.filterStartedAt == void 0
? void 0
: serializeDateTime(val.filterStartedAt),
['filter_ended_at']:
val.filterEndedAt == void 0 ? void 0 : val.filterEndedAt,
val.filterEndedAt == void 0
? void 0
: serializeDateTime(val.filterEndedAt),
['is_ongoing']: val.isOngoing == void 0 ? void 0 : val.isOngoing,
};
}
Expand All @@ -343,10 +350,14 @@ export function deserializeCreateLegalHoldPolicyRequestBody(
const policyName: string = val.policy_name;
const description: undefined | string =
val.description == void 0 ? void 0 : val.description;
const filterStartedAt: undefined | string =
val.filter_started_at == void 0 ? void 0 : val.filter_started_at;
const filterEndedAt: undefined | string =
val.filter_ended_at == void 0 ? void 0 : val.filter_ended_at;
const filterStartedAt: undefined | DateTime =
val.filter_started_at == void 0
? void 0
: deserializeDateTime(val.filter_started_at);
const filterEndedAt: undefined | DateTime =
val.filter_ended_at == void 0
? void 0
: deserializeDateTime(val.filter_ended_at);
const isOngoing: undefined | boolean =
val.is_ongoing == void 0 ? void 0 : val.is_ongoing;
return {
Expand Down
21 changes: 13 additions & 8 deletions src/managers/sharedLinksFiles.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { serializeFileFull } from '../schemas.generated.js';
import { deserializeFileFull } from '../schemas.generated.js';
import { serializeClientError } from '../schemas.generated.js';
import { deserializeClientError } from '../schemas.generated.js';
import { serializeDateTime } from '../internal/utils.js';
import { deserializeDateTime } from '../internal/utils.js';
import { FileFull } from '../schemas.generated.js';
import { ClientError } from '../schemas.generated.js';
import { Authentication } from '../networking/auth.generated.js';
Expand All @@ -15,6 +17,7 @@ import { FetchOptions } from '../networking/fetch.js';
import { FetchResponse } from '../networking/fetch.js';
import { fetch } from '../networking/fetch.js';
import { SerializedData } from '../serialization/json.js';
import { DateTime } from '../internal/utils.js';
import { BoxSdkError } from '../box/errors.js';
import { sdIsEmpty } from '../serialization/json.js';
import { sdIsBoolean } from '../serialization/json.js';
Expand Down Expand Up @@ -83,7 +86,7 @@ export interface AddShareLinkToFileRequestBodySharedLinkField {
readonly access?: AddShareLinkToFileRequestBodySharedLinkAccessField;
readonly password?: string;
readonly vanityName?: string;
readonly unsharedAt?: string;
readonly unsharedAt?: DateTime;
readonly permissions?: AddShareLinkToFileRequestBodySharedLinkPermissionsField;
}
export interface AddShareLinkToFileRequestBody {
Expand Down Expand Up @@ -124,7 +127,7 @@ export interface UpdateSharedLinkOnFileRequestBodySharedLinkField {
readonly access?: UpdateSharedLinkOnFileRequestBodySharedLinkAccessField;
readonly password?: string;
readonly vanityName?: string;
readonly unsharedAt?: string;
readonly unsharedAt?: DateTime;
readonly permissions?: UpdateSharedLinkOnFileRequestBodySharedLinkPermissionsField;
}
export interface UpdateSharedLinkOnFileRequestBody {
Expand Down Expand Up @@ -460,7 +463,8 @@ export function serializeAddShareLinkToFileRequestBodySharedLinkField(
),
['password']: val.password == void 0 ? void 0 : val.password,
['vanity_name']: val.vanityName == void 0 ? void 0 : val.vanityName,
['unshared_at']: val.unsharedAt == void 0 ? void 0 : val.unsharedAt,
['unshared_at']:
val.unsharedAt == void 0 ? void 0 : serializeDateTime(val.unsharedAt),
['permissions']:
val.permissions == void 0
? void 0
Expand All @@ -482,8 +486,8 @@ export function deserializeAddShareLinkToFileRequestBodySharedLinkField(
val.password == void 0 ? void 0 : val.password;
const vanityName: undefined | string =
val.vanity_name == void 0 ? void 0 : val.vanity_name;
const unsharedAt: undefined | string =
val.unshared_at == void 0 ? void 0 : val.unshared_at;
const unsharedAt: undefined | DateTime =
val.unshared_at == void 0 ? void 0 : deserializeDateTime(val.unshared_at);
const permissions:
| undefined
| AddShareLinkToFileRequestBodySharedLinkPermissionsField =
Expand Down Expand Up @@ -584,7 +588,8 @@ export function serializeUpdateSharedLinkOnFileRequestBodySharedLinkField(
),
['password']: val.password == void 0 ? void 0 : val.password,
['vanity_name']: val.vanityName == void 0 ? void 0 : val.vanityName,
['unshared_at']: val.unsharedAt == void 0 ? void 0 : val.unsharedAt,
['unshared_at']:
val.unsharedAt == void 0 ? void 0 : serializeDateTime(val.unsharedAt),
['permissions']:
val.permissions == void 0
? void 0
Expand All @@ -608,8 +613,8 @@ export function deserializeUpdateSharedLinkOnFileRequestBodySharedLinkField(
val.password == void 0 ? void 0 : val.password;
const vanityName: undefined | string =
val.vanity_name == void 0 ? void 0 : val.vanity_name;
const unsharedAt: undefined | string =
val.unshared_at == void 0 ? void 0 : val.unshared_at;
const unsharedAt: undefined | DateTime =
val.unshared_at == void 0 ? void 0 : deserializeDateTime(val.unshared_at);
const permissions:
| undefined
| UpdateSharedLinkOnFileRequestBodySharedLinkPermissionsField =
Expand Down
Loading