UNPKG

smartsuite-typescript-api

Version:

Typescript type generator and wrapper for the REST API provided by SmartSuite. Currently in pre 1.0 so no semver guarantees are given

581 lines (580 loc) 17.7 kB
/** * This file contains a bunch of type models for objects used by the metadata endpoints */ export declare enum SolutionColor { Primary_Blue = "#3A86FF", Primary_Light_Blue = "#4ECCFD", Primary_Green = "#3EAC40", Primary_Red = "#FF5757", Primary_Orange = "#FF9210", Primary_Yellow = "#FFB938", Primary_Purple = "#883CD0", Primary_Pink_ = "#EC506E", Primary_Teal = "#17C4C4", Primary_Grey_ = "#6A849B", Dark_Primary_Blue = "#0C41F3", Dark_Primary_Light_Blue = "#00B3FA", Dark_Primary_Green = "#199A27", Dark_Primary_Red = "#F1273F", Dark_Primary_Orange = "#FF702E", Dark_Primary_Yellow = "#FDA80D", Dark_Primary_Purple = "#673DB6", Dark_Primary_Pink_ = "#CD286A", Dark_Primary_Teal = "#00B2A8", Dark_Primary_Grey_ = "#50515B" } export interface SmartDoc { data: {}; html: ''; preview: ''; } export interface SolutionMetadata { /** * Title of Solution */ name: string; /** * Slug value of the solution(SmartSuite internal id) */ slug: string; /** * A color in hex format, see enum for possible colors */ logo_color: SolutionColor; /** * This is the icon name as it appears on {@link https://fontawesome.com/icons Font Awesome Icons} */ logo_icon: string; /** * The content for the Solution guide */ description?: SmartDoc; /** * @see SolutionPermission */ permissions?: SolutionPermission; /** * Is this solution hidden from display in the workspace? */ hidden?: boolean; created: string; created_by: string; updated: string; updated_by: string; has_demo_data: boolean; /** * Legacy value, not in use for anything... */ status?: "in_development"; automation_count?: number; records_count?: number; members_count?: number; /** * Hash used in constructing the Shared Solution URL */ sharing_hash?: string; sharing_password?: string | null; sharing_enabled?: boolean; sharing_allow_copy?: boolean; /** * Application = Table */ applications_count?: number; last_access: string; id: string; delete_date?: string | null; deleted_by: string | null; template: string | null; homepage_category: string | null; } export interface SolutionPermission { level: 'private_to_me' | "all_members" | 'teams' | 'advanced'; members: EntityAndPermissionLevel[]; teams: EntityAndPermissionLevel[]; owners: string[]; /** * null if permission level is not "private_to_me" */ private_to: string | null; } export interface TablePermission { level: "all_members" | string; members: string[]; teams: string[]; permissions_metadata: any; } export type EntityAndPermissionLevel = { access: "full_access" | "editor" | "contributor" | "assignee" | "commenter" | "viewer"; entity: string; }; export interface TableSettings { emails: boolean; meeting_notes: boolean; call_log: boolean; } export interface TableFieldsCount { countfield: number; formulafield: number; linkedrecordfield: number; lookopfield: number; rollupfield: number; total: number; } export type TableFieldTypes = (readonly [ "recordtitlefield", "richtextareafield", "firstcreatedfield", "lastupdatedfield", "userfield", "commentscountfield", "autonumberfield", "textfield", "textareafield", "numberfield", "numbersliderfield", "percentfield", "currencyfield", "yesnofield", "singleselectfield", "multipleselectfield", "datefield", "fullnamefield", "emailfield", "phonefield", "addressfield", "linkfield", "filefield", "linkedrecordfield", "timefield", "daterangefield", "percentcompletefield", "statusfield", "duedatefield", "dependencyfield", "dependencyrelationfield", "durationfield", "timetrackingfield", "checklistfield", "ratingfield", "votefield", "socialnetworkfield", "tagsfield", "recordidfield", "signaturefield", "countfield", "subitemsfield", "buttonfield", "colorpickerfield", "ipaddressfield", "rollupfield", "formulafield", "lookupfield" ])[number]; export interface HelpDocumentation { data: { type: "doc" | string; content: string[]; }; html: "" | string; preview: "" | string; } export interface CommonFieldParams { required: boolean; unique: boolean; hidden: boolean; help_text_display_format: "tooltip" | "below_field_name"; help_doc: HelpDocumentation | null; default_value: any; valid: boolean; is_migrating: boolean; width: number; system: boolean; placeholder: "" | string; restore_application_id?: string | null; } export interface MultiOrSingleField { entries_allowed: "multiple" | "single"; } export interface Choice { label: string; value: string; } export interface Comparison { /** * The comparison type */ comparison: "is" | "is_not" | "is_empty" | "is_not_empty" | "contains" | "does_not_contain"; /** * This field is matched by field name, and not id/slug */ field: string; /** * The value to compare the value of the given field to */ value: string; } export interface FieldFilter { operator: string; fields: Comparison[]; } export interface FieldWithFilterParams { include_filters: boolean; field_filter: null | FieldFilter; } export interface RecordTitleFieldParams extends Omit<CommonFieldParams, "default_value" & "system"> { is_auto_generated: boolean; template: string; primary: boolean; max_length: number | null; indexed: boolean; } export interface RichTextAreaFieldParams extends CommonFieldParams { default_value: SmartDoc; placeholder: string; system: boolean; } export interface ChoiceOrderedAndColored extends Choice { value_color: string; value_order: number; } export interface StatusFieldParams extends CommonFieldParams { choices: ChoiceOrderedAndColored[]; is_completed: boolean | null; default_value: { value: string; updated_on: null | string; }; } export interface FirstCreatedFieldParams extends CommonFieldParams { display_format: "avatar_date" | string; date_format: "standard" | string; include_time: boolean; default_value: null; } export type LastUpdatedFieldParams = FirstCreatedFieldParams; export interface UserFieldParams extends CommonFieldParams, FieldWithFilterParams, MultiOrSingleField { display_format: "image_name" | string; notifications_enabled: boolean; linked_application: "members" | string; linked_field_slug: string | null; default_value: []; } export type CommmentsCountFieldParams = CommonFieldParams; export interface AutoNumberFieldParams extends CommonFieldParams { include_labels: boolean; suffix: string; prefix: string; starting_number: number; leading_zeros: number; primary: boolean; } export interface DateFieldParams extends CommonFieldParams { display_format: "standard" | string; } export interface LinkedRecordFieldParams extends CommonFieldParams, MultiOrSingleField { display_format: "compact" | "simplified" | "standard" | "expanded" | "table"; visible_fields: string[]; column_widths: any; filter_data: null | any; sort_data: null | any; do_not_create_backlink: boolean; select_record_modal_visible_fields: null; select_record_modal_filter_data: null; select_record_modal_sort_data: null; select_record_modal_cover_image_field: null; cover_image_field: boolean; linked_application: string; linked_field_slug: string | null; default_value: []; symmetric_field?: string; autocreated_symmetric_field?: boolean; } export interface SelectChoice extends ChoiceOrderedAndColored { value_help_text?: string | null; value_icon?: null | any; icon_type?: "icon" | string; records?: null; default_color?: string; weight?: number; } export interface MultipleSelectFieldParams extends CommonFieldParams { display_format: "importance" | string; control_type: "dropdown" | "checkboxes"; edit_values: boolean; edit_help_texts: boolean; new_choices_allowed: boolean; choices: SelectChoice[]; } export interface NumberFieldParams extends CommonFieldParams { include_labels: boolean; suffix: string; prefix: string; primary: boolean; decimal_separator: null | string; thousand_separator: null | string; number_abbreviation: null | string; allow_negative: boolean; precision: number; separator: boolean; } export interface FileFieldParams extends CommonFieldParams { view_mode: "list" | string; items_in_row: number; } export interface CurrencyFieldParams extends CommonFieldParams { currency: string; allow_negative: boolean; precision: number; decimal_separator: null | string; thousand_separator: null | string; number_abbreviation: null | string; } export interface TextFieldParams extends CommonFieldParams { primary: boolean; max_length: number | null; composite: null | any; delimiter: ", " | string; } export interface TagChoice extends Omit<ChoiceOrderedAndColored, "value_color"> { is_default: boolean; } export interface TagsFieldParams extends CommonFieldParams { tag_type: "private" | "public"; choices: TagChoice[]; default_value: []; } export interface NumberSliderFieldParams extends CommonFieldParams { color: string; display_format: 1 | 2 | 3; min_value: number; max_value: number; value_increment: number; default_value: string; } export interface PercentFieldParams extends CommonFieldParams { decimal_separator: null | string; thousand_separator: null | string; allow_negative: boolean; precision: number; separator: boolean; } export interface YesNoFieldParams extends CommonFieldParams { default_value: boolean; display_format: "checkmark" | "heart" | "thumbs_up" | "star" | "flag" | "round_toggle" | "rectangle_toggle" | "yes_no_toggle"; color: string; primary: boolean; } export interface SingleSelectFieldParams extends CommonFieldParams { display_format: "importance" | string; control_type: "dropdown" | "radio_buttons"; edit_values: boolean; edit_help_texts: boolean; new_choices_allowed: boolean; choices: SelectChoice[]; } export type FullNameFields = "first_name" | "middle_name" | "last_name" | "title"; export interface FullNameFieldParams extends CommonFieldParams { nested: any[]; choices: Choice[]; display_fields: FullNameFields[]; } export interface EmailFieldParams extends CommonFieldParams, MultiOrSingleField { default_value: []; } export interface PhoneFieldParams extends CommonFieldParams, MultiOrSingleField { display_format: "number" | "number_with_flag"; default_country: null | string; custom_default_label: "default_country"; } export interface AddressFieldParams extends CommonFieldParams { display_format: "single" | "multiple"; include_map: boolean; display_fields: string[]; nested: any[]; } export interface LinkFieldParams extends CommonFieldParams { entires_allowed: "single" | "multiple"; display_format: "link" | "link_with_favicon" | "icon"; } export type TimeFieldParams = CommonFieldParams; export interface DateRangeFieldParams extends CommonFieldParams { display_format: "compact" | "standard" | "long" | "pill"; primary: boolean; default_value: { from_date: { date: null | string; include_time: boolean; }; to_date: { date: null | string; include_time: boolean; }; }; nested: any[]; } export interface PercentCompletedFieldParams extends CommonFieldParams { include_labels: boolean; suffix: string; color: string; gardient_color: string; display_format: 1 | 2 | 3; min_value: number; max_value: number; value_increment: number; } export interface DueDateFieldParams extends CommonFieldParams { display_format: "compact" | "standard" | "long"; linked_field: string; nested: any[]; } export interface DurationFieldParams extends CommonFieldParams { display_format: "compact" | "standard" | "long"; duration_format: string; linked_field: string; } export interface TimeTrackingFieldParams extends CommonFieldParams { color: string; display_format: "pill" | "text"; } export type ChecklistFieldParams = CommonFieldParams; export interface RatingFieldParams extends CommonFieldParams { scale: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; color: string; display_format: "star" | "heart" | "smiley_face" | "flag" | "thumbs_up" | "number_badge" | "rectangles"; include_labels: boolean; rating_lowest: string; rating_highest: string; } export interface VoteFieldParams extends CommonFieldParams { color: string; show_vote_list: boolean; default_value: { total_votes: number; votes: any[]; }; } export interface SocialNetworkFieldParams extends CommonFieldParams, MultiOrSingleField { "choices": [ { "label": "Facebook"; "value": "1"; }, { "label": "Twitter"; "value": "2"; }, { "label": "Instagram"; "value": "3"; }, { "label": "Linkedin"; "value": "4"; } ]; nested: any[]; } export type RecordIDFieldParams = CommonFieldParams; export type SignatureFieldParams = CommonFieldParams; export interface CountFieldParams extends CommonFieldParams, FieldWithFilterParams { include_labels: boolean; suffix: string; prefix: string; linked_field: string; color: string; target_application: boolean; drill_in: { visible_fields: string[]; }; } export interface SubItemsFieldParams extends CommonFieldParams { structure: any; fields_count: { linkedrecordfield: number; total: number; }; current_field_view: number; field_views: any[]; visible_fields: string[]; } export interface ButtonFieldParams extends CommonFieldParams { display_format: "colored_pill" | string; color: string; button_label: string; button_action: "open_url" | string; button_actions_params: any[]; } export interface ColorPickerFieldParams extends CommonFieldParams, MultiOrSingleField { display_format: "hex" | string; } export interface IPAddressFieldParams extends CommonFieldParams, MultiOrSingleField { display_format: "ip_only" | "ip_with_flag"; default_value: []; primary: boolean; } export interface RollupFieldParams extends CommonFieldParams, FieldWithFilterParams { linked_field: string; filed_selection: string; function: "average" | "min" | "max" | "range" | "sum"; precision: number; target_field_structure: any; drill_in: { visible_fields: string[]; }; } export interface FormulaFieldParams extends CommonFieldParams { formula: string; is_advanced: boolean; target_field_structure: any; score: number; target_formats: any; } export interface LookupFieldParams extends CommonFieldParams, FieldWithFilterParams { /** * The id of the related lookup field in another table */ linked_field: string; /** * This seems to be the field id of the field to be looked up */ field_selection: string; target_field_structure: any; } export type AllFieldTypes = RecordTitleFieldParams | RichTextAreaFieldParams | StatusFieldParams | FirstCreatedFieldParams | LastUpdatedFieldParams | UserFieldParams | CommmentsCountFieldParams | AutoNumberFieldParams | DateFieldParams | LinkedRecordFieldParams | MultipleSelectFieldParams | NumberFieldParams | FileFieldParams | CurrencyFieldParams | TextFieldParams | TagsFieldParams | NumberSliderFieldParams | PercentFieldParams | YesNoFieldParams | SingleSelectFieldParams | FullNameFieldParams | EmailFieldParams | PhoneFieldParams | AddressFieldParams | LinkFieldParams | TimeFieldParams | DateRangeFieldParams | PercentCompletedFieldParams | DueDateFieldParams | DurationFieldParams | TimeTrackingFieldParams | ChecklistFieldParams | RatingFieldParams | VoteFieldParams | SocialNetworkFieldParams | RecordIDFieldParams | SignatureFieldParams | CountFieldParams | SubItemsFieldParams | ButtonFieldParams | ColorPickerFieldParams | IPAddressFieldParams | RollupFieldParams | FormulaFieldParams | LookupFieldParams; export interface TableField<FieldTypes = AllFieldTypes> { slug: string; label: string; field_type: TableFieldTypes; params: FieldTypes; } export interface TableMetadata { first_created: { on: string; by: string; }; solution: string; name: string; slug: string; status: string; order: number; show_all_reports_members: any[]; fields_metadata: any; permissions: TablePermission; field_permissions: any[]; settings: TableSettings; /** * The default name is "record" */ record_term: "record" | string; fields_count: TableFieldsCount; primary_field: string; id: string; /** * The record in this table, described Field by field */ structure: TableField[]; /** * How the fields are structured in the UI when adding a new record */ structure_layout: {}; }