From 1f45bb35ab5e90b3648817880b4083b25d156742 Mon Sep 17 00:00:00 2001 From: Mathias Lykkegaard Lorenzen Date: Wed, 21 Feb 2024 04:44:32 -0800 Subject: [PATCH] feat: types for statuses and priorities (#40) --- .../default-custom-attributes.snap | 118 -- .../__snapshots__/default-ftrack-schema.snap | 1458 ----------------- .../__snapshots__/default-highway-test.snap | 112 ++ .../__snapshots__/default-object-types.snap | 162 -- source/__snapshots__/default-types.snap | 158 -- .../responses/query_priorities.json | 42 + .../responses/query_statuses.json | 134 ++ .../__snapshots__/schema-has-array-type.snap | 14 + .../__snapshots__/schema-has-base-schema.snap | 14 + .../schema-has-immutable-property.snap | 14 + .../schema-has-integer-type.snap | 14 + .../schema-has-variable-type.snap | 14 + .../schema-subtype-of-TypedContext.snap | 14 + source/emit.test.ts | 160 +- source/emit.ts | 78 +- 15 files changed, 486 insertions(+), 2020 deletions(-) delete mode 100644 source/__snapshots__/default-custom-attributes.snap delete mode 100644 source/__snapshots__/default-ftrack-schema.snap delete mode 100644 source/__snapshots__/default-object-types.snap delete mode 100644 source/__snapshots__/default-types.snap create mode 100644 source/__snapshots__/responses/query_priorities.json create mode 100644 source/__snapshots__/responses/query_statuses.json diff --git a/source/__snapshots__/default-custom-attributes.snap b/source/__snapshots__/default-custom-attributes.snap deleted file mode 100644 index c9d92e6..0000000 --- a/source/__snapshots__/default-custom-attributes.snap +++ /dev/null @@ -1,118 +0,0 @@ -// :copyright: Copyright (c) 2023 ftrack - -// Generated on 2023-02-01T00:00:00.000Z using schema -// from an instance running version 4.13.8 using server on https://ftrack.example.com -// Not intended to modify manually - -export interface TypedContext< - K extends TypedContextSubtype = TypedContextSubtype -> { - __entity_type__?: K; - __permissions?: Record; -} -export interface BasicLink { - id: string; - type: string; - name: string; -} -export interface EntityTypeMap { - TypedContext: TypedContext; -} -export type EntityType = keyof EntityTypeMap; -export type EntityData = - EntityTypeMap[TEntityType]; -export interface TypedContextSubtypeMap { - TypedContext: TypedContext; -} -export type TypedContextSubtype = keyof TypedContextSubtypeMap; -export function getAttributeConfigurations() { - return [ - { - name: "fend", - label: "Frame end", - entityType: "task", - default: 1, - objectType: "Shot", - isHierarchical: false, - }, - { - name: "handles", - label: "Frame handles", - entityType: "task", - default: 0, - objectType: "Shot", - isHierarchical: false, - }, - { - name: "duration", - label: "Frame duration", - entityType: "task", - default: "{self.fend - self.fstart + 1}", - objectType: "Shot", - isHierarchical: false, - }, - { - name: "fstart", - label: "Frame start", - entityType: "task", - default: 1, - objectType: "Shot", - isHierarchical: false, - }, - { - name: "fps", - label: "fps", - entityType: "show", - default: 24, - objectType: undefined, - isHierarchical: false, - }, - { - name: "fps", - label: "fps", - entityType: "task", - default: 25, - objectType: "Sequence", - isHierarchical: false, - }, - { - name: "fps", - label: "fps", - entityType: "task", - default: 25, - objectType: "Shot", - isHierarchical: false, - }, - ] as const; -} - -export type RuntimeCustomAttributeConfiguration = ReturnType< - typeof getAttributeConfigurations ->[number]; -export type RuntimeCustomAttributeConfigurationName = - RuntimeCustomAttributeConfiguration["name"]; -export type RuntimeCustomAttributeConfigurationLabel = - RuntimeCustomAttributeConfiguration["label"]; - -export function getTypes() { - return [] as const; -} - -export type RuntimeType = ReturnType[number]; -export type RuntimeTypeName = RuntimeType["name"]; - -export function getObjectTypes() { - return [] as const; -} - -export type RuntimeObjectType = ReturnType[number]; -export type RuntimeObjectTypeName = RuntimeObjectType["name"]; - -export function getProjectSchemas() { - return [] as const; -} - -export type RuntimeProjectSchema = ReturnType[number]; -export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; - -// Errors: diff --git a/source/__snapshots__/default-ftrack-schema.snap b/source/__snapshots__/default-ftrack-schema.snap deleted file mode 100644 index f270552..0000000 --- a/source/__snapshots__/default-ftrack-schema.snap +++ /dev/null @@ -1,1458 +0,0 @@ -// :copyright: Copyright (c) 2023 ftrack - -// Generated on 2023-02-01T00:00:00.000Z using schema -// from an instance running version 4.13.8 using server on https://ftrack.example.com -// Not intended to modify manually - -export interface Dashboard { - created_by?: User; - created_by_id?: string; - dashboard_resources?: DashboardResource[]; - readonly id: string; - is_shared_with_everyone?: boolean; - name?: string; - widgets?: DashboardWidget[]; - __entity_type__?: "Dashboard"; - __permissions?: Record; -} -export interface Timer { - comment: string; - context?: Context; - context_id?: string; - readonly id: string; - name?: string; - start: string; - user?: User; - user_id: string; - __entity_type__?: "Timer"; - __permissions?: Record; -} -export interface StatusChange { - date?: string; - from_status?: Status; - from_status_id?: string; - readonly id: string; - parent_id?: string; - parent_type?: string; - status?: Status; - status_id?: string; - user?: User; - user_id?: string; - __entity_type__?: "StatusChange"; - __permissions?: Record; -} -export interface TypedContextStatusRuleGroup - extends Omit { - object_type?: ObjectType; - object_type_id: string; - __entity_type__?: "TypedContextStatusRuleGroup"; - __permissions?: Record; -} -export interface CalendarEventResource { - calendar_event?: CalendarEvent; - calendar_event_id: string; - created_at?: string; - created_by?: User; - created_by_id?: string; - readonly id: string; - resource?: Resource; - resource_id: string; - __entity_type__?: "CalendarEventResource"; - __permissions?: Record; -} -export interface FileComponent - extends Omit { - __entity_type__?: "FileComponent"; - __permissions?: Record; -} -export interface State { - readonly id: string; - name?: string; - short?: string; - __entity_type__?: "State"; - __permissions?: Record; -} -export interface AssetType { - assets?: Asset[]; - component?: string; - readonly id: string; - name: string; - short: string; - __entity_type__?: "AssetType"; - __permissions?: Record; -} -export interface Group - extends Omit { - children?: Group[]; - custom_attribute_links?: CustomAttributeLink[]; - custom_attribute_links_from?: CustomAttributeLinkFrom[]; - readonly link?: BasicLink[]; - local: boolean; - memberships?: Membership[]; - name: string; - parent?: Group; - parent_id?: string; - __entity_type__?: "Group"; - __permissions?: Record; -} -export interface TypedContextLink { - from?: TypedContext; - from_id: string; - readonly id: string; - lag?: number; - metadata?: Metadata[]; - to?: TypedContext; - to_id: string; - type?: string; - __entity_type__?: "TypedContextLink"; - __permissions?: Record; -} -export interface CalendarEvent { - calendar_event_resources?: CalendarEventResource[]; - created_at?: string; - created_by?: User; - created_by_id?: string; - effort?: number; - end: string; - estimate?: number; - everyone?: boolean; - forecast?: boolean; - readonly id: string; - leave?: boolean; - metadata?: Metadata[]; - name: string; - project?: Project; - project_id?: string; - start: string; - type?: Type; - type_id?: string; - __entity_type__?: "CalendarEvent"; - __permissions?: Record; -} -export interface CustomAttributeLink { - configuration?: CustomAttributeLinkConfiguration; - readonly configuration_id: string; - from_entity_type?: string; - from_id: string; - readonly id: string; - to_entity_type?: string; - to_id: string; - __entity_type__?: "CustomAttributeLink"; - __permissions?: Record; -} -export interface Membership { - group?: Group; - group_id: string; - readonly id: string; - user?: User; - user_id: string; - __entity_type__?: "Membership"; - __permissions?: Record; -} -export interface DashboardWidget { - config?: string; - dashboard?: Dashboard; - dashboard_id?: string; - readonly id: string; - sort?: number; - type?: string; - __entity_type__?: "DashboardWidget"; - __permissions?: Record; -} -export interface AssetVersionStatusRuleGroup - extends Omit { - __entity_type__?: "AssetVersionStatusRuleGroup"; - __permissions?: Record; -} -export interface ReviewSessionObject { - annotations?: ReviewSessionObjectAnnotation[]; - asset_version?: AssetVersion; - created_at: string; - description: string; - readonly id: string; - name: string; - notes?: Note[]; - review_session?: ReviewSession; - review_session_id: string; - sort_order: number; - statuses?: ReviewSessionObjectStatus[]; - version: string; - version_id: string; - __entity_type__?: "ReviewSessionObject"; - __permissions?: Record; -} -export interface ProjectSchema { - asset_version_workflow_schema?: WorkflowSchema; - asset_version_workflow_schema_id?: string; - readonly id: string; - name?: string; - object_type_schemas?: Schema[]; - object_types?: ObjectType[]; - task_templates?: TaskTemplate[]; - task_type_schema?: TaskTypeSchema; - task_type_schema_id?: string; - task_workflow_schema?: WorkflowSchema; - task_workflow_schema_id?: string; - task_workflow_schema_overrides?: ProjectSchemaOverride[]; - __entity_type__?: "ProjectSchema"; - __permissions?: Record; -} -export interface Appointment { - context?: Context; - context_id: string; - readonly id: string; - resource?: Resource; - resource_id: string; - type: string; - __entity_type__?: "Appointment"; - __permissions?: Record; -} -export interface TaskTypeSchema { - readonly id: string; - name?: string; - types?: Type[]; - __entity_type__?: "TaskTypeSchema"; - __permissions?: Record; -} -export interface ReviewSessionFolder { - readonly id: string; - name: string; - project?: Project; - project_id?: string; - review_sessions?: ReviewSession[]; - __entity_type__?: "ReviewSessionFolder"; - __permissions?: Record; -} -export interface CustomAttributeLinkFrom { - configuration?: CustomAttributeLinkConfiguration; - readonly configuration_id: string; - from_entity_type?: string; - from_id: string; - readonly id: string; - to_entity_type?: string; - to_id: string; - __entity_type__?: "CustomAttributeLinkFrom"; - __permissions?: Record; -} -export interface Location { - description?: string; - readonly id: string; - label?: string; - location_components?: ComponentLocation[]; - name: string; - __entity_type__?: "Location"; - __permissions?: Record; -} -export interface CustomAttributeGroup { - custom_attribute_configurations?: CustomAttributeConfiguration[]; - readonly id: string; - name?: string; - __entity_type__?: "CustomAttributeGroup"; - __permissions?: Record; -} -export interface CustomAttributeValue { - configuration?: CustomAttributeConfiguration; - readonly configuration_id: string; - readonly entity_id: string; - value?: string | number | boolean | string[]; - __entity_type__?: "CustomAttributeValue"; - __permissions?: Record; -} -export interface UserSecurityRole { - readonly id: string; - is_all_open_projects?: boolean; - is_all_projects?: boolean; - security_role?: SecurityRole; - security_role_id?: string; - user?: User; - user_id?: string; - user_security_role_projects?: UserSecurityRoleProject[]; - __entity_type__?: "UserSecurityRole"; - __permissions?: Record; -} -export interface DashboardResource { - dashboard?: Dashboard; - readonly dashboard_id: string; - resource?: Resource; - readonly resource_id: string; - __entity_type__?: "DashboardResource"; - __permissions?: Record; -} -export interface Component { - component_locations?: ComponentLocation[]; - container?: ContainerComponent; - container_id?: string; - custom_attribute_links?: CustomAttributeLink[]; - custom_attribute_links_from?: CustomAttributeLinkFrom[]; - file_type?: string; - readonly id: string; - metadata?: Metadata[]; - name: string; - size?: number; - system_type: string; - version?: AssetVersion; - version_id?: string; - __entity_type__?: "Component"; - __permissions?: Record; -} -export interface NoteAnnotationComponent - extends Omit { - data?: object; - __entity_type__?: "NoteAnnotationComponent"; - __permissions?: Record; -} -export interface SequenceComponent - extends Omit { - padding: number; - __entity_type__?: "SequenceComponent"; - __permissions?: Record; -} -export interface Collaborator - extends Omit { - created_from_shared_url?: string; - __entity_type__?: "Collaborator"; - __permissions?: Record; -} -export interface CustomAttributeConfiguration - extends Omit { - default?: string | number | boolean | string[]; - is_hierarchical?: boolean; - type?: CustomAttributeType; - type_id?: string; - values?: CustomAttributeValue[]; - __entity_type__?: "CustomAttributeConfiguration"; - __permissions?: Record; -} -export interface Status { - color?: string; - readonly id: string; - is_active: boolean; - name?: string; - sort?: number; - state?: State; - tasks?: Task[]; - __entity_type__?: "Status"; - __permissions?: Record; -} -export interface Scope { - readonly id: string; - name: string; - __entity_type__?: "Scope"; - __permissions?: Record; -} -export interface StatusRuleGroup { - entity_type: string; - readonly id: string; - role?: SecurityRole; - role_id?: string; - schema?: ProjectSchema; - schema_id: string; - status?: Status; - status_id: string; - status_rules?: StatusRule[]; - __entity_type__?: "StatusRuleGroup"; - __permissions?: Record; -} -export interface TypedContext< - K extends TypedContextSubtype = TypedContextSubtype -> extends Omit { - ancestors?: TypedContext[]; - bid: number; - readonly bid_time_logged_difference?: number; - descendants?: TypedContext[]; - description?: string; - end_date?: string; - incoming_links?: TypedContextLink[]; - lists?: TypedContextList[]; - metadata?: Metadata[]; - object_type?: ObjectType; - object_type_id: string; - outgoing_links?: TypedContextLink[]; - priority?: Priority; - priority_id: string; - project?: Project; - sort: number; - split_parts?: SplitTaskPart[]; - start_date?: string; - status?: Status; - status_changes?: StatusChange[]; - status_id: string; - readonly thumbnail_source_id?: string; - readonly time_logged?: number; - type?: Type; - type_id: string; - __entity_type__?: K; - __permissions?: Record; -} -export interface Manager { - context?: Context; - context_id?: string; - readonly id: string; - type?: ManagerType; - type_id?: string; - user?: User; - user_id?: string; - __entity_type__?: "Manager"; - __permissions?: Record; -} -export interface CustomConfigurationBase { - config: string; - core: boolean; - entity_type?: string; - group?: CustomAttributeGroup; - group_id?: string; - readonly id: string; - key?: string; - label?: string; - object_type?: ObjectType; - object_type_id?: string; - project_id?: string; - read_security_roles?: SecurityRole[]; - sort?: number; - write_security_roles?: SecurityRole[]; - __entity_type__?: "CustomConfigurationBase"; - __permissions?: Record; -} -export interface AssetVersionLink { - from?: AssetVersion; - from_id: string; - readonly id: string; - metadata?: Metadata[]; - to?: AssetVersion; - to_id: string; - __entity_type__?: "AssetVersionLink"; - __permissions?: Record; -} -export interface ReviewSessionObjectAnnotation { - created_at: string; - data?: string; - frame_number: number; - readonly id: string; - review_session_object?: ReviewSessionObject; - review_session_object_id?: string; - updated_at?: string; - __entity_type__?: "ReviewSessionObjectAnnotation"; - __permissions?: Record; -} -export interface TypedContextList - extends Omit { - items?: Task[]; - __entity_type__?: "TypedContextList"; - __permissions?: Record; -} -export interface NoteLabelLink { - label?: NoteLabel; - readonly label_id: string; - note?: Note; - readonly note_id: string; - __entity_type__?: "NoteLabelLink"; - __permissions?: Record; -} -export interface TypedContextStatusChange - extends Omit { - parent?: TypedContext; - __entity_type__?: "TypedContextStatusChange"; - __permissions?: Record; -} -export interface CustomAttributeLinkConfiguration - extends Omit { - readonly entity_type_to: string; - readonly object_type_id_to?: string; - object_type_to?: ObjectType; - one_to_one?: boolean; - __entity_type__?: "CustomAttributeLinkConfiguration"; - __permissions?: Record; -} -export interface ContainerComponent - extends Omit { - members?: Component[]; - __entity_type__?: "ContainerComponent"; - __permissions?: Record; -} -export interface AssetVersion { - asset?: Asset; - asset_id?: string; - comment?: string; - components?: Component[]; - custom_attribute_links?: CustomAttributeLink[]; - custom_attribute_links_from?: CustomAttributeLinkFrom[]; - custom_attributes?: AssetVersionCustomAttributeValue[]; - date?: string; - readonly id: string; - incoming_links?: AssetVersionLink[]; - readonly is_latest_version?: boolean; - is_published: boolean; - readonly link?: BasicLink[]; - lists?: AssetVersionList[]; - metadata?: Metadata[]; - notes?: Note[]; - outgoing_links?: AssetVersionLink[]; - project_id?: string; - review_session_objects?: ReviewSessionObject[]; - status?: Status; - status_changes?: StatusChange[]; - status_id: string; - task?: Task; - task_id?: string; - thumbnail?: Component; - thumbnail_id?: string; - readonly thumbnail_url?: object; - used_in_versions?: AssetVersion[]; - user?: User; - user_id?: string; - uses_versions?: AssetVersion[]; - version?: number; - __entity_type__?: "AssetVersion"; - __permissions?: Record; -} -export interface SecurityRole { - readonly id: string; - name?: string; - type?: string; - user_security_roles?: UserSecurityRole[]; - __entity_type__?: "SecurityRole"; - __permissions?: Record; -} -export interface UserApplicationState { - readonly key: string; - readonly user_id: string; - value: string; - __entity_type__?: "UserApplicationState"; - __permissions?: Record; -} -export interface ReviewSessionInvitee { - created_at: string; - created_by?: User; - created_by_id: string; - readonly created_from_shared_url?: boolean; - email: string; - readonly id: string; - last_sent_at?: string; - name: string; - resource?: Resource; - resource_id?: string; - review_session?: ReviewSession; - review_session_id: string; - statuses?: ReviewSessionObjectStatus[]; - __entity_type__?: "ReviewSessionInvitee"; - __permissions?: Record; -} -export interface Note { - author?: BaseUser; - category?: NoteCategory; - category_id?: string; - completed_at?: string; - completed_by?: User; - completed_by_id?: string; - content?: string; - date?: string; - frame_number?: number; - readonly id: string; - in_reply_to?: Note; - in_reply_to_id?: string; - is_todo?: boolean; - metadata?: Metadata[]; - note_components?: NoteComponent[]; - note_label_links?: NoteLabelLink[]; - parent_id?: string; - parent_type?: string; - project?: Project; - project_id?: string; - recipients?: Recipient[]; - replies?: Note[]; - thread_activity?: string; - user_id: string; - __entity_type__?: "Note"; - __permissions?: Record; -} -export interface Event { - action?: string; - created_at?: string; - data?: string; - feeds?: Feed[]; - readonly id: number; - insert?: string; - parent_id?: string; - parent_type?: string; - project?: Project; - project_id?: string; - user?: User; - user_id?: string; - __entity_type__?: "Event"; - __permissions?: Record; -} -export interface ListObject { - custom_attributes?: ListObjectCustomAttributeValue[]; - entity_id: string; - readonly id: string; - list?: List; - list_id: string; - __entity_type__?: "ListObject"; - __permissions?: Record; -} -export interface AssetVersionList - extends Omit { - items?: AssetVersion[]; - __entity_type__?: "AssetVersionList"; - __permissions?: Record; -} -export interface UserSession { - accessed_time?: string; - creation_time?: string; - readonly id: string; - user?: User; - user_id?: string; - __entity_type__?: "UserSession"; - __permissions?: Record; -} -export interface EntitySetting { - readonly group: string; - readonly name: string; - readonly parent_id: string; - parent_type: string; - value: string; - __entity_type__?: "EntitySetting"; - __permissions?: Record; -} -export interface Disk { - readonly id: string; - name: string; - projects?: Project[]; - unix?: string; - windows?: string; - __entity_type__?: "Disk"; - __permissions?: Record; -} -export interface Job { - created_at?: string; - data?: string; - finished_at?: string; - readonly id: string; - job_components?: JobComponent[]; - status: string; - readonly type: string; - user?: User; - user_id?: string; - __entity_type__?: "Job"; - __permissions?: Record; -} -export interface TaskTemplateItem { - readonly id: string; - task_type?: Type; - task_type_id: string; - template?: TaskTemplate; - template_id: string; - __entity_type__?: "TaskTemplateItem"; - __permissions?: Record; -} -export interface ProjectSchemaOverride { - readonly id: string; - project_schema_id?: string; - type_id?: string; - workflow_schema?: WorkflowSchema; - workflow_schema_id?: string; - __entity_type__?: "ProjectSchemaOverride"; - __permissions?: Record; -} -export interface User - extends Omit { - custom_attribute_links?: CustomAttributeLink[]; - custom_attribute_links_from?: CustomAttributeLinkFrom[]; - custom_attributes?: UserCustomAttributeValue[]; - is_active: boolean; - is_otp_enabled?: boolean; - is_totp_enabled?: boolean; - memberships?: Membership[]; - metadata?: Metadata[]; - require_details_update?: boolean; - timelogs?: Timelog[]; - user_security_roles?: UserSecurityRole[]; - user_type?: UserType; - user_type_id?: string; - username: string; - __entity_type__?: "User"; - __permissions?: Record; -} -export interface Feed { - cluster_id?: string; - created_at?: string; - distance?: number; - event?: Event; - readonly id: string; - owner_id?: string; - relation?: string; - social_id?: number; - __entity_type__?: "Feed"; - __permissions?: Record; -} -export interface BaseUser - extends Omit { - email?: string; - first_name?: string; - last_name?: string; - thumbnail?: Component; - thumbnail_id?: string; - readonly thumbnail_url?: object; - __entity_type__?: "BaseUser"; - __permissions?: Record; -} -export interface ReviewSession { - availability?: string; - created_at: string; - created_by?: User; - created_by_id: string; - description: string; - end_date: string; - readonly id: string; - is_moderated?: boolean; - readonly is_open?: boolean; - name: string; - passphrase?: string; - passphrase_enabled?: boolean; - project?: Project; - project_id: string; - review_session_folder?: ReviewSessionFolder; - review_session_folder_id?: string; - review_session_invitees?: ReviewSessionInvitee[]; - review_session_objects?: ReviewSessionObject[]; - settings?: EntitySetting[]; - shareable_url_enabled?: boolean; - start_date: string; - readonly thumbnail_id?: string; - thumbnail_source_id?: string; - readonly thumbnail_url?: object; - __entity_type__?: "ReviewSession"; - __permissions?: Record; -} -export interface UserView { - global?: boolean; - readonly id: string; - name?: string; - shared_with?: Resource[]; - user?: User; - user_id?: string; - __entity_type__?: "UserView"; - __permissions?: Record; -} -export interface Metadata { - readonly key: string; - readonly parent_id: string; - parent_type: string; - value: string; - __entity_type__?: "Metadata"; - __permissions?: Record; -} -export interface NoteCategory - extends Omit { - __entity_type__?: "NoteCategory"; - __permissions?: Record; -} -export interface Type { - color: string; - readonly id: string; - is_billable: boolean; - name?: string; - sort: number; - task_type_schemas?: TaskTypeSchema[]; - tasks?: Task[]; - __entity_type__?: "Type"; - __permissions?: Record; -} -export interface UserType { - readonly id: string; - readonly name?: string; - __entity_type__?: "UserType"; - __permissions?: Record; -} -export interface JobComponent { - component?: Component; - readonly component_id: string; - job?: Job; - readonly job_id: string; - readonly url?: object; - __entity_type__?: "JobComponent"; - __permissions?: Record; -} -export interface ListCategory { - readonly id: string; - lists?: List[]; - name?: string; - __entity_type__?: "ListCategory"; - __permissions?: Record; -} -export interface WorkflowSchema { - readonly id: string; - name?: string; - overrides?: ProjectSchemaOverride[]; - statuses?: Status[]; - __entity_type__?: "WorkflowSchema"; - __permissions?: Record; -} -export interface ReviewSessionObjectStatus { - created_at: string; - readonly id: string; - invitee?: ReviewSessionInvitee; - resource?: Resource; - resource_id?: string; - review_session_invitee_id?: string; - review_session_object?: ReviewSessionObject; - review_session_object_id?: string; - status?: string; - __entity_type__?: "ReviewSessionObjectStatus"; - __permissions?: Record; -} -export interface Context { - allocations?: Appointment[]; - appointments?: Appointment[]; - assets?: Asset[]; - assignments?: Appointment[]; - children?: Context[]; - context_type: string; - readonly created_at?: string; - readonly created_by?: User; - readonly created_by_id?: string; - custom_attribute_links?: CustomAttributeLink[]; - custom_attribute_links_from?: CustomAttributeLinkFrom[]; - custom_attributes?: ContextCustomAttributeValue[]; - readonly id: string; - readonly link?: BasicLink[]; - managers?: Manager[]; - name: string; - notes?: Note[]; - parent?: Context; - parent_id?: string; - project_id?: string; - scopes?: Scope[]; - thumbnail?: Component; - thumbnail_id?: string; - readonly thumbnail_url?: object; - timelogs?: Timelog[]; - __entity_type__?: "Context"; - __permissions?: Record; -} -export interface Schema { - readonly id: string; - object_type_id?: string; - project_schema_id: string; - statuses?: SchemaStatus[]; - type_id: string; - types?: SchemaType[]; - __entity_type__?: "Schema"; - __permissions?: Record; -} -export interface WorkflowSchemaStatus { - readonly status_id: string; - readonly workflow_schema_id: string; - __entity_type__?: "WorkflowSchemaStatus"; - __permissions?: Record; -} -export interface SchemaType { - readonly schema_id: string; - sort?: number; - task_type?: Type; - readonly type_id: string; - __entity_type__?: "SchemaType"; - __permissions?: Record; -} -export interface Asset { - ancestors?: TypedContext[]; - context_id?: string; - custom_attribute_links?: CustomAttributeLink[]; - custom_attribute_links_from?: CustomAttributeLinkFrom[]; - custom_attributes?: AssetCustomAttributeValue[]; - readonly id: string; - readonly latest_version?: AssetVersion; - metadata?: Metadata[]; - name?: string; - parent?: Context; - project_id?: string; - type?: AssetType; - type_id?: string; - versions?: AssetVersion[]; - __entity_type__?: "Asset"; - __permissions?: Record; -} -export interface SettingComponent { - component?: Component; - readonly component_id: string; - readonly group: string; - readonly name: string; - setting?: Setting; - readonly thumbnail_url?: object; - readonly url?: object; - __entity_type__?: "SettingComponent"; - __permissions?: Record; -} -export interface StatusRule { - readonly id: string; - status?: Status; - status_id: string; - status_rule_group?: StatusRuleGroup; - status_rule_group_id: string; - __entity_type__?: "StatusRule"; - __permissions?: Record; -} -export interface ComponentLocation { - component?: Component; - component_id?: string; - readonly id: string; - location?: Location; - location_id?: string; - resource_identifier?: string; - readonly url?: object; - __entity_type__?: "ComponentLocation"; - __permissions?: Record; -} -export interface ReviewSessionObjectAnnotationComponent { - component?: Component; - readonly component_id: string; - readonly frame_number: string; - review_session_object?: ReviewSessionObject; - readonly review_session_object_id: string; - readonly thumbnail_url?: object; - readonly url?: object; - __entity_type__?: "ReviewSessionObjectAnnotationComponent"; - __permissions?: Record; -} -export interface CustomAttributeType { - core: boolean; - custom_attribute_configurations?: CustomAttributeConfiguration[]; - form_config?: string; - readonly id: string; - name?: string; - __entity_type__?: "CustomAttributeType"; - __permissions?: Record; -} -export interface Timelog { - comment: string; - context?: Context; - context_id?: string; - duration: number; - readonly id: string; - name?: string; - start: string; - time_zone_offset?: number; - user?: User; - user_id?: string; - __entity_type__?: "Timelog"; - __permissions?: Record; -} -export interface SchemaStatus { - readonly schema_id: string; - sort?: number; - readonly status_id: string; - task_status?: Status; - __entity_type__?: "SchemaStatus"; - __permissions?: Record; -} -export interface UserSecurityRoleProject { - readonly id: string; - project?: Project; - project_id?: string; - user_security_role?: UserSecurityRole; - user_security_role_id?: string; - __entity_type__?: "UserSecurityRoleProject"; - __permissions?: Record; -} -export interface ObjectType { - icon: string; - readonly id: string; - is_leaf?: boolean; - is_prioritizable?: boolean; - is_schedulable: boolean; - is_statusable: boolean; - is_taskable: boolean; - is_time_reportable: boolean; - is_typeable: boolean; - name: string; - project_schemas?: ProjectSchema[]; - sort: number; - tasks?: Task[]; - __entity_type__?: "ObjectType"; - __permissions?: Record; -} -export interface Project - extends Omit { - calendar_events?: CalendarEvent[]; - color?: string; - descendants?: TypedContext[]; - disk?: Disk; - disk_id?: string; - end_date?: string; - full_name?: string; - is_global: boolean; - is_private?: boolean; - metadata?: Metadata[]; - project_schema?: ProjectSchema; - project_schema_id: string; - review_session_folders?: ReviewSessionFolder[]; - review_sessions?: ReviewSession[]; - root?: string; - start_date?: string; - status: string; - user_security_role_projects?: UserSecurityRoleProject[]; - __entity_type__?: "Project"; - __permissions?: Record; -} -export interface TaskTemplate { - readonly id: string; - items?: TaskTemplateItem[]; - name: string; - project_schema?: ProjectSchema; - project_schema_id: string; - __entity_type__?: "TaskTemplate"; - __permissions?: Record; -} -export interface AssetVersionStatusChange - extends Omit { - parent?: AssetVersion; - __entity_type__?: "AssetVersionStatusChange"; - __permissions?: Record; -} -export interface Setting { - readonly group: string; - readonly name: string; - value?: string; - __entity_type__?: "Setting"; - __permissions?: Record; -} -export interface ApiKey { - readonly id: string; - identifier?: string; - prefix?: string; - resource_id?: string; - __entity_type__?: "ApiKey"; - __permissions?: Record; -} -export interface NoteLabel { - color?: string; - readonly id: string; - name?: string; - sort?: number; - __entity_type__?: "NoteLabel"; - __permissions?: Record; -} -export interface ManagerType { - readonly id: string; - name?: string; - __entity_type__?: "ManagerType"; - __permissions?: Record; -} -export interface Recipient { - note?: Note; - readonly note_id: string; - recipient?: Resource; - readonly resource_id: string; - text_mentioned?: string; - user?: User; - __entity_type__?: "Recipient"; - __permissions?: Record; -} -export interface NoteComponent { - component?: Component; - readonly component_id: string; - note?: Note; - readonly note_id: string; - readonly thumbnail_url?: object; - readonly url?: object; - __entity_type__?: "NoteComponent"; - __permissions?: Record; -} -export interface ProjectSchemaObjectType { - object_type?: ObjectType; - readonly object_type_id: string; - project_schema?: ProjectSchema; - readonly project_schema_id: string; - __entity_type__?: "ProjectSchemaObjectType"; - __permissions?: Record; -} -export interface List { - category?: ListCategory; - category_id: string; - custom_attribute_links?: CustomAttributeLink[]; - custom_attribute_links_from?: CustomAttributeLinkFrom[]; - custom_attributes?: ListCustomAttributeValue[]; - date?: string; - readonly id: string; - is_open: boolean; - name?: string; - owner?: User; - project?: Project; - project_id: string; - system_type?: string; - user_id?: string; - __entity_type__?: "List"; - __permissions?: Record; -} -export interface SplitTaskPart { - end_date: string; - readonly id: string; - label?: string; - start_date: string; - task?: Task; - task_id: string; - __entity_type__?: "SplitTaskPart"; - __permissions?: Record; -} -export interface Resource { - allocations?: Appointment[]; - appointments?: Appointment[]; - assignments?: Appointment[]; - dashboard_resources?: DashboardResource[]; - readonly id: string; - resource_type: string; - __entity_type__?: "Resource"; - __permissions?: Record; -} -export interface TaskTypeSchemaType { - readonly task_type_schema_id: string; - readonly type_id: string; - __entity_type__?: "TaskTypeSchemaType"; - __permissions?: Record; -} -export interface Priority { - color?: string; - readonly id: string; - name?: string; - sort?: number; - tasks?: Task[]; - value?: number; - __entity_type__?: "Priority"; - __permissions?: Record; -} -export type Milestone = TypedContext<"Milestone">; -export type Task = TypedContext<"Task">; -export type Episode = TypedContext<"Episode">; -export type Scene = TypedContext<"Scene">; -export type Folder = TypedContext<"Folder">; -export type Image = TypedContext<"Image">; -export type AssetBuild = TypedContext<"AssetBuild">; -export type Shot = TypedContext<"Shot">; -export type Sequence = TypedContext<"Sequence">; -export type Information = TypedContext<"Information">; -export interface ContextCustomAttributeValue { - configuration?: CustomAttributeConfiguration; - readonly configuration_id: string; - readonly entity_id: string; - key?: string; - value?: string | number | boolean | string[]; - __entity_type__?: "ContextCustomAttributeValue"; - __permissions?: Record; -} -export interface AssetVersionCustomAttributeValue { - configuration?: CustomAttributeConfiguration; - readonly configuration_id: string; - readonly entity_id: string; - key?: string; - value?: string | number | boolean | string[]; - __entity_type__?: "AssetVersionCustomAttributeValue"; - __permissions?: Record; -} -export interface ListCustomAttributeValue { - configuration?: CustomAttributeConfiguration; - readonly configuration_id: string; - readonly entity_id: string; - key?: string; - value?: string | number | boolean | string[]; - __entity_type__?: "ListCustomAttributeValue"; - __permissions?: Record; -} -export interface ListObjectCustomAttributeValue { - configuration?: CustomAttributeConfiguration; - readonly configuration_id: string; - readonly entity_id: string; - key?: string; - value?: string | number | boolean | string[]; - __entity_type__?: "ListObjectCustomAttributeValue"; - __permissions?: Record; -} -export interface UserCustomAttributeValue { - configuration?: CustomAttributeConfiguration; - readonly configuration_id: string; - readonly entity_id: string; - key?: string; - value?: string | number | boolean | string[]; - __entity_type__?: "UserCustomAttributeValue"; - __permissions?: Record; -} -export interface AssetCustomAttributeValue { - configuration?: CustomAttributeConfiguration; - readonly configuration_id: string; - readonly entity_id: string; - key?: string; - value?: string | number | boolean | string[]; - __entity_type__?: "AssetCustomAttributeValue"; - __permissions?: Record; -} -export interface ContextCustomAttributeLink - extends Omit { - context?: Context; - __entity_type__?: "ContextCustomAttributeLink"; - __permissions?: Record; -} -export interface ContextCustomAttributeLinkFrom - extends Omit { - context?: Context; - __entity_type__?: "ContextCustomAttributeLinkFrom"; - __permissions?: Record; -} -export interface AssetVersionCustomAttributeLink - extends Omit { - asset_version?: AssetVersion; - __entity_type__?: "AssetVersionCustomAttributeLink"; - __permissions?: Record; -} -export interface AssetVersionCustomAttributeLinkFrom - extends Omit { - asset_version?: AssetVersion; - __entity_type__?: "AssetVersionCustomAttributeLinkFrom"; - __permissions?: Record; -} -export interface ListCustomAttributeLink - extends Omit { - list?: List; - __entity_type__?: "ListCustomAttributeLink"; - __permissions?: Record; -} -export interface ListCustomAttributeLinkFrom - extends Omit { - list?: List; - __entity_type__?: "ListCustomAttributeLinkFrom"; - __permissions?: Record; -} -export interface UserCustomAttributeLink - extends Omit { - user?: User; - __entity_type__?: "UserCustomAttributeLink"; - __permissions?: Record; -} -export interface UserCustomAttributeLinkFrom - extends Omit { - user?: User; - __entity_type__?: "UserCustomAttributeLinkFrom"; - __permissions?: Record; -} -export interface GroupCustomAttributeLink - extends Omit { - group?: Group; - __entity_type__?: "GroupCustomAttributeLink"; - __permissions?: Record; -} -export interface GroupCustomAttributeLinkFrom - extends Omit { - group?: Group; - __entity_type__?: "GroupCustomAttributeLinkFrom"; - __permissions?: Record; -} -export interface AssetCustomAttributeLink - extends Omit { - asset?: Asset; - __entity_type__?: "AssetCustomAttributeLink"; - __permissions?: Record; -} -export interface AssetCustomAttributeLinkFrom - extends Omit { - asset?: Asset; - __entity_type__?: "AssetCustomAttributeLinkFrom"; - __permissions?: Record; -} -export interface ComponentCustomAttributeLink - extends Omit { - component?: Component; - __entity_type__?: "ComponentCustomAttributeLink"; - __permissions?: Record; -} -export interface ComponentCustomAttributeLinkFrom - extends Omit { - component?: Component; - __entity_type__?: "ComponentCustomAttributeLinkFrom"; - __permissions?: Record; -} -export interface BasicLink { - id: string; - type: string; - name: string; -} -export interface EntityTypeMap { - Dashboard: Dashboard; - Timer: Timer; - StatusChange: StatusChange; - TypedContextStatusRuleGroup: TypedContextStatusRuleGroup; - CalendarEventResource: CalendarEventResource; - FileComponent: FileComponent; - State: State; - AssetType: AssetType; - Group: Group; - TypedContextLink: TypedContextLink; - CalendarEvent: CalendarEvent; - CustomAttributeLink: CustomAttributeLink; - Membership: Membership; - DashboardWidget: DashboardWidget; - AssetVersionStatusRuleGroup: AssetVersionStatusRuleGroup; - ReviewSessionObject: ReviewSessionObject; - ProjectSchema: ProjectSchema; - Appointment: Appointment; - TaskTypeSchema: TaskTypeSchema; - ReviewSessionFolder: ReviewSessionFolder; - CustomAttributeLinkFrom: CustomAttributeLinkFrom; - Location: Location; - CustomAttributeGroup: CustomAttributeGroup; - CustomAttributeValue: CustomAttributeValue; - UserSecurityRole: UserSecurityRole; - DashboardResource: DashboardResource; - Component: Component; - NoteAnnotationComponent: NoteAnnotationComponent; - SequenceComponent: SequenceComponent; - Collaborator: Collaborator; - CustomAttributeConfiguration: CustomAttributeConfiguration; - Status: Status; - Scope: Scope; - StatusRuleGroup: StatusRuleGroup; - TypedContext: TypedContext; - Manager: Manager; - CustomConfigurationBase: CustomConfigurationBase; - AssetVersionLink: AssetVersionLink; - ReviewSessionObjectAnnotation: ReviewSessionObjectAnnotation; - TypedContextList: TypedContextList; - NoteLabelLink: NoteLabelLink; - TypedContextStatusChange: TypedContextStatusChange; - CustomAttributeLinkConfiguration: CustomAttributeLinkConfiguration; - ContainerComponent: ContainerComponent; - AssetVersion: AssetVersion; - SecurityRole: SecurityRole; - UserApplicationState: UserApplicationState; - ReviewSessionInvitee: ReviewSessionInvitee; - Note: Note; - Event: Event; - ListObject: ListObject; - AssetVersionList: AssetVersionList; - UserSession: UserSession; - EntitySetting: EntitySetting; - Disk: Disk; - Job: Job; - TaskTemplateItem: TaskTemplateItem; - ProjectSchemaOverride: ProjectSchemaOverride; - User: User; - Feed: Feed; - BaseUser: BaseUser; - ReviewSession: ReviewSession; - UserView: UserView; - Metadata: Metadata; - NoteCategory: NoteCategory; - Type: Type; - UserType: UserType; - JobComponent: JobComponent; - ListCategory: ListCategory; - WorkflowSchema: WorkflowSchema; - ReviewSessionObjectStatus: ReviewSessionObjectStatus; - Context: Context; - Schema: Schema; - WorkflowSchemaStatus: WorkflowSchemaStatus; - SchemaType: SchemaType; - Asset: Asset; - SettingComponent: SettingComponent; - StatusRule: StatusRule; - ComponentLocation: ComponentLocation; - ReviewSessionObjectAnnotationComponent: ReviewSessionObjectAnnotationComponent; - CustomAttributeType: CustomAttributeType; - Timelog: Timelog; - SchemaStatus: SchemaStatus; - UserSecurityRoleProject: UserSecurityRoleProject; - ObjectType: ObjectType; - Project: Project; - TaskTemplate: TaskTemplate; - AssetVersionStatusChange: AssetVersionStatusChange; - Setting: Setting; - ApiKey: ApiKey; - NoteLabel: NoteLabel; - ManagerType: ManagerType; - Recipient: Recipient; - NoteComponent: NoteComponent; - ProjectSchemaObjectType: ProjectSchemaObjectType; - List: List; - SplitTaskPart: SplitTaskPart; - Resource: Resource; - TaskTypeSchemaType: TaskTypeSchemaType; - Priority: Priority; - Milestone: Milestone; - Task: Task; - Episode: Episode; - Scene: Scene; - Folder: Folder; - Image: Image; - AssetBuild: AssetBuild; - Shot: Shot; - Sequence: Sequence; - Information: Information; - ContextCustomAttributeValue: ContextCustomAttributeValue; - AssetVersionCustomAttributeValue: AssetVersionCustomAttributeValue; - ListCustomAttributeValue: ListCustomAttributeValue; - ListObjectCustomAttributeValue: ListObjectCustomAttributeValue; - UserCustomAttributeValue: UserCustomAttributeValue; - AssetCustomAttributeValue: AssetCustomAttributeValue; - ContextCustomAttributeLink: ContextCustomAttributeLink; - ContextCustomAttributeLinkFrom: ContextCustomAttributeLinkFrom; - AssetVersionCustomAttributeLink: AssetVersionCustomAttributeLink; - AssetVersionCustomAttributeLinkFrom: AssetVersionCustomAttributeLinkFrom; - ListCustomAttributeLink: ListCustomAttributeLink; - ListCustomAttributeLinkFrom: ListCustomAttributeLinkFrom; - UserCustomAttributeLink: UserCustomAttributeLink; - UserCustomAttributeLinkFrom: UserCustomAttributeLinkFrom; - GroupCustomAttributeLink: GroupCustomAttributeLink; - GroupCustomAttributeLinkFrom: GroupCustomAttributeLinkFrom; - AssetCustomAttributeLink: AssetCustomAttributeLink; - AssetCustomAttributeLinkFrom: AssetCustomAttributeLinkFrom; - ComponentCustomAttributeLink: ComponentCustomAttributeLink; - ComponentCustomAttributeLinkFrom: ComponentCustomAttributeLinkFrom; -} -export type EntityType = keyof EntityTypeMap; -export type EntityData = - EntityTypeMap[TEntityType]; -export interface TypedContextSubtypeMap { - TypedContext: TypedContext; - Milestone: Milestone; - Task: Task; - Episode: Episode; - Scene: Scene; - Folder: Folder; - Image: Image; - AssetBuild: AssetBuild; - Shot: Shot; - Sequence: Sequence; - Information: Information; -} -export type TypedContextSubtype = keyof TypedContextSubtypeMap; -export function getAttributeConfigurations() { - return [] as const; -} - -export type RuntimeCustomAttributeConfiguration = ReturnType< - typeof getAttributeConfigurations ->[number]; -export type RuntimeCustomAttributeConfigurationName = - RuntimeCustomAttributeConfiguration["name"]; -export type RuntimeCustomAttributeConfigurationLabel = - RuntimeCustomAttributeConfiguration["label"]; - -export function getTypes() { - return [] as const; -} - -export type RuntimeType = ReturnType[number]; -export type RuntimeTypeName = RuntimeType["name"]; - -export function getObjectTypes() { - return [] as const; -} - -export type RuntimeObjectType = ReturnType[number]; -export type RuntimeObjectTypeName = RuntimeObjectType["name"]; - -export function getProjectSchemas() { - return [] as const; -} - -export type RuntimeProjectSchema = ReturnType[number]; -export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; - -// Errors: diff --git a/source/__snapshots__/default-highway-test.snap b/source/__snapshots__/default-highway-test.snap index 8b12a51..7ea2617 100644 --- a/source/__snapshots__/default-highway-test.snap +++ b/source/__snapshots__/default-highway-test.snap @@ -1752,4 +1752,116 @@ export function getProjectSchemas() { export type RuntimeProjectSchema = ReturnType[number]; export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; +export function getPriorities() { + return [ + { + name: "Urgent", + color: "#E74C3C", + value: 0, + sort: 0, + }, + { + name: "High", + color: "#E67E22", + value: 0, + sort: 1, + }, + { + name: "Medium", + color: "#F1C40F", + value: 0, + sort: 2, + }, + { + name: "Low", + color: "#1CBC90", + value: 0, + sort: 3, + }, + { + name: "None", + color: "#CACACA", + value: 0, + sort: 4, + }, + ] as const; +} + +export type RuntimePriority = ReturnType[number]; +export type RuntimePriorityName = RuntimePriority["name"]; + +export function getStatuses() { + return [ + { + name: "Completed", + color: "#1cbc90", + isActive: true, + sort: 0, + }, + { + name: "Omitted", + color: "#E74C3C", + isActive: true, + sort: 1, + }, + { + name: "On Hold", + color: "#E74C3C", + isActive: true, + sort: 2, + }, + { + name: "Revise", + color: "#FF6600", + isActive: true, + sort: 3, + }, + { + name: "Client approved", + color: "#1CBC90", + isActive: true, + sort: 4, + }, + { + name: "Approved", + color: "#1cbc90", + isActive: true, + sort: 5, + }, + { + name: "Pending Review", + color: "#F1C40F", + isActive: true, + sort: 6, + }, + { + name: "In progress", + color: "#3498DB", + isActive: true, + sort: 7, + }, + { + name: "WIP", + color: "#CC99FF", + isActive: true, + sort: 8, + }, + { + name: "Ready to start", + color: "#00FFFF", + isActive: true, + sort: 9, + }, + { + name: "Not started", + color: "#CACACA", + isActive: true, + sort: 10, + }, + ] as const; +} + +export type RuntimeStatus = ReturnType[number]; +export type RuntimeStatusName = RuntimeStatus["name"]; + // Errors: diff --git a/source/__snapshots__/default-object-types.snap b/source/__snapshots__/default-object-types.snap deleted file mode 100644 index cb8130b..0000000 --- a/source/__snapshots__/default-object-types.snap +++ /dev/null @@ -1,162 +0,0 @@ -// :copyright: Copyright (c) 2023 ftrack - -// Generated on 2023-02-01T00:00:00.000Z using schema -// from an instance running version 4.13.8 using server on https://ftrack.example.com -// Not intended to modify manually - -export interface TypedContext< - K extends TypedContextSubtype = TypedContextSubtype -> { - __entity_type__?: K; - __permissions?: Record; -} -export interface BasicLink { - id: string; - type: string; - name: string; -} -export interface EntityTypeMap { - TypedContext: TypedContext; -} -export type EntityType = keyof EntityTypeMap; -export type EntityData = - EntityTypeMap[TEntityType]; -export interface TypedContextSubtypeMap { - TypedContext: TypedContext; -} -export type TypedContextSubtype = keyof TypedContextSubtypeMap; -export function getAttributeConfigurations() { - return [] as const; -} - -export type RuntimeCustomAttributeConfiguration = ReturnType< - typeof getAttributeConfigurations ->[number]; -export type RuntimeCustomAttributeConfigurationName = - RuntimeCustomAttributeConfiguration["name"]; -export type RuntimeCustomAttributeConfigurationLabel = - RuntimeCustomAttributeConfiguration["label"]; - -export function getTypes() { - return [] as const; -} - -export type RuntimeType = ReturnType[number]; -export type RuntimeTypeName = RuntimeType["name"]; - -export function getObjectTypes() { - return [ - { - name: "Folder", - isTimeReportable: false, - isTaskable: true, - isTypeable: false, - isStatusable: false, - isSchedulable: false, - isPrioritizable: true, - isLeaf: false, - }, - { - name: "Asset Build", - isTimeReportable: false, - isTaskable: true, - isTypeable: true, - isStatusable: true, - isSchedulable: false, - isPrioritizable: true, - isLeaf: false, - }, - { - name: "Episode", - isTimeReportable: false, - isTaskable: true, - isTypeable: false, - isStatusable: true, - isSchedulable: false, - isPrioritizable: true, - isLeaf: false, - }, - { - name: "Scene", - isTimeReportable: false, - isTaskable: true, - isTypeable: false, - isStatusable: true, - isSchedulable: false, - isPrioritizable: false, - isLeaf: false, - }, - { - name: "Sequence", - isTimeReportable: false, - isTaskable: true, - isTypeable: false, - isStatusable: false, - isSchedulable: false, - isPrioritizable: true, - isLeaf: false, - }, - { - name: "Shot", - isTimeReportable: false, - isTaskable: true, - isTypeable: false, - isStatusable: true, - isSchedulable: false, - isPrioritizable: true, - isLeaf: false, - }, - { - name: "Milestone", - isTimeReportable: false, - isTaskable: false, - isTypeable: true, - isStatusable: true, - isSchedulable: true, - isPrioritizable: true, - isLeaf: true, - }, - { - name: "Task", - isTimeReportable: true, - isTaskable: false, - isTypeable: true, - isStatusable: true, - isSchedulable: true, - isPrioritizable: true, - isLeaf: true, - }, - { - name: "Image", - isTimeReportable: false, - isTaskable: true, - isTypeable: false, - isStatusable: false, - isSchedulable: false, - isPrioritizable: false, - isLeaf: false, - }, - { - name: "Information", - isTimeReportable: false, - isTaskable: true, - isTypeable: false, - isStatusable: false, - isSchedulable: false, - isPrioritizable: false, - isLeaf: false, - }, - ] as const; -} - -export type RuntimeObjectType = ReturnType[number]; -export type RuntimeObjectTypeName = RuntimeObjectType["name"]; - -export function getProjectSchemas() { - return [] as const; -} - -export type RuntimeProjectSchema = ReturnType[number]; -export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; - -// Errors: diff --git a/source/__snapshots__/default-types.snap b/source/__snapshots__/default-types.snap deleted file mode 100644 index b3ed72b..0000000 --- a/source/__snapshots__/default-types.snap +++ /dev/null @@ -1,158 +0,0 @@ -// :copyright: Copyright (c) 2023 ftrack - -// Generated on 2023-02-01T00:00:00.000Z using schema -// from an instance running version 4.13.8 using server on https://ftrack.example.com -// Not intended to modify manually - -export interface TypedContext< - K extends TypedContextSubtype = TypedContextSubtype -> { - __entity_type__?: K; - __permissions?: Record; -} -export interface BasicLink { - id: string; - type: string; - name: string; -} -export interface EntityTypeMap { - TypedContext: TypedContext; -} -export type EntityType = keyof EntityTypeMap; -export type EntityData = - EntityTypeMap[TEntityType]; -export interface TypedContextSubtypeMap { - TypedContext: TypedContext; -} -export type TypedContextSubtype = keyof TypedContextSubtypeMap; -export function getAttributeConfigurations() { - return [] as const; -} - -export type RuntimeCustomAttributeConfiguration = ReturnType< - typeof getAttributeConfigurations ->[number]; -export type RuntimeCustomAttributeConfigurationName = - RuntimeCustomAttributeConfiguration["name"]; -export type RuntimeCustomAttributeConfigurationLabel = - RuntimeCustomAttributeConfiguration["label"]; - -export function getTypes() { - return [ - { - name: "Concept Art", - isBillable: true, - }, - { - name: "Modeling", - isBillable: true, - }, - { - name: "Rigging", - isBillable: true, - }, - { - name: "Texture", - isBillable: true, - }, - { - name: "Lookdev", - isBillable: true, - }, - { - name: "Character", - isBillable: true, - }, - { - name: "Prop", - isBillable: true, - }, - { - name: "Furniture", - isBillable: false, - }, - { - name: "Vehicle", - isBillable: true, - }, - { - name: "Environment", - isBillable: true, - }, - { - name: "Matte Painting", - isBillable: true, - }, - { - name: "Production", - isBillable: false, - }, - { - name: "Editing", - isBillable: true, - }, - { - name: "Conform", - isBillable: true, - }, - { - name: "Tracking", - isBillable: true, - }, - { - name: "Rotoscoping", - isBillable: true, - }, - { - name: "Previz", - isBillable: true, - }, - { - name: "Layout", - isBillable: true, - }, - { - name: "Animation", - isBillable: true, - }, - { - name: "FX", - isBillable: true, - }, - { - name: "Lighting", - isBillable: true, - }, - { - name: "Rendering", - isBillable: true, - }, - { - name: "Compositing", - isBillable: true, - }, - { - name: "Deliverable", - isBillable: true, - }, - ] as const; -} - -export type RuntimeType = ReturnType[number]; -export type RuntimeTypeName = RuntimeType["name"]; - -export function getObjectTypes() { - return [] as const; -} - -export type RuntimeObjectType = ReturnType[number]; -export type RuntimeObjectTypeName = RuntimeObjectType["name"]; - -export function getProjectSchemas() { - return [] as const; -} - -export type RuntimeProjectSchema = ReturnType[number]; -export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; - -// Errors: diff --git a/source/__snapshots__/responses/query_priorities.json b/source/__snapshots__/responses/query_priorities.json new file mode 100644 index 0000000..2eadf8c --- /dev/null +++ b/source/__snapshots__/responses/query_priorities.json @@ -0,0 +1,42 @@ +[ + { + "__entity_type__": "Priority", + "id": "847fb90e-ead3-11e2-846c-f23c91dfaa16", + "name": "Urgent", + "value": 0, + "sort": 0, + "color": "#E74C3C" + }, + { + "__entity_type__": "Priority", + "id": "847f9cda-ead3-11e2-846c-f23c91dfaa16", + "name": "High", + "value": 0, + "sort": 1, + "color": "#E67E22" + }, + { + "__entity_type__": "Priority", + "id": "847f8146-ead3-11e2-846c-f23c91dfaa16", + "name": "Medium", + "value": 0, + "sort": 2, + "color": "#F1C40F" + }, + { + "__entity_type__": "Priority", + "id": "847f663e-ead3-11e2-846c-f23c91dfaa16", + "name": "Low", + "value": 0, + "sort": 3, + "color": "#1CBC90" + }, + { + "__entity_type__": "Priority", + "id": "9661b320-3a0c-11e2-81c1-0800200c9a66", + "name": "None", + "value": 0, + "sort": 4, + "color": "#CACACA" + } +] diff --git a/source/__snapshots__/responses/query_statuses.json b/source/__snapshots__/responses/query_statuses.json new file mode 100644 index 0000000..63311d2 --- /dev/null +++ b/source/__snapshots__/responses/query_statuses.json @@ -0,0 +1,134 @@ +[ + { + "__entity_type__": "Status", + "id": "9bb65936-88e7-11e3-9264-04011030cf01", + "name": "Completed", + "sort": 0, + "color": "#1cbc90", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea116d4-acb5-11e1-8668-f23c91df1211" + } + }, + { + "__entity_type__": "Status", + "id": "a0bc3f24-15e2-11e1-b21a-0019bb4983d8", + "name": "Omitted", + "sort": 1, + "color": "#E74C3C", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "5709c04e-2f4b-11e2-b663-0019bb4983d8" + } + }, + { + "__entity_type__": "Status", + "id": "a0bc2444-15e2-11e1-b21a-0019bb4983d8", + "name": "On Hold", + "sort": 2, + "color": "#E74C3C", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "5709c04e-2f4b-11e2-b663-0019bb4983d8" + } + }, + { + "__entity_type__": "Status", + "id": "2286947e-a2d4-11e9-825d-d27cf242b68b", + "name": "Revise", + "sort": 3, + "color": "#FF6600", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea0efc4-acb5-11e1-8668-f23c91df1211" + } + }, + { + "__entity_type__": "Status", + "id": "d5d6d8ca-ebb2-11e2-aef9-f23c91dfaa16", + "name": "Client approved", + "sort": 4, + "color": "#1CBC90", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea116d4-acb5-11e1-8668-f23c91df1211" + } + }, + { + "__entity_type__": "Status", + "id": "44de097a-4164-11df-9218-0019bb4983d8", + "name": "Approved", + "sort": 5, + "color": "#1cbc90", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea116d4-acb5-11e1-8668-f23c91df1211" + } + }, + { + "__entity_type__": "Status", + "id": "44dded64-4164-11df-9218-0019bb4983d8", + "name": "Pending Review", + "sort": 6, + "color": "#F1C40F", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea0efc4-acb5-11e1-8668-f23c91df1211" + } + }, + { + "__entity_type__": "Status", + "id": "44ddd0fe-4164-11df-9218-0019bb4983d8", + "name": "In progress", + "sort": 7, + "color": "#3498DB", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea0efc4-acb5-11e1-8668-f23c91df1211" + } + }, + { + "__entity_type__": "Status", + "id": "cadb9a06-acb5-11e1-8668-f23c91df1211", + "name": "WIP", + "sort": 8, + "color": "#CC99FF", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea0ba04-acb5-11e1-8668-f23c91df1211" + } + }, + { + "__entity_type__": "Status", + "id": "9078de1a-40ce-11ed-a028-8e70b81a65da", + "name": "Ready to start", + "sort": 9, + "color": "#00FFFF", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea0ba04-acb5-11e1-8668-f23c91df1211" + } + }, + { + "__entity_type__": "Status", + "id": "44dd9fb2-4164-11df-9218-0019bb4983d8", + "name": "Not started", + "sort": 10, + "color": "#CACACA", + "is_active": true, + "state": { + "__entity_type__": "State", + "id": "cea0ba04-acb5-11e1-8668-f23c91df1211" + } + } +] diff --git a/source/__snapshots__/schema-has-array-type.snap b/source/__snapshots__/schema-has-array-type.snap index d5c3405..69bdddd 100644 --- a/source/__snapshots__/schema-has-array-type.snap +++ b/source/__snapshots__/schema-has-array-type.snap @@ -70,4 +70,18 @@ export function getProjectSchemas() { export type RuntimeProjectSchema = ReturnType[number]; export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; +export function getPriorities() { + return [] as const; +} + +export type RuntimePriority = ReturnType[number]; +export type RuntimePriorityName = RuntimePriority["name"]; + +export function getStatuses() { + return [] as const; +} + +export type RuntimeStatus = ReturnType[number]; +export type RuntimeStatusName = RuntimeStatus["name"]; + // Errors: diff --git a/source/__snapshots__/schema-has-base-schema.snap b/source/__snapshots__/schema-has-base-schema.snap index 9e102cf..9db72eb 100644 --- a/source/__snapshots__/schema-has-base-schema.snap +++ b/source/__snapshots__/schema-has-base-schema.snap @@ -69,4 +69,18 @@ export function getProjectSchemas() { export type RuntimeProjectSchema = ReturnType[number]; export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; +export function getPriorities() { + return [] as const; +} + +export type RuntimePriority = ReturnType[number]; +export type RuntimePriorityName = RuntimePriority["name"]; + +export function getStatuses() { + return [] as const; +} + +export type RuntimeStatus = ReturnType[number]; +export type RuntimeStatusName = RuntimeStatus["name"]; + // Errors: diff --git a/source/__snapshots__/schema-has-immutable-property.snap b/source/__snapshots__/schema-has-immutable-property.snap index 8087a91..182782f 100644 --- a/source/__snapshots__/schema-has-immutable-property.snap +++ b/source/__snapshots__/schema-has-immutable-property.snap @@ -64,4 +64,18 @@ export function getProjectSchemas() { export type RuntimeProjectSchema = ReturnType[number]; export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; +export function getPriorities() { + return [] as const; +} + +export type RuntimePriority = ReturnType[number]; +export type RuntimePriorityName = RuntimePriority["name"]; + +export function getStatuses() { + return [] as const; +} + +export type RuntimeStatus = ReturnType[number]; +export type RuntimeStatusName = RuntimeStatus["name"]; + // Errors: diff --git a/source/__snapshots__/schema-has-integer-type.snap b/source/__snapshots__/schema-has-integer-type.snap index 555303b..7d83e68 100644 --- a/source/__snapshots__/schema-has-integer-type.snap +++ b/source/__snapshots__/schema-has-integer-type.snap @@ -64,4 +64,18 @@ export function getProjectSchemas() { export type RuntimeProjectSchema = ReturnType[number]; export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; +export function getPriorities() { + return [] as const; +} + +export type RuntimePriority = ReturnType[number]; +export type RuntimePriorityName = RuntimePriority["name"]; + +export function getStatuses() { + return [] as const; +} + +export type RuntimeStatus = ReturnType[number]; +export type RuntimeStatusName = RuntimeStatus["name"]; + // Errors: diff --git a/source/__snapshots__/schema-has-variable-type.snap b/source/__snapshots__/schema-has-variable-type.snap index a153c50..b7a3f03 100644 --- a/source/__snapshots__/schema-has-variable-type.snap +++ b/source/__snapshots__/schema-has-variable-type.snap @@ -64,4 +64,18 @@ export function getProjectSchemas() { export type RuntimeProjectSchema = ReturnType[number]; export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; +export function getPriorities() { + return [] as const; +} + +export type RuntimePriority = ReturnType[number]; +export type RuntimePriorityName = RuntimePriority["name"]; + +export function getStatuses() { + return [] as const; +} + +export type RuntimeStatus = ReturnType[number]; +export type RuntimeStatusName = RuntimeStatus["name"]; + // Errors: diff --git a/source/__snapshots__/schema-subtype-of-TypedContext.snap b/source/__snapshots__/schema-subtype-of-TypedContext.snap index 84a1456..d5a1759 100644 --- a/source/__snapshots__/schema-subtype-of-TypedContext.snap +++ b/source/__snapshots__/schema-subtype-of-TypedContext.snap @@ -61,4 +61,18 @@ export function getProjectSchemas() { export type RuntimeProjectSchema = ReturnType[number]; export type RuntimeProjectSchemaName = RuntimeProjectSchema["name"]; +export function getPriorities() { + return [] as const; +} + +export type RuntimePriority = ReturnType[number]; +export type RuntimePriorityName = RuntimePriority["name"]; + +export function getStatuses() { + return [] as const; +} + +export type RuntimeStatus = ReturnType[number]; +export type RuntimeStatusName = RuntimeStatus["name"]; + // Errors: diff --git a/source/emit.test.ts b/source/emit.test.ts index e8bf935..d089354 100644 --- a/source/emit.test.ts +++ b/source/emit.test.ts @@ -2,7 +2,9 @@ import { beforeEach, expect, test, vi } from "vitest"; import { CustomAttributeConfiguration, ObjectType, + Priority, ProjectSchema, + Status, Type, emitToString, } from "./emit"; @@ -23,6 +25,8 @@ test("emitting with no schemas returns error", async () => { [], [], [], + [], + [], [] ); @@ -50,6 +54,8 @@ test("schema subtype of TypedContext", async () => { [], [], [], + [], + [], [] ); @@ -82,6 +88,8 @@ test("schema has base schema", async () => { [], [], [], + [], + [], [] ); @@ -115,6 +123,8 @@ test("schema has immutable property", async () => { [], [], [], + [], + [], [] ); @@ -147,6 +157,8 @@ test("schema has integer type", async () => { [], [], [], + [], + [], [] ); @@ -179,6 +191,8 @@ test("schema has variable type", async () => { [], [], [], + [], + [], [] ); @@ -224,127 +238,21 @@ test("schema has array type", async () => { [], [], [], - [] - ); - - //assert - expect(emitResult.errors).toEqual([]); - expect(emitResult.prettifiedContent).toMatchFileSnapshot( - join(".", "__snapshots__", "schema-has-array-type.snap") - ); -}); - -test("default ftrack schema", async () => { - //arrange - const contents = await readFile( - join(".", "source", "__snapshots__", "responses", "query_schemas.json") - ); - const schemas: Array = JSON.parse(contents.toString()); - - //act - const emitResult = await emitToString( - "4.13.8", - "https://ftrack.example.com", - schemas, - [], - [], - [], - [] - ); - - //assert - expect(emitResult.errors).toEqual([]); - expect(emitResult.prettifiedContent).toMatchFileSnapshot( - join(".", "__snapshots__", "default-ftrack-schema.snap") - ); -}); - -test("default custom attributes", async () => { - //arrange - const contents = await readFile( - join( - ".", - "source", - "__snapshots__", - "responses", - "query_custom_attribute_configurations.json" - ) - ); - const customAttributes: CustomAttributeConfiguration[] = JSON.parse( - contents.toString() - ); - - //act - const emitResult = await emitToString( - "4.13.8", - "https://ftrack.example.com", - [getTypedContextSchema()], - customAttributes, - [], - [], - [] - ); - - //assert - expect(emitResult.errors).toEqual([]); - expect(emitResult.prettifiedContent).toMatchFileSnapshot( - join(".", "__snapshots__", "default-custom-attributes.snap") - ); -}); - -test("default types", async () => { - //arrange - const contents = await readFile( - join(".", "source", "__snapshots__", "responses", "query_types.json") - ); - const types: Type[] = JSON.parse(contents.toString()); - - //act - const emitResult = await emitToString( - "4.13.8", - "https://ftrack.example.com", - [getTypedContextSchema()], - [], - types, - [], - [] - ); - - //assert - expect(emitResult.errors).toEqual([]); - expect(emitResult.prettifiedContent).toMatchFileSnapshot( - join(".", "__snapshots__", "default-types.snap") - ); -}); - -test("default object types", async () => { - //arrange - const contents = await readFile( - join(".", "source", "__snapshots__", "responses", "query_object_types.json") - ); - const objectTypes: ObjectType[] = JSON.parse(contents.toString()); - - //act - const emitResult = await emitToString( - "4.13.8", - "https://ftrack.example.com", - [getTypedContextSchema()], [], [], - objectTypes, [] ); //assert expect(emitResult.errors).toEqual([]); expect(emitResult.prettifiedContent).toMatchFileSnapshot( - join(".", "__snapshots__", "default-object-types.snap") + join(".", "__snapshots__", "schema-has-array-type.snap") ); }); test("default highway test (all values specified)", async () => { //arrange - const projectSchemasContents = await readFile( + const projectSchemas = await parseJsonFromFile( join( ".", "source", @@ -353,16 +261,14 @@ test("default highway test (all values specified)", async () => { "query_project_schema.json" ) ); - const projectSchemas: Array = JSON.parse( - projectSchemasContents.toString() - ); - const schemasContents = await readFile( + const schemas = await parseJsonFromFile( join(".", "source", "__snapshots__", "responses", "query_schemas.json") ); - const schemas: Array = JSON.parse(schemasContents.toString()); - const customAttributeContents = await readFile( + const customAttributes = await parseJsonFromFile< + CustomAttributeConfiguration[] + >( join( ".", "source", @@ -371,19 +277,22 @@ test("default highway test (all values specified)", async () => { "query_custom_attribute_configurations.json" ) ); - const customAttributes: CustomAttributeConfiguration[] = JSON.parse( - customAttributeContents.toString() - ); - const typesContents = await readFile( + const types = await parseJsonFromFile( join(".", "source", "__snapshots__", "responses", "query_types.json") ); - const types: Type[] = JSON.parse(typesContents.toString()); - const objectTypeContents = await readFile( + const objectTypes = await parseJsonFromFile( join(".", "source", "__snapshots__", "responses", "query_object_types.json") ); - const objectTypes: ObjectType[] = JSON.parse(objectTypeContents.toString()); + + const statuses = await parseJsonFromFile( + join(".", "source", "__snapshots__", "responses", "query_statuses.json") + ); + + const priorities = await parseJsonFromFile( + join(".", "source", "__snapshots__", "responses", "query_priorities.json") + ); //act const emitResult = await emitToString( @@ -393,7 +302,9 @@ test("default highway test (all values specified)", async () => { customAttributes, types, objectTypes, - projectSchemas + projectSchemas, + statuses, + priorities ); //assert @@ -403,6 +314,11 @@ test("default highway test (all values specified)", async () => { ); }); +async function parseJsonFromFile(path: string): Promise { + const contents = await readFile(path); + return JSON.parse(contents.toString()); +} + function getTypedContextSchema() { return { id: "TypedContext", diff --git a/source/emit.ts b/source/emit.ts index 856be73..fdbac93 100644 --- a/source/emit.ts +++ b/source/emit.ts @@ -16,6 +16,8 @@ export async function emitToFile( const types = await getTypes(session); const objectTypes = await getObjectTypes(session); const projectSchemas = await getProjectSchemas(session); + const statuses = await getStatuses(session); + const priorities = await getPriorities(session); const { prettifiedContent, @@ -27,7 +29,9 @@ export async function emitToFile( customAttributes, types, objectTypes, - projectSchemas + projectSchemas, + statuses, + priorities ); fs.mkdirSync(path.resolve(outputPath), { recursive: true }); fs.writeFileSync(path.join(outputPath, outputFilename), prettifiedContent); @@ -84,6 +88,22 @@ export type ObjectType = { is_leaf: boolean; }; +export type Priority = { + color: string; + id: string; + name: string; + sort: number; + value: number; +}; + +export type Status = { + color: string; + id: string; + is_active: boolean; + name: string; + sort: number; +}; + export type CustomAttributeConfiguration = { __entity_type__: "CustomAttributeConfiguration"; id: string; @@ -108,7 +128,9 @@ export async function emitToString( customAttributes: CustomAttributeConfiguration[], types: Type[], objectTypes: ObjectType[], - projectSchemas: ProjectSchema[] + projectSchemas: ProjectSchema[], + statuses: Status[], + priorities: Priority[] ) { const preamble = `// :copyright: Copyright (c) ${new Date().getFullYear()} ftrack \n\n// Generated on ${new Date().toISOString()} using schema \n// from an instance running version ${serverVersion} using server on ${serverUrl} \n// Not intended to modify manually\n\n`; @@ -153,6 +175,42 @@ export async function emitToString( export type RuntimeTypeName = RuntimeType["name"]; `; + const statusesString = ` + export function getStatuses() { + return [ + ${statuses.map( + (x) => `{ + name: "${x.name}", + color: "${x.color}", + isActive: ${x.is_active}, + sort: ${x.sort} + }` + )} + ] as const; + } + + export type RuntimeStatus = ReturnType[number]; + export type RuntimeStatusName = RuntimeStatus["name"]; + `; + + const prioritiesString = ` + export function getPriorities() { + return [ + ${priorities.map( + (x) => `{ + name: "${x.name}", + color: "${x.color}", + value: ${x.value}, + sort: ${x.sort} + }` + )} + ] as const; + } + + export type RuntimePriority = ReturnType[number]; + export type RuntimePriorityName = RuntimePriority["name"]; + `; + const objectTypesString = ` export function getObjectTypes() { return [ @@ -248,6 +306,8 @@ export async function emitToString( typesString + objectTypesString + projectSchemasString + + prioritiesString + + statusesString + "\n \n// Errors: \n" + errors.map((error) => `// ${error}`).join("\n"); const prettifiedContent = prettier.format(allContent, { @@ -280,6 +340,20 @@ async function getTypes(session: Session) { return types.data; } +async function getPriorities(session: Session) { + const priorities = await session.query( + "select id, color, name, sort, value from Priority order by sort" + ); + return priorities.data; +} + +async function getStatuses(session: Session) { + const priorities = await session.query( + "select id, color, is_active, name, sort, state from Status order by sort" + ); + return priorities.data; +} + async function getObjectTypes(session: Session) { const objectTypes = await session.query( "select id, is_leaf, is_prioritizable, is_schedulable, is_statusable, is_taskable, is_time_reportable, is_typeable, name, project_schemas from ObjectType order by sort"