import { EndPoints } from "../index.js"; import { SalesAnalyticsFieldAccumulators, SalesAnalyticsReportProjectionKey, SalesAnalyticsReportFilter, SalesAnalyticsGroupByIDs, SalesAnalyticsReportSortedKey, } from "./report-type.js"; export interface Params { [key: string]: any; } export type ReportType = | "sales-analytics" | "retail-execution-gallery" | "from-v2-gallery" | "object-detection-metrics" | "object-detection-segments"; export interface Data { [key: string]: any; } export interface Options { env?: "staging" | "local" | "production"; headers?: { [key: string]: string }; timeout?: number | undefined; retryAttempts?: number; nameSpace?: string; refresh_token?: string; reauthCallBackFn?: (res: Service.Reauth.Result) => void; } interface ReportColumn { _id?: string; disabled: boolean; key: string; name: string; report_types: ReportType[]; default_show: boolean; selectable: boolean; position: number; show: "default" | "hide" | "show"; column_group?: StringId | string; totals_key?: string; createdAt?: Date; updatedAt?: Date; } type QueryCriteriaCondition = { [key: string]: any }; type QueryCriteriaValue = | boolean | string | number | QueryCriteriaElement | QueryCriteriaLogical | null | Date; type LogicalOperators = "and" | "or"; export type QueryCriteriaOperators = | "gt" | "lt" | "gte" | "lte" | "in" | "nin" | "eq" | "between" | "last_seven_days" | "today" | "yesterday" | "last_thirty_days" | "last_month" | "last_three_months" | "last_six_months" | "last_twelve_months"; type QueryCriteriaElement = { key: string; operator: QueryCriteriaOperators; value: QueryCriteriaValue; conditions?: QueryCriteriaCondition[]; }; type QueryCriteriaLogical = { operator: LogicalOperators; value: QueryCriteriaValue[]; }; type BaseKey = string; type BaseValue = any; type FilterMap = SalesAnalyticsReportFilter; type GroupByKeys = SalesAnalyticsGroupByIDs; type FieldAccumulators = SalesAnalyticsFieldAccumulators; type SortValue = { field: Keys; type: "asc" | "desc" | -1 | 1; }; interface EnhancedQueryCriteriaElement< TKeys extends keyof FilterMap, TValue extends BaseValue = QueryCriteriaValue, TCondition = QueryCriteriaCondition, > { key: TKeys; operator: FilterMap[TKeys][number]; value: TValue; conditions?: TCondition[]; } type GroupByType = { _id: TGroupID; fields: { [K in GroupByKeys[TGroupID]]: { key: K; acc: K extends keyof TFieldAccumulators ? TFieldAccumulators[K] : never; }; }[GroupByKeys[TGroupID]][]; }; interface GenericQuery< TSortKey extends BaseKey, TFilterMap extends FilterMap, TGroupKey extends GroupByKeys, TFieldAccumulators extends FieldAccumulators, TProjectionKeys extends BaseKey, TMaxAnyOfLength extends number = 1, > { maxAnyOfLength: TMaxAnyOfLength; anyOf: { criteria: { [K in keyof TFilterMap]: EnhancedQueryCriteriaElement< K & keyof FilterMap >; }[keyof TFilterMap][]; }[]; options?: { sort?: SortValue[]; limit?: number; page?: number; totals_summary?: "none" | "all" | "page"; without_currency?: boolean; }; group?: GroupByType< keyof TGroupKey & keyof GroupByKeys, TFieldAccumulators >[]; projection?: TProjectionKeys[]; columns?: ReportColumn[]; metadata?: any; } export interface Headers { "api-key": string; "Content-Type": string; Accept: string; [key: string]: string; } interface AdminCreator { _id: string; type: "admin"; name?: string; admin?: string; } interface RepCreator { _id: string; type: "rep"; name?: string; rep?: string; } interface ClientCreator { _id: string; type: "client"; name?: string; client?: string; } export interface SerialNumber { identifier: string; formatted: string; count: number; } interface PlanList { client?: string; note?: string; route?: string; calendar?: string; route_name?: string; isCompleted?: boolean; } interface PaymentData { payment_serial_number?: SerialNumber; payment_id?: string; invoice_serial_number?: SerialNumber; return_serial_number?: SerialNumber; fullinvoice_id?: string; refund_serial_number?: SerialNumber; refund_id?: string; adjustment_serial_number?: SerialNumber; adjustment_id?: string; adjustment_account_id?: string; view_serial_number?: SerialNumber; type?: "invoice" | "payment" | "return_invoice" | "refund" | "adjustment"; amount: number; account_index?: number; is_linked_txn?: boolean; is_original?: boolean; } interface Check { _id: string; drawer_name: string; bank: string; bank_branch: string; check_number: number; check_date: string; photo?: string; caption?: string; photo_meta?: { device_orientation?: number; height?: number; width?: number; }; disabled?: boolean; } interface AssetUnitsPopulated { _id: StringId; name: string; local_name?: string; cover_photo: MediaPopulated; } interface AssetsPopulated { _id: StringId; name: string; local_name?: string; cover_photo: MediaPopulated; } interface RepresentativesPopulated { name: string; _id: string; } interface ClientLocationPopulated { _id: StringId; name: string; local_name?: string; } interface FormPopulated { name: string; _id: StringId; local_name?: string; } interface RetailExecutionTemplatePopulated { _id: StringId; name: string; } interface VisitMeta { geo_fence_setting_visit_start: boolean; geo_fence_setting_visit_end: boolean; geo_fence_setting_radius: number; offline_mode: boolean; start_visit_in_fence: boolean; end_visit_in_fence: boolean; client_verified: boolean; } interface thumbnailStoragePopulated { _id: string; createdAt: string; ContentType: string; mime_type: string; publicUrl: string; type_name: "FileAttachment" | "ImageAttachment"; file_name: string; media_id: string; media_type: | "csv" | "json" | "image" | "pdf" | " ppt" | "pptx" | "xls" | "xlsx" | "doc" | "docx" | " images" | "zip"; } interface MediaPopulated { _id: string; media_type: | "csv" | "json" | "image" | "pdf" | " ppt" | "pptx" | "xls" | "xlsx" | "doc" | "docx" | " images" | "zip"; mime_type: string; publicUrl: string; file_name: string; type_name: "FileAttachment" | "ImageAttachment"; media_id: string; ContentType: string; createdAt: string; updatedAt: string; thumbnails: thumbnailStoragePopulated; } export interface DefaultPaginationQueryParams { per_page?: number; page?: number; sort?: string; sortPageOrder?: "asc" | "dsc"; } interface WorkorderCategoryPopulated { _id: StringId; name: string; local_name?: string; } export interface DefaultPaginationResult { total_result: number; current_count: number; total_pages: number; current_page: number; per_page: number; first_page_url: string; last_page_url: string; next_page_url: string | null; prev_page_url: string | null; path: string; data: any[]; columns?: ReportColumn[]; keys?: ReportKey[]; } export interface AgendaPaginationResult extends DefaultPaginationResult { meta?: { day_current_page: number; day_per_page: number; }; } export interface List { client: string | { _id: string }; note?: string; route?: string; calendar: string; } export interface Build { day: string; list: List[]; start_date?: number | undefined; } export type Calendar = CalendarWeekly | CalendarWeeklyGroup; export interface Route { disabled: boolean; list: List[]; _id: string; } export type Priority = 0 | 1 | 2 | 3; export type WorkorderStatus = "open" | "done" | "cancelled" | "inprogress" | "onhold"; export type Priority_human = "none" | "low" | "medium" | "high"; export type Day = "Sun" | "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | string; export type FieldType = | "Text" | "String" | "Date" | "Image" | "Boolean" | "Number" | "List" | "Separator" | "Heading" | "Media"; export type Method = "find" | "get" | "create" | "update" | "patch" | "remove"; export interface WeeklyDetails { every: number; days: Day[]; } export interface CalendarWeekly { type: "weekly"; disabled: boolean; startsAt: string; endsAt: string; details: WeeklyDetails; occurrences: number; routes: Route[]; clients: string[] | string; note?: string; _id: string; } export interface DaysGroup { days: Day[]; } export interface WeeklyGroupDetails { daysGroups: DaysGroup[]; groupSize: number; } export interface CalendarWeeklyGroup { type: "weeklyGroup"; disabled: boolean; startsAt: string; endsAt: string; details: WeeklyGroupDetails; occurrences: number; routes: Route[]; clients: string[] | string; note?: string; _id: string; } export type Model = | "quickConvertToPdf" | "warehouses" | "dayShift" | "transfers" | "transactions" | "taxes" | "productvariations" | "products" | "pricelistsitems" | "pricelists" | "payments" | "ledger_payments" | "mslsales" | "mslproducts" | "measureunits" | "measureunitfamilies" | "invoicesitems" | "invoices" | "ledger_goods" | "fullinvoices" | "checks" | "clients" | "activities" | "bigReports" | "admins"; export type DocumentTypes = | "form" | "quickConvertToPdf" | "clients" | "asset" | "assetUnit" | "workorder" | "clientLocation" | "clientContact" | "commentsThread" | "workorderRequest" | "workorderPortal" | "invoice" | "products" | "productvariations" | "representatives" | "productcategories" | "productSubCategory" | "speciality" | "line" | "banner" | "intgAvailableApps" | "availability_msl" | "reminders" | "audits" | "availability" | "photos" | "planogram" | "tasks" | "checks" | "notificationsCenter" | "admins" | "settings" | "printWorkorderPortalLink" | "bulkExport" | "generateRule" | "scheduleEmail" | "custom-list-item" | "days" | "bulkImport" | "sv.activitiesstorechecks" | "retailExecutionPreset" | "paymentMethod" | "approvalRequest" | "activityFormV2Result" | "formV2" | "payments" | "ocrInvoiceJob" | "contract" | "contractInstallment" | "form" | "paymentMethod" | "aiObjectDetectionModelVersion" | "aiObjectDetectionTask" | "assetPart" | "assetPartReceival" | "assetPartUnit" | "returnAssetPartUnit" | "storeAssetPartUnit" | "activityAiSalesOrder" | "ocrInvoiceJobGroup"; export type PrintTypes = "workorder" | "form" | "invoice" | "proforma" | "settlement" | "formV2"; export type InvoiceFontStyles = | "InvoiceHeaderTitle" | "InvoiceTaxNumber" | "InvoiceType" | "InvoiceInfo" | "ItemsHeader" | "ItemLabel" | "ItemValue" | "ItemVariant" | "TotalItemsQty" | "TotalAmount" | "RepReciver" | "Address" | "PrintTime" | "InvoiceHeader" | "ClientBalance"; type Granularity = | "Year" | "Year Month" | "Year Week" | "Month" | "Year Month Day" | "Year Month Day Time" | "Year Month Day Time Offset"; export interface MediaDoc { _id?: string; media_id: string; media_type: | "csv" | "json" | "image" | "pdf" | "ppt" | "pptx" | "xls" | "xlsx" | "thumbnail" | "doc" | "docx" | "images" | "zip" | "pt"; mime_type: "image/jpeg" | string; ContentType: "image/jpeg" | string; file_name: string; width: number; height: number; company_namespace: string[]; ContentLength?: number; ETag?: string; Metadata?: {}; key: string; pathSuffix: string; pathPrefix: string; parentDocumentType?: DocumentTypes; parentDocumentId?: string; parentDocumentKey?: string; publicUrl: string; baseUrl: string; type_name: "FileAttachment" | "ImageAttachment"; thumbnails: thumbnailStoragePopulated; extension: string; bucket_name: string; region: string; time: number; } export interface GeoTag { lat: number; lng: number; formatted_address: string; } interface GeoPoint { type: "Point"; coordinates: [number, number]; } export namespace Service { export namespace Client { interface Financials { credit_limit?: number; } type JobType = 0 | 1 | 2 | 3 | 4 | 5 | 6; interface JobObject { type: JobType[]; description: string; tag: string; product_id?: string; form_id?: string; is_required?: boolean; category_id?: string; order?: number; company_namespace: string[]; } interface ShelfShareTarget { msl: string; contracted_checkout: number; contracted_shelf_length: number; total_category_length: number; } interface RepTarget { rep: string; target: number; classification: string; } interface Sales { name_on_invoice?: string; invoice_footer?: string; logo_media?: StringId; invoice_title?: string; invoice_local_title?: string; proforma_title?: string; proforma_local_title?: string; return_invoice_title?: string; return_invoice_local_title?: string; address_1?: string; address_2?: string; } export interface ClientSchema { _id: StringId; name: string; disabled: boolean; local_name?: string; tags?: StringId[]; cell_phone?: string; city?: string; client_code?: string; contact_name?: string; contact_title?: string; contacts?: StringId[]; country?: string; formatted_address?: string; lat?: number; lng?: number; location_verified?: boolean; phone?: string; state?: string; zip?: string; assigned_to: StringId[]; last_location_update?: number; // credit_limit?: number; tax_number?: string; sync_id?: string; rep_targets?: RepTarget[]; shelf_share_targets?: ShelfShareTarget[]; profile_pic?: string; logo?: string; website?: string; email?: string; comment?: string; parent_client_id?: string; target_visit?: number; geofencing_radius?: number; price_tag?: StringId; jobs?: JobObject[]; status?: StringId; job_category?: StringId[]; availability_msl?: StringId[]; assigned_msl?: StringId[]; territory?: StringId; sv_priceList?: StringId; assigned_media?: StringId[]; assigned_products?: StringId[]; assigned_product_groups?: StringId[]; verifiedUntil?: number; financials?: Financials; customFields?: { [key: string]: string | number | boolean | StringId }; paymentTerm?: StringId; speciality?: StringId[]; company_namespace: string[]; channel?: StringId; isChain?: boolean; chain?: StringId; teams?: StringId[]; payment_type: "cash" | "credit"; integration_meta?: { [key: string]: any }; integrated_client_balance?: number; invoice_balance_limit?: number; payment_terms_grace_period_days?: number; enable_invoice_balance_limit?: boolean; enable_payment_terms_grace_period_days?: boolean; enable_credit_limit_on_invoice?: boolean; enable_credit_limit_on_proforma?: boolean; enable_invoice_balance_limit_on_proforma?: boolean; enable_payment_terms_grace_period_days_on_proforma?: boolean; is_simplified?: boolean; last_login_time?: number; assigned_forms_v2_templates?: StringId[]; retail_execution_templates?: StringId[]; assigned_clm_presentations?: StringId[]; last_sales_invoice_time?: number; last_sales_proforma_time?: number; media?: StringId[]; cover_photo?: StringId; sales?: Sales; createdAt: string; updatedAt: string; __v: number; } export type Data = ClientSchema; export interface CreateBody { name?: string; local_name?: string; tags?: StringId[]; cell_phone?: string; city?: string; client_code?: string; contact_name?: string; contact_title?: string; contacts?: StringId[]; country?: string; disabled?: boolean; formatted_address?: string; lat?: number; lng?: number; location_verified?: boolean; phone?: string; state?: string; zip?: string; assigned_to?: StringId[]; last_location_update?: number; // credit_limit?: number; tax_number?: string; sync_id?: string; rep_targets?: RepTarget[]; shelf_share_targets?: ShelfShareTarget[]; profile_pic?: string; logo?: string; website?: string; email?: string; comment?: string; parent_client_id?: string; target_visit?: number; geofencing_radius?: number; price_tag?: StringId; jobs?: JobObject[]; status?: StringId; job_category?: StringId[]; availability_msl?: StringId[]; assigned_msl?: StringId[]; territory?: StringId; sv_priceList?: StringId; assigned_media?: StringId[]; assigned_products?: StringId[]; assigned_product_groups?: StringId[]; verifiedUntil?: number; financials?: Financials; customFields?: { [key: string]: string | number | boolean | StringId }; paymentTerm?: StringId; speciality?: StringId[]; company_namespace?: string[]; channel?: StringId; isChain?: boolean; chain?: StringId; teams?: StringId[]; payment_type?: "cash" | "credit"; integration_meta?: { [key: string]: any }; integrated_client_balance?: number; invoice_balance_limit?: number; payment_terms_grace_period_days?: number; enable_invoice_balance_limit?: boolean; enable_payment_terms_grace_period_days?: boolean; enable_credit_limit_on_invoice?: boolean; enable_credit_limit_on_proforma?: boolean; enable_invoice_balance_limit_on_proforma?: boolean; enable_payment_terms_grace_period_days_on_proforma?: boolean; is_simplified?: boolean; last_login_time?: number; assigned_forms_v2_templates?: StringId[]; retail_execution_templates?: StringId[]; assigned_clm_presentations?: StringId[]; last_sales_invoice_time?: number; last_sales_proforma_time?: number; media?: StringId[]; cover_photo?: StringId; sales?: Sales; } export type PopulatedKeys = | "tags" | "reps" | "assigned_to" | "sv_priceList" | "paymentTerm" | "job_category" | "msl" | "chain" | "channel" | "status" | "product" | "assigned_products" | "assigned_product_groups" | "speciality" | "teams" | "contacts" | "retail_execution_templates" | "assigned_forms_v2_templates" | "assigned_clm_presentations" | "media" | "cover_photo" | "sales.logo_media"; type ClientSchemaWithPopulatedKeys = ClientSchema & { assigned_products?: StringId[] | Pick[]; assigned_product_groups?: StringId | Pick[]; teams?: StringId[] | Pick[]; contacts?: StringId[] | ClientContact.ClientContactSchema[]; speciality?: StringId[] | Speciality.SpecialitySchema[]; assigned_to?: StringId[] | Pick[]; tags?: StringId[] | Tag.TagSchema[]; price_tag?: StringId | Tag.TagSchema; job_category?: StringId[] | JobCategory.JobCategorySchema[]; sv_priceList?: StringId | Pick[]; chain?: | StringId | Pick< Client.ClientSchema, "_id" | "name" | "client_code" | "local_name" >; channel?: StringId | Channel.ChannelSchema; assigned_forms_v2_templates?: StringId[] | Pick[]; assigned_clm_presentations?: StringId[] | Pick[]; retail_execution_templates?: StringId[] | Pick[]; media?: StringId[] | PopulatedMediaStorage[]; cover_photo?: StringId | PopulatedMediaStorage; paymentTerm?: | StringId | Pick; sales?: Sales & { logo_media?: StringId | MediaPopulated }; // availability_msl?: StringId[] | AvailabilityMsl.AvailabilityMslSchema[]; assigned_msl?: StringId[] | Pick[]; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; createdAt?: number; updatedAt?: number; name?: string[] | string; search?: string; disabled?: boolean; active?: boolean; tags?: string[] | string; _id?: string[] | string; assigned_to?: string[] | string; availability_msl?: StringId[] | StringId; assigned_msl?: StringId[] | StringId; status?: string[] | string; CLIENT_TAGS?: string[] | string; AREA_TAGS?: string[] | string; isChain?: boolean; chain?: string[] | string; channel?: string[] | string; city?: string[] | string; client_code?: string[] | string; country?: string[] | string; location_verified?: boolean; state?: string[] | string; sv_priceList?: string[] | string; assigned_media?: string[] | string; assigned_products?: string[] | string; teams?: string[] | string; integrated_client_balance?: number[] | number; tax_number?: string[] | string; speciality?: string[] | string; assigned_product_groups?: string[] | string; populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; customFields?: Record; assigned_clm_presentations?: string[] | string; integration_meta?: Record; // Index signatures for dynamic keys // [key: `integration_meta.${string}`]: any; // [key: `customFields.${string}`]: any; [key: string]: any; }; export interface Result extends DefaultPaginationResult { data: ClientSchemaWithPopulatedKeys[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = ClientSchemaWithPopulatedKeys; } export namespace Create { export interface Body extends CreateBody { name: string; } export type Result = ClientSchema; } export namespace Update { export type ID = string; export interface Body extends CreateBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; /** * @type {any} with dynamic keys supporting integration_meta. and customFields. */ // [key: string]: any; // integration_meta & customFields. customFields?: Record; integration_meta?: Record; [key: `integration_meta.${string}`]: any; [key: `customFields.${string}`]: any; } export type Result = ClientSchema; } export namespace Remove { export type ID = string; export type Result = ClientSchema; } } export namespace RepBalanceSummary { export interface RepBalanceSummarySchema { _id: string; rep: string; rep_name: string; total_outstanding_balance_of_invoices_created_by_rep: number; } export namespace Find { export type Params = DefaultPaginationQueryParams & { rep: string; }; export interface Result extends DefaultPaginationResult { data: RepBalanceSummarySchema[]; totals: { total_balances: number; }; } } } export namespace Product { export interface ProductSchema { _id: string; name: string; category: string; active: boolean; company_namespace: string[]; local_name?: string; sku?: string; sub_category?: string[]; assigned_to?: string[]; auditable?: boolean; barcode?: string; sv_tax?: string; sv_measureUnit?: string; description?: string; local_description?: string; product_img?: string; base_price?: string; assigned_media?: string[]; html_description?: string; modifiers_group?: string[]; featured?: boolean; brand?: string; rsp?: number; measureunit_family?: string; integration_meta?: { [key: string]: any }; teams?: string[]; position?: number; product_groups?: string[]; frozen_pre_sales?: boolean; frozen_sales?: boolean; createdAt: string; updatedAt: string; __v: number; } export type Data = ProductSchema; interface ProductBody { name?: string; category?: string; active?: boolean; company_namespace?: string[]; local_name?: string; sku?: string; sub_category?: string[]; assigned_to?: string[]; auditable?: boolean; barcode?: string; sv_tax?: string; sv_measureUnit?: string; description?: string; local_description?: string; product_img?: string; base_price?: string; assigned_media?: string[]; html_description?: string; modifiers_group?: string[]; featured?: boolean; brand?: string; rsp?: number; measureunit_family?: string; integration_meta?: { [key: string]: any }; teams?: string[]; position?: number; product_groups?: string[]; frozen_pre_sales?: boolean; frozen_sales?: boolean; variants?: (Variant.VariantBody & { name: string; product?: string; price: number; _id?: string; createdAt?: string; updatedAt?: string; __v?: number; })[]; } type ProductWithPopulatedKeys = ProductSchema & { category: string | Category.CategorySchema; sub_category?: string[] | SubCategory.SubCategorySchema[]; sv_tax?: string | Tax.TaxSchema | Pick; tax?: string | Tax.TaxSchema; sv_measureUnit?: | string | MeasureUnit.MeasureUnitSchema | Pick; brand?: string | Brand.BrandSchema; measureunit_family?: string | MeasureUnitFamily.MeasureUnitFamilySchema; product_groups?: string[] | Pick[]; variants?: Variant.VariantSchema[]; defaultVariant?: Variant.VariantSchema; assigned_media?: string | Media.MediaSchema; teams?: string[] | Team.TeamSchema[]; }; type PopulatedKeys = | "category" | "sub_category" | "tax" | "sv_tax" | "media" | "measureunit_family" | "measureunit" | "sv_measureUnit" | "brand" | "product_groups" | "teams" | "measureunit_family_with_measureunit"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys[]; _id?: string[] | string; category?: string[] | string; sub_category?: string[] | string; name?: string[] | string; search?: string; active?: boolean; disabled?: boolean; sv_measureUnit?: string[] | string; base_price?: number[] | number; assigned_media?: string[] | string; modifiers_group?: string[] | string; brand?: string[] | string; rsp?: number[] | number; measureunit_family?: string[] | string; teams?: string[] | string; position?: number[] | number; product_groups?: string[] | string; sv_tax?: string[] | string; createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; barcode?: string[] | string; sku?: string[] | string; local_name?: string[] | string; frozen_pre_sales?: boolean; frozen_sales?: boolean; withMedia?: boolean; withDefaultVariant?: boolean; withVariants?: boolean; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: ProductWithPopulatedKeys[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; withVariants?: boolean; } export type Result = ProductWithPopulatedKeys; } export namespace Create { export interface Body extends ProductBody { name: string; category: string; } export type Result = ProductSchema; } export namespace Update { export type ID = string; export interface Body extends ProductBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = ProductSchema; } export namespace Remove { export type ID = string; export type Result = ProductSchema; } } export namespace Variant { export interface VariantSchema { _id: string; name: string; product: string | Product.ProductSchema; price: number; company_namespace: string[]; disabled?: boolean; uuid?: string; local_name?: string; sku?: string; barcode?: string; weight?: number; length?: number; width?: number; height?: number; position?: number; default?: boolean; variant_img?: string; modifiers_groups?: string[]; integration_meta?: { [key: string]: any }; createdAt: string; updatedAt: string; __v: number; } export type Data = VariantSchema; export interface VariantBody { name?: string; product?: string; price?: number; company_namespace?: string[]; disabled?: boolean; uuid?: string; local_name?: string; sku?: string; barcode?: string; weight?: number; length?: number; width?: number; height?: number; position?: number; default?: boolean; variant_img?: string; modifiers_groups?: string[]; integration_meta?: { [key: string]: any }; } type PopulatedKeys = "product" | "modifiers_groups"; type VariantWithPopulatedKeys = VariantSchema & { modifiers_groups?: string[] | ProductModifiersGroup.ProductModifiersGroupSchema[]; product?: string | Product.ProductSchema; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; product?: string[] | string; barcode?: string[] | string; sku?: string[] | string; price?: number[] | number; position?: number[] | number; createdAt?: number; updatedAt?: number; from_updatedAt?: number; from__id?: string; to__id?: string; default?: boolean; category?: string[] | string; subCategory?: string[] | string; brand?: string[] | string; productGroup?: string[] | string; teams?: string[] | string; withProduct?: boolean; withDisabled?: boolean; populatedKeys?: PopulatedKeys[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: VariantWithPopulatedKeys[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = VariantSchema; } export namespace Create { export interface Body extends VariantBody { name: string; product: string; price: number; } export type Result = VariantSchema; } export namespace Update { export type ID = string; export interface Body extends VariantBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = VariantSchema; } export namespace Remove { export type ID = string; export type Result = VariantSchema; } } export namespace Category { export interface CategorySchema { _id: string; type?: "main"; name: string; photo?: string; local_name?: string; icon?: string; disabled?: boolean; position?: number; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface CategoryBody { name?: string; company_namespace?: string[]; type?: "main"; disabled?: boolean; photo?: string; local_name?: string; icon?: string; position?: number; integration_meta?: { [key: string]: any }; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; position?: number[] | number; createdAt?: number; updatedAt?: number; from_updatedAt?: number; withProduct?: boolean; hasSubCategory?: boolean; isLeaf?: boolean; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: (CategorySchema & { hasSubCategory?: boolean; isLeaf?: boolean; })[]; } } export namespace Get { export type ID = string; export type Result = CategorySchema; } export namespace Create { export interface Body extends CategoryBody { name: string; } export type Result = CategorySchema; } export namespace Update { export type ID = string; export interface Body extends CategoryBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = CategorySchema; } export namespace Remove { export type ID = string; export type Result = CategorySchema; } } export namespace Brand { export interface BrandSchema { _id: string; name: string; local_name?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface BrandBody { name?: string; company_namespace?: string[]; disabled?: boolean; local_name?: string; integration_meta?: { [key: string]: any }; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; from_updatedAt?: number; createdAt?: number; updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: BrandSchema[]; } } export namespace Get { export type ID = string; export type Result = BrandSchema; } export namespace Create { export interface Body extends BrandBody { name: string; } export type Result = BrandSchema; } export namespace Update { export type ID = string; export interface Body extends BrandBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = BrandSchema; } export namespace Remove { export type ID = string; export type Result = BrandSchema; } } export namespace SubCategory { export interface SubCategorySchema { _id: string; name: string; parent_id: string | Pick; local_name?: string; disabled?: boolean; photo?: string; position?: number; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface SubCategoryBody { name?: string; company_namespace?: string[]; disabled?: boolean; local_name?: string; photo?: string; position?: number; parent_id?: string; integration_meta?: { [key: string]: any }; } type PopulatedKeys = "parent_id"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys[]; _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; parent_id?: string[] | string; disabled?: boolean; position?: number | number[]; from_updatedAt?: number; createdAt?: number; updatedAt?: number; withProduct?: boolean; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: SubCategorySchema[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = SubCategorySchema; } export namespace Create { export interface Body extends SubCategoryBody { name: string; parent_id: string; } export type Result = SubCategorySchema; } export namespace Update { export type ID = string; export interface Body extends SubCategoryBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = SubCategorySchema; } export namespace Remove { export type ID = string; export type Result = SubCategorySchema; } } export namespace ProductGroup { export interface ProductGroupSchema { _id: string; name: string; local_name?: string; disabled?: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface ProductGroupBody { name?: string; company_namespace?: string[]; disabled?: boolean; local_name?: string; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; createdAt?: number; updatedAt?: number; }; export interface Result extends DefaultPaginationResult { data: ProductGroupSchema[]; } } export namespace Get { export type ID = string; export type Result = ProductGroupSchema; } export namespace Create { export interface Body extends ProductGroupBody { name: string; } export type Result = ProductGroupSchema; } export namespace Update { export type ID = string; export interface Body extends ProductGroupBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = ProductGroupSchema; } export namespace Remove { export type ID = string; export type Result = ProductGroupSchema; } } export namespace Tax { type TaxType = "inclusive" | "additive"; export interface TaxSchema { _id: string; name: string; rate: number; type: TaxType; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface TaxBody { name?: string; rate?: number; type?: TaxType; company_namespace?: string[]; disabled?: boolean; integration_meta?: { [key: string]: any }; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; rate?: number | number[]; type?: TaxType | TaxType[]; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: TaxSchema[]; } } export namespace Get { export type ID = string; export type Result = TaxSchema; } export namespace Create { export interface Body extends TaxBody { name: string; rate: number; type: TaxType; } export type Result = TaxSchema; } export namespace Update { export type ID = string; export interface Body extends TaxBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = TaxSchema; } export namespace Remove { export type ID = string; export type Result = TaxSchema; } } export namespace MeasureUnit { export interface MeasureUnitSchema { _id: StringId; name: string; factor: number; local_name?: string; parent?: StringId; disabled?: boolean; integration_meta?: { [key: string]: any }; aliases: string[]; sellable: boolean; returnable: boolean; loadable: boolean; unloadable: boolean; receivable: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface MeasureUnitBody { name?: string; factor: number; local_name?: string; parent?: StringId; aliases?: string[]; sellable?: boolean; returnable?: boolean; loadable?: boolean; unloadable?: boolean; receivable?: boolean; company_namespace?: string[]; disabled?: boolean; integration_meta?: { [key: string]: any }; } export type UpdateBody = Partial; export type Data = MeasureUnitSchema; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; factor?: number | number[]; parent?: "nil"; disabled?: boolean; from_updatedAt?: number; family_name?: string[] | string; withFamily?: boolean; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; sellable?: boolean | boolean[]; returnable?: boolean | boolean[]; loadable?: boolean | boolean[]; unloadable?: boolean | boolean[]; receivable?: boolean | boolean[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: (MeasureUnitSchema & { family?: MeasureUnitFamily.MeasureUnitFamilySchema[]; })[]; } } export namespace Get { export type ID = string; export type Result = MeasureUnitSchema; } export namespace Create { export interface Body extends MeasureUnitBody { name: string; } export type Result = MeasureUnitSchema; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = MeasureUnitSchema; } } export namespace MeasureUnitFamily { export interface MeasureUnitFamilySchema { _id: string; name: string; local_name?: string; measureunits: | string[] | Pick[]; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface MeasureUnitFamilyBody { name?: string; local_name?: string; measureunits?: string[]; company_namespace?: string[]; disabled?: boolean; integration_meta?: { [key: string]: any }; } type PopulatedKeys = "measureunits"; type MeasureUnitFamilySchemaWithPopulatedKeys = MeasureUnitFamilySchema & { measureunits_populated?: string[] | MeasureUnit.MeasureUnitSchema[]; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; from_updatedAt?: number; measureunits?: string[] | string; populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: MeasureUnitFamilySchemaWithPopulatedKeys[]; } } export namespace Get { export type ID = string; export type Result = MeasureUnitFamilySchema; } export namespace Create { export interface Body extends MeasureUnitFamilyBody { name: string; } export type Result = MeasureUnitFamilySchema; } export namespace Update { export type ID = string; export interface Body extends MeasureUnitFamilyBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = MeasureUnitFamilySchema; } export namespace Remove { export type ID = string; export type Result = MeasureUnitFamilySchema; } } export namespace Media { type MediaType = "ppt" | "pptx" | "pdf" | "jpeg" | "jpg" | "png" | "doc" | "docx"; export interface MediaSchema { _id: string; name: string; type: MediaType; url: string; creator: AdminCreator | RepCreator; caption?: string; disabled?: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface MediaBody { name?: string; type?: MediaType; url?: string[]; caption?: string; company_namespace?: string[]; disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; "creator._id"?: string[] | string; caption?: string[] | string; url?: string[] | string; type?: MediaType[] | MediaType; disabled?: boolean; repID?: string[] | string; }; export interface Result extends DefaultPaginationResult { data: MediaSchema[]; } } export namespace Get { export type ID = string; export type Result = MediaSchema; } export namespace Create { export interface Body extends MediaBody { name: string; } export type Result = MediaSchema; } export namespace Update { export type ID = string; export interface Body extends MediaBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = MediaSchema; } export namespace Remove { export type ID = string; export type Result = string; } } export namespace PriceList { interface creator { _id: string; name: string; } export interface PriceListSchema { _id: string; name: string; createdby: creator; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface PriceListBody { name?: string; integration_meta?: { [key: string]: any }; disabled?: boolean; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; "createdby._id"?: string[] | string; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: PriceListSchema[]; } } export namespace Get { export type ID = string; export type Result = PriceListSchema; } export namespace Create { export interface Body extends PriceListBody { name: string; } export type Result = PriceListSchema; } export namespace Update { export type ID = string; export interface Body extends PriceListBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = PriceListSchema; } export namespace Remove { export type ID = string; export type Result = PriceListSchema; } } export namespace PriceListItem { export interface PriceListItemSchema { _id: string; product_id: string; variant_id: string; pricelist_id: string; price: number; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface PriceListItemBody { product_id?: string; variant_id?: string; pricelist_id?: string; price?: number; integration_meta?: { [key: string]: any }; disabled?: boolean; company_namespace?: string[]; } type PopulatedKeys = "product" | "variant" | "pricelist"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; product_id?: string[] | string; variant_id?: string[] | string; pricelist_id?: string[] | string; disabled?: boolean; from_updatedAt?: number; populatedKeys?: PopulatedKeys[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: (PriceListItemSchema & { product_id: string | Product.ProductSchema; variant_id: string | Variant.VariantSchema; pricelist_id: string | PriceList.PriceListSchema; })[]; } } export namespace Get { export type ID = string; export type Result = PriceListItemSchema; } export namespace Create { export interface Body extends PriceListItemBody { product_id: string; variant_id: string; pricelist_id: string; price: number; } export type Result = PriceListItemSchema; } export namespace Update { export type ID = string; export interface Body extends PriceListItemBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = PriceListItemSchema; } export namespace Remove { export type ID = string; export type Result = PriceListItemSchema; } } export namespace MediaStorage { type MediaType = | "html" | "csv" | "json" | "image" | "pdf" | "ppt" | "pptx" | "xls" | "xlsx" | "doc" | "docx" | "images" | "zip" | "pt"; type ParentDocumentType = | "clients" | "asset" | "assetUnit" | "workorder" | "clientLocation" | "clientContact" | "commentsThread" | "workorderRequest" | "workorderPortal" | "invoice" | "products" | "productvariations" | "representatives" | "productcategories" | "productSubCategory" | "speciality" | "line" | "banner" | "intgAvailableApps" | "availability_msl" | "reminders" | "audits" | "availability" | "photos" | "planogram" | "tasks" | "checks" | "notificationsCenter" | "admins" | "settings" | "printWorkorderPortalLink" | "bulkExport" | "generateRule" | "scheduleEmail" | "custom-list-item" | "days" | "bulkImport" | "sv.activitiesstorechecks" | "retailExecutionPreset" | "quickConvertToPdf" | "proforma" | "approvalRequest" | "activityFormV2Result" | "formV2" | "payments" | "ocrInvoiceJob" | "contract" | "contractInstallment" | "form" | "paymentMethod" | "aiObjectDetectionModelVersion" | "aiObjectDetectionTask" | "assetPart" | "assetPartReceival" | "assetPartUnit" | "returnAssetPartUnit" | "storeAssetPartUnit"; type SourceEnums = | "product" | "variant" | "product-category" | "product-sub-category" | "product-brand" | "product-group"; export interface MediaStorageSchema { _id: string; ContentLength?: number; ETag?: string; ContentType?: string; media_type?: MediaType; Metadata?: any; key?: string; pathSuffix?: string; pathPrefix?: string; file_name: string; parentDocumentType: ParentDocumentType; parentDocumentId?: string; parentDocumentKey?: string; parentDocumentKeyisArray?: boolean; mime_type?: string; publicUrl?: string; media_id: string; baseUrl?: string; type_name: "FileAttachment" | "ImageAttachment"; width?: number; height?: number; thumbnails: string[]; extension: string; bucket_name?: string; region?: string; retail_execution_source_type?: SourceEnums; retail_execution_source_id?: string; retail_execution_source_name?: string; time?: number; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface Thumbnail { _id: StringId; ContentLength?: number; ETag?: string; ContentType?: string; Metadata?: { [key: string]: any }; key?: string; file_name: string; mime_type?: string; publicUrl?: string; type_name?: "FileAttachment" | "ImageAttachment"; width?: number; height?: number; extension?: string; bucket_name?: string; region?: string; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { ContentLength?: number; ETag?: string; ContentType?: string; media_type?: MediaType; Metadata?: any; key?: string; pathSuffix?: string; pathPrefix?: string; file_name: string; parentDocumentType: ParentDocumentType; parentDocumentId?: string; parentDocumentKey?: string; parentDocumentKeyisArray?: boolean; mime_type?: string; publicUrl?: string; media_id: string; baseUrl?: string; type_name: "FileAttachment" | "ImageAttachment"; width?: number; height?: number; thumbnails: string[]; extension: string; bucket_name?: string; region?: string; retail_execution_source_type?: SourceEnums; retail_execution_source_id?: string; retail_execution_source_name?: string; time?: number; company_namespace: string[]; } export interface UpdateBody { _id?: string; ContentLength?: number; ETag?: string; ContentType?: string; media_type?: MediaType; Metadata?: any; key?: string; pathSuffix?: string; pathPrefix?: string; file_name?: string; parentDocumentType?: ParentDocumentType; parentDocumentId?: string; parentDocumentKey?: string; parentDocumentKeyisArray?: boolean; mime_type?: string; publicUrl?: string; media_id: string; baseUrl?: string; type_name?: "FileAttachment" | "ImageAttachment"; width?: number; height?: number; thumbnails?: string[]; extension?: string; bucket_name?: string; region?: string; retail_execution_source_type?: SourceEnums; retail_execution_source_id?: string; retail_execution_source_name?: string; time?: number; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; key?: string; from_updatedAt?: number; from__id?: string; to__id?: string; from_time?: number; to_time?: number; parentDocumentId?: string[] | string; type_name?: "FileAttachment" | "ImageAttachment"; media_type?: MediaType | MediaType[]; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: MediaStorageSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = MediaStorageSchema; } export namespace Create { export type Body = CreateBody; export type Result = MediaStorageSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = MediaStorageSchema; } export namespace Remove { export type ID = string; export type Result = MediaStorageSchema; } } export namespace StorecheckTemplate { type SourceType = | "product" | "variant" | "product-category" | "product-sub-category" | "product-brand" | "product-group"; type DataType = | "Separator" | "timestamp" | "String" | "Number" | "Boolean" | "Date" | "Image" | "coords" | "Text" | "Media" | "Heading" | "List" | "Phone" | "Email" | "Signature" | "DateTime" | "YesNo" | "ProductBarcodeScan" | "BarcodeScan" | "GeoPoint"; interface UsedField { code: string; key: string; data_type: DataType; field_type: "template_field" | "source_attribute" | "activity_attribute"; label: string; isArray?: boolean; formula_key: string; field_id?: string; example_value: DataType; manipulator_function?: string; lookup?: { from?: string; localField?: string; foreignField?: string; as?: string; select?: string; unwind?: boolean; filter?: { input?: string; as: string; cond: any; }; }; } interface Field { _id?: string; name: string; local_name?: string; description?: string; local_description?: string; type: FieldType; isArray?: boolean; isRequired?: boolean; readOnly?: boolean; presets?: any[]; previous_entry?: any; show_previous_result?: boolean; hidden?: boolean; force_live_photo?: boolean; custom_list?: string; custom_list_element?: string; parent_field?: string; invisible?: boolean; display_on_home_screen?: boolean; custom_list_end_point?: { [key: string]: any }; visibility?: { operator: "and" | "or"; conditions: { field_id: string; type: "Boolean" | "List"; // FieldType; custom_list?: string; operator: "lte" | "lt" | "gte" | "gt" | "eq" | "ne" | "in" | "nin"; value: any[]; }[]; }; barcode_scan?: boolean; is_calculated_field?: boolean; formula?: string; formula_key: string; used_fields?: UsedField[]; } interface Entry { _id?: string; repeatable: boolean; grouping: "product-category" | "product-brand" | "product-group"; require_all_source_elements: boolean; require_group_source_elements: boolean; source: SourceType; filters: string[]; fields: Field[]; } export interface StorecheckTemplateSchema { _id: string; name: string; local_name?: string; description?: string; local_description?: string; disabled: boolean; entries: Entry[]; company_namespace: string[]; can_edit_types?: boolean; copied_from?: string; client_specific_sources: boolean; previous_result_activated: boolean; presets_activated: boolean; apply_preset_to_all_sources: boolean; intersect_in_product_group_level: boolean; createdAt?: string; updatedAt?: string; __v?: number; } export interface CreateBody { name: string; local_name?: string; description?: string; local_description?: string; disabled: boolean; company_namespace: string[]; can_edit_types?: boolean; copied_from?: string; client_specific_sources: boolean; previous_result_activated: boolean; presets_activated: boolean; apply_preset_to_all_sources: boolean; intersect_in_product_group_level?: boolean; } export interface UpdateBody { _id?: string; name?: string; local_name?: string; description?: string; local_description?: string; disabled?: boolean; company_namespace?: string[]; can_edit_types?: boolean; copied_from?: string; client_specific_sources?: boolean; previous_result_activated?: boolean; presets_activated?: boolean; apply_preset_to_all_sources: boolean; intersect_in_product_group_level?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; key?: string; name?: string; local_name?: string; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: StorecheckTemplateSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = StorecheckTemplateSchema; } export namespace Create { export type Body = CreateBody; export type Result = StorecheckTemplateSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = StorecheckTemplateSchema; } export namespace Remove { export type ID = string; export type Result = StorecheckTemplateSchema; } } export namespace ActivityStorecheck { export interface Field { _id?: string; name: string; type: FieldType; isArray: boolean; isRequired?: boolean; is_calculated_field?: boolean; formula_key?: string; parent_field?: string; custom_list?: string; field_id: string; result: any[]; result_custom_list_ids?: any[]; calculation_status?: "success" | "failed"; calculation_error?: string | any[]; company_namespace?: string[]; } export interface Division { fields: Field[]; } export interface Result { source_id: string; source_name: string; injected_by_system?: boolean; divisions: Division[]; } export interface Entry { entry_id: string; source: | "product" | "variant" | "product-category" | "product-sub-category" | "product-brand" | "product-group"; results: Result[]; } export interface ActivityStorecheckSchema { _id: string; company_namespace: string[]; client: string; client_name: string; sync_id: string; time_zone: string; template_id: string; visit?: string; visit_id: string; battery_level?: number; user: string; user_name: string; time: number; geo_tag?: GeoTag; geoPoint: GeoPoint; teams?: string[]; route?: string; tags?: string[]; entries: Entry[]; platform?: string; version_name?: string; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; serial_number?: SerialNumber; job_start_time?: number; job_end_time?: number; job_duration?: number; createdAt: string; updatedAt: string; } export interface CreateBody { company_namespace: string[]; client: string; client_name: string; time_zone: string; template_id: string; visit?: string; visit_id: string; user: string; user_name: string; time: number; geo_tag?: GeoTag; geoPoint: GeoPoint; teams?: string[]; route?: string; tags?: string[]; entries: Entry[]; } export interface UpdateBody { _id?: string; company_namespace?: string[]; client?: string; client_name?: string; sync_id?: string; time_zone?: string; template_id?: string; visit?: string; visit_id?: string; battery_level?: number; user?: string; user_name?: string; time?: number; geo_tag?: GeoTag; geoPoint?: GeoPoint; teams?: string[]; route?: string; tags?: string[]; entries?: Entry[]; platform?: string; version_name?: string; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; serial_number?: SerialNumber; job_start_time?: number; job_end_time?: number; job_duration?: number; } export type PopulatedKeys = "teams" | "tags" | "client" | "user" | "route" | "visit" | "template_id"; export type ActivityStoreCheckWithPopulatedKeysSchema = ActivityStorecheckSchema & { teams_populated: Team.TeamSchema[] | string[]; tags_populated: Tag.TagSchema[] | string[]; client_populated: Client.ClientSchema | string; user_populated: Rep.RepSchema | string; route_populated: Route.RouteSchema | string; visit_populated: Visit.VisitSchema | string; template_id_populated: StorecheckTemplate.StorecheckTemplateSchema | string; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; from_updatedAt?: number; from_time?: number; to_time?: number; client?: string; user?: string; tags?: string[]; template_id?: string; teams?: string[]; route?: string; populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; }; export interface Result extends DefaultPaginationResult { data: ActivityStoreCheckWithPopulatedKeysSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = ActivityStorecheckSchema; } export namespace Create { export type Body = CreateBody; export type Result = ActivityStorecheckSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = ActivityStorecheckSchema; } } export namespace Msl { export interface MslSchema { _id: string; name: string; disabled: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; } export type Data = MslSchema; export interface CreateBody { name: string; disabled: boolean; company_namespace: string[]; } export interface UpdateBody { _id?: string; name?: string; disabled?: boolean; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; disabled?: boolean; name?: string; search?: string; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: MslSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = MslSchema; } export namespace Create { export type Body = CreateBody; export type Result = MslSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = MslSchema; } export namespace Remove { export type ID = string; export type Result = MslSchema; } } export namespace MslProduct { export interface MslProductSchema { _id: string; msl_id: string; variant_id: string; product_id: string; min_qty?: number; max_qty?: number; force_min?: boolean; force_max?: boolean; disabled: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { msl_id: string; variant_id: string; product_id: string; min_qty?: number; max_qty?: number; force_min?: boolean; force_max?: boolean; disabled: boolean; company_namespace: string[]; } export interface UpdateBody { _id?: string; msl_id?: string; variant_id?: string; product_id?: string; min_qty?: number; max_qty?: number; force_min?: boolean; force_max?: boolean; disabled?: boolean; company_namespace?: string[]; } type PopulatedKeys = "product" | "variant" | "msl"; export type MslProductWithPopulatedKeysSchema = MslProductSchema & { product_id: string | Product.ProductSchema; variant_id: string | Variant.VariantSchema; msl_id: string | Msl.MslSchema; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; disabled?: boolean; product_id?: string; variant_id?: string; msl_id?: string; from_updatedAt?: number; to_updatedAt?: number; populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: MslProductWithPopulatedKeysSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = MslProductSchema; } export namespace Create { export type Body = CreateBody; export type Result = MslProductSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = MslProductSchema; } export namespace Remove { export type ID = string; export type Result = MslProductSchema; } } export namespace Team { export interface TeamSchema { _id: string; name: string; disabled?: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export type Data = TeamSchema; export interface TeamBody { name?: string; company_namespace?: string[]; disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: TeamSchema[]; } } export namespace Get { export type ID = string; export type Result = TeamSchema & { admins: any; // Admin.Schema reps: any; // Rep.Schema }; } export namespace Create { export interface Body extends TeamBody { name: string; } export type Result = TeamSchema; } export namespace Update { export type ID = string; export interface Body extends TeamBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = TeamSchema; } export namespace Remove { export type ID = string; export type Result = TeamSchema; } } export namespace GeoZone { export interface Polygon { type: "Polygon"; coordinates: [number, number][][]; } export interface AssignedRep { _id: StringId; name: string; } export interface Data { _id: StringId; name: string; description?: string; polygon: Polygon; disabled: boolean; editor: AdminOrRepOrTenantOrClient; assigned_reps?: AssignedRep[]; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface CreateBody { name: string; description?: string; polygon: Polygon; company_namespace?: string[]; } export interface UpdateBody { name?: string; description?: string; polygon?: Polygon; disabled?: boolean; editor?: AdminOrRepOrTenantOrClient; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; search?: string; disabled?: boolean; inject_assigned_reps?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Params = { inject_assigned_reps?: boolean; }; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace Rep { interface RepPermissions { rep_can_print_payment_after_allowance_period?: boolean; rep_can_add_client: boolean; rep_can_edit_client: boolean; rep_can_add_calendar: boolean; rep_can_edit_calendar: boolean; rep_can_edit_others_calendar: boolean; rep_can_skip_photo_tag: boolean; rep_can_edit_product_price?: boolean; rep_must_add_client_with_location?: boolean; rep_can_access_shared_history?: boolean; rep_can_edit_total_shelf_share?: boolean; rep_can_create_transfer?: boolean; rep_can_make_call?: boolean; rep_can_read_stock?: boolean; can_rep_pay_other_reps_invoices?: boolean; rep_can_create_sales_order?: boolean; rep_can_create_invoice?: boolean; rep_can_create_transfer_load?: boolean; rep_can_create_transfer_unload?: boolean; rep_can_create_return_invoice?: boolean; rep_can_create_partial_return_invoice?: boolean; rep_can_sell_zero_product_price?: boolean; rep_can_create_sales_order_out_of_visit?: boolean; rep_can_create_return_out_of_visit?: boolean; rep_can_create_partial_return_out_of_visit?: boolean; rep_can_skip_return_reason?: boolean; rep_can_create_invoice_out_of_visit?: boolean; rep_can_create_free_payments?: boolean; rep_can_partially_pay_invoice?: boolean; auto_close_visit_when_out_of_geo_fence?: boolean; end_visit_when_low_accuracy?: boolean; rep_can_create_cash_invoice?: boolean; rep_can_sell_above_product_price?: boolean; rep_can_sell_below_product_price?: boolean; rep_can_create_workorder?: boolean; rep_can_create_asset?: boolean; rep_can_skip_promotions?: boolean; rep_can_skip_item_status_feedback?: boolean; rep_can_skip_item_status_note?: boolean; rep_can_skip_item_status_type?: boolean; rep_can_end_visit_without_submitting_item_status?: boolean; rep_can_submit_multiple_item_status_products?: boolean; rep_can_edit_return_product_price?: boolean; rep_can_overwrite_partial_return_invoice_price?: boolean; rep_can_edit_invoice_discount?: boolean; rep_can_edit_sales_order_discount?: boolean; rep_can_skip_cart_calculation_until_checkout?: boolean; rep_can_start_day_without_gps_signal?: boolean; rep_can_start_day_with_outstanding_settlement_balance?: boolean; rep_can_create_add_client_approval_request?: boolean; rep_can_create_edit_client_details_approval_request?: boolean; rep_can_create_edit_client_assigned_to_approval_request?: boolean; rep_can_create_edit_client_location_approval_request?: boolean; rep_can_create_delete_client_approval_request?: boolean; rep_can_create_skip_job_at_visit_end_approval_request?: boolean; rep_can_create_skip_geofence_at_visit_end_approval_request?: boolean; rep_can_view_client_credit_limit?: boolean; rep_can_create_edit_client_credit_limit_approval_request?: boolean; rep_can_assign_workorder?: boolean; rep_can_create_credit_invoice_for_cash_client?: boolean; rep_can_visit_outside_route?: boolean; rep_can_edit_retail_execution_entry?: boolean; rep_can_edit_form_entry?: boolean; rep_can_skip_visit_from_route_sequence?: boolean; rep_can_create_return_sales_order?: boolean; rep_can_edit_sales_order_custom_status?: boolean; rep_can_edit_invoice_custom_status?: boolean; rep_to_create_invoice_variant_batch_from_assigned_warehouse?: boolean; rep_to_create_sales_order_variant_batch_assigned_main_warehouse?: boolean; rep_can_create_pull_from_client_assigned_to_approval_request?: boolean; rep_can_create_payment?: boolean; rep_can_print_offline_invoice?: boolean; rep_can_print_offline_sales_order?: boolean; rep_can_skip_exp_date_in_audit_stock?: boolean; rep_must_start_day_within_specific_time_frame: boolean; rep_can_skip_assigned_client_filter_on_workorder_assigned_to?: boolean; rep_can_assign_client_to_other_reps?: boolean; rep_must_enter_sales_order_external_serial_number?: boolean; rep_must_enter_invoice_external_serial_number?: boolean; rep_can_create_negative_invoices?: boolean; rep_must_end_day_after_specific_time: boolean; rep_can_upload_media_on_payment?: boolean; rep_can_access_sales_reports?: boolean; rep_must_add_delivery_date_on_sales_order?: boolean; rep_must_add_delivery_date_on_invoice?: boolean; rep_can_view_stock_on_transfers?: boolean; rep_must_invoice_items_from_cross_inventory_and_msl?: boolean; rep_can_create_client_line_approval_request?: boolean; rep_can_enter_client_code_at_create_client?: boolean; rep_can_edit_client_location_at_create_client?: boolean; rep_can_start_visit_out_of_geofence?: boolean; rep_can_create_approval_request_to_start_visit_out_of_geofence?: boolean; rep_must_start_day_within_shift_window: boolean; rep_must_end_day_within_shift_window: boolean; rep_can_start_day_on_non_working_day?: boolean; } interface TargetResults { totalPoints: number; targetsCount: number; totalAchievements: number; averageAchievements: number; pointsCap: number; } interface RepSettings { allowable_accuracy?: number; is_item_status_per_visit_limited?: boolean; item_status_per_visit_limit?: number; location_permission?: "always_allow" | "while_using"; activities_report_scope?: "self" | "team" | "company_namespace"; maximum_cash_outstanding_settlement_balance_to_start_day?: number; maximum_check_outstanding_settlement_balance_to_start_day?: number; maximum_total_outstanding_settlement_balance_to_start_day?: number; watermark_client_name?: boolean; watermark_time?: boolean; watermark_date?: boolean; watermark_coordinates?: boolean; watermark_font_size?: number; rep_must_end_day_after: `${number}:${number}`; treating_invoice_as_proforma_for_etax?: boolean; disable_auto_timezone_enforcement?: boolean; disable_auto_time_date_enforcement?: boolean; start_day_specific_time_frame_start: `${number}:${number}`; start_day_specific_time_frame_end: `${number}:${number}`; start_day_minutes_before_shift_start?: number; start_day_minutes_after_shift_start?: number; end_day_minutes_before_shift_end?: number; } type JobOption = 0 | 1 | 2; export interface RepSchema { _id: string; username: string; name: string; password: string; device_id?: string; linked_to_device?: boolean; live_location?: boolean; phone?: string; email?: string; integration_id?: string; permissions: RepPermissions; preferences: { isLightModeEnabled?: boolean; }; profile_pic?: string; teams?: string[]; identifier?: number; notification_id?: string; monthly_sales_target?: number; daily_target_visit?: number; sales_type?: 1 | 2; job_option?: JobOption; msl_sales?: string[]; job_category?: string[]; assigned_warehouse?: string; assigned_main_warehouse?: string; assigned_plan?: string; assigned_shift?: string | Pick; integration_meta?: { [key: string]: any }; force_online_connectivity?: boolean; assigned_targets?: string[]; assigned_geo_zones?: (string | GeoZone.Data)[]; lines?: string[]; targetResults?: TargetResults; previously_assigned_clients?: string[]; freshchat_id?: string; disabled?: boolean; company_namespace: string[]; settings: RepSettings; is_test?: boolean; form_v2_option?: "all" | "none" | "assigned" | "client_assigned"; assigned_forms_v2?: string[]; retail_execution_template_option?: "all" | "client_assigned" | "assigned" | "none"; assigned_retail_execution_templates?: string[]; clm_presentation_option?: "all" | "client_assigned" | "assigned" | "none"; assigned_clm_presentations?: string[]; customFields?: { [key: string]: boolean | string | number | StringId }; media?: string[]; cover_photo?: string; last_login_time?: number; is_locked_device: boolean; handle_credit_limit: boolean; credit_limit?: number; createdAt: string; updatedAt: string; __v: number; } export type Data = RepSchema; export interface RepBody { username?: string; name?: string; password?: string; device_id?: string; linked_to_device?: boolean; live_location?: boolean; phone?: string; email?: string; integration_id?: string; permissions?: RepPermissions; preferences?: { isLightModeEnabled?: boolean; }; profile_pic?: string; teams?: string[]; identifier?: number; notification_id?: string; monthly_sales_target?: number; daily_target_visit?: number; sales_type?: 1 | 2; job_option?: JobOption; msl_sales?: string[]; job_category?: string[]; assigned_warehouse?: string; assigned_main_warehouse?: string; assigned_plan?: string; assigned_shift?: string | null; integration_meta?: { [key: string]: any }; force_online_connectivity?: boolean; assigned_targets?: string[]; assigned_geo_zones?: string[] | null; lines?: string[]; targetResults?: TargetResults; previously_assigned_clients?: string[]; freshchat_id?: string; disabled?: boolean; company_namespace: string[]; settings?: RepSettings; is_test?: boolean; form_v2_option?: "all" | "none" | "assigned" | "client_assigned"; assigned_forms_v2?: string[]; retail_execution_template_option?: "all" | "client_assigned" | "assigned" | "none"; assigned_retail_execution_templates?: string[]; clm_presentation_option?: "all" | "client_assigned" | "assigned" | "none"; assigned_clm_presentations?: string[]; customFields?: { [key: string]: boolean | string | number | StringId }; media?: string[]; cover_photo?: string; last_login_time?: number; is_locked_device?: boolean; handle_credit_limit?: boolean; credit_limit?: number; } type PopulatedKeys = | "line" | "lines" | "job_category" | "teams" | "assigned_forms_v2" | "job_category" | "cover_photo" | "assigned_plan" | "assigned_retail_execution_templates" | "assigned_clm_presentations" | "assigned_geo_zones" | "assigned_shift" | "warehouse"; export type RepWithPopulatedKeysSchema = RepSchema & { lines?: string[] | Line.LineSchema[]; job_category?: string[] | JobCategory.JobCategorySchema[]; teams?: string[] | Team.TeamSchema[]; assigned_warehouse?: | string | Pick< Warehouse.WarehouseSchema, "_id" | "name" | "code" | "type" | "integration_meta" >; assigned_main_warehouse?: | string | Pick< Warehouse.WarehouseSchema, "_id" | "name" | "code" | "type" | "integration_meta" >; assigned_shift?: string | Pick; assigned_geo_zones?: (string | GeoZone.Data)[]; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; disabled?: boolean; createdAt?: number; updatedAt?: number; from_updatedAt?: number; username?: string | string[]; phone?: string | string[]; teams?: string | string[]; identifier?: number | number[]; msl_sales?: string | string[]; job_category?: string | string[]; assigned_warehouse?: string | string[]; assigned_main_warehouse?: string | string[]; assigned_plan?: string | string[]; assigned_shift?: string | string[]; force_online_connectivity?: boolean; assigned_targets?: string | string[]; assigned_geo_zones?: string | string[]; lines?: string | string[]; job_option?: JobOption | JobOption[]; "permissions.rep_can_add_client"?: boolean; "permissions.rep_can_edit_client"?: boolean; "permissions.rep_can_add_calendar"?: boolean; "permissions.rep_can_edit_calendar"?: boolean; "permissions.rep_can_edit_others_calendar"?: boolean; "permissions.rep_can_skip_photo_tag"?: boolean; "permissions.rep_can_edit_product_price"?: boolean; "permissions.rep_must_add_client_with_location"?: boolean; "permissions.rep_can_access_shared_history"?: boolean; "permissions.rep_can_edit_total_shelf_share"?: boolean; "permissions.rep_can_create_transfer"?: boolean; "permissions.rep_can_make_call"?: boolean; "permissions.rep_can_read_stock"?: boolean; "permissions.can_rep_pay_other_reps_invoices"?: boolean; "permissions.rep_can_create_sales_order"?: boolean; "permissions.rep_can_create_invoice"?: boolean; "permissions.rep_can_create_transfer_load"?: boolean; "permissions.rep_can_create_transfer_unload"?: boolean; "permissions.rep_can_create_return_invoice"?: boolean; "permissions.rep_can_create_sales_order_out_of_visit"?: boolean; "permissions.rep_can_create_cash_invoice"?: boolean; "permissions.rep_can_sell_above_product_price"?: boolean; "permissions.rep_can_sell_below_product_price"?: boolean; "permissions.rep_can_create_return_out_of_visit"?: boolean; "permissions.rep_can_skip_return_reason"?: boolean; "permissions.rep_can_create_invoice_out_of_visit"?: boolean; "permissions.rep_can_create_free_payments"?: boolean; "permissions.rep_can_partially_pay_invoice"?: boolean; "permissions.auto_close_visit_when_out_of_geo_fence"?: boolean; "permissions.end_visit_when_out_of_geofence"?: boolean; "permissions.end_visit_when_low_accuracy"?: boolean; "permissions.rep_can_create_workorder"?: boolean; "permissions.rep_can_create_asset"?: boolean; "permissions.rep_can_skip_promotions"?: boolean; "permissions.rep_can_skip_item_status_feedback"?: boolean; "permissions.rep_can_skip_item_status_note"?: boolean; "permissions.rep_can_skip_item_status_type"?: boolean; "permissions.rep_can_end_visit_without_submitting_item_status"?: boolean; "permissions.rep_can_submit_multiple_item_status_products"?: boolean; "permissions.rep_can_edit_return_product_price"?: boolean; "permissions.rep_can_skip_cart_calculation_until_checkout"?: boolean; "permissions.rep_can_start_day_without_gps_signal"?: boolean; "permissions.rep_can_create_add_client_approval_request"?: boolean; "permissions.rep_can_create_edit_client_details_approval_request"?: boolean; "permissions.rep_can_create_edit_client_assigned_to_approval_request"?: boolean; "permissions.rep_can_create_edit_client_location_approval_request"?: boolean; "permissions.rep_can_create_delete_client_approval_request"?: boolean; "permissions.rep_can_create_skip_job_at_visit_end_approval_request"?: boolean; "permissions.rep_can_create_skip_geofence_at_visit_end_approval_request"?: boolean; "permissions.rep_can_create_credit_invoice_for_cash_client"?: boolean; "permissions.rep_can_view_client_credit_limit"?: boolean; "permissions.rep_can_create_edit_client_credit_limit_approval_request"?: boolean; "permissions.rep_can_assign_workorder"?: boolean; "permissions.rep_can_visit_outside_route"?: boolean; "permissions.rep_can_edit_retail_execution_entry"?: boolean; "permissions.rep_can_edit_form_entry"?: boolean; "permissions.rep_can_skip_visit_from_route_sequence"?: boolean; "permissions.rep_can_create_return_sales_order"?: boolean; "permissions.rep_can_edit_sales_order_custom_status"?: boolean; "permissions.rep_can_edit_invoice_custom_status"?: boolean; "permissions.rep_can_start_day_with_outstanding_settlement_balance"?: boolean; "permissions.rep_to_create_invoice_variant_batch_from_assigned_warehouse"?: boolean; "permissions.rep_to_create_sales_order_variant_batch_assigned_main_warehouse"?: boolean; "permissions.rep_can_create_pull_from_client_assigned_to_approval_request"?: boolean; "permissions.rep_can_print_payment_after_allowance_period"?: boolean; "permissions.rep_can_overwrite_partial_return_invoice_price"?: boolean; "permissions.rep_can_edit_invoice_discount"?: boolean; "permissions.rep_can_edit_sales_order_discount"?: boolean; "permissions.rep_can_create_payment"?: boolean; "permissions.rep_can_print_offline_invoice"?: boolean; "permissions.rep_can_print_offline_sales_order"?: boolean; "permissions.rep_can_skip_exp_date_in_audit_stock"?: boolean; "permissions.rep_must_start_day_within_specific_time_frame"?: boolean; "permissions.rep_must_start_day_within_shift_window"?: boolean; "permissions.rep_can_skip_assigned_client_filter_on_workorder_assigned_to"?: boolean; "permissions.rep_can_assign_client_to_other_reps"?: boolean; "permissions.rep_must_enter_sales_order_external_serial_number"?: boolean; "permissions.rep_must_enter_invoice_external_serial_number"?: boolean; "permissions.rep_must_end_day_after_specific_time"?: boolean; "permissions.rep_must_end_day_within_shift_window"?: boolean; "permissions.rep_can_start_day_on_non_working_day"?: boolean; "permissions.rep_can_create_negative_invoices"?: boolean; "permissions.rep_can_upload_media_on_payment"?: boolean; "permissions.rep_can_access_sales_reports"?: boolean; "permissions.rep_must_add_delivery_date_on_sales_order"?: boolean; "permissions.rep_must_add_delivery_date_on_invoice"?: boolean; "permissions.rep_can_create_client_line_approval_request"?: boolean; "permissions.rep_can_enter_client_code_at_create_client"?: boolean; "permissions.rep_can_edit_client_location_at_create_client"?: boolean; "permissions.rep_can_start_visit_out_of_geofence"?: boolean; "permissions.rep_can_create_approval_request_to_start_visit_out_of_geofence"?: boolean; "permissions.rep_can_view_stock_on_transfers"?: boolean; "permissions.rep_must_invoice_items_from_cross_inventory_and_msl"?: boolean; "settings.rep_must_end_day_after"?: `${number}:${number}`; "settings.allowable_accuracy"?: number; "settings.is_item_status_per_visit_limited"?: boolean; "settings.item_status_per_visit_limit"?: number; "settings.location_permission"?: "always_allow" | "while_using"; "settings.activities_report_scope"?: "self" | "team" | "company_namespace"; "settings.maximum_cash_outstanding_settlement_balance_to_start_day"?: number; "settings.maximum_check_outstanding_settlement_balance_to_start_day"?: number; "settings.maximum_total_outstanding_settlement_balance_to_start_day"?: number; "settings.watermark_client_name"?: boolean; "settings.watermark_time"?: boolean; "settings.watermark_date"?: boolean; "settings.watermark_coordinates"?: boolean; "settings.watermark_font_size"?: number; "settings.disable_auto_timezone_enforcement"?: boolean; "settings.disable_auto_time_date_enforcement"?: boolean; "settings.start_day_specific_time_frame_start"?: string; "settings.start_day_specific_time_frame_end"?: string; "settings.start_day_minutes_before_shift_start"?: number; "settings.start_day_minutes_after_shift_start"?: number; "settings.end_day_minutes_before_shift_end"?: number; "settings.treating_invoice_as_proforma_for_etax"?: boolean; is_test?: boolean; form_v2_option?: "all" | "none" | "assigned" | "client_assigned"; assigned_forms_v2?: StringId | StringId[]; retail_execution_template_option?: "all" | "client_assigned" | "assigned" | "none"; assigned_retail_execution_templates?: StringId | StringId[]; clm_presentation_option?: "all" | "client_assigned" | "assigned" | "none"; assigned_clm_presentations?: StringId | StringId[]; media?: string | string[]; cover_photo?: string; last_login_time?: number; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; withProductLines?: boolean; withStatus?: boolean; }; export interface Result extends DefaultPaginationResult { data: (RepWithPopulatedKeysSchema & { status?: | "Inactive" | "Ended a day" | "Active" | "Visiting" | "Started a day"; latest_activity?: string; })[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; withProductLines?: boolean; } export type Result = RepWithPopulatedKeysSchema; } export namespace Create { export interface Body extends RepBody { name: string; username: string; password: string; [key: `integration_meta.${string}`]: any; [key: `customFields.${string}`]: any; [key: `settings.${string}`]: any; } export type Result = RepSchema; } export namespace Update { export type ID = string; export interface Body extends RepBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; [key: `integration_meta.${string}`]: any; [key: `customFields.${string}`]: any; [key: `settings.${string}`]: any; } export type Result = RepSchema; } export namespace Remove { export type ID = string; export type Result = RepSchema; } } export namespace Line { export interface LineSchema { _id: string; name: string; local_name?: string; icon?: string; disabled?: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } } export namespace JobCategory { /* type 0 => task 1 => photo, 2 => note, 3 => form, 4 => audit, 5 => availability, 6 => return 7 => shelf share 8 => secondary 9 => checkout 10 => item-status 11 => retail-execution 12 => form-v2 13 => planogram */ interface JobSchema { _id?: StringId; type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13; description: string; tag?: StringId | Tag.TagSchema; product_id?: StringId; form_id?: StringId; msl_id?: StringId; template_id?: StringId; formV2_id?: StringId; is_required: boolean; order: number; } export type AutoSkipActivitySlugs = | "activity-ai-sales-order" | "ocr-invoice-job-group" | "activity-audit" | "activity-availability" | "activity-checkout-display" | "activity-form-result" | "activity-form-v2-result" | "activity-item-status" | "activity-note" | "activity-photo" | "activity-planogram" | "activity-secondary-display" | "activity-shelfshare" | "activity-storecheck" | "activity-task" | "approval-request" | "asset-part-receival" | "asset-part-transfer" | "clicks" | "clm-feedback-activity" | "fullinvoices" | "payments" | "proforma" | "refund" | "return-asset-part-unit" | "store-asset-part-unit"; export interface JobCategorySchema { _id: StringId; en_name: string; ar_name?: string; from_date: number; end_date?: number; description?: string; deleted_at?: number; is_sequence: boolean; jobs: JobSchema[]; disabled?: boolean; company_namespace: string[]; enable_auto_skip_conditions?: boolean; auto_skip_conditions?: { enable_auto_skip_interval_conditions?: boolean; occurrences_per_interval?: number; interval?: "day" | "week" | "month" | "year" | "life_time" | "last_30_days"; per_client?: boolean; per_rep?: boolean; enable_auto_skip_excluded_clients?: boolean; excluded_clients?: StringId[]; enable_auto_skip_calendar_days?: boolean; skip_if_calendar_day_is_less_than?: number; // (1-31) skip_if_calendar_day_is_more_than?: number; // (1-31) enable_auto_skip_activity_existence?: boolean; auto_skip_activity_slugs?: AutoSkipActivitySlugs[]; auto_skip_activity_slugs_operator?: "and" | "or"; enable_auto_skip_visit_duration?: boolean; skip_if_visit_duration_minutes_is_less_than?: number; skip_if_visit_duration_minutes_is_more_than?: number; }; createdAt: string; updatedAt: string; __v: number; } export type Data = JobCategorySchema; export type PopulatedDoc = Data & { jobs: (JobSchema & { tag?: string | Tag.TagSchema })[]; auto_skip_conditions?: Data["auto_skip_conditions"] & { excluded_clients?: (string | Client.ClientSchema)[]; }; }; type CreateBody = Omit; type PopulatedKeys = "jobs.tag" | "auto_skip_conditions.excluded_clients"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; disabled?: boolean; en_name?: string[] | string; from_updatedAt?: number; to_updatedAt?: number; from__id?: string; to__id?: string; populatedKeys?: PopulatedKeys[]; [key: string]: any; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = Partial; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace JobCategoryAutoSkipAnalyze { export interface Data { client: StringId; rep?: StringId; visit_id?: string; job_category: (JobCategory.Data & { skipped?: boolean; jobs: (JobCategory.Data["jobs"][0] & { skipped?: boolean })[]; })[]; company_namespace: string[]; } export namespace Create { export type Body = Data; export type Result = Data; } } export namespace Tag { type TagType = "photo" | "client" | "area" | "price"; export interface TagSchema { _id: string; type: TagType; tag: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; teams?: string[]; teams_populated?: Team.TeamSchema[]; createdAt: string; updatedAt: string; __v: number; } export type Data = TagSchema; export interface TagBody { tag?: string; type?: TagType; disabled?: boolean; teams?: string[]; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } type PopulatedKeys = "teams"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; tag?: string[] | string; type?: TagType[] | TagType; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; populatedKeys?: PopulatedKeys[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: TagSchema[]; } } export namespace Get { export type ID = string; export type Result = TagSchema; } export namespace Create { export interface Body extends TagBody { type: TagType; tag: string; } export type Result = TagSchema; } export namespace Update { export type ID = string; export interface Body extends TagBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = TagSchema; } export namespace Remove { export type ID = string; export type Result = TagSchema; } } export namespace Route { export interface RouteSchema { _id: string; name: string; disabled: boolean; sync_id: string; force_sequence: boolean; editor: AdminCreator; list: List[]; company_namespace: string[]; createdAt: string; updatedAt: string; } export type Data = RouteSchema; export interface RouteBody { name?: string; disabled?: boolean; sync_id?: string; force_sequence?: boolean; editor?: AdminCreator; list?: List[]; company_namespace?: string[]; } type PopulatedKeys = "client" | "list.client"; interface List { client: string; from?: string; to?: string; } export type RouteWithPopulatedKeysSchema = RouteSchema & { "list.client"?: | string[] | { client: string | Pick; from?: string; to?: string; }[]; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; name?: string[] | string; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: RouteWithPopulatedKeysSchema[]; } } export namespace Get { export type ID = string; export type Result = RouteSchema; } export namespace Create { export interface Body extends RouteBody { name: string; force_sequence: boolean; list: List[]; sync_id: string; } export type Result = RouteSchema; } export namespace Update { export type ID = string; export interface Body extends RouteBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = RouteSchema; } export namespace Remove { export type ID = string; export type Result = RouteSchema; } } export namespace Warehouse { type WarehouseType = "van" | "main" | "origin"; export interface WarehouseSchema { _id: string; type: WarehouseType; name: string; code?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; teams?: string[]; createdAt: string; updatedAt: string; __v: number; } export type Data = WarehouseSchema; export interface WarehouseBody { name?: string; type?: "van" | "main"; code?: string; disabled?: boolean; teams?: string[]; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } type PopulatedKeys = "rep_id" | "teams"; export type WarehouseWithPopulatedKeysSchema = WarehouseSchema & { rep_id?: string[] | Pick[]; teams_populated?: string[] | Team.TeamSchema[]; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; code?: string[] | string; type?: WarehouseType[] | WarehouseType; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: WarehouseWithPopulatedKeysSchema[]; } } export namespace Get { export type ID = string; export type Result = WarehouseSchema; } export namespace Create { export interface Body extends WarehouseBody { name: string; type: "van" | "main"; } export type Result = WarehouseSchema; } export namespace Update { export type ID = string; export interface Body extends WarehouseBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = WarehouseSchema; } export namespace Remove { export type ID = string; export type Result = WarehouseSchema; } } export namespace ProductModifiersGroup { export interface ProductModifiersGroupSchema { _id: string; name: string; disabled: boolean; local_name?: string; position: number; multiple_modifiers: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface ProductModifiersGroupBody { name?: string; disabled?: boolean; local_name?: string; position?: number; multiple_modifiers?: boolean; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: ProductModifiersGroupSchema[]; } } export namespace Get { export type ID = string; export type Result = ProductModifiersGroupSchema; } export namespace Create { export interface Body extends ProductModifiersGroupBody { name: string; position: number; multiple_modifiers: boolean; } export type Result = ProductModifiersGroupSchema; } export namespace Update { export type ID = string; export interface Body extends ProductModifiersGroupBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = ProductModifiersGroupSchema; } export namespace Remove { export type ID = string; export type Result = ProductModifiersGroupSchema; } } export namespace Channel { export interface ChannelSchema { _id: string; name: string; local_name?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface ChannelBody { name?: string; local_name?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: ChannelSchema[]; } } export namespace Get { export type ID = string; export type Result = ChannelSchema; } export namespace Create { export interface Body extends ChannelBody { name: string; } export type Result = ChannelSchema; } export namespace Update { export type ID = string; export interface Body extends ChannelBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = ChannelSchema; } export namespace Remove { export type ID = string; export type Result = ChannelSchema; } } export namespace Speciality { export interface SpecialitySchema { _id: string; name: string; local_name?: string; disabled?: boolean; icon?: string; icon_media?: string; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface SpecialityBody { name?: string; local_name?: string; disabled?: boolean; icon?: string; icon_media?: string; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: SpecialitySchema[]; } } export namespace Get { export type ID = string; export type Result = SpecialitySchema; } export namespace Create { export interface Body extends SpecialitySchema { name: string; } export type Result = SpecialitySchema; } export namespace Update { export type ID = string; export interface Body extends SpecialityBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = SpecialitySchema; } export namespace Remove { export type ID = string; export type Result = SpecialitySchema; } } export namespace ClientContact { export interface ClientContactSchema { _id: string; creator: AdminCreator | RepCreator | ClientCreator; editor?: AdminCreator | RepCreator | ClientCreator; name: string; local_name?: string; phone1?: string; phone2?: string; email?: string; title?: string; extra_info?: string; disabled?: boolean; media?: string[]; cover_photo?: string; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface ClientContactBody { name?: string; creator?: AdminCreator | RepCreator | ClientCreator; editor?: AdminCreator | RepCreator | ClientCreator; local_name?: string; phone1?: string; phone2?: string; email?: string; title?: string; extra_info?: string; disabled?: boolean; media?: string[]; cover_photo?: string; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; from_updatedAt?: number; to_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: ClientContactSchema[]; } } export namespace Get { export type ID = string; export type Result = ClientContactSchema; } export namespace Create { export interface Body extends ClientContactBody { name: string; } export type Result = ClientContactSchema; } export namespace Update { export type ID = string; export interface Body extends ClientContactBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = ClientContactSchema; } export namespace Remove { export type ID = string; export type Result = ClientContactSchema; } } export namespace PaymentTerm { export interface PaymentTermSchema { _id: string; name: string; due_days: number; editor: AdminCreator; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface PaymentTermBody { name?: string; due_days?: number; editor?: AdminCreator; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; disabled?: boolean; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: PaymentTermSchema[]; } } export namespace Get { export type ID = string; export type Result = PaymentTermSchema; } export namespace Create { export interface Body extends PaymentTermBody { name: string; due_days: number; } export type Result = PaymentTermSchema; } export namespace Update { export type ID = string; export interface Body extends PaymentTermBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = PaymentTermSchema; } export namespace Remove { export type ID = string; export type Result = PaymentTermSchema; } } export namespace Bank { export interface BankSchema { _id: string; name: string; country?: string[]; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface BankBody { name?: string; country?: string[]; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: BankSchema[]; } } export namespace Get { export type ID = string; export type Result = BankSchema; } export namespace Create { export interface Body extends BankBody { name: string; } export type Result = BankSchema; } export namespace Update { export type ID = string; export interface Body extends BankBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = BankSchema; } } export namespace BankList { export interface BankListSchema { _id: string; name: string; banks: { _id: string; bank: string }[]; integration_meta?: { [key: string]: any }; createdAt: string; updatedAt: string; __v: number; } export interface BankListBody { name?: string; banks?: { bank: string }[]; integration_meta?: { [key: string]: any }; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; me?: true; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: BankListSchema[]; } } export namespace Get { export type ID = string; export type Result = BankListSchema; } export namespace Create { export interface Body extends BankListBody { name: string; } export type Result = BankListSchema; } export namespace Update { export type ID = string; export interface Body extends BankListBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = BankListSchema; } } export namespace CustomStatus { type CustomStatusModel = | "proformas" | "fullinvoices" | "transfers" | "payments" | "workorder" | "assetPartReceival" | "assetPartUnit" | "assetPartTransfer" | "returnAssetPartUnit" | "storeAssetPartUnit" | "adjustInventory"; export interface CustomStatusSchema { _id: string; name: string; code: string; model: CustomStatusModel; local_name?: string; is_default: boolean; color?: string; disabled?: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface CustomStatusBody { name?: string; code: string; model: CustomStatusModel; local_name?: string; is_default: boolean; color?: string; company_namespace?: string[]; disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; code?: string[] | string; model?: CustomStatusModel | CustomStatusModel[]; is_default?: boolean; color?: string[] | string; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: CustomStatusSchema[]; } } export namespace Get { export type ID = string; export type Result = CustomStatusSchema; } export namespace Create { export interface Body extends CustomStatusBody { name: string; model: CustomStatusModel; } export type Result = CustomStatusSchema; } export namespace Update { export type ID = string; export interface Body extends CustomStatusBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = CustomStatusSchema; } export namespace Remove { export type ID = string; export type Result = CustomStatusSchema; } } export namespace CustomList { interface EndPoint { _id?: string; is_read?: boolean; input_type?: "List"; render_key?: string; filter_key?: "_id"; type?: "String" | "Array" | "Number" | "Boolean"; path?: string; method?: "get" | "post" | "put" | "patch" | "delete"; body?: { [key: string]: any }; search?: boolean; multi_select?: boolean; } interface Source { source_id: string; company_namespace: string[]; photo?: string; source_name: string; source_local_name?: string; } interface Filter { key: string; value: any[]; operator: "lte" | "lt" | "gte" | "gt" | "eq" | "ne" | "in" | "nin" | "search"; id?: string; } interface Element { _id: string; name: string; type: "Number" | "String"; key?: string; is_required?: boolean; isArray?: boolean; disabled: boolean; manipulator_function?: string; } export interface CustomListSchema { _id: string; code: string; name: string; local_name?: string; disabled: boolean; type: "reference" | "template"; //| "items_list" filters: Filter[]; list_type: "String" | "Number"; source: | "product" | "variant" | "product-category" | "product-sub-category" | "client" | "measureunits" | "tag" | "paymentterms" | "client-channel" | "speciality" | "rep"; template_elements: Element[]; company_namespace: string[]; sources?: Source[]; can_edit_types?: boolean; end_point: EndPoint; createdAt: string; updatedAt: string; } export type Data = CustomListSchema; export interface CreateBody { code: string; name: string; local_name?: string; disabled: boolean; type: "reference" | "template"; //| "items_list" filters: Filter[]; list_type: "String" | "Number"; source: | "product" | "variant" | "product-category" | "product-sub-category" | "client" | "measureunits" | "tag" | "paymentterms" | "client-channel" | "speciality" | "rep"; template_elements: Element[]; company_namespace: string[]; sources?: Source[]; can_edit_types?: boolean; end_point: EndPoint; } export interface UpdateBody { _id?: string; code?: string; name?: string; local_name?: string; disabled?: boolean; type?: "reference" | "template"; //| "items_list" filters?: Filter[]; list_type?: "String" | "Number"; source?: | "product" | "variant" | "product-category" | "product-sub-category" | "client" | "measureunits" | "tag" | "paymentterms" | "client-channel" | "speciality" | "rep"; template_elements?: Element[]; company_namespace?: string[]; sources?: Source[]; can_edit_types?: boolean; end_point: EndPoint; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; name?: string[] | string; type?: string; code?: string; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: CustomListSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = CustomListSchema; } export namespace Create { export type Body = CreateBody; export type Result = CustomListSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = CustomListSchema; } export namespace Remove { export type ID = string; export type Result = CustomListSchema; } } export namespace CustomListItem { type CustomItemType = "String" | "Number"; interface CustomListItemElementModel { _id: string; template_element: string; value: string | number; name: string; type: CustomItemType; } export interface CustomListItemSchema { _id: string; disabled: boolean; custom_list: string; type: CustomItemType; value: string | number; photo?: string; media?: string[]; position?: number; elements: CustomListItemElementModel[]; score?: number; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { disabled: boolean; custom_list: string; type: CustomItemType; value: string | number; photo?: string; media?: string[]; position?: number; elements: CustomListItemElementModel[]; score?: number; company_namespace: string[]; } export interface UpdateBody { _id?: string; disabled?: boolean; custom_list?: string; type?: CustomItemType; value?: string | number; photo?: string; media?: string[]; position?: number; elements?: CustomListItemElementModel[]; score?: number; company_namespace?: string[]; } type CustomListItemSchemaWithPopulatedKeys = CustomListItemSchema & { custom_list?: string | CustomList.CustomListSchema; cover_photo?: string | MediaStorage.MediaStorageSchema; }; type PopulatedKeys = "custom_list" | "cover_photo"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; custom_list?: string; from_updatedAt?: number; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: CustomListItemSchemaWithPopulatedKeys[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = CustomListItemSchema; } export namespace Create { export type Body = CreateBody; export type Result = CustomListItemSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = CustomListItemSchema; } export namespace Remove { export type ID = string; export type Result = CustomListItemSchema; } } export namespace ReturnReason { export interface Schema { _id: string; name: string; local_name?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface Data { name?: string; local_name?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; local_name?: string[] | string; disabled?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Schema[]; } } export namespace Get { export type ID = string; export type Result = Schema; } export namespace Create { export interface Body extends Data { name: string; } export type Result = Schema; } export namespace Update { export type ID = string; export interface Body extends Data { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = Schema; } export namespace Remove { export type ID = string; export type Result = Schema; } } export namespace Promotion { export interface CartFilter { _id?: StringId; filter_type: | "product" | "category" | "sub_category" | "product_group" | "brand" | "variant" | "cart_total" | "items_count" | "client" | "tag" | "channel" | "distinct_variants_count" | "distinct_products_count" | "promotion" | "cart_type" | "invoice_payment_type" | "creator_id"; value: string[]; operator: "lte" | "lt" | "gte" | "gt" | "eq"; reject_if_pass: boolean; limit_type?: "count" | "price_amount"; limit_value?: number; exclude_additional_items_taxable_subtotal?: boolean; variants?: StringId[]; } export interface ItemFilter { _id?: StringId; filter_type: | "product" | "category" | "sub_category" | "product_group" | "brand" | "variant" | "any" | "gift"; value: StringId[]; limit_type: "count" | "price_amount"; limit_value: number; variants?: StringId[]; } export interface CartAdjustment { _id?: StringId; adjustment_type: | "discount_amount" | "discount_ratio" | "shipping_fixed_price" | "shipping_discount_amount" | "shipping_discount_ratio" | "tax_exempt"; value: any; } export interface LineFilter { _id?: StringId; filter_type: | "product" | "category" | "sub_category" | "product_group" | "brand" | "variant" | "line_total" | "base_unit_qty" | "promotion"; value: string[]; operator: "lte" | "lt" | "gte" | "gt" | "eq"; reject_if_pass: boolean; limit_type: "count" | "price_amount"; limit_value: number; variants?: StringId[]; } export interface LineAdjustment { _id?: StringId; adjustment_type: "discount_amount" | "discount_ratio" | "fixed_price"; value: number; } export interface GetItem { _id?: StringId; filter_type: | "product" | "category" | "sub_category" | "product_group" | "brand" | "variant" | "gift"; value: string[]; limit_type: "count"; limit_value: number; discount_ratio: number; variants?: StringId[]; } interface Compound { _id?: StringId; type: "compound"; manual_allocation?: boolean; appliedCount: number; sorting: "cheapest" | "expensive"; enforcement_mode: "all_in_inventory" | "all" | "gift_in_inventory" | "gift"; calculate_hidden_price: boolean; usage_limit?: number; usage_limit_per_rep?: number; usage_limit_per_client?: number; cart_filters_operator: "and" | "or"; cart_filters: CartFilter[]; items_filters_operator: "and" | "or"; items_filters: ItemFilter[]; get_items_operator: "and" | "or"; get_items: GetItem[]; cart_adjustments: CartAdjustment[]; line_filters: LineFilter[]; line_adjustments: LineAdjustment[]; line_filters_operator: "and" | "or"; is_bulk?: boolean; rounding: "round" | "floor" | "ceil"; bulk_over_provide?: boolean; bulk_limit_type?: "count" | "price_amount" | "ratio"; bulk_data: { from_limit_value: number; to_limit_value?: number; get_limit_value: number; }[]; } export interface Data { _id: StringId; type: "compound"; from: number; to: number; status: "published" | "unpublished"; priority?: number; name: string; description?: string; duration?: number; startsAt?: string; disabled: boolean; promotions_groups?: StringId[]; details: Compound; copied_from?: StringId; ref?: string; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; } interface CreateBody { type: "compound"; from?: number; to?: number; priority?: number; name: string; description?: string; duration?: number; startsAt?: string; disabled: boolean; promotions_groups?: string[]; details: Compound; copied_from?: string; ref?: string; company_namespace?: string[]; } export type Schema = Data; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; ref?: string | string[]; from_updatedAt?: number; to_updatedAt?: number; asset_types?: StringId | StringId[]; location?: StringId | StringId[]; from_createdAt?: number; to_createdAt?: number; search?: string; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; disabled?: boolean; from?: number; to?: number; from_from?: number; to_from?: number; from_to?: number; to_to?: number; promotions_groups?: StringId | StringId[]; status?: Data["status"] | Data["status"][]; expired?: boolean; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Params = {}; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = Partial; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace Item { interface Modifier { modifiers_group_id?: string; name?: string; local_name?: string; price?: number; position?: number; disabled?: boolean; company_namespace: string[]; overwritePrice?: number; discounted_price?: number; tax_amount?: number; gross_value?: number; } export interface ModifierGroup { name?: string; local_name?: string; position?: number; disabled?: boolean; multiple_modifiers?: boolean; company_namespace: string[]; modifiers?: Modifier[]; group_total?: number; group_total_before_tax?: number; group_tax_total?: number; } export interface Item_Variant { product_id: | StringId | { _id: StringId; name: string; local_name: string; barcode: string; integration_meta?: { [key: string]: any }; }; product_name: string; variant_id: | StringId | { _id: StringId; name: string; local_name: string; sku: string; barcode: string; integration_meta?: { [key: string]: any }; }; variant_name: string; listed_price: number; variant_local_name?: string; variant_img?: string; product_local_name?: string; product_img?: string; product_sku?: string; product_barcode?: string; variant_sku?: string; variant_barcode?: string; _id: StringId; } export interface Schema { _id: StringId; variant: Item_Variant; measureunit: { _id: StringId; name: string; factor: number; parent?: StringId; disabled?: boolean; company_namespace: string[]; }; tax: { _id: StringId; name: string; rate: number; type: "inclusive" | "additive" | "N/A"; ubl_tax_details?: { tax_code: "O" | "Z" | "E" | "S"; reason: string; reason_code?: string; }; disabled?: boolean; company_namespace?: string[]; }; promotions?: { isGet: boolean; taken: number; free: number; bookings?: { promotion: StringId; type: "get" | "buy"; count: number; round_id: number; filter_index: number; rounds_details: { round_id: number; taken: number; }[]; }[]; promoPrice?: number; highlight: boolean; [key: string]: any; }; used_promotions?: { id: StringId; name: string; ref?: string }[]; general_promotions?: { id: StringId; name: string; ref?: string }[]; applicable_promotions?: { id: StringId; name: string; ref?: string }[]; modifiers_groups: ModifierGroup[]; isAdditional?: boolean; additional_on_promo?: string; qty: number; base_unit_qty?: number; overwritePrice?: number; price: number; discounted_price: number; tax_amount: number; tax_total: number; discount_value: number; gross_value?: number; line_total?: number; total_before_tax?: number; hidden_price?: number; modifiers_total?: number; modifiers_total_before_tax?: number; modifiers_tax_total?: number; tax_total_without_modifiers?: number; line_total_without_modifiers?: number; total_before_tax_without_modifiers?: number; deductionRatio?: number; deductedTax?: number; deduction?: number; deductionBeforeTax?: number; lineTotalAfterDeduction?: number; company_namespace: string[]; class: "invoice" | "return"; note?: string; return_reason?: string; variant_batches?: { _id: StringId; batch_number: string; expiry_date?: string; non_txn_quantity?: number; qty: number; base_unit_qty?: number; warehouse?: StringId; non_txn_quantity_in_measure_unit?: number; isSelected?: boolean; }[]; delivery_tracking?: { free: number; noted_for_delivery: number; delivered: number; }; } export type Data = Schema; export interface Body { variant: Item_Variant; measureunit: { _id: string; name: string; factor: number; parent?: string; disabled?: boolean; company_namespace: string[]; }; tax: { _id: string; name: string; rate: number; type: "inclusive" | "additive" | "N/A"; disabled?: boolean; }; promotions?: { isGet: boolean; taken: number; free: number; bookings?: { promotion: string; type: "get" | "buy"; count: number; round_id: number; filter_index: number; rounds_details: { round_id: number; taken: number; }[]; }[]; promoPrice?: number; highlight: boolean; [key: string]: any; }; used_promotions?: { id: string; name: string; ref?: string }[]; general_promotions?: { id: string; name: string; ref?: string }[]; applicable_promotions?: { id: string; name: string; ref?: string }[]; modifiers_groups?: ModifierGroup[]; isAdditional?: boolean; qty: number; base_unit_qty?: number; overwritePrice?: number; price: number; discounted_price: number; tax_amount: number; tax_total: number; discount_value: number; gross_value?: number; line_total?: number; total_before_tax?: number; hidden_price?: number; modifiers_total?: number; modifiers_total_before_tax?: number; modifiers_tax_total?: number; tax_total_without_modifiers?: number; line_total_without_modifiers?: number; total_before_tax_without_modifiers?: number; deductionRatio?: number; deductedTax?: number; deduction?: number; deductionBeforeTax?: number; lineTotalAfterDeduction?: number; company_namespace?: string[]; note?: string; } } export namespace Visit { export interface VisitSchema { _id: string; geoPoint: { type: "Point"; coordinates: number[]; }; start_geo_tag: GeoTag; end_geo_tag: GeoTag; route: string; time: number; user: Rep.RepSchema; tags: Tag.TagBody[]; client: string; client_name: string; client_location_verified?: boolean; user_name?: string; visit_id: string; sync_id?: string; start_time: number; end_time: number; business_day_rep?: string; business_day: string; call_start_time?: number; call_end_time?: number; call_total_time?: number; total_time: number; platform: string; version_name: string; battery_level: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; type?: string; notes?: string[]; photos?: string[]; forms?: string[]; teams?: string[]; tasks?: string[]; audits?: string[]; network_state?: number; distance?: number; start_distance?: number; end_distance?: number; delta_distance?: number; start_out_of_geofence?: boolean; end_out_of_geofence?: boolean; start_accuracy?: number; end_accuracy?: number; closed_by_system?: boolean; meta: VisitMeta; lines?: string[]; client_geo_location: { lat: number; lng: number; }; geofencing_radius?: number; availability?: string[]; selected_product_lines: Line.LineSchema[]; workorder: Workorder.WorkorderSchema; asset?: string; asset_unit?: string; auto_closed_by_geofence?: boolean; auto_closed_by_geofence_reason: "out_of_geofence" | "low_accuracy" | "location_turned_off"; company_namespace: string[]; option_id?: string; invoice_total?: number; invoice_pre_total?: number; invoice_return_total?: number; proforma_total?: number; proforma_pre_total?: number; proforma_return_total?: number; payment_total?: number; refund_total?: number; geo_tag?: { lat: number; lng: number; formatted_address?: string; extra?: {}; }; delayed?: boolean; visit_reason?: StringId; visit_note?: string; createdAt: Date; updatedAt: Date; } export type Data = VisitSchema; export interface CreateBody { geoPoint: { type: "Point"; coordinates: number[]; }; start_geo_tag: GeoTag; route: string; time: number; user: Rep.RepSchema; tags: Tag.TagBody[]; client: string; client_name: string; client_location_verified?: boolean; user_name?: string; visit_id: string; sync_id?: string; start_time: number; business_day_rep?: string; business_day: string; platform: string; version_name: string; battery_level: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; type?: string; network_state?: number; distance?: number; start_distance?: number; start_accuracy?: number; meta: VisitMeta; lines?: string[]; client_geo_location: { lat: number; lng: number; }; geofencing_radius?: number; availability?: string[]; workorder: Workorder.WorkorderSchema; asset?: string; asset_unit?: string; company_namespace: string[]; option_id?: string; invoice_total?: number; invoice_pre_total?: number; invoice_return_total?: number; proforma_total?: number; proforma_pre_total?: number; proforma_return_total?: number; payment_total?: number; refund_total?: number; geo_tag?: { lat: number; lng: number; formatted_address?: string; extra?: {}; }; delayed?: boolean; } export interface UpdateBody { geoPoint?: { type: "Point"; coordinates: number[]; }; end_geo_tag?: GeoTag; route?: string; time?: number; user?: Rep.RepSchema; tags?: Tag.TagBody[]; client?: string; client_name?: string; client_location_verified?: boolean; user_name?: string; visit_id?: string; sync_id?: string; end_time?: number; business_day_rep?: string; business_day?: string; call_start_time?: number; call_end_time?: number; call_total_time?: number; total_time?: number; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; type?: string; notes?: string[]; photos?: string[]; forms?: string[]; teams?: string[]; tasks?: string[]; audits?: string[]; network_state?: number; distance?: number; end_distance?: number; delta_distance?: number; end_out_of_geofence?: boolean; end_accuracy?: number; closed_by_system?: boolean; meta: VisitMeta; lines?: string[]; client_geo_location?: { lat: number; lng: number; }; geofencing_radius?: number; availability?: string[]; selected_product_lines?: Line.LineSchema[]; workorder?: Workorder.WorkorderSchema; asset?: string; asset_unit?: string; auto_closed_by_geofence?: boolean; auto_closed_by_geofence_reason?: "out_of_geofence" | "low_accuracy" | "location_turned_off"; company_namespace?: string[]; option_id?: string; invoice_total?: number; invoice_pre_total?: number; invoice_return_total?: number; proforma_total?: number; proforma_pre_total?: number; proforma_return_total?: number; payment_total?: number; refund_total?: number; geo_tag?: { lat: number; lng: number; formatted_address?: string; extra?: {}; }; delayed?: boolean; } type VisitSchemaWithPopulatedKeys = VisitSchema & { notes: { content: string; geo_tag: GeoTag; time: number; platform: string; version_name: string; battery_level: number; comments: ActivityComment[]; }; tasks: { start_photo: string; end_photo: string; start_media: MediaDoc; end_media: MediaDoc; geo_tag: GeoTag; time: number; platform: string; version_name: string; battery_level: number; start_time: number; end_time: number; total_time: number; comments: ActivityComment[]; }; photos: { photo: string; media: MediaDoc; geo_tag: GeoTag; caption: string; time: number; platform: string; version_name: string; battery_level: number; comments: ActivityComment[]; }; forms: { results: { [key: string]: any }; form_id: string; geo_tag: GeoTag; time: number; platform: string; version_name: string; battery_level: number; comments: ActivityComment[]; }; audits: { audits: { inventories: { media: MediaDoc; }; }; geo_tag: GeoTag; time: number; platform: string; version_name: string; battery_level: number; comments: ActivityComment[]; }; availability: { products_available: { product_id: Pick; available: boolean; }; media: MediaDoc; geo_tag: GeoTag; time: number; platform: string; version_name: string; battery_level: number; comment: ActivityComment[]; }; tags?: string[] | Tag.TagSchema[]; teams?: string[] | Team.TeamSchema[]; user?: string | Rep.RepSchema; client?: string | Client.ClientSchema; route?: string | Route.RouteSchema; visit_reason?: StringId | Pick; }; export type PopulatedKeys = | "notes" | "tasks" | "photos" | "forms" | "audits" | "tags" | "availability" | "teams" | "client" | "user" | "route" | "visit_reason"; export namespace Find { export type Params = DefaultPaginationQueryParams & { user?: string; from_time?: number; to_time?: number; client?: string; route?: string; teams?: string[]; company_namespace?: string; tags?: string[]; CLIENT_TAGS?: string[]; AREA_TAGS?: string; availability?: string[]; visit_id?: string; from_total_time?: number; to_total_time?: number; closed_by_system?: boolean; from_updatedAt?: number; from__id?: string; to__id?: string; visit_reason?: StringId | StringId[]; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: VisitSchemaWithPopulatedKeys[]; absolute_total: number; page_total: number; } } export namespace Create { export type Body = CreateBody; export type Result = VisitSchema; } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = VisitSchemaWithPopulatedKeys; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = VisitSchema; } } export namespace ActivityFeedback { export interface ActivityFeedbackSchema { _id: string; route?: string; visit_id: string; visit_UUID: string; teams?: string[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { route?: string; visit_id: string; visit_UUID: string; teams?: string[]; } export interface UpdateBody { route?: string; visit_id?: string; visit_UUID?: string; teams?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { route?: string; teams?: string[]; visit_id?: string; from_createdAt?: number; to_createdAt?: number; from__id?: string; to__id?: string; [key: string]: any; // integration_meta. sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: ActivityFeedbackSchema[]; absolute_total: number; page_total: number; } } export namespace Create { export type Body = CreateBody; export type Result = ActivityFeedbackSchema; } export namespace Get { export type ID = string; export interface Params {} export type Result = ActivityFeedbackSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = ActivityFeedbackSchema; } } export namespace ActivityFeedbackV2 { export interface ActivityFeedbackV2Schema { _id: string; route?: string; visit_id: string; visit_UUID: string; teams?: string[]; feed_back_option: string; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { route?: string; visit_id: string; visit_UUID: string; feed_back_option: string; teams?: string[]; } export interface UpdateBody { route?: string; visit_id?: string; visit_UUID?: string; teams?: string[]; feed_back_option?: string; } export type PopulatedKeys = "teams" | "route" | "visit_id" | "feed_back_option"; export type ActivityFeedbackV2SchemaWithPopulatedKeys = ActivityFeedbackV2Schema & { teams_populated?: string[] | Team.TeamSchema[]; route_populated?: string | Route.RouteSchema; visit_id_populated?: string | Visit.VisitSchema; feed_back_option_populated?: string | FeedbackOption.FeedbackOptionSchema; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { route?: string; teams?: string[]; visit_id?: string; from_createdAt?: number; to_createdAt?: number; from__id?: string; to__id?: string; populatedKeys?: PopulatedKeys | PopulatedKeys[]; [key: string]: any; // integration_meta. sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: ActivityFeedbackV2SchemaWithPopulatedKeys[]; absolute_total: number; page_total: number; } } export namespace Create { export type Body = CreateBody; export type Result = ActivityFeedbackV2Schema; } export namespace Get { export type ID = string; export interface Params {} export type Result = ActivityFeedbackV2SchemaWithPopulatedKeys; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = ActivityFeedbackV2Schema; } } export namespace FeedbackOption { export interface FeedbackOptionSchema { _id: string; label: string; score?: number; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { label: string; score?: number; } export interface UpdateBody { label: string; score?: number; disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { label?: string; score?: number; deleted_at?: number; disabled?: boolean; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: FeedbackOptionSchema[]; absolute_total: number; page_total: number; } } export namespace Create { export type Body = CreateBody; export type Result = FeedbackOptionSchema; } export namespace Get { export type ID = string; export interface Params {} export type Result = FeedbackOptionSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = FeedbackOptionSchema; } } export namespace Workorder { export interface WorkorderSchema { _id: StringId; name: string; local_name?: string; disabled: boolean; client: StringId; client_name: string; sync_id: string; status: WorkorderStatus; creator: AdminCreator | RepCreator | ClientCreator; editor?: AdminCreator | RepCreator | ClientCreator; workorder_categories: StringId[]; description?: string; integration_meta?: { [key: string]: any }; assets?: StringId[]; asset_units?: StringId[]; asset_part_units?: StringId[]; due_date?: number; start_date?: number; client_location: StringId; priority?: Priority; priority_human?: Priority_human; workorder_request?: string; serial_number?: SerialNumber; assigned_to?: StringId[]; forms?: StringId[]; time: number; is_overdue: boolean; opened_at: number; done_at: number; cancelled_at: number; inprogress_at: number; done_by?: AdminCreator | RepCreator | ClientCreator; cancelled_by?: AdminCreator | RepCreator | ClientCreator; opened_by?: AdminCreator | RepCreator | ClientCreator; inprogress_by?: AdminCreator | RepCreator | ClientCreator; build: Build[]; calendars: Calendar[]; builtAt: number; due_date_day?: string; last_done_at?: number; last_done_by?: AdminCreator | RepCreator | ClientCreator; resolve_time?: number; startsAt: string; endsAt?: string; is_dunning_allowed?: boolean; score_required_for_dunning?: boolean; min_score_required_for_dunning?: number; score?: number; is_completed?: boolean; forms_v2?: { form_id: StringId; form_activity_id?: StringId; completion_required_for_dunning?: boolean; score_required_for_dunning?: boolean; min_score_required_for_dunning?: number; score?: number; is_completed?: boolean; }[]; teams?: StringId[]; media?: StringId[]; cover_photo?: StringId; custom_status?: StringId; contract?: StringId; parent_repeating_workorder?: StringId; parent_repeating_day?: string; filter_asset_units_by_location?: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type Data = WorkorderSchema; export interface PopulatedData { _id: StringId; name: string; local_name?: string; disabled: boolean; client: StringId; client_name: string; sync_id: string; status: WorkorderStatus; creator: AdminCreator | RepCreator | ClientCreator; editor?: AdminCreator | RepCreator | ClientCreator; workorder_categories: StringId[]; description?: string; integration_meta?: { [key: string]: any }; assets?: StringId[]; asset_units?: StringId[]; asset_part_units?: StringId[]; due_date?: number; start_date?: number; client_location: StringId; priority?: Priority; priority_human?: Priority_human; workorder_request?: string; serial_number?: SerialNumber; assigned_to?: StringId[]; forms?: StringId[]; time: number; is_overdue: boolean; opened_at: number; done_at: number; cancelled_at: number; inprogress_at: number; done_by?: AdminCreator | RepCreator | ClientCreator; cancelled_by?: AdminCreator | RepCreator | ClientCreator; opened_by?: AdminCreator | RepCreator | ClientCreator; inprogress_by?: AdminCreator | RepCreator | ClientCreator; build: Build[]; calendars: Calendar[]; builtAt: number; due_date_day?: string; last_done_at?: number; last_done_by?: AdminCreator | RepCreator | ClientCreator; resolve_time?: number; startsAt: string; endsAt?: string; is_dunning_allowed?: boolean; score_required_for_dunning?: boolean; min_score_required_for_dunning?: number; score?: number; is_completed?: boolean; forms_v2?: { form_id: StringId | Pick; form_activity_id?: StringId; completion_required_for_dunning?: boolean; score_required_for_dunning?: boolean; min_score_required_for_dunning?: number; score?: number; is_completed?: boolean; }[]; teams?: StringId[]; media?: StringId[]; cover_photo?: StringId; custom_status?: StringId; contract?: StringId; parent_repeating_workorder?: StringId; parent_repeating_day?: string; filter_asset_units_by_location?: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; teams_populated?: Pick; client_populated?: Pick; asset_units_populated?: AssetUnitsPopulated[]; assets_populated?: AssetsPopulated[]; asset_part_units_populated?: (Pick< AssetPartUnit.Data, | "_id" | "asset_part" | "custom_status" | "qty" | "directional_status" | "warehouse" | "warehouse_name" > & { asset_part: Pick & { cover_photo?: PopulatedMediaStorage[]; }; custom_status?: Pick< CustomStatus.CustomStatusSchema, "_id" | "code" | "color" | "local_name" | "name" >; })[]; assigned_to_populated?: RepresentativesPopulated; client_location_populated?: ClientLocationPopulated; workorder_categories_populated?: WorkorderCategoryPopulated[]; forms_populated?: FormPopulated[]; media_populated?: MediaPopulated; cover_photo_populated?: MediaPopulated; contract_populated?: { _id: StringId; serial_number: SerialNumber; title?: string; external_serial_number?: string; status?: "open" | "closed" | "canceled"; }; // Pick; } export interface CreateBody { company_namespace?: string[]; creator?: AdminCreator | RepCreator | ClientCreator; name: string; local_name?: string; description?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; status?: WorkorderStatus; assets?: StringId[]; asset_units?: StringId[]; asset_part_units?: StringId[]; workorder_categories: StringId[]; due_date?: number; start_date?: number; client_location: StringId; priority?: Priority; priority_human?: Priority_human; client: StringId; client_name?: string; serial_number?: SerialNumber; workorder_request?: StringId; assigned_to?: StringId[]; forms?: StringId[]; calendars: Calendar[]; parent_repeating_workorder?: StringId; due_date_day?: string; last_done_at?: number; last_done_by?: AdminCreator | RepCreator | ClientCreator; resolve_time?: number; sync_id: string; opened_at?: number; time?: number; opened_by?: AdminCreator | RepCreator | ClientCreator; teams?: StringId[]; media?: StringId[]; cover_photo?: StringId; custom_status?: StringId; contract?: StringId; is_dunning_allowed?: boolean; score_required_for_dunning?: boolean; min_score_required_for_dunning?: number; score?: number; is_completed?: boolean; forms_v2?: { form_id: StringId; form_activity_id?: StringId; completion_required_for_dunning?: boolean; score_required_for_dunning?: boolean; min_score_required_for_dunning?: number; score?: number; is_completed?: boolean; }[]; filter_asset_units_by_location?: boolean; } export interface UpdateBody { company_namespace?: string[]; _id?: StringId; creator?: AdminCreator | RepCreator | ClientCreator; editor?: AdminCreator | RepCreator | ClientCreator; name?: string; local_name?: string; description?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; status?: WorkorderStatus; assets?: StringId[]; asset_units?: StringId[]; asset_part_units?: StringId[]; workorder_categories?: string[]; due_date?: number; start_date?: number; client_location: StringId; priority?: Priority; priority_human?: Priority_human; client?: StringId; client_name?: string; workorder_request?: StringId; createdAt?: Date; updatedAt?: Date; serial_number?: SerialNumber; assigned_to?: StringId[]; forms?: StringId[]; time?: number; is_overdue?: boolean; opened_at?: number; done_at?: number; cancelled_at?: number; inprogress_at?: number; done_by?: AdminCreator | RepCreator | ClientCreator; cancelled_by?: AdminCreator | RepCreator | ClientCreator; opened_by?: AdminCreator | RepCreator | ClientCreator; inprogress_by?: AdminCreator | RepCreator | ClientCreator; calendars?: Calendar[]; parent_repeating_workorder?: string; due_date_day?: string; last_done_at?: number; last_done_by?: AdminCreator | RepCreator | ClientCreator; resolve_time?: number; sync_id?: string; teams?: StringId[]; media?: StringId[]; cover_photo?: StringId; custom_status?: StringId; contract?: StringId; } type SortingKeys = | "due_date" | "priority" | "updatedAt" | "createdAt" | "from_updatedAt" | "to_updatedAt" | "_id"; type PopulatedKeys = | "client" | "asset_units" | "asset_part_units" | "assets" | "assigned_to" | "client_location" | "workorder_categories" | "forms" | "media" | "cover_photo" | "teams" | "forms_v2" | "contract"; type GetPopulatedKey = | PopulatedKeys | "fullinvoice" | "proforma" | "activity-form-v2" | "activity-form" | "receive-parts"; export namespace Find { export type Params = DefaultPaginationQueryParams & { name?: string | string[]; _id?: StringId | StringId[]; assigned_to?: StringId | StringId[]; priority?: Priority | Priority[]; priority_human?: Priority_human | Priority_human[]; status?: WorkorderStatus | WorkorderStatus[]; workorder_categories?: StringId | StringId[]; client_location?: StringId | StringId[]; client?: StringId | StringId[]; assets?: StringId | StringId[]; asset_units?: StringId | StringId[]; asset_part_units?: StringId | StringId[]; due_date?: number; start_date?: number; forms?: StringId | StringId[]; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; from_start_date?: number; to_start_date?: number; from_due_date?: number; to_due_date?: number; teams?: StringId | StringId[]; is_dunning_allowed?: boolean | boolean[]; is_completed?: boolean | boolean[]; from_score?: number; to_score?: number; score?: number; contract?: StringId | StringId[]; "forms_v2.form_id"?: StringId | StringId[]; started?: boolean; assignedToMe?: boolean; search?: string; populatedKeys?: PopulatedKeys | PopulatedKeys[]; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: WorkorderSchema[] | PopulatedData[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: GetPopulatedKey[]; sortPage?: SortingKeys; } export type Result = WorkorderSchema | PopulatedData; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace WorkorderRequest { export type Status = "pending" | "rejected" | "approved"; export interface Data { _id: StringId; name: string; disabled: boolean; client?: StringId; client_location?: StringId; workorder_categories?: StringId[]; workorder?: StringId; contract?: StringId; status: Status; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[]; workorder_portal?: StringId; workorder_portal_link?: StringId; creator: AdminCreator | RepCreator | ClientCreator; editor?: AdminCreator | RepCreator | ClientCreator; teams?: StringId[]; sync_id: string; description?: string; assets?: StringId[]; asset_units?: StringId[]; priority?: Priority; priority_human?: Priority_human; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PopulatedData { _id: StringId; name: string; disabled: boolean; client?: StringId; client_location?: StringId; workorder_categories?: StringId[]; workorder?: StringId; contract?: StringId; status: Status; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[]; workorder_portal?: StringId; workorder_portal_link?: StringId; creator: AdminCreator | RepCreator | ClientCreator; editor?: AdminCreator | RepCreator | ClientCreator; teams?: StringId[]; sync_id: string; description?: string; assets?: StringId[]; asset_units?: StringId[]; priority?: Priority; priority_human?: Priority_human; company_namespace: string[]; createdAt: Date; updatedAt: Date; client_populated?: Pick< Client.ClientSchema, "client_code" | "name" | "_id" >; asset_units_populated?: AssetUnitsPopulated[]; assets_populated?: AssetsPopulated[]; client_location_populated?: ClientLocationPopulated; workorder_categories_populated?: WorkorderCategoryPopulated[]; media_populated?: MediaPopulated; workorder_populated?: Workorder.WorkorderSchema; } export interface CreateBody { name: string; disabled?: boolean; client?: StringId; client_location?: StringId; workorder_categories?: StringId[]; workorder?: StringId; contract?: StringId; status?: Status; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[]; workorder_portal?: StringId; workorder_portal_link?: StringId; creator?: AdminCreator | RepCreator | ClientCreator; teams?: StringId[]; sync_id: string; description?: string; assets?: StringId[]; asset_units?: StringId[]; priority?: Priority; priority_human?: Priority_human; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; name?: string; disabled?: boolean; client?: StringId; client_location?: StringId; workorder_categories?: StringId[]; workorder?: StringId; contract?: StringId; status?: Status; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[]; workorder_portal?: StringId; workorder_portal_link?: StringId; creator?: AdminCreator | RepCreator | ClientCreator; editor?: AdminCreator | RepCreator | ClientCreator; teams?: StringId[]; sync_id?: string; description?: string; assets?: StringId[]; asset_units?: StringId[]; priority?: Priority; priority_human?: Priority_human; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; } type SortingKeys = "priority" | "updatedAt" | "createdAt" | "_id"; type PopulatedKeys = | "client" | "client_location" | "asset_units" | "assets" | "workorder_categories" | "media" | "workorder"; export namespace Find { export type Params = DefaultPaginationQueryParams & { name?: string | string[]; _id?: StringId | StringId[]; priority?: Priority | Priority[]; priority_human?: Priority_human | Priority_human[]; status?: Status | Status[]; workorder_categories?: StringId | StringId[]; client_location?: StringId | StringId[]; client?: StringId | StringId[]; assets?: StringId | StringId[]; asset_units?: StringId | StringId[]; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; teams?: StringId | StringId[]; "creator._id"?: StringId | StringId[]; search?: string; populatedKeys?: PopulatedKeys | PopulatedKeys[]; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedData[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; [key: string]: any; } export type Result = Data | PopulatedData; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace WorkorderPortal { interface Accepted_system_fields { field: "clients" | "clientLocation" | "asset" | "assetUnit"; is_required: true; is_name_visible: Boolean; } type Default_Priority_human = "none" | "low" | "medium" | "high"; type Default_Priority = 0 | 1 | 2 | 3; export interface Data { creator: AdminOrRep; name: string; description?: string; default_priority_human?: Default_Priority_human; default_priority?: Default_Priority; default_workorder_categories?: StringId[]; teams?: string[]; company_namespace: string[]; allow_media_upload: "optional" | "required" | "hidden"; allow_signature: "optional" | "required" | "hidden"; header?: string; footer?: string; accepted_custom_fields?: string[]; accepted_system_fields: Accepted_system_fields[]; header_logo?: string; footer_logo?: string; createdAt?: Date; updatedAt?: Date; editor?: AdminOrRep; _id: StringId; disabled: boolean; website?: string; cover_photo?: StringId; activate_formV2_portal: boolean; activate_sales_order_portal: boolean; activate_workorder_request_portal: boolean; formV2?: StringId[]; product_groups?: StringId[]; geoPoint?: GeoPoint; location_name?: string; social_media_platforms?: { platform: StringId; handle?: string; url?: string; account_type: string; }[]; } export interface CreateBody { creator?: AdminOrRep; name: string; description?: string; default_priority_human?: Default_Priority_human; default_priority?: Default_Priority; default_workorder_categories?: StringId[]; customFields?: { [key: string]: string | number | boolean | StringId }; teams?: StringId[]; allow_media_upload?: "optional" | "required" | "hidden"; allow_signature?: "optional" | "required" | "hidden"; header?: string; footer?: string; accepted_custom_fields?: StringId[]; accepted_system_fields?: Accepted_system_fields[]; header_logo?: string; footer_logo?: string; website?: string; cover_photo?: StringId; activate_formV2_portal: boolean; activate_sales_order_portal: boolean; activate_workorder_request_portal: boolean; formV2?: StringId[]; product_groups?: StringId[]; geoPoint?: GeoPoint; location_name?: string; social_media_platforms?: { platform: StringId; handle?: string; url?: string; account_type: string; }[]; } export interface UpdateBody { name?: string; description?: string; default_priority_human?: Default_Priority_human; default_priority?: Default_Priority; default_workorder_categories?: StringId[]; teams?: StringId[]; allow_media_upload?: "optional" | "required" | "hidden"; allow_signature?: "optional" | "required" | "hidden"; header?: string; footer?: string; accepted_custom_fields?: StringId[]; accepted_system_fields?: Accepted_system_fields[]; header_logo?: string; footer_logo?: string; editor?: AdminOrRep; website?: string; cover_photo?: StringId; activate_formV2_portal?: boolean; activate_sales_order_portal?: boolean; activate_workorder_request_portal?: boolean; formV2?: StringId[]; product_groups?: StringId[]; geoPoint?: GeoPoint; location_name?: string; social_media_platforms?: { platform: StringId; handle: string; url: string; account_type: string; }[]; } export interface PopulatedDoc { creator: AdminOrRep; name: string; description?: string; default_priority_human?: Default_Priority_human; default_priority?: Default_Priority; default_workorder_categories?: StringId[]; default_workorder_categories_populated?: WorkorderCategoryPopulated[]; teams?: string[]; company_namespace: string[]; allow_media_upload: "optional" | "required" | "hidden"; allow_signature: "optional" | "required" | "hidden"; header?: string; footer?: string; accepted_custom_fields?: string[]; accepted_custom_fields_populated?: { [key: string]: string | number | boolean; }[]; accepted_system_fields: Accepted_system_fields[]; header_logo?: string; header_logo_populated?: PopulatedMediaStorage[]; footer_logo?: string; footer_logo_populated?: PopulatedMediaStorage[]; createdAt?: Date; updatedAt?: Date; editor?: AdminOrRep; _id: StringId; disabled: boolean; website?: string; cover_photo?: StringId; activate_formV2_portal: boolean; activate_sales_order_portal: boolean; activate_workorder_request_portal: boolean; formV2?: StringId[]; formV2_populated?: FormPopulated[]; product_groups?: Pick< ProductGroup.ProductGroupSchema, "_id" | "name" | "local_name" >[]; geoPoint?: GeoPoint; location_name?: string; social_media_platforms?: { platform: StringId; handle?: string; url?: string; account_type: string; }[]; } type SortingKeys = "default_priority" | "updatedAt" | "createdAt"; type PopulatedKeys = | "default_workorder_categories" | "header_logo" | "footer_logo" | "accepted_custom_fields" | "formV2" | "product_groups"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; default_priority?: Default_Priority | Default_Priority[]; default_priority_human?: Default_Priority_human | Default_Priority_human[]; default_workorder_categories?: StringId | StringId[]; formV2?: StringId | StringId[]; product_groups?: StringId | StringId[]; activate_formV2_portal?: boolean; activate_sales_order_portal?: boolean; activate_workorder_request_portal?: boolean; from_updatedAt?: number; to_updatedAt?: number; disabled?: boolean; search?: string; populatedKeys?: PopulatedKeys | PopulatedKeys[]; sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = Data | PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace QuickConvertToPdf { export interface QuickConvertToPdfSchema { _id?: string; creator: AdminCreator | RepCreator | ClientCreator; document_id?: string[]; document_type: PrintTypes; print_media?: string | MediaDoc; state?: | "queued" | "initiated" | "started" | "delayed" | "completed" | "in_progress" | "failed"; content?: string; sync_id: string; createdAt: string; updatedAt: string; } export interface CreateBody { document_id: string[]; document_type: PrintTypes; sync_id: string; } type PopulatedKeys = "print_media"; export namespace Find { export type Params = DefaultPaginationQueryParams & { document_id?: string; document_type?: PrintTypes; print_media?: string | MediaDoc; disabled?: boolean; }; export interface Result extends DefaultPaginationResult { data: QuickConvertToPdfSchema[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = QuickConvertToPdfSchema; } export namespace Create { export type Body = CreateBody; export type Result = QuickConvertToPdfSchema; } export namespace Remove { export type ID = string; export type Result = QuickConvertToPdfSchema; } } export namespace FullInvoice { export interface InvoiceSchema { _id: string; items: Item.Schema[]; return_items: Item.Schema[]; integration_meta?: { [key: string]: any }; external_serial_number?: string; qr_code_tlv?: string; processable?: boolean; client_id: string; client_balance?: number; client_name: string; comment?: string; return_comment?: string; creator: AdminCreator | RepCreator | ClientCreator; implemented_by?: AdminCreator | RepCreator | ClientCreator; latest?: boolean; version?: number; time?: number; issue_date: string; delivery_date?: string; business_day?: string; currency: string; serial_number: SerialNumber; geo_tag?: { type: "Point"; coordinates: number[]; }; sync_id: string; address?: { [key: string]: any }; company_namespace: string[]; promotions: Promotion.Schema[]; priceLists: { [key: string]: any }[]; visit_id?: string; teams?: string[]; converter?: AdminCreator | RepCreator | ClientCreator; converted_proforma_serial_number?: SerialNumber; converted_proforma_return_serial_number?: SerialNumber; proforma_reference?: string; converted_at?: number; exclude_return_items?: boolean; returned_from?: string; returned_to?: string; returned_from_serial_number?: SerialNumber; returned_to_serial_number?: SerialNumber; is_void?: boolean; due_date: string; return_serial_number?: SerialNumber; origin_warehouse: string; route?: string; paymentsData: { _id: string; invoice_value: number; paid: number; balance: number; payments: PaymentData[]; }; consumption: { status: "consumed" | "unconsumed" | "partially_consumed"; remainder: number; }; status: InvoiceStatus; custom_status?: string; subtotal: number; discount_amount: number; taxable_subtotal: number; tax_amount: number; total: number; pre_subtotal: number; pre_discount_amount: number; pre_taxable_subtotal: number; pre_tax_amount: number; pre_total: number; return_subtotal: number; return_discount_amount: number; return_taxable_subtotal: number; return_tax_amount: number; return_total: number; deductionRatio?: number; deductionFixed?: number; totalDeductedTax?: number; totalDeduction?: number; totalDeductionBeforeTax?: number; totalAfterDeduction?: number; taxes?: { [key: string]: any }; overwriteDeductionFixed?: number; overwriteTaxExempt?: boolean; tax_exempt?: boolean; overwriteDeductionRatio?: number; shipping_zone?: { geoData: { type: "Polygon"; coordinates: number[][][]; // ?????? }[]; name: string; local_name?: string; shipping_method?: { local_name?: string; name: string; rate?: number; tax?: string; description?: string; local_description?: string; company_namespace: string[]; }; note?: string; local_note?: string; country: string; reachable: boolean; company_namespace: string[]; }; payment_method?: { name: string; local_name?: string; fee?: number; rate?: number; type: "online" | "offline"; company_namespace: string[]; }; shipping_price?: number; shipping_tax?: number; shipping_charge?: number; payment_charge?: number; total_with_charges?: number; payment?: { amount?: number }; createdAt: string; updatedAt: string; __v: number; transaction_processed: boolean; advanced_serial_number?: string; ubl_qr?: string; ubl_uuid?: string; ubl_id?: string; ubl_reported_time?: number; ubl_reported?: boolean; ubl_clearance_qr?: string; ubl_clearance_time?: number; ubl_clearance?: boolean; ubl_invoice_type?: "simplified" | "standard"; ubl_reporting_type?: "report" | "clearance"; ubl_invoice_counter_number?: number; simulation_ubl_reported_time?: number; simulation_ubl_reported?: boolean; simulation_ubl_clearance_time?: number; simulation_ubl_clearance?: boolean; simulation_ubl_invoice_type?: "simplified" | "standard"; simulation_ubl_reporting_type?: "report" | "clearance"; simulation_ubl_invoice_counter_number?: number; simulation_ubl_qr?: string; simulation_reporting_status?: boolean; production_reporting_status?: boolean; skip_promos?: boolean; skipped_promotions?: { _id: StringId; name?: string; ref?: string }[]; partially_returned_from?: StringId; partially_returned_to?: StringId[]; partially_returned_from_serial_number?: SerialNumber; partially_returned_to_serial_number?: SerialNumber[]; discount_amount_float?: number; net_total?: number; tax_amount_after_deduction_float?: number; tax_amount_after_deduction_float_rounded_sum?: number; tax_amount_after_deduction_float_rounded?: number; total_float?: number; total_float_rounded?: number; total_float_rounded_sum?: number; total_before_tax?: number; /** * `total_before_tax + totalDeductionBeforeTax`: net of tax and before the * cart (header) deduction. Net of tax for inclusive-tax lines too, unlike * `taxable_subtotal`. */ total_before_deduction_and_tax?: number; taxable_amount_float?: number; taxable_amount_float_rounded_sum?: number; taxable_amount_float_rounded?: number; pre_discount_amount_float?: number; pre_net_total?: number; pre_tax_amount_after_deduction_float?: number; pre_tax_amount_after_deduction_float_rounded?: number; pre_tax_amount_after_deduction_float_rounded_sum?: number; pre_total_float?: number; pre_total_float_rounded?: number; pre_total_float_rounded_sum?: number; pre_total_before_tax?: number; pre_total_before_deduction_and_tax?: number; pre_taxable_amount_float?: number; pre_taxable_amount_float_rounded?: number; pre_taxable_amount_float_rounded_sum?: number; return_discount_amount_float?: number; return_net_total?: number; return_tax_amount_after_deduction_float?: number; return_tax_amount_after_deduction_float_rounded?: number; return_tax_amount_after_deduction_float_rounded_sum?: number; return_total_float?: number; return_total_float_rounded?: number; return_total_float_rounded_sum?: number; return_total_before_tax?: number; return_total_before_deduction_and_tax?: number; return_taxable_amount_float?: number; return_taxable_amount_float_rounded?: number; return_taxable_amount_float_rounded_sum?: number; totalDeductedTaxFloat?: number; totalDeductionFloat?: number; totalDeductionBeforeTaxFloat?: number; totalAfterDeductionFloat?: number; lines_discount?: number; lines_discount_float?: number; total_word?: string; total_local_word?: string; workorder?: StringId; asset?: StringId; asset_unit?: StringId; signature?: StringId; media?: StringId[]; total_items_base_unit_qty?: number; total_return_items_base_unit_qty?: number; total_items_qty?: number; total_return_items_qty?: number; invoice_payment_type?: "cash" | "credit"; client_geo_location?: { lat: number; lng: number }; network_state?: number; platform?: string; version_name?: string; battery_level?: number; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; treat_invoice_as_proforma_for_etax?: boolean; bypass_freshness_window_code_entered?: boolean; promotion_freshness_window_exceeded?: boolean; } export type Data = InvoiceSchema; export interface CreateBody { items?: Item.Body[]; return_items?: Item.Body[]; integration_meta?: { [key: string]: any }; external_serial_number?: string; processable?: boolean; client_id: string; client_name: string; comment?: string; return_comment?: string; creator?: AdminCreator | RepCreator | ClientCreator; version?: number; time?: number; issue_date: string; delivery_date?: string; currency?: string; serial_number?: SerialNumber; geo_tag?: { type: "Point"; coordinates: number[]; }; sync_id: string; address?: { [key: string]: any }; company_namespace?: string[]; promotions?: Promotion.Schema[]; priceLists: { [key: string]: any }[]; visit_id?: string; teams?: string[]; due_date: string; return_serial_number?: SerialNumber; origin_warehouse: string; route?: string; custom_status?: string; subtotal: number; discount_amount: number; taxable_subtotal: number; tax_amount: number; total: number; pre_subtotal: number; pre_discount_amount: number; pre_taxable_subtotal: number; pre_tax_amount: number; pre_total: number; return_subtotal: number; return_discount_amount: number; return_taxable_subtotal: number; return_tax_amount: number; return_total: number; deductionRatio?: number; deductionFixed?: number; totalDeductedTax?: number; totalDeduction?: number; totalDeductionBeforeTax?: number; totalAfterDeduction?: number; taxes?: { [key: string]: any }; overwriteDeductionFixed?: number; overwriteTaxExempt?: boolean; tax_exempt?: boolean; overwriteDeductionRatio?: number; shipping_zone?: { geoData: { type: "Polygon"; coordinates: number[][][]; }[]; name: string; local_name?: string; shipping_method?: { local_name?: string; name: string; rate?: number; tax?: string; description?: string; local_description?: string; company_namespace: string[]; }; note?: string; local_note?: string; country: string; reachable: boolean; company_namespace: string[]; }; payment_method?: { name: string; local_name?: string; fee?: number; rate?: number; type: "online" | "offline"; company_namespace: string[]; }; shipping_price?: number; shipping_tax?: number; shipping_charge?: number; payment_charge?: number; total_with_charges?: number; payment?: { amount?: number }; transaction_processed: boolean; advanced_serial_number?: string; ubl_qr?: string; ubl_uuid?: string; ubl_id?: string; ubl_reported_time?: number; ubl_reported?: boolean; ubl_clearance_qr?: string; ubl_clearance_time?: number; ubl_clearance?: boolean; ubl_invoice_type?: "simplified" | "standard"; ubl_reporting_type?: "report" | "clearance"; ubl_invoice_counter_number?: number; simulation_ubl_reported_time?: number; simulation_ubl_reported?: boolean; simulation_ubl_clearance_time?: number; simulation_ubl_clearance?: boolean; simulation_ubl_invoice_type?: "simplified" | "standard"; simulation_ubl_reporting_type?: "report" | "clearance"; simulation_ubl_invoice_counter_number?: number; simulation_ubl_qr?: string; simulation_reporting_status?: boolean; production_reporting_status?: boolean; skip_promos?: boolean; skipped_promotions?: { _id: StringId; name?: string; ref?: string }[]; partially_returned_from?: StringId; partially_returned_to?: StringId[]; partially_returned_from_serial_number?: SerialNumber; partially_returned_to_serial_number?: SerialNumber[]; discount_amount_float?: number; net_total?: number; tax_amount_after_deduction_float?: number; tax_amount_after_deduction_float_rounded_sum?: number; tax_amount_after_deduction_float_rounded?: number; total_float?: number; total_float_rounded?: number; total_float_rounded_sum?: number; total_before_tax?: number; /** * `total_before_tax + totalDeductionBeforeTax`: net of tax and before the * cart (header) deduction. Net of tax for inclusive-tax lines too, unlike * `taxable_subtotal`. */ total_before_deduction_and_tax?: number; taxable_amount_float?: number; taxable_amount_float_rounded_sum?: number; taxable_amount_float_rounded?: number; pre_discount_amount_float?: number; pre_net_total?: number; pre_tax_amount_after_deduction_float?: number; pre_tax_amount_after_deduction_float_rounded?: number; pre_tax_amount_after_deduction_float_rounded_sum?: number; pre_total_float?: number; pre_total_float_rounded?: number; pre_total_float_rounded_sum?: number; pre_total_before_tax?: number; pre_total_before_deduction_and_tax?: number; pre_taxable_amount_float?: number; pre_taxable_amount_float_rounded?: number; pre_taxable_amount_float_rounded_sum?: number; return_discount_amount_float?: number; return_net_total?: number; return_tax_amount_after_deduction_float?: number; return_tax_amount_after_deduction_float_rounded?: number; return_tax_amount_after_deduction_float_rounded_sum?: number; return_total_float?: number; return_total_float_rounded?: number; return_total_float_rounded_sum?: number; return_total_before_tax?: number; return_total_before_deduction_and_tax?: number; return_taxable_amount_float?: number; return_taxable_amount_float_rounded?: number; return_taxable_amount_float_rounded_sum?: number; totalDeductedTaxFloat?: number; totalDeductionFloat?: number; totalDeductionBeforeTaxFloat?: number; totalAfterDeductionFloat?: number; lines_discount?: number; lines_discount_float?: number; total_word?: string; total_local_word?: string; workorder?: StringId; asset?: StringId; asset_unit?: StringId; signature?: StringId; media?: StringId[]; total_items_base_unit_qty?: number; total_return_items_base_unit_qty?: number; total_items_qty?: number; total_return_items_qty?: number; invoice_payment_type?: "cash" | "credit"; client_geo_location?: { lat: number; lng: number }; network_state?: number; platform?: string; version_name?: string; battery_level?: number; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; implemented_by?: AdminCreator | RepCreator | ClientCreator; business_day?: string; bypass_freshness_window_code_entered?: boolean; promotion_freshness_window_exceeded?: boolean; createdAt?: string; updatedAt?: string; } export interface UpdateBody { integration_meta?: { [key: string]: any }; issue_date?: string; } type InvoiceSchemaWithPopulatedKeys = { _id: string; items: { variant: { product_name: string; variant_id: Pick; product_id: Pick; variant_name: string; listed_price: number; variant_local_name?: string; variant_img?: string; product_local_name?: string; product_img?: string; product_sku?: string; product_barcode?: string; variant_sku?: string; variant_barcode?: string; }; measureunit: { _id: string; name: string; factor: number; parent?: string; disabled?: boolean; company_namespace: string[]; }; tax: { name: string; rate: number; type: "inclusive" | "additive" | "N/A"; disabled?: boolean; }; promotions?: Promotion.Schema[]; used_promotions?: { id: string; name: string; ref?: string }[]; general_promotions?: { id: string; name: string; ref?: string }[]; applicable_promotions?: { id: string; name: string; ref?: string }[]; modifiers_groups?: Item.ModifierGroup[]; isAdditional?: boolean; qty: number; base_unit_qty?: number; overwritePrice?: number; price: number; discounted_price: number; tax_amount: number; tax_total: number; class: string; discount_value: number; gross_value?: number; line_total?: number; total_before_tax?: number; hidden_price?: number; modifiers_total?: number; modifiers_total_before_tax?: number; modifiers_tax_total?: number; tax_total_without_modifiers?: number; line_total_without_modifiers?: number; total_before_tax_without_modifiers?: number; deductionRatio?: number; deductedTax?: number; deduction?: number; deductionBeforeTax?: number; lineTotalAfterDeduction?: number; company_namespace?: string[]; note?: string; }[]; return_items: { variant: { product_name: string; variant_id: Pick; product_id: Pick; variant_name: string; listed_price: number; variant_local_name?: string; variant_img?: string; product_local_name?: string; product_img?: string; product_sku?: string; product_barcode?: string; variant_sku?: string; variant_barcode?: string; }; measureunit: { _id: string; name: string; factor: number; parent?: string; disabled?: boolean; company_namespace: string[]; }; tax: { name: string; rate: number; type: "inclusive" | "additive" | "N/A"; disabled?: boolean; }; promotions?: Promotion.Schema[]; used_promotions?: { id: string; name: string; ref?: string }[]; general_promotions?: { id: string; name: string; ref?: string }[]; applicable_promotions?: { id: string; name: string; ref?: string }[]; modifiers_groups?: Item.ModifierGroup[]; isAdditional?: boolean; qty: number; base_unit_qty?: number; overwritePrice?: number; price: number; discounted_price: number; tax_amount: number; tax_total: number; discount_value: number; gross_value?: number; line_total?: number; total_before_tax?: number; hidden_price?: number; modifiers_total?: number; modifiers_total_before_tax?: number; modifiers_tax_total?: number; tax_total_without_modifiers?: number; line_total_without_modifiers?: number; total_before_tax_without_modifiers?: number; deductionRatio?: number; deductedTax?: number; deduction?: number; deductionBeforeTax?: number; lineTotalAfterDeduction?: number; company_namespace?: string[]; note?: string; class: string; return_reason?: string | ReturnReason.Schema; }[]; integration_meta?: { [key: string]: any }; external_serial_number?: string; qr_code_tlv?: string; processable?: boolean; client_name: string; client_balance?: number; comment?: string; return_comment?: string; creator: AdminCreator | RepCreator | ClientCreator; latest?: boolean; version?: number; time?: number; issue_date: string; delivery_date?: string; currency: string; serial_number: SerialNumber; geo_tag?: { type: "Point"; coordinates: number[]; }; sync_id: string; address?: { [key: string]: any }; company_namespace: string[]; promotions: Promotion.Schema[]; priceLists: { [key: string]: any }[]; visit_id?: string; teams?: string[] | Team.TeamSchema[]; converter?: AdminCreator | RepCreator | ClientCreator; converted_proforma_serial_number?: SerialNumber; converted_proforma_return_serial_number?: SerialNumber; proforma_reference?: string; converted_at?: number; exclude_return_items?: boolean; returned_from?: | string | Pick< FullInvoice.InvoiceSchema, "_id" | "serial_number" | "advanced_serial_number" >; returned_to?: string | FullInvoice.InvoiceSchema; returned_from_serial_number?: SerialNumber; returned_to_serial_number?: SerialNumber; is_void?: boolean; due_date: string; return_serial_number?: SerialNumber; origin_warehouse: string | Warehouse.WarehouseSchema; route?: string | Route.RouteSchema; paymentsData: { _id: string; invoice_value: number; paid: number; balance: number; payments: PaymentData[]; }; consumption: { status: "consumed" | "unconsumed" | "partially_consumed"; remainder: number; }; status: InvoiceStatus; subtotal: number; discount_amount: number; taxable_subtotal: number; tax_amount: number; total: number; pre_subtotal: number; pre_discount_amount: number; pre_taxable_subtotal: number; pre_tax_amount: number; pre_total: number; return_subtotal: number; return_discount_amount: number; return_taxable_subtotal: number; return_tax_amount: number; return_total: number; deductionRatio?: number; deductionFixed?: number; totalDeductedTax?: number; totalDeduction?: number; totalDeductionBeforeTax?: number; totalAfterDeduction?: number; taxes?: { [key: string]: any }; overwriteDeductionFixed?: number; overwriteTaxExempt?: boolean; tax_exempt?: boolean; overwriteDeductionRatio?: number; shipping_zone?: { geoData: { type: "Polygon"; coordinates: number[][][]; // ?????? }[]; name: string; local_name?: string; shipping_method?: { local_name?: string; name: string; rate?: number; tax?: string; description?: string; local_description?: string; company_namespace: string[]; }; note?: string; local_note?: string; country: string; reachable: boolean; company_namespace: string[]; }; payment_method?: { name: string; local_name?: string; fee?: number; rate?: number; type: "online" | "offline"; company_namespace: string[]; }; shipping_price?: number; shipping_tax?: number; shipping_charge?: number; payment_charge?: number; total_with_charges?: number; payment?: { amount?: number }; createdAt: string; updatedAt: string; __v: number; client_id?: string | Client.ClientSchema; custom_status?: string | CustomStatus.CustomStatusSchema; tax_number?: string | Pick; transaction_processed: boolean; advanced_serial_number?: string; ubl_qr?: string; ubl_uuid?: string; ubl_id?: string; ubl_reported_time?: number; ubl_reported?: boolean; ubl_clearance_qr?: string; ubl_clearance_time?: number; ubl_clearance?: boolean; ubl_invoice_type?: "simplified" | "standard"; ubl_reporting_type?: "report" | "clearance"; ubl_invoice_counter_number?: number; simulation_ubl_reported_time?: number; simulation_ubl_reported?: boolean; simulation_ubl_clearance_time?: number; simulation_ubl_clearance?: boolean; simulation_ubl_invoice_type?: "simplified" | "standard"; simulation_ubl_reporting_type?: "report" | "clearance"; simulation_ubl_invoice_counter_number?: number; simulation_ubl_qr?: string; simulation_reporting_status?: boolean; production_reporting_status?: boolean; skip_promos?: boolean; skipped_promotions?: { _id: StringId; name?: string; ref?: string }[]; partially_returned_from?: | StringId | Pick< FullInvoice.InvoiceSchema, "_id" | "serial_number" | "advanced_serial_number" >; partially_returned_to?: StringId[]; partially_returned_from_serial_number?: SerialNumber; partially_returned_to_serial_number?: SerialNumber[]; discount_amount_float?: number; net_total?: number; tax_amount_after_deduction_float?: number; tax_amount_after_deduction_float_rounded_sum?: number; tax_amount_after_deduction_float_rounded?: number; total_float?: number; total_float_rounded?: number; total_float_rounded_sum?: number; total_before_tax?: number; /** * `total_before_tax + totalDeductionBeforeTax`: net of tax and before the * cart (header) deduction. Net of tax for inclusive-tax lines too, unlike * `taxable_subtotal`. */ total_before_deduction_and_tax?: number; taxable_amount_float?: number; taxable_amount_float_rounded_sum?: number; taxable_amount_float_rounded?: number; pre_discount_amount_float?: number; pre_net_total?: number; pre_tax_amount_after_deduction_float?: number; pre_tax_amount_after_deduction_float_rounded?: number; pre_tax_amount_after_deduction_float_rounded_sum?: number; pre_total_float?: number; pre_total_float_rounded?: number; pre_total_float_rounded_sum?: number; pre_total_before_tax?: number; pre_total_before_deduction_and_tax?: number; pre_taxable_amount_float?: number; pre_taxable_amount_float_rounded?: number; pre_taxable_amount_float_rounded_sum?: number; return_discount_amount_float?: number; return_net_total?: number; return_tax_amount_after_deduction_float?: number; return_tax_amount_after_deduction_float_rounded?: number; return_tax_amount_after_deduction_float_rounded_sum?: number; return_total_float?: number; return_total_float_rounded?: number; return_total_float_rounded_sum?: number; return_total_before_tax?: number; return_total_before_deduction_and_tax?: number; return_taxable_amount_float?: number; return_taxable_amount_float_rounded?: number; return_taxable_amount_float_rounded_sum?: number; totalDeductedTaxFloat?: number; totalDeductionFloat?: number; totalDeductionBeforeTaxFloat?: number; totalAfterDeductionFloat?: number; lines_discount?: number; lines_discount_float?: number; total_word?: string; total_local_word?: string; workorder?: | StringId | Pick< Workorder.WorkorderSchema, "_id" | "serial_number" | "name" | "local_name" >; asset?: StringId; asset_unit?: StringId; signature?: PopulatedMediaStorage; media?: PopulatedMediaStorage[]; total_items_base_unit_qty?: number; total_return_items_base_unit_qty?: number; total_items_qty?: number; total_return_items_qty?: number; invoice_payment_type?: "cash" | "credit"; client_geo_location?: { lat: number; lng: number }; network_state?: number; platform?: string; version_name?: string; battery_level?: number; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; implemented_by?: AdminCreator | RepCreator | ClientCreator; business_day?: string; bypass_freshness_window_code_entered?: boolean; promotion_freshness_window_exceeded?: boolean; }; type InvoiceStatus = "paid" | "unpaid" | "partially_paid"; type PopulatedKeys = | "client" | "tax_number" | "custom_status" | "return_reason" | "teams" | "warehouse" | "route" | "workorder" | "returned_from" | "partially_returned_from" | "returned_to"; type SortingKeys = | "line_total" | "product_name" | "variant_name" | "product_sku" | "product_barcode" | "variant_sku" | "variant_barcode"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; creator?: string[] | string; client_id?: string[] | string; clients?: string[] | string; from_issue_date?: number; to_issue_date?: number; origin_warehouse?: string[] | string; custom_status?: string[] | string; status?: InvoiceStatus | InvoiceStatus[]; is_void?: false; has_return?: boolean; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; sortPage?: SortingKeys; "serial_number.formatted"?: string[] | string; "return_serial_number.formatted"?: string[] | string; returned_from?: string[] | string; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; treat_invoice_as_proforma_for_etax?: boolean; }; export interface Result extends DefaultPaginationResult { data: InvoiceSchemaWithPopulatedKeys[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; sortPage?: SortingKeys; } export type Result = InvoiceSchemaWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = InvoiceSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = InvoiceSchema; } } export namespace Proforma { export interface ProformaSchema { _id: string; items: Item.Schema[]; return_items: Item.Schema[]; integration_meta?: { [key: string]: any }; external_serial_number?: string; processable?: boolean; client_id: string; client_name: string; comment?: string; creator: AdminOrRepOrTenant | ClientCreator; implemented_by?: AdminCreator | RepCreator; latest: boolean; version?: number; time?: number; issue_date: string; delivery_date?: string; currency: string; serial_number: SerialNumber; return_serial_number?: SerialNumber; geo_tag?: { type: "Point"; coordinates: number[]; }; sync_id: string; address?: { [key: string]: any }; company_namespace: string[]; promotions: Promotion.Schema[]; priceLists: { [key: string]: any }[]; visit_id?: string; teams?: string[]; converter?: AdminCreator | RepCreator | ClientCreator; invoice_reference?: string; converted_at?: number; route?: string; class: "proforma" | "return"; status: ProformaStatus; custom_status?: string; editor?: AdminCreator | RepCreator | ClientCreator; disabled: boolean; subtotal: number; discount_amount: number; taxable_subtotal: number; tax_amount: number; total: number; total_before_tax?: number; /** * `total_before_tax + totalDeductionBeforeTax`: net of tax and before the * cart (header) deduction. Net of tax for inclusive-tax lines too, unlike * `taxable_subtotal`. */ total_before_deduction_and_tax?: number; pre_total_before_tax?: number; pre_total_before_deduction_and_tax?: number; return_total_before_tax?: number; return_total_before_deduction_and_tax?: number; pre_subtotal?: number; pre_discount_amount?: number; pre_taxable_subtotal?: number; pre_tax_amount?: number; pre_total?: number; return_subtotal: number; return_discount_amount: number; return_taxable_subtotal: number; return_tax_amount: number; return_total: number; deductionRatio?: number; deductionFixed?: number; totalDeductedTax?: number; totalDeduction?: number; totalDeductionBeforeTax?: number; totalAfterDeduction?: number; taxes?: { [key: string]: any }; overwriteDeductionFixed?: number; overwriteTaxExempt?: boolean; tax_exempt?: boolean; overwriteDeductionRatio?: number; shipping_zone?: { geoData: { type: "Polygon"; coordinates: number[][][]; }[]; name: string; local_name?: string; shipping_method?: { local_name?: string; name: string; rate?: number; tax?: string; description?: string; local_description?: string; company_namespace: string[]; }; note?: string; local_note?: string; country: string; reachable: boolean; company_namespace: string[]; }; payment_method?: { name: string; local_name?: string; fee?: number; rate?: number; type: "online" | "offline"; company_namespace: string[]; }; shipping_price?: number; shipping_tax?: number; shipping_charge?: number; payment_charge?: number; total_with_charges?: number; media?: StringId[]; signature?: StringId; bypass_freshness_window_code_entered?: boolean; promotion_freshness_window_exceeded?: boolean; total_word?: string; total_local_word?: string; createdAt: string; updatedAt: string; __v: number; } export type Data = ProformaSchema; export interface CreateBody { items: Item.Schema[]; return_items?: Item.Schema[]; integration_meta?: { [key: string]: any }; external_serial_number?: string; processable?: boolean; client_id: string; client_name: string; comment?: string; class: "proforma" | "return"; creator: AdminCreator | RepCreator | ClientCreator; implemented_by?: AdminCreator | RepCreator; version?: number; time?: number; issue_date: string; delivery_date?: string; currency?: string; serial_number?: SerialNumber; return_serial_number?: SerialNumber; geo_tag?: { type: "Point"; coordinates: number[]; }; sync_id: string; address?: { [key: string]: any }; company_namespace?: string[]; promotions?: Promotion.Schema[]; priceLists?: { [key: string]: any }[]; visit_id?: string; teams?: string[]; route?: string; custom_status?: string; disabled?: boolean; subtotal: number; discount_amount: number; taxable_subtotal: number; tax_amount: number; total: number; total_before_tax?: number; /** * `total_before_tax + totalDeductionBeforeTax`: net of tax and before the * cart (header) deduction. Net of tax for inclusive-tax lines too, unlike * `taxable_subtotal`. */ total_before_deduction_and_tax?: number; pre_total_before_tax?: number; pre_total_before_deduction_and_tax?: number; return_total_before_tax?: number; return_total_before_deduction_and_tax?: number; pre_subtotal?: number; pre_discount_amount?: number; pre_taxable_subtotal?: number; pre_tax_amount?: number; pre_total?: number; return_subtotal: number; return_discount_amount: number; return_taxable_subtotal: number; return_tax_amount: number; return_total: number; deductionRatio?: number; deductionFixed?: number; totalDeductedTax?: number; totalDeduction?: number; totalDeductionBeforeTax?: number; totalAfterDeduction?: number; taxes?: { [key: string]: any }; overwriteDeductionFixed?: number; overwriteTaxExempt?: boolean; tax_exempt?: boolean; overwriteDeductionRatio?: number; shipping_zone?: { geoData: { type: "Polygon"; coordinates: number[][][]; }[]; name: string; local_name?: string; shipping_method?: { local_name?: string; name: string; rate?: number; tax?: string; description?: string; local_description?: string; company_namespace: string[]; }; note?: string; local_note?: string; country: string; reachable: boolean; company_namespace: string[]; }; payment_method?: { name: string; local_name?: string; fee?: number; rate?: number; type: "online" | "offline"; company_namespace: string[]; }; shipping_price?: number; shipping_tax?: number; shipping_charge?: number; payment_charge?: number; total_with_charges?: number; media?: StringId[]; signature?: StringId; bypass_freshness_window_code_entered?: boolean; promotion_freshness_window_exceeded?: boolean; } export interface UpdateBody { _id?: string; items?: Item.Schema[]; return_items?: Item.Schema[]; integration_meta?: { [key: string]: any }; external_serial_number?: string; processable?: boolean; client_id?: string; client_name?: string; comment?: string; creator?: AdminOrRepOrTenant | ClientCreator; implemented_by?: AdminCreator | RepCreator; latest?: boolean; version?: number; time?: number; issue_date?: string; delivery_date?: string; class?: "proforma" | "return"; currency?: string; serial_number?: SerialNumber; return_serial_number?: SerialNumber; geo_tag?: { type: "Point"; coordinates: number[]; }; sync_id?: string; address?: { [key: string]: any }; company_namespace?: string[]; promotions?: Promotion.Schema[]; priceLists?: { [key: string]: any }[]; visit_id?: string; teams?: string[]; converter?: AdminCreator | RepCreator | ClientCreator; invoice_reference?: string; converted_at?: number; route?: string; status?: ProformaStatus; custom_status?: string; editor?: AdminCreator | RepCreator | ClientCreator; disabled?: boolean; subtotal?: number; discount_amount?: number; taxable_subtotal?: number; tax_amount?: number; total?: number; total_before_tax?: number; /** * `total_before_tax + totalDeductionBeforeTax`: net of tax and before the * cart (header) deduction. Net of tax for inclusive-tax lines too, unlike * `taxable_subtotal`. */ total_before_deduction_and_tax?: number; pre_total_before_tax?: number; pre_total_before_deduction_and_tax?: number; return_total_before_tax?: number; return_total_before_deduction_and_tax?: number; pre_subtotal?: number; pre_discount_amount?: number; pre_taxable_subtotal?: number; pre_tax_amount?: number; pre_total?: number; return_subtotal?: number; return_discount_amount?: number; return_taxable_subtotal?: number; return_tax_amount?: number; return_total?: number; deductionRatio?: number; deductionFixed?: number; totalDeductedTax?: number; totalDeduction?: number; totalDeductionBeforeTax?: number; totalAfterDeduction?: number; taxes?: { [key: string]: any }; overwriteDeductionFixed?: number; overwriteTaxExempt?: boolean; tax_exempt?: boolean; overwriteDeductionRatio?: number; shipping_zone?: { geoData: { type: "Polygon"; coordinates: number[][][]; }[]; name: string; local_name?: string; shipping_method?: { local_name?: string; name: string; rate?: number; tax?: string; description?: string; local_description?: string; company_namespace: string[]; }; note?: string; local_note?: string; country: string; reachable: boolean; company_namespace: string[]; }; payment_method?: { name: string; local_name?: string; fee?: number; rate?: number; type: "online" | "offline"; company_namespace: string[]; }; shipping_price?: number; shipping_tax?: number; shipping_charge?: number; payment_charge?: number; total_with_charges?: number; media?: StringId[]; signature?: StringId; bypass_freshness_window_code_entered?: boolean; promotion_freshness_window_exceeded?: boolean; createdAt?: string; updatedAt?: string; __v?: number; } type ProformaSchemaWithPopulatedKeys = ProformaSchema & { items: { variant: { product_name: string; variant_id: string | Pick; product_id: string | Pick; variant_name: string; listed_price: number; variant_local_name?: string; variant_img?: string; product_local_name?: string; product_img?: string; product_sku?: string; product_barcode?: string; variant_sku?: string; variant_barcode?: string; }; measureunit: { _id: string; name: string; factor: number; parent?: string; disabled?: boolean; company_namespace: string[]; }; tax: { name: string; rate: number; type: "inclusive" | "additive" | "N/A"; disabled?: boolean; }; promotions?: Promotion.Schema[]; used_promotions?: { id: string; name: string; ref?: string }[]; general_promotions?: { id: string; name: string; ref?: string }[]; applicable_promotions?: { id: string; name: string; ref?: string }[]; modifiers_groups?: Item.ModifierGroup[]; isAdditional?: boolean; qty: number; base_unit_qty?: number; overwritePrice?: number; price: number; discounted_price: number; tax_amount: number; tax_total: number; class: string; discount_value: number; gross_value?: number; line_total?: number; total_before_tax?: number; hidden_price?: number; modifiers_total?: number; modifiers_total_before_tax?: number; modifiers_tax_total?: number; tax_total_without_modifiers?: number; line_total_without_modifiers?: number; total_before_tax_without_modifiers?: number; deductionRatio?: number; deductedTax?: number; deduction?: number; deductionBeforeTax?: number; lineTotalAfterDeduction?: number; company_namespace?: string[]; note?: string; }[]; return_items: { variant: { product_name: string; variant_id: string | Pick; product_id: string | Pick; variant_name: string; listed_price: number; variant_local_name?: string; variant_img?: string; product_local_name?: string; product_img?: string; product_sku?: string; product_barcode?: string; variant_sku?: string; variant_barcode?: string; }; measureunit: { _id: string; name: string; factor: number; parent?: string; disabled?: boolean; company_namespace: string[]; }; tax: { name: string; rate: number; type: "inclusive" | "additive" | "N/A"; disabled?: boolean; }; promotions?: Promotion.Schema[]; used_promotions?: { id: string; name: string; ref?: string }[]; general_promotions?: { id: string; name: string; ref?: string }[]; applicable_promotions?: { id: string; name: string; ref?: string }[]; modifiers_groups?: Item.ModifierGroup[]; isAdditional?: boolean; qty: number; base_unit_qty?: number; overwritePrice?: number; price: number; discounted_price: number; tax_amount: number; tax_total: number; discount_value: number; gross_value?: number; line_total?: number; total_before_tax?: number; hidden_price?: number; modifiers_total?: number; modifiers_total_before_tax?: number; modifiers_tax_total?: number; tax_total_without_modifiers?: number; line_total_without_modifiers?: number; total_before_tax_without_modifiers?: number; deductionRatio?: number; deductedTax?: number; deduction?: number; deductionBeforeTax?: number; lineTotalAfterDeduction?: number; company_namespace?: string[]; note?: string; class: string; return_reason?: string | ReturnReason.Schema; }[]; client_id?: string | Client.ClientSchema; custom_status?: string | CustomStatus.CustomStatusSchema; cycle?: Cycle.Schema; return_reason?: string | ReturnReason.Schema; teams?: string[] | Team.TeamSchema[]; route?: string | Route.RouteSchema; media?: StringId[] | PopulatedMediaStorage[]; signature?: StringId | PopulatedMediaStorage; }; type PopulatedKeys = | "custom_status" | "return_reason" | "teams" | "route" | "media" | "signature"; type ProformaStatus = "pending" | "approved" | "processing" | "rejected"; type VariantSortingKeys = | "product_sku" | "product_barcode" | "variant_name" | "product_name" | "variant_sku" | "variant_barcode"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; creator?: string[] | string; clients?: string[] | string; disabled?: boolean; latest?: boolean; "serial_number.formatted"?: string[] | string; client_id?: string[] | string; from_issue_date?: number; to_issue_date?: number; from_time?: number; to_time?: number; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; custom_status?: string[] | string; status?: ProformaStatus | ProformaStatus[]; [key: string]: any; // integration_meta. sortPage?: VariantSortingKeys; export?: "excel"; withClientDetails?: boolean; populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; nodeCycles?: StringId[] | StringId; withCycle?: boolean; conversion_status?: "converted" | "not_converted" | "all"; }; export interface Result extends DefaultPaginationResult { data: ProformaSchemaWithPopulatedKeys[]; } } export namespace Get { export type ID = string; export interface Params { sortPage?: VariantSortingKeys; withClientDetails?: boolean; withCycle?: boolean; } export type Result = | (ProformaSchemaWithPopulatedKeys & { custom_status: CustomStatus.CustomStatusSchema; }) | { proforma: ProformaSchemaWithPopulatedKeys & { custom_status: CustomStatus.CustomStatusSchema; }; cycle: Cycle.Schema & { can_edit: boolean; current_nodes: string[] | AdminOrRep[]; }; }; } export namespace Create { export type Body = CreateBody; export type Result = ProformaSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = ProformaSchema; } } export namespace Payment { export interface PaymentSchema { _id: StringId; status: PaymentStatus; remainder: number; amount: number; client_id: StringId; client_name: string; creator: AdminCreator | RepCreator; implemented_by?: AdminCreator | RepCreator; transaction_processed: boolean; time?: number; serial_number: SerialNumber; route?: StringId; paytime: string; note?: string; currency: string; payment_type: PaymentType; payment_method?: StringId; check?: Check; LinkedTxn?: { Txn_serial_number: SerialNumber; Txn_invoice_total: number; TxnType: "refund" | "invoice"; }; client_geo_location?: { lat?: number; lng?: number; }; company_namespace: string[]; integration_meta?: { [key: string]: any }; sync_id: string; custom_status?: StringId; visit_id?: string; teams?: StringId[]; paymentsData: { amount: number; paid: number; balance: number; payments: PaymentData[]; }; reference?: string; media?: StringId[]; network_state?: number; platform?: string; version_name?: string; battery_level?: number; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; ending_balance?: number; createdAt: string; updatedAt: string; __v: number; } export type Data = PaymentSchema; export interface CreateBody { amount: number; client_id: string; client_name: string; time?: number; serial_number?: SerialNumber; route?: string; paytime: string; note?: string; currency: string; payment_type: PaymentType; payment_method?: StringId; transaction_processed: boolean; check?: Check; LinkedTxn?: { Txn_serial_number: SerialNumber; Txn_invoice_total: number; TxnType: "refund" | "invoice"; }; client_geo_location?: { lat?: number; lng?: number; }; company_namespace?: string[]; integration_meta?: { [key: string]: any }; sync_id: string; custom_status?: string; visit_id?: string; teams?: string[]; reference?: string; media?: StringId[]; } export interface UpdateBody { integration_meta?: { [key: string]: any }; } type PaymentSchemaWithPopulatedKeys = PaymentSchema & { balance_to_refund: number; custom_status?: string | CustomStatus.CustomStatusSchema; check?: Check & { bank: Bank.BankSchema }; invoice?: { invoice_serial_number: string; invoice_date: string; invoice_due_date: string; original_amount: number; payment: number; }; teams?: StringId[] | Team.TeamSchema[]; route?: StringId | Route.RouteSchema; payment_method?: StringId | PaymentMethod.Data; media?: (StringId | PopulatedMediaStorage)[]; }; type PaymentType = "check" | "cash"; type PopulatedKeys = "custom_status" | "teams" | "route" | "payment_method"; type PaymentStatus = "consumed" | "unconsumed" | "partially_consumed"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; client_id?: string[] | string; from_paytime?: number; to_paytime?: number; custom_status?: string[] | string; payment_type?: PaymentType | PaymentType[]; creator?: string[] | string; clients?: string[] | string; withPrintDetails?: boolean; from_updatedAt?: number; "serial_number.formatted"?: string[] | string; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc" }[]; }; export interface Result extends DefaultPaginationResult { data: PaymentSchemaWithPopulatedKeys[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params { withPrintDetails?: boolean; populatedKeys?: PopulatedKeys[]; } export type Result = PaymentSchemaWithPopulatedKeys & { custom_status: CustomStatus.CustomStatusSchema; }; } export namespace Create { export type Body = CreateBody; export type Result = PaymentSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = PaymentSchema; } } export namespace Refund { export interface RefundSchema { _id: string; status: RefundStatus; remainder: number; amount: number; client_id: string; client_name: string; creator: AdminCreator | RepCreator; implemented_by?: AdminCreator | RepCreator; time?: number; serial_number: SerialNumber; route?: string; paytime: string; note?: string; currency: string; transaction_type: RefundType; transaction_processed: boolean; check?: Check; LinkedTxn?: { Txn_serial_number: SerialNumber; Txn_total: number; TxnType: "return_invoice" | "payment" | "invoice"; }; company_namespace: string[]; integration_meta?: { [key: string]: any }; sync_id: string; custom_status?: string; visit_id?: string; teams?: string[]; paymentsData: { amount: number; paid: number; balance: number; payments: PaymentData[]; }; client_geo_location?: { lat: number; lng: number; }; createdAt: string; updatedAt: string; __v: number; } export type Data = RefundSchema; export interface CreateBody { amount: number; client_id: string; client_name: string; time?: number; serial_number?: SerialNumber; transaction_processed: boolean; client_geo_location?: { lat: number; lng: number; }; route?: string; paytime: string; note?: string; currency: string; transaction_type: RefundType; check?: Check; LinkedTxn?: { Txn_serial_number: SerialNumber; Txn_total: number; TxnType: "return_invoice" | "payment" | "invoice"; }; company_namespace?: string[]; integration_meta?: { [key: string]: any }; sync_id: string; custom_status?: string; visit_id?: string; teams?: string[]; } export interface UpdateBody { integration_meta?: { [key: string]: any }; } type RefundSchemaWithPopulatedKeys = RefundSchema & { balance_to_refund: number; custom_status?: string | CustomStatus.CustomStatusSchema; check?: Check & { bank: Bank.BankSchema }; invoice?: { invoice_serial_number: string; invoice_date: string; invoice_due_date: string; original_amount: number; refund: number; }; teams?: string[] | Team.TeamSchema[]; route?: string | Route.RouteSchema; }; type RefundType = "check" | "cash"; type PopulatedKeys = "custom_status" | "teams" | "route"; type RefundStatus = "consumed" | "unconsumed" | "partially_consumed"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; client_id?: string[] | string; from_paytime?: number; to_paytime?: number; custom_status?: string[] | string; transaction_type?: RefundType | RefundType[]; creator?: string[] | string; clients?: string[] | string; from_updatedAt?: number; withPrintDetails?: boolean; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: RefundSchemaWithPopulatedKeys[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params { withPrintDetails?: boolean; populatedKeys?: PopulatedKeys[]; } export type Result = RefundSchemaWithPopulatedKeys & { custom_status: CustomStatus.CustomStatusSchema; }; } export namespace Create { export type Body = CreateBody; export type Result = RefundSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = RefundSchema; } } export namespace Settlement { export interface SettlementSchema { _id: string; amount: number; creator: { _id: string; type: "admin" | "rep"; admin?: string; rep?: string; name: string; }; origin: { _id: string; type: "rep" | "admin"; name: string; rep?: string; admin?: string; }; time?: number; serial_number: SerialNumber; paytime: string; note?: string; payment_type: "check" | "cash"; check_id?: string; teams: string[]; company_namespace: string[]; sync_id: string; transaction_processed: boolean; media?: StringId[]; currency?: string; is_void: boolean; returned_to?: StringId; returned_to_serial_number?: SerialNumber; returned_from?: StringId; returned_from_serial_number?: SerialNumber; createdAt: Date; updatedAt: Date; __v?: number; } export type Data = SettlementSchema; export interface CreateBody { amount: number; time?: number; creator?: { _id: string; type: "admin" | "rep"; admin?: string; rep?: string; name: string; }; origin: { _id: string; type: "rep" | "admin"; name: string; rep?: string; admin?: string; }; serial_number: SerialNumber; paytime: string; note?: string; payment_type: "check" | "cash"; check_id?: string; teams: string[]; company_namespace: string[]; sync_id: string; transaction_processed: boolean; media?: StringId[]; is_void: boolean; returned_to?: StringId; returned_to_serial_number?: SerialNumber; returned_from?: StringId; returned_from_serial_number?: SerialNumber; } type SettlementSchemaWithPopulatedKeys = SettlementSchema & { teams_populated?: string[] | Team.TeamSchema[]; check_populated?: string | Check.CheckSchema; media_populated?: StringId[] | MediaPopulated[]; }; type PopulatedKeys = "teams" | "check_id" | "media"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; "creator._id"?: StringId[] | StringId; "origin._id"?: StringId[] | StringId; creator?: StringId[] | StringId; origin?: StringId[] | StringId; "creator.type"?: string[] | string; "origin.type"?: string[] | string; creator_type?: string[] | string; origin_type?: string[] | string; amount?: number; payment_type?: string; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; is_void?: boolean; }; export interface Result extends DefaultPaginationResult { data: SettlementSchemaWithPopulatedKeys[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = SettlementSchemaWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = SettlementSchema; } } export namespace VoidSettlement { export interface CreateBody { settlement: StringId; company_namespace?: string[]; note?: string; media?: StringId[]; } export namespace Create { export type Body = CreateBody; export type Result = Settlement.Data; } } export namespace Check { export interface CheckSchema { _id: string; drawer_name: string; bank: string; bank_branch: string; check_number: number; amount: number; check_date: string; photo?: string; media?: string[]; caption?: string; photo_meta?: { device_orientation?: 1 | 2 | 3 | 4; height?: 1 | 2 | 3 | 4; width?: 1 | 2 | 3 | 4; }; paytime: string; client_id: string; client_name: string; creator: { _id: string; type: "rep" | "admin"; rep?: string; admin?: string; name?: string; }; sync_id: string; payment_serial_number: SerialNumber; refund_serial_number?: SerialNumber; disabled: boolean; settled?: boolean; teams?: string[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { drawer_name: string; bank: string; bank_branch: string; check_number: number; amount: number; check_date: string; photo?: string; media?: string[]; caption?: string; photo_meta?: { device_orientation?: 1 | 2 | 3 | 4; height?: 1 | 2 | 3 | 4; width?: 1 | 2 | 3 | 4; }; paytime: string; client_id: string; client_name: string; creator: { _id: string; type: "rep" | "admin"; rep?: string; admin?: string; name?: string; }; sync_id: string; payment_serial_number: SerialNumber; refund_serial_number?: SerialNumber; disabled: boolean; settled?: boolean; teams?: string[]; company_namespace: string[]; } type CheckSchemaWithPopulatedKeys = CheckSchema & { teams?: string[] | Team.TeamSchema[]; bank?: string | Bank.BankSchema; client_id?: string | Client.ClientSchema; }; type PopulatedKeys = "bank" | "teams" | "client_id"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; client_id?: string[] | string; check_number?: number; client_name?: string; rep_name?: string; drawer_name?: string; bank_name?: string; amount?: number; settled?: boolean; from_updatedAt?: number; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: CheckSchemaWithPopulatedKeys[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params { withPrintDetails?: boolean; populatedKeys?: PopulatedKeys[]; } export type Result = CheckSchemaWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = CheckSchema; } } export namespace DayShift { export type Weekday = | "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday"; export interface ShiftRange { from: `${number}:${number}`; to: `${number}:${number}`; } export interface ShiftEntry { day: Weekday; work_time: ShiftRange[]; } export type ShiftSchedule = ShiftEntry[] | null | undefined; export interface Data { _id: StringId; name: string; designation?: string; disabled: boolean; schedule: ShiftEntry[]; total_working_hours: number; total_working_days: number; assigned_reps?: Pick[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; designation?: string; schedule: ShiftEntry[]; company_namespace?: string[]; } export type UpdateBody = Partial; type SortingKeys = "_id"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; designation?: string | string[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: string; to__id?: string; from_total_working_hours?: number; to_total_working_hours?: number; total_working_hours?: number; from_total_working_days?: number; to_total_working_days?: number; total_working_days?: number; inject_assigned_reps?: boolean; sortBy?: { field: SortingKeys; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export interface Params { inject_assigned_reps?: boolean; } export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace Day { export interface DaySchema { _id: string; creator: RepCreator; startTime: string[]; endTime: string[]; plan: { day?: string; list?: PlanList[]; }; groupedPlan?: { [key: string]: any }; day: string; timeFrame: { startOfDay?: number; endOfDay?: number }; timeZone?: string; EOD?: string; shift?: DayShift.Data | null; closed_by_system?: boolean; open: boolean; not_working_day?: boolean; paymentSnapShot_start?: any[]; paymentSnapShot_end?: any[]; inventorySnapShot?: any[]; target?: { scheduled: any[]; unscheduled: any[]; missed: any[]; }; timeOnDuty?: number; breaksTime?: number; timeInVisits?: number; totalTime?: number; totalTravelTime?: number; travelTimeBetweenVisists?: number; teams: string[]; created_by_system?: boolean; previously_closed?: boolean; geoPoint?: GeoPoint; start_geoPoint?: { type: string; coordinates: number[]; }; end_geoPoint?: { type: string; coordinates: number[]; }; odometer?: number; startTime_unix?: number[]; endTime_unix?: number[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type Data = DaySchema; export interface CreateBody { startTime: string[]; endTime: string[]; plan: { day?: string; list?: PlanList[]; }; groupedPlan?: { [key: string]: any }; day: string; timeFrame: { startOfDay?: number; endOfDay?: number }; timeZone?: string; EOD?: string; shift?: DayShift.Data | null; closed_by_system?: boolean; open: boolean; not_working_day?: boolean; paymentSnapShot_start?: any[]; paymentSnapShot_end?: any[]; inventorySnapShot?: any[]; target?: { [key: string]: any }; timeOnDuty?: number; breaksTime?: number; timeInVisits?: number; totalTime?: number; totalTravelTime?: number; travelTimeBetweenVisists?: number; teams: string[]; created_by_system?: boolean; previously_closed?: boolean; geoPoint?: GeoPoint; start_geoPoint?: { type: string; coordinates: number[]; }; end_geoPoint?: { type: string; coordinates: number[]; }; odometer?: number; startTime_unix?: number[]; endTime_unix?: number[]; company_namespace: string[]; } export interface UpdateBody { _id?: string; startTime?: string[]; endTime?: string[]; plan?: { day?: string; list?: PlanList[]; }; groupedPlan?: { [key: string]: any }; day?: string; timeFrame?: { startOfDay?: number; endOfDay?: number }; timeZone?: string; EOD?: string; shift?: DayShift.Data | null; closed_by_system?: boolean; open?: boolean; not_working_day?: boolean; paymentSnapShot_start?: any[]; paymentSnapShot_end?: any[]; inventorySnapShot?: any[]; target?: { scheduled: any[]; unscheduled: any[]; missed: any[]; }; timeOnDuty?: number; breaksTime?: number; timeInVisits?: number; totalTime?: number; totalTravelTime?: number; travelTimeBetweenVisists?: number; teams?: string[]; created_by_system?: boolean; previously_closed?: boolean; geoPoint?: GeoPoint; start_geoPoint?: { type: string; coordinates: number[]; }; end_geoPoint?: { type: string; coordinates: number[]; }; odometer?: number; startTime_unix?: number[]; endTime_unix?: number[]; company_namespace?: string[]; } type DaySchemaWithPopulatedKeys = DaySchema & { teams_populated?: string[] | Team.TeamSchema[]; }; type PopulatedKeys = "teams"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; reps?: string[] | string; open?: boolean; not_working_day?: boolean; day?: string; from_day?: string; to_day?: string; from_updatedAt?: number; [key: string]: any; // integration_meta. populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: DaySchemaWithPopulatedKeys[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = DaySchemaWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = DaySchema; } } export namespace ReceivingMaterial { export interface ReceivingMaterialSchema { _id: string; serial_number: SerialNumber; from: string | Warehouse.WarehouseSchema; to: string | Warehouse.WarehouseSchema; time: number; creator: AdminCreator | RepCreator; editor?: AdminCreator | RepCreator; sync_id: string; variants: { _id: string; variant_id: string; qty: number; variant_name?: string; variant_local_name?: string; product_id?: string; product_name?: string; product_local_name?: string; measure_unit_id?: string; measure_unit_name?: string; measure_unit_qty?: number; measure_unit_factor?: number; updatedAt?: Date; note?: string; }[]; teams: string[] | Team.TeamSchema[]; items_count?: number; total_items_base_unit_qty?: number; total_measure_unit_qty?: number; company_namespace: string[]; transaction_processed: boolean; status: "pending" | "approved" | "processing" | "rejected" | "processed"; comment?: string; business_day?: string; document_type?: "receiving-material"; supplier?: string | Supplier.SupplierSchema; createdAt: string; updatedAt: string; } export type Data = ReceivingMaterialSchema; export interface CreateBody { from?: StringId; to: StringId; time: number; sync_id: string; variants: { _id: string; variant_id: string; qty: number; variant_name?: string; variant_local_name?: string; product_id?: string; product_name?: string; product_local_name?: string; measure_unit_id?: string; measure_unit_name?: string; measure_unit_qty?: number; measure_unit_factor?: number; updatedAt?: Date; note?: string; }[]; teams: string[]; items_count?: number; total_items_base_unit_qty?: number; company_namespace: string[]; transaction_processed: boolean; status: "pending" | "approved" | "processing" | "rejected" | "processed"; comment?: string; business_day?: string; supplier?: string; } export interface UpdateBody { _id?: string; serial_number?: SerialNumber; from?: string; to?: string; time?: number; sync_id?: string; variants?: { _id: string; variant_id: string; qty: number; variant_name?: string; variant_local_name?: string; product_id?: string; product_name?: string; product_local_name?: string; measure_unit_id?: string; measure_unit_name?: string; measure_unit_qty?: number; measure_unit_factor?: number; updatedAt?: Date; note?: string; }[]; teams?: string[]; items_count?: number; total_items_base_unit_qty?: number; company_namespace?: string[]; transaction_processed?: boolean; status?: "pending" | "approved" | "processing" | "rejected" | "processed"; comment?: string; business_day?: string; supplier?: string; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; "creator.name"?: string[] | string; "creator.type"?: string[] | string; type?: string; to?: string; from?: string; status?: string; supplier?: string; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: ReceivingMaterialSchema[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params {} export type Result = ReceivingMaterialSchema; } export namespace Create { export type Body = CreateBody; export type Result = ReceivingMaterialSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = ReceivingMaterialSchema; } } export namespace Supplier { export interface SupplierSchema { _id: string; name: string; local_name?: string; phone?: string; address?: string; tax_number?: string; type: "individual" | "company"; disabled: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { name: string; local_name?: string; phone?: string; address?: string; tax_number?: string; type: "individual" | "company"; disabled: boolean; company_namespace: string[]; } export interface UpdateBody { _id?: string; name?: string; local_name?: string; phone?: string; address?: string; tax_number?: string; type?: "individual" | "company"; disabled?: boolean; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; name?: string; local_name?: string; type?: string; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: SupplierSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = SupplierSchema; } export namespace Create { export type Body = CreateBody; export type Result = SupplierSchema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = SupplierSchema; } } export namespace Approval { interface AdminNode { _id: StringId; type: "admin"; name?: string; admin: StringId; } interface RepNode { _id: StringId; type: "rep"; name?: string; rep: StringId; } export interface Data { _id: StringId; creator: AdminCreator; name: string; disabled: boolean; company_namespace: string[]; type: | "proforma" | "transfer" | "approval-request" | "receiving-material" | "asset-part-transfer" | "adjust-inventory" | "return-asset-part-unit" | "store-asset-part-unit" | "activity-form-v2-result"; position?: number; description?: string; rules: { index: number; name: string; permissions: { can_edit: boolean }; admins: AdminNode[]; reps: RepNode[]; append_creator?: boolean; append_assigned_origin_warehouse_rep?: boolean; append_assigned_destination_warehouse_rep?: boolean; notify_all_admins_before?: boolean; notify_admins_before: AdminNode[]; notify_admins_after: AdminNode[]; }[]; filters?: { key: string; operator: "eq" | "ne" | "in" | "nin" | "gt" | "gte" | "lt" | "lte"; value: any[]; manipulator_function?: string; }[]; createdAt: Date; updatedAt: Date; __v: number; } export interface CreateBody { name: string; type: | "proforma" | "transfer" | "approval-request" | "receiving-material" | "asset-part-transfer" | "adjust-inventory" | "return-asset-part-unit" | "store-asset-part-unit" | "activity-form-v2-result"; creator?: AdminCreator; disabled?: boolean; company_namespace?: string[]; position?: number; description?: string; rules: { index: number; name: string; permissions?: { can_edit: boolean }; admins?: { _id: StringId; name?: string; type: "admin" }[]; reps?: { _id: StringId; name?: string; type: "rep" }[]; append_creator?: boolean; append_assigned_origin_warehouse_rep?: boolean; append_assigned_destination_warehouse_rep?: boolean; notify_all_admins_before?: boolean; notify_admins_before: AdminNode[]; notify_admins_after: AdminNode[]; }[]; filters?: { key: string; operator: "eq" | "ne" | "in" | "nin" | "gt" | "gte" | "lt" | "lte"; value: any[]; manipulator_function?: string; }[]; } export interface UpdateBody { _id?: StringId; creator?: AdminCreator; name?: string; disabled?: boolean; company_namespace?: string[]; type?: | "proforma" | "transfer" | "approval-request" | "receiving-material" | "asset-part-transfer" | "adjust-inventory" | "return-asset-part-unit" | "store-asset-part-unit" | "activity-form-v2-result"; position?: number; description?: string; rules?: { index: number; name: string; permissions?: { can_edit: boolean }; admins?: { _id: StringId; name?: string; type: "admin" }[]; reps?: { _id: StringId; name?: string; type: "rep" }[]; append_creator?: boolean; append_assigned_origin_warehouse_rep?: boolean; append_assigned_destination_warehouse_rep?: boolean; notify_all_admins_before?: boolean; notify_admins_before: AdminNode[]; notify_admins_after: AdminNode[]; }[]; filters?: { key: string; operator: "eq" | "ne" | "in" | "nin" | "gt" | "gte" | "lt" | "lte"; value: any[]; manipulator_function?: string; }[]; createdAt?: Date; updatedAt?: Date; __v?: number; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; search?: string; name?: string[] | string; disabled?: boolean; sortBy?: { field: "_id" | "position" | "updatedAt"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Params = { [key: string]: any }; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type ID = string; export type Params = { bulkUpdatePositions?: boolean; [key: string]: any; }; export type Body = { items: Pick[] }; export type Result = { messages: string[]; errors: any[]; status: "success" | "failed" | "partial"; }; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace Cycle { type CycleStatus = "pending" | "approved" | "processing" | "rejected"; export interface Schema { _id: string; document_type: | "proforma" | "transfer" | "approval-request" | "receiving-material" | "asset-part-transfer" | "adjust-inventory" | "return-asset-part-unit" | "store-asset-part-unit" | "activity-form-v2-result"; document_id: string; status: CycleStatus; node?: AdminCreator | RepCreator | ClientCreator; creator?: AdminCreator | RepCreator | ClientCreator; current_nodes: (AdminCreator | RepCreator | ClientCreator)[]; stage?: number; stageName?: string; company_namespace: string[]; note?: string; serial_number: SerialNumber; version: number; history: { _id: string; status: CycleStatus; stage: number; stageName: string; node: AdminCreator | RepCreator | ClientCreator; creator: AdminCreator | RepCreator | ClientCreator; note: string; serial_number: SerialNumber; version?: number; createdAt: string; updatedAt: string; __v: number; }[]; createdAt: string; updatedAt: string; __v: number; } export type Data = Schema; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: "_id"; type: "asc" | "desc" }[]; _id?: string | string[]; document_id?: string | string[]; document_type?: Schema["document_type"] | Schema["document_type"][]; status?: CycleStatus | CycleStatus[]; "creator._id"?: string | string[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: string; to__id?: string; [key: string]: any; }; export interface Result extends DefaultPaginationResult { data: Schema[]; } } export namespace Get { export type ID = string; export type Params = { [key: string]: any }; export type Result = Schema; } } export namespace CycleReport { type CycleStatus = "pending" | "approved" | "processing" | "rejected"; type ProformaDoc = Pick< Proforma.Data, | "_id" | "class" | "serial_number" | "return_serial_number" | "client_name" | "client_id" | "issue_date" | "creator" | "time" | "createdAt" | "currency" | "teams" | "total_word" | "total_local_word" | "total" >; type TransferDoc = Pick< Transfer.Data, | "_id" | "serial_number" | "type" | "time" | "createdAt" | "from" | "to" | "items_count" | "total_items_base_unit_qty" | "total_measure_unit_qty" > & { from_name?: string; to_name?: string }; type ApprovalRequestDoc = Pick< ApprovalRequest.Data, | "_id" | "serial_number" | "type" | "subtype" | "time" | "createdAt" | "creator" | "reference_name" | "reference_local_name" >; type ReceivingMaterialDoc = Pick< ReceivingMaterial.Data, | "_id" | "to" | "serial_number" | "time" | "createdAt" | "from" | "items_count" | "total_items_base_unit_qty" | "total_measure_unit_qty" > & { to_name?: string }; type AssetPartTransferDoc = Pick< AssetPartTransfer.Data, | "_id" | "type" | "from_name" | "to_name" | "creator" | "serial_number" | "asset_part_units_count" | "total_asset_part_units_qty" | "time" | "createdAt" | "from" | "to" >; type AdjustInventoryDoc = Pick; type ReturnAssetPartUnitDoc = Pick< ReturnAssetPartUnit.Data, | "_id" | "warehouse" | "warehouse_name" | "creator" | "serial_number" | "asset_part_units_count" | "total_asset_part_units_qty" | "time" | "createdAt" | "client" | "client_name" >; type StoreAssetPartUnitDoc = Pick< StoreAssetPartUnit.Data, | "_id" | "warehouse" | "warehouse_name" | "creator" | "serial_number" | "asset_part_units_count" | "total_asset_part_units_qty" | "time" | "createdAt" >; type ActivityFormV2ResultDoc = Pick< ActivityFormV2Result.Data, | "_id" | "client" | "client_name" | "creator" | "serial_number" | "time" | "createdAt" | "form_id" > & { form_name?: string; }; interface SchemaBase { _id: string; document_id: string; status: CycleStatus; node?: AdminCreator | RepCreator | ClientCreator; creator?: AdminCreator | RepCreator | ClientCreator; current_nodes: (AdminCreator | RepCreator | ClientCreator)[]; stage?: number; stageName?: string; company_namespace: string[]; note?: string; serial_number: SerialNumber; version: number; createdAt: string; updatedAt: string; __v: number; } export type Schema = | (SchemaBase & { document_type: "proforma"; document: ProformaDoc }) | (SchemaBase & { document_type: "transfer"; document: TransferDoc }) | (SchemaBase & { document_type: "approval-request"; document: ApprovalRequestDoc; }) | (SchemaBase & { document_type: "receiving-material"; document: ReceivingMaterialDoc; }) | (SchemaBase & { document_type: "asset-part-transfer"; document: AssetPartTransferDoc; }) | (SchemaBase & { document_type: "adjust-inventory"; document: AdjustInventoryDoc; }) | (SchemaBase & { document_type: "return-asset-part-unit"; document: ReturnAssetPartUnitDoc; }) | (SchemaBase & { document_type: "store-asset-part-unit"; document: StoreAssetPartUnitDoc; }) | (SchemaBase & { document_type: "activity-form-v2-result"; document: ActivityFormV2ResultDoc; }); export type Data = Schema; interface Totals { "approval-request"?: number; "receiving-material"?: number; "store-asset-part-unit"?: number; "return-asset-part-unit"?: number; transfer?: number; proforma?: number; "adjust-inventory"?: number; "activity-form-v2-result"?: number; "asset-part-transfer"?: number; } export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: "_id"; type: "asc" | "desc" }[]; _id?: StringId | StringId[]; document_id?: StringId | StringId[]; document_type?: Schema["document_type"] | Schema["document_type"][]; status?: CycleStatus | CycleStatus[]; "creator._id"?: StringId | StringId[]; disabled?: boolean; from?: number; to?: number; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: StringId; to__id?: StringId; approval?: StringId | StringId[]; "current_nodes.type"?: string | string[]; "current_nodes.rep"?: StringId | StringId[]; "current_nodes.admin"?: StringId | StringId[]; [key: string]: any; }; export interface Result extends DefaultPaginationResult { data: Schema[]; totals?: Totals; } } } export namespace Transfer { export interface VariantTransfer { variant_id: string; variant_name?: string; product_id?: string; product_name?: string; qty: number; measure_unit_id?: string; measure_unit_name?: string; measure_unit_qty?: number; measure_unit_factor?: number; } export interface Schema { _id: string; serial_number: SerialNumber; time: number; creator: AdminCreator | RepCreator; type: TransferType; from: string | Warehouse.WarehouseSchema; to: string | Warehouse.WarehouseSchema; status: TransferStatus; variants: VariantTransfer[]; items_count?: number; total_items_base_unit_qty?: number; total_measure_unit_qty?: number; teams?: string[]; custom_status?: string; sync_id: string; transaction_processed: boolean; business_day?: string; comment?: string; document_type?: "transfer"; process_time?: number; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export type Data = Schema; export interface CreateBody { serial_number?: SerialNumber; time: number; type?: TransferType; from: string; to: string; variants: { variant_id: string; variant_name?: string; product_id?: string; product_name?: string; qty: number; measureunit?: { _id: string; name: string; factor: number; [key: string]: any; }; }[]; custom_status?: string; sync_id: string; integration_meta?: { [key: string]: any }; } type UpdateBody = | { _id?: string; serial_number?: SerialNumber; time?: number; creator?: AdminCreator | RepCreator; type?: TransferType; from?: string; to?: string; status?: "pending" | "approved" | "processing" | "rejected"; variants?: ( | VariantTransfer | { variant_id: string; variant_name?: string; product_id?: string; product_name?: string; qty: number; measureunit?: { _id: string; name: string; factor: number; [key: string]: any; }; } )[]; items_count?: number; total_items_base_unit_qty?: number; total_measure_unit_qty?: number; teams?: string[]; custom_status?: string; sync_id?: string; integration_meta?: { [key: string]: any }; company_namespace?: string[]; createdAt?: string; updatedAt?: string; __v?: number; } | { integration_meta?: { [key: string]: any }; }; type FindResult = Schema & { custom_status?: string | CustomStatus.CustomStatusSchema; from: string | Warehouse.WarehouseSchema; to: string | Warehouse.WarehouseSchema; teams: string[] | Team.TeamSchema[]; variants: { _id: string; variant_id: string; product_id: string; variant_name: string; product_name: string; qty: number; measure_unit_id?: string; measure_unit_name?: string; measure_unit_qty?: number; measure_unit_factor?: number; UpdatedAt: string; }[]; }; type GetResult = FindResult & { custom_status: CustomStatus.CustomStatusSchema & { variants: { _id: string; variant_id: string; product_id: string; variant_name: string; product_name: string; qty: number; measure_unit_id?: string; measure_unit_name?: string; measure_unit_qty?: number; measure_unit_factor?: number; UpdatedAt: string; qty_from_before?: number; qty_from_after?: number; qty_to_before?: number; qty_to_after?: number; }[]; }; }; type TransferType = "load" | "unload"; type PopulatedKeys = "custom_status" | "teams"; type TransferStatus = "pending" | "approved" | "processing" | "rejected" | "processed"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; "creator.name"?: string[] | string; "creator.type"?: string[] | string; type?: TransferType[] | TransferType; to?: string[] | string; from?: string[] | string; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; status?: TransferStatus | TransferStatus[]; custom_status?: string[] | string; creator?: string[] | string; nodeCycles?: StringId[] | StringId; from__id?: string; to__id?: string; populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: FindResult[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; withCycle?: boolean; } export type Result = | GetResult | { transfer: GetResult & { can_edit: boolean; current_nodes: string[]; }; cycle: Cycle.Schema; }; } export namespace Create { export type Body = CreateBody; export type Result = Schema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Schema; } } export namespace AdjustAccount { export interface AdjustAccountSchema { _id: string; serial_number: SerialNumber; from: string; time: number; creator: { _id: string; type: "admin"; admin?: string; name?: string; }; sync_id: string; comment?: string; accounts: { accountHolder: string; description?: string; company_namespace: string[]; name?: string; type: "client" | "rep" | "namespace" | "admin"; cash?: number; check?: number; credit?: number; status: "consumed" | "unconsumed" | "partially_consumed"; note?: string; paymentsData: { amount: number; paid: number; balance: number; payments: { payment_serial_number?: SerialNumber; payment_id?: string; invoice_serial_number?: SerialNumber; return_serial_number?: SerialNumber; fullinvoice_id?: string; refund_serial_number?: SerialNumber; refund_id?: string; adjustment_serial_number?: SerialNumber; adjustment_id?: string; adjustment_account_id?: string; account_index?: number; view_serial_number?: SerialNumber; type: | "invoice" | "return_invoice" | "payment" | "refund" | "adjustment"; amount: number; is_linked_txn?: boolean; }[]; }; account_index?: number; }[]; teams: string[]; transaction_processed: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { serial_number: SerialNumber; from: string; time: number; sync_id: string; comment?: string; accounts: { accountHolder: string; description?: string; company_namespace: string[]; name?: string; type: "client" | "rep" | "namespace" | "admin"; cash?: number; check?: number; credit?: number; status: "consumed" | "unconsumed" | "partially_consumed"; note?: string; paymentsData: { amount: number; paid: number; balance: number; payments: { payment_serial_number?: SerialNumber; payment_id?: string; invoice_serial_number?: SerialNumber; return_serial_number?: SerialNumber; fullinvoice_id?: string; refund_serial_number?: SerialNumber; refund_id?: string; adjustment_serial_number?: SerialNumber; adjustment_id?: string; adjustment_account_id?: string; account_index?: number; view_serial_number?: SerialNumber; type: | "invoice" | "return_invoice" | "payment" | "refund" | "adjustment"; amount: number; is_linked_txn?: boolean; }[]; }; account_index?: number; }[]; teams: string[]; transaction_processed: boolean; company_namespace: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; "creator._id"?: string[] | string; "accounts.type"?: string; "accounts.accountHolder"?: string; from_time?: number; to_time?: number; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: AdjustAccountSchema[]; absolute_total: number; page_total: number; } } export namespace Get { export type ID = string; export interface Params {} export type Result = AdjustAccountSchema; } export namespace Create { export type Body = CreateBody; export type Result = AdjustAccountSchema; } } export namespace AdjustInventory { export interface Schema { _id: StringId; serial_number: SerialNumber; status: "pending" | "approved" | "processing" | "rejected" | "processed"; time: number; creator: AdminCreator | RepCreator; editor: AdminCreator; from: StringId; to: StringId; variants: { variant: StringId; qty: number; variant_name?: string; product_id?: StringId; product_name?: string; _id: StringId; }[]; teams?: StringId[]; sync_id: string; reason?: StringId; transaction_processed: boolean; custom_status?: StringId; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export type Data = Schema; export interface PopulatedData { _id: StringId; serial_number: SerialNumber; status: "pending" | "approved" | "processing" | "rejected" | "processed"; time: number; creator: AdminCreator | RepCreator; editor: AdminCreator; from: StringId | Warehouse.WarehouseSchema; to: StringId | Warehouse.WarehouseSchema; variants: { variant: | StringId | (Pick & { product: Pick< Product.ProductSchema, "_id" | "name" | "local_name" >; }); qty: number; variant_name?: string; product_id?: StringId; product_name?: string; _id: StringId; }[]; teams?: StringId[] | Team.TeamSchema[]; sync_id: string; reason?: StringId | InventoryAdjustmentReason.InventoryAdjustmentReasonSchema; transaction_processed: boolean; custom_status?: StringId | CustomStatus.CustomStatusSchema; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; can_edit?: boolean; current_nodes?: string[]; cycle?: Cycle.Schema; } export interface CreateBody { sync_id: string; time: number; serial_number?: SerialNumber; status?: "pending"; creator?: AdminCreator | RepCreator; from?: StringId; to: StringId; variants: { variant: string; qty: number; variant_name?: string; product_id?: string; product_name?: string; }[]; transaction_processed?: false; teams?: string[]; reason?: StringId; custom_status?: StringId; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; serial_number?: SerialNumber; isResubmitted?: boolean; note?: string; stage?: number; status?: "pending" | "approved" | "processing" | "rejected" | "processed"; time?: number; creator?: AdminCreator | RepCreator; editor?: AdminCreator; from?: StringId; to?: StringId; variants?: { variant: StringId; qty: number; variant_name?: string; product_id?: StringId; product_name?: string; _id: StringId; }[]; teams?: StringId[]; sync_id?: string; reason?: StringId; transaction_processed?: boolean; custom_status?: StringId; company_namespace?: string[]; createdAt?: string; updatedAt?: string; __v?: number; } type PopulatedKeys = "warehouse" | "teams" | "custom_status" | "reason" | "variant"; export namespace Find { export type Params = DefaultPaginationQueryParams & { nodeCycles?: StringId[] | StringId; _id?: StringId[] | StringId; status?: AdjustInventory.Schema["status"][]; search?: string; // serial_number.formatted serial_number?: string[] | string; "serial_number.formatted"?: string[] | string; sync_id?: string[] | string; to?: StringId[] | StringId; creator?: StringId | StringId[]; "creator._id"?: StringId[] | StringId; creator_type?: string | string[]; "creator.type"?: string | string[]; editor?: StringId | StringId[]; "editor._id"?: StringId[] | StringId; editor_type?: string | string[]; "editor.type"?: string | string[]; teams?: StringId[] | StringId; reason?: StringId[] | StringId; custom_status?: StringId[] | StringId; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedData[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; withCycle?: boolean; } export type Result = Data | PopulatedData; } export namespace Create { export type Body = CreateBody; export type Result = Schema; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } } export namespace InventoryAdjustmentReason { export interface InventoryAdjustmentReasonSchema { _id: string; name: string; local_name?: string; disabled: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { name: string; local_name?: string; disabled: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; } export interface UpdateBody { _id?: string; name?: string; local_name?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; name?: string; from_updatedAt?: number; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: InventoryAdjustmentReasonSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace Inventory { export interface InventorySchema { _id: string; warehouse_id: string; warehouse_name: string; variant_id: string; variant_name: string; product_id: string; product_name: string; listed_price: number; qty: number; UpdatedAt: string; } export namespace Find { export type Params = DefaultPaginationQueryParams & { warehouse_id?: string[] | string; variant_id?: string[] | string; rep?: string[] | string; qty?: number[] | number; from_updatedAt?: number; export_behaviour?: boolean; }; export interface Result extends DefaultPaginationResult { data: InventorySchema[]; } } } export namespace ActionLogs { export type Status = "success" | "fail" | "processing"; export type Detail = { timestamp: number; content: string; meta?: { [key: string]: any }; }; export interface Schema { _id: string; available_app_name: string; available_app_id: string; app_id: string; sync_id: string; action: string; status: Status; error?: { [key: string]: any } | { [key: string]: any }[]; start_time: number; end_time?: number; total_time?: number; company_namespace: string[]; body?: { [key: string]: any }; meta?: { [key: string]: any }; message: string; details: Detail[]; createdAt: string; updatedAt: string; __v: number; } interface Data { available_app_name: string; available_app_id: string; app_id: string; sync_id?: string; action: string; status: Status; error?: { [key: string]: any } | { [key: string]: any }[]; start_time: number; end_time?: number; total_time?: number; company_namespace?: string[]; body?: { [key: string]: any }; meta?: { [key: string]: any }; message: string; details: Detail[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; available_app_name?: string[] | string; available_app_id?: string[] | string; app_id?: string[] | string; action?: string[] | string; status?: Status[] | Status; sync_id?: string[] | string; disabled?: boolean; start_time?: number; end_time?: number; total_time?: number; }; export interface Result extends DefaultPaginationResult { data: Schema[]; } } export namespace Get { export type ID = string; export interface Params { available_app_name?: string[] | string; available_app_id?: string[] | string; app_id?: string[] | string; action?: string[] | string; status?: Status[] | Status; sync_id?: string[] | string; disabled?: boolean; start_time?: number; end_time?: number; total_time?: number; } export type Result = Schema; } export namespace Create { export type Body = Data; export type Result = Schema; } export namespace Update { export type ID = string; export interface Body extends Data { _id?: string; sync_id: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = Schema; } } export namespace CommandLog { export type Status = "success" | "fail" | "processing" | "queued" | "received" | "skipped"; export type Detail = { timestamp: number; content: string; meta?: { [key: string]: any }; }; export interface Schema { _id: string; command: string; available_app_name: string; available_app_id: string; app_id: string; status: Status; error?: { [key: string]: any } | { [key: string]: any }[]; start_time: number; end_time?: number; total_time?: number; company_namespace: string[]; body?: { [key: string]: any }; meta?: { [key: string]: any }; message: string; details: Detail[]; sync_id: string; queuedAt?: Date; failedAt?: Date; succeededAt?: Date; skippedAt?: Date; receivedAt?: Date; processedAt?: Date; onGoing?: boolean; retries?: number; trigger?: string; sync_details: { timestamp: number; body: { [key: string]: any } }[]; error_details: { timestamp: number; error: { [key: string]: any } }[]; createdAt: string; updatedAt: string; __v: number; } interface Data { command: string; available_app_name: string; available_app_id: string; app_id: string; status: Status; error?: { [key: string]: any } | { [key: string]: any }[]; start_time: number; end_time?: number; total_time?: number; company_namespace: string[]; body?: { [key: string]: any }; meta?: { [key: string]: any }; message: string; details: Detail[]; sync_id?: string; queuedAt?: Date; failedAt?: Date; succeededAt?: Date; skippedAt?: Date; receivedAt?: Date; processedAt?: Date; onGoing?: boolean; retries?: number; trigger?: string; sync_details: { timestamp: number; body: { [key: string]: any } }[]; error_details: { timestamp: number; error: { [key: string]: any } }[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; available_app_name?: string[] | string; available_app_id?: string[] | string; app_id?: string[] | string; command?: string[] | string; status?: Status[] | Status; sync_id?: string[] | string; disabled?: boolean; start_time?: number; end_time?: number; total_time?: number; }; export interface Result extends DefaultPaginationResult { data: Schema[]; } } export namespace Get { export type ID = string; export interface Params { available_app_name?: string[] | string; available_app_id?: string[] | string; app_id?: string[] | string; command?: string[] | string; status?: Status[] | Status; sync_id?: string[] | string; disabled?: boolean; start_time?: number; end_time?: number; total_time?: number; } export type Result = Schema; } export namespace Create { export type Body = Data; export type Result = Schema; } export namespace Update { export type ID = string; export interface Body extends Data { _id?: string; sync_id: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = Schema; } } export namespace JoinActionsWeHook { interface JoinData { app: string; app_id: string; action: string; event: string; join: boolean; } export interface Result { data: JoinData[]; status?: "success" | "failure"; error?: any; } export interface Data { data: JoinData[]; } } export namespace App { export interface Schema { _id: string; name: string; disabled?: boolean; available_app: string; formData: any; options_formData?: any; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } export interface Schema_with_populated_AvailableApp { _id: string; name: string; disabled?: boolean; available_app: AvailableApp; formData: any; options_formData?: any; company_namespace: string[]; createdAt: string; updatedAt: string; __v: number; } type PopulatedKeys = "available_app"; export interface AppBody { name?: string; disabled?: boolean; available_app?: string; formData?: any; options_formData?: any; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; search?: string; name?: string[] | string; disabled?: boolean; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: (Schema | Schema_with_populated_AvailableApp)[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = Schema | Schema_with_populated_AvailableApp; } export namespace Create { export interface Body extends AppBody { name: string; available_app: string; formData: any; } export type Result = Schema; } export namespace Update { export type ID = string; export interface Body extends AppBody { _id?: string; createdAt?: string; updatedAt?: string; __v?: number; } export type Result = Schema; } } export interface AvailableApp { _id: StringId; name: string; disabled: boolean; JSONSchema: any; UISchema: any; app_settings: { repo: string; serviceEndPoint: string; meta: {} }; app_category: string; } export namespace PatchAction { type ReadOperator = "lte" | "lt" | "gte" | "gt" | "eq" | "ne" | "in" | "nin" | "search"; type WriteOperator = "set" | "addToSet" | "pull"; type Slug = | "client" | "product" | "availability-msl" | "product-category" | "product-sub-category" | "product-brand" | "variant" | "product-group" | "msl" | "rep" | "line-classification" | "line" | "activity-storecheck" | "measureunits" | "promotions" | "tax" | "tag" | "warehouse" | "client-channel" | "measureunit-family" | "paymentterms"; interface ReadQuery { /** * @type {string} filed to filter by */ key: string; value: | string | string[] | [] | null | number | boolean | number[] | boolean[] | null[]; /** * @type {string} Operator value set according to filter document and of enum type set according to each corresponding key * @example {<"eq">} */ operator: ReadOperator; } interface WriteQuery { /** * @type {string} filed to filter by */ key: string; value: any; /** * @type {string} command value set according to filter document and of enum type set according to each corresponding key * @example {<"addToSet">} */ command: WriteOperator; } interface FormattedWriteQuery { /** * @type {string} update $command key */ [key: string]: { /** * @type {string } update field key and update value */ [key: string]: any; }; } interface CreateBody { /** * @type {string} name of model (an enum value) as specified in patch-filter schema */ slug: Slug; /** * @type {ReadQuery} an array of objects key sent in body to include read-filter keys, values and operators * @example {<[ {key: "field_test", value: "ex_1", "operator": "eq"}, {key: "second_field", value: ["ex_2"], "operator": "in"} ]>} */ readQuery: ReadQuery[]; } export interface UpdateBody { /** * @type {string} name of model (an enum value) as specified in patch-filter schema */ slug: Slug; /** * @type {ReadQuery} an array of objects key sent in body to include read-filter keys, values and operators * @example {<[ {key: "field_test", value: "ex_1", "operator": "eq"}, {key: "second_field", value: ["ex_2"], "operator": "in"} ]>} */ readQuery: ReadQuery[]; /** * @type {WriteQuery} an object sent in body to include write-filter key, value and an update command accordingly * @example {<{ key: "field_test", value: "ex_1", "command": "set" }>} */ writeQuery: WriteQuery | WriteQuery[]; // | FormattedWriteQuery; } export namespace Create { export type Params = DefaultPaginationQueryParams & { [key: string]: any; }; export type Body = CreateBody; export type Result = DefaultPaginationResult; } export namespace Update { export type Body = UpdateBody; export type Result = { nFound: number; nModified: number; }; } } export namespace UpdateIntegrationMeta { export namespace Create { export type Params = DefaultPaginationQueryParams & { _id: string; type: string; }; export type Body = | { key: string; value: any }[] | { integration_meta_keys: { key: string; value: any }[] }; export interface Result { [key: string]: any; } } } export namespace AssetPartType { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; color: string; local_name?: string; disabled: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { creator?: AdminOrRep; name: string; color: string; local_name?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; creator?: AdminOrRep; editor?: AdminOrRep; name?: string; local_name?: string; color?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; search?: string; name?: string[] | string; color?: string[] | string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; sortBy?: { field: "_id"; type: "asc" | "desc" }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace AssetPart { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; local_name?: string; description?: string; barcode?: string; model?: string; manufacturer?: string; year?: string; asset_part_types: StringId[]; assets?: StringId[]; asset_units?: StringId[]; customFields?: { [key: string]: string | number | boolean | StringId }; disabled: boolean; integration_meta?: { [key: string]: any }; media?: StringId[]; cover_photo?: StringId; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; local_name?: string; description?: string; barcode?: string; model?: string; manufacturer?: string; year?: string; asset_part_types: | StringId[] | Pick[]; assets?: StringId[]; // | Asset[]; asset_units?: StringId[]; // | AssetUnit[]; customFields?: { [key: string]: string | number | boolean | StringId }; disabled: boolean; integration_meta?: { [key: string]: any }; media?: StringId[] | PopulatedMediaStorage[]; cover_photo?: StringId | PopulatedMediaStorage; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; asset_part_types: StringId[]; creator?: AdminOrRep; local_name?: string; description?: string; barcode?: string; model?: string; manufacturer?: string; year?: string; assets?: StringId[]; asset_units?: StringId[]; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[]; cover_photo?: StringId; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; creator?: AdminOrRep; editor?: AdminOrRep; name?: string; local_name?: string; description?: string; barcode?: string; model?: string; manufacturer?: string; year?: string; asset_part_types?: StringId[]; assets?: StringId[]; asset_units?: StringId[]; customFields?: { [key: string]: string | number | boolean | StringId }; disabled?: boolean; integration_meta?: { [key: string]: any }; media?: StringId[]; cover_photo?: StringId; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; } type PopulatedKeys = "asset_part_types" | "assets" | "asset_units" | "media" | "cover_photo"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; search?: string; name?: string[] | string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; asset_part_types?: string[] | string; assets?: string[] | string; asset_units?: string[] | string; populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id" | "name" | "barcode" | "model" | "createdAt" | "updatedAt"; type: "asc" | "desc"; }[]; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; [key: string]: any; }; export type Result = Data | PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace AssetPartUnit { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; directional_status: "received" | "handed" | "picked" | "returned" | "stored"; asset_part_receival: StringId; asset_part_return?: StringId; asset_part_index: number; splitted_from?: StringId; client: StringId; client_name: string; warehouse: StringId; warehouse_name: string; receival_warehouse: string; receival_warehouse_name: string; asset_part: StringId; asset_part_name: string; qty: number; custom_status?: StringId; receival_comment?: string; comment?: string; media?: StringId[]; teams?: StringId[]; integration_meta?: { [key: string]: any }; quotation_is_recommended: boolean; quotation_internal_approval_status: "pending" | "approved" | "completed" | "rejected"; quotation_detail?: string; quotation_client_approval_status: "pending" | "approved" | "collected" | "rejected"; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; directional_status: "received" | "handed" | "picked" | "returned" | "stored"; asset_part_receival: StringId | AssetPartReceival.Data; asset_part_return?: StringId | ReturnAssetPartUnit.Data; asset_part_index: number; splitted_from?: StringId | Data; client: StringId | Pick; client_name: string; warehouse: | StringId | Pick; receival_warehouse: | string | Pick; asset_part: | StringId | (Pick< AssetPart.Data, | "name" | "local_name" | "barcode" | "model" | "asset_part_types" | "media" | "cover_photo" > & { asset_part_types?: AssetPartType.Data[]; media?: MediaDoc[]; cover_photo?: MediaDoc; }); asset_part_name: string; warehouse_name: string; receival_warehouse_name: string; qty: number; custom_status?: | StringId | Pick< CustomStatus.CustomStatusSchema, "_id" | "name" | "local_name" | "code" | "color" >; receival_comment?: string; comment?: string; media?: StringId[] | PopulatedMediaStorage[]; teams?: StringId[] | Pick[]; integration_meta?: { [key: string]: any }; quotation_is_recommended: boolean; quotation_internal_approval_status: "pending" | "approved" | "completed" | "rejected"; quotation_detail?: string; quotation_client_approval_status: "pending" | "approved" | "collected" | "rejected"; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { creator?: AdminOrRep; directional_status: "received" | "handed" | "picked" | "returned" | "stored"; asset_part_receival: StringId; asset_part_index: number; splitted_from?: StringId; client: StringId; client_name: string; warehouse: StringId; warehouse_name?: string; receival_warehouse: string; receival_warehouse_name?: string; asset_part: StringId; asset_part_name: string; qty: number; custom_status?: StringId; receival_comment?: string; comment?: string; media?: StringId[]; teams?: StringId[]; integration_meta?: { [key: string]: any }; quotation_is_recommended?: boolean; quotation_internal_approval_status?: "pending" | "approved" | "completed" | "rejected"; quotation_detail?: string; quotation_client_approval_status?: "pending" | "approved" | "collected" | "rejected"; company_namespace?: string[]; } export interface UpdateBody { custom_status?: StringId; comment?: string; media?: StringId[]; editor?: AdminOrRep; quotation_is_recommended?: boolean; quotation_internal_approval_status?: "pending" | "approved" | "completed" | "rejected"; quotation_detail?: string; quotation_client_approval_status?: "pending" | "approved" | "collected" | "rejected"; } type PopulatedKeys = | "asset_part_receival" | "asset_part_return" | "asset_part" | "client" | "warehouse" | "teams" | "custom_status" | "media"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; asset_part_receival?: StringId[] | StringId; asset_part_return?: StringId[] | StringId; client?: StringId[] | StringId; warehouse?: StringId[] | StringId; receival_warehouse?: StringId[] | StringId; asset_part?: StringId[] | StringId; from_qty?: number; to_qty?: number; qty?: number; custom_status?: StringId[] | StringId; directional_status?: Data["directional_status"] | Data["directional_status"][]; teams?: StringId[] | StringId; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id" | "asset_part_index" | "createdAt" | "updatedAt"; type: "asc" | "desc"; }[]; quotation_is_recommended?: boolean; quotation_internal_approval_status?: Data["quotation_client_approval_status"][]; quotation_client_approval_status?: Data["quotation_client_approval_status"][]; rep?: StringId | StringId[]; admin?: StringId | StringId[]; creator?: StringId | StringId[]; "creator._id"?: StringId[] | StringId; creator_type?: string | string[]; "creator.type"?: string | string[]; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; [key: string]: any; }; export type Result = Data | PopulatedDoc; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } } export namespace AssetPartReceival { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; transaction_processed: boolean; client: StringId; client_name: string; warehouse: StringId; warehouse_name: string; teams?: StringId[]; time: number; business_day?: string; visit_id?: string; serial_number: SerialNumber; description?: string; custom_status?: StringId; signature?: StringId; media?: StringId[]; asset_parts: { asset_part: StringId; asset_part_name: string; qty: number; comment?: string; }[]; asset_parts_count?: number; total_asset_parts_qty?: number; integration_meta?: { [key: string]: any }; workorder?: StringId; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; transaction_processed: boolean; client: StringId | Pick; client_name: string; warehouse: | StringId | Pick; warehouse_name: string; teams?: StringId[] | Pick[]; time: number; business_day?: string; visit_id?: string; serial_number: SerialNumber; description?: string; custom_status?: | StringId | Pick< CustomStatus.CustomStatusSchema, "_id" | "name" | "local_name" | "code" | "color" >; signature?: StringId | PopulatedMediaStorage; media?: StringId[] | PopulatedMediaStorage[]; asset_parts: { _id: StringId; asset_part: StringId | AssetPart.Data; asset_part_name: string; qty: number; comment?: string; }[]; asset_parts_count?: number; total_asset_parts_qty?: number; integration_meta?: { [key: string]: any }; workorder?: StringId | Workorder.WorkorderSchema; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { creator?: AdminOrRep; editor?: AdminOrRep; sync_id: string; transaction_processed: false; serial_number?: SerialNumber; client: StringId; client_name: string; warehouse: StringId; warehouse_name: string; teams?: StringId[]; time: number; business_day?: string; visit_id?: string; description?: string; custom_status?: StringId; signature?: StringId; media?: StringId[]; asset_parts: { asset_part: StringId; asset_part_name: string; qty: number; comment?: string; }[]; integration_meta?: { [key: string]: any }; asset_parts_count?: number; total_asset_parts_qty?: number; workorder?: StringId; company_namespace: string[]; } export interface UpdateBody { editor?: AdminOrRep; description?: string; custom_status?: StringId; media?: StringId[]; integration_meta?: { [key: string]: any }; workorder?: StringId; } type PopulatedKeys = | "asset_part" | "client" | "warehouse" | "teams" | "custom_status" | "media" | "signature" | "workorder"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; search?: string; // serial_number.formatted serial_number?: string[] | string; "serial_number.formatted"?: string[] | string; sync_id?: string[] | string; client?: string[] | string; warehouse?: string[] | string; rep?: StringId | StringId[]; admin?: StringId | StringId[]; creator?: StringId | StringId[]; "creator._id"?: StringId[] | StringId; creator_type?: string | string[]; "creator.type"?: string | string[]; teams?: string[] | string; visit_id?: string[] | string; custom_status?: string[] | string; asset_part?: string[] | string; "asset_parts.asset_part"?: string[] | string; from_time?: number; to_time?: number; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; workorder?: StringId | StringId[]; populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id" | "time" | "createdAt" | "updatedAt"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; [key: string]: any; }; export type Result = Data | PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type Params = { updateStatus: true }; export type Body = { readQuery: [{ key: "_id"; operator: "in"; value: StringId[] }]; writeQuery: { key: "custom_status"; command: "set"; value: StringId }; }; export type Result = { nFound: number; nModified: number }; } } export namespace AssetPartTransfer { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; transaction_processed: boolean; serial_number: SerialNumber; type: "load" | "unload"; from: StringId; to: StringId; from_name?: string; to_name?: string; time: number; status: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; sync_id: string; asset_part_units: { _id: StringId; asset_part_unit: StringId; qty: number; asset_part?: StringId; asset_part_name?: string; note?: string; splitted_from?: StringId; }[]; teams?: StringId[]; business_day?: string; asset_part_units_count?: number; total_asset_part_units_qty?: number; custom_status?: StringId; description?: string; process_time?: number; visit_id?: string; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; transaction_processed: boolean; serial_number: SerialNumber; type: "load" | "unload"; from: | StringId | Pick; to: | StringId | Pick; from_name?: string; to_name?: string; time: number; status: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; sync_id: string; asset_part_units: { _id: StringId; asset_part_unit: | StringId | (AssetPartUnit.Data & { custom_status?: Pick< CustomStatus.CustomStatusSchema, "_id" | "name" | "local_name" | "code" | "color" >; }); qty: number; asset_part?: StringId | AssetPart.Data; asset_part_name?: string; note?: string; splitted_from?: StringId | AssetPartUnit.Data; }[]; teams?: StringId[] | Pick[]; business_day?: string; asset_part_units_count?: number; total_asset_part_units_qty?: number; custom_status?: | StringId | Pick< CustomStatus.CustomStatusSchema, "_id" | "name" | "local_name" | "code" | "color" >; description?: string; process_time?: number; visit_id?: string; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { creator?: AdminOrRep; serial_number?: SerialNumber; type: "load" | "unload"; from: StringId; to: StringId; from_name?: string; to_name?: string; time: number; transaction_processed?: false; status?: "pending"; sync_id: string; asset_part_units: { _id?: StringId; asset_part_unit: StringId; qty: number; asset_part?: StringId; asset_part_name?: string; note?: string; }[]; teams?: StringId[]; business_day?: string; asset_part_units_count?: number; total_asset_part_units_qty?: number; custom_status?: StringId; description?: string; visit_id?: string; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; company_namespace: string[]; } export interface UpdateBody { _id?: StringId; creator?: AdminOrRep; editor?: AdminOrRep; transaction_processed?: boolean; serial_number?: SerialNumber; type?: "load" | "unload"; from?: StringId; to?: StringId; from_name?: string; to_name?: string; time?: number; status?: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; sync_id?: string; asset_part_units?: { _id?: StringId; asset_part_unit: StringId; qty: number; asset_part_name?: string; note?: string; splitted_from?: StringId; }[]; teams?: StringId[]; business_day?: string; asset_part_units_count?: number; total_asset_part_units_qty?: number; custom_status?: StringId; description?: string; process_time?: number; visit_id?: string; integration_meta?: { [key: string]: any }; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; isResubmitted?: boolean; note?: string; stage?: number; failed_reasons?: { code: string; message: string; [key: string]: any }[]; } type PopulatedKeys = | "asset_part_unit" | "warehouse" | "teams" | "custom_status" | "from" | "to"; export namespace Find { export type Params = DefaultPaginationQueryParams & { nodeCycles?: StringId[] | StringId; _id?: StringId[] | StringId; search?: string; // serial_number.formatted serial_number?: string[] | string; "serial_number.formatted"?: string[] | string; sync_id?: string[] | string; creator?: StringId[] | StringId; creator_type?: Data["creator"]["type"] | Data["creator"]["type"][]; "creator._id"?: StringId[] | StringId; rep?: StringId | StringId[]; admin?: StringId | StringId[]; "creator.type"?: string | string[]; type?: Data["type"][] | Data["type"]; from?: StringId[] | StringId; to?: StringId[] | StringId; warehouse?: StringId[] | StringId; teams?: StringId[] | StringId; visit_id?: string[] | string; custom_status?: StringId[] | StringId; transaction_processed?: boolean; asset_part_unit?: StringId[] | StringId; "asset_part_units.asset_part_unit"?: StringId[] | StringId; from_time?: number; to_time?: number; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id" | "time" | "createdAt" | "updatedAt"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = StringId; export type Params = { withCycle?: boolean; validityCheck?: boolean; populatedKeys?: PopulatedKeys[]; [key: string]: any; // integration_meta. }; export type Result = (Data | PopulatedDoc) & { cycle?: Cycle.Schema; validityCheck?: ValidityCheck; you_can_approve?: boolean; }; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type Params = { updateStatus: true }; export type Body = { readQuery: [{ key: "_id"; operator: "in"; value: StringId[] }]; writeQuery: { key: "custom_status"; command: "set"; value: StringId }; }; export type Result = { nFound: number; nModified: number }; } } export namespace ReturnAssetPartUnit { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; status: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; transaction_processed: boolean; client: StringId; client_name: string; warehouse: StringId; warehouse_name: string; teams?: StringId[]; time: number; business_day?: string; visit_id?: string; serial_number: SerialNumber; description?: string; custom_status?: StringId; signature?: StringId; media?: StringId[]; asset_part_units: { _id?: StringId; asset_part_unit: StringId; qty: number; asset_part?: StringId; asset_part_name?: string; comment?: string; splitted_from?: StringId; }[]; asset_part_units_count?: number; total_asset_part_units_qty?: number; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; workorder?: StringId; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; status: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; transaction_processed: boolean; client: StringId | Pick; client_name: string; warehouse: | StringId | Pick; warehouse_name: string; teams?: StringId[] | Pick[]; time: number; business_day?: string; visit_id?: string; serial_number: SerialNumber; description?: string; custom_status?: | StringId | Pick< CustomStatus.CustomStatusSchema, "_id" | "name" | "local_name" | "code" | "color" >; signature?: StringId | PopulatedMediaStorage; media?: StringId[] | PopulatedMediaStorage[]; asset_part_units: { _id: StringId; asset_part_unit: StringId | AssetPartUnit.Data; qty: number; asset_part?: StringId | AssetPart.Data; asset_part_name?: string; comment?: string; splitted_from?: StringId | AssetPartUnit.Data; }[]; asset_part_units_count?: number; total_asset_part_units_qty?: number; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; workorder?: StringId | Workorder.WorkorderSchema; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { creator?: AdminOrRep; editor?: AdminOrRep; sync_id: string; status?: "pending"; transaction_processed: boolean; serial_number?: SerialNumber; client: StringId; client_name?: string; warehouse: StringId; warehouse_name?: string; teams?: StringId[]; time: number; business_day?: string; visit_id?: string; description?: string; custom_status?: StringId; signature?: StringId; media?: StringId[]; asset_part_units: { _id?: StringId; asset_part_unit: StringId; qty: number; asset_part?: StringId; asset_part_name?: string; comment?: string; }[]; integration_meta?: { [key: string]: any }; asset_part_units_count?: number; total_asset_part_units_qty?: number; workorder?: StringId; company_namespace: string[]; } export interface UpdateBody { _id?: StringId; creator?: AdminOrRep; editor?: AdminOrRep; sync_id?: string; status?: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; transaction_processed?: boolean; client?: StringId; client_name?: string; warehouse?: StringId; warehouse_name?: string; teams?: StringId[]; time?: number; business_day?: string; visit_id?: string; serial_number?: SerialNumber; description?: string; custom_status?: StringId; signature?: StringId; media?: StringId[]; asset_part_units?: { _id?: StringId; asset_part_unit: StringId; qty: number; asset_part?: StringId; asset_part_name?: string; comment?: string; splitted_from?: StringId; }[]; asset_part_units_count?: number; total_asset_part_units_qty?: number; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; isResubmitted?: boolean; note?: string; stage?: number; workorder?: StringId; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; } type PopulatedKeys = | "client" | "asset_part_unit" | "warehouse" | "teams" | "custom_status" | "meadia" | "signature" | "workorder"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; search?: string; // serial_number.formatted serial_number?: string[] | string; "serial_number.formatted"?: string[] | string; sync_id?: string[] | string; client?: StringId[] | StringId; warehouse?: StringId[] | StringId; "creator._id"?: StringId[] | StringId; "creator.type"?: string[] | string; creator?: StringId[] | StringId; creator_type?: string[] | string; rep?: StringId | StringId[]; admin?: StringId | StringId[]; teams?: StringId[] | StringId; visit_id?: string[] | string; custom_status?: StringId[] | StringId; asset_part_unit?: StringId[] | StringId; "asset_part_units.asset_part_unit"?: StringId[] | StringId; from_time?: number; to_time?: number; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; workorder?: StringId | StringId[]; populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id" | "time" | "createdAt" | "updatedAt"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { withCycle?: boolean; validityCheck?: boolean; populatedKeys?: PopulatedKeys[]; [key: string]: any; // integration_meta. }; export type Result = (Data | PopulatedDoc) & { cycle?: Cycle.Schema; validityCheck?: ValidityCheck; }; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type Params = { updateStatus: true }; export type Body = { readQuery: [{ key: "_id"; operator: "in"; value: StringId[] }]; writeQuery: { key: "custom_status"; command: "set"; value: StringId }; }; export type Result = { nFound: number; nModified: number }; } } export namespace StoreAssetPartUnit { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; status: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; transaction_processed: boolean; warehouse: StringId; warehouse_name: string; teams?: StringId[]; time: number; business_day?: string; visit_id?: string; serial_number: SerialNumber; description?: string; custom_status?: StringId; signature?: StringId; media?: StringId[]; asset_part_units: { _id?: StringId; asset_part_unit: StringId; qty: number; asset_part?: StringId; asset_part_name?: string; comment?: string; splitted_from?: StringId; }[]; asset_part_units_count?: number; total_asset_part_units_qty?: number; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; status: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; transaction_processed: boolean; warehouse: | StringId | Pick; warehouse_name: string; teams?: StringId[] | Pick[]; time: number; business_day?: string; visit_id?: string; serial_number: SerialNumber; description?: string; custom_status?: | StringId | Pick< CustomStatus.CustomStatusSchema, "_id" | "name" | "local_name" | "code" | "color" >; signature?: StringId | PopulatedMediaStorage; media?: StringId[] | PopulatedMediaStorage[]; asset_part_units: { _id: StringId; asset_part_unit: StringId | AssetPartUnit.Data; qty: number; asset_part?: StringId | AssetPart.Data; asset_part_name?: string; comment?: string; splitted_from?: StringId | AssetPartUnit.Data; }[]; asset_part_units_count?: number; total_asset_part_units_qty?: number; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { creator?: AdminOrRep; editor?: AdminOrRep; sync_id: string; status?: "pending"; transaction_processed: boolean; serial_number?: SerialNumber; warehouse: StringId; warehouse_name?: string; teams?: StringId[]; time: number; business_day?: string; visit_id?: string; description?: string; custom_status?: StringId; signature?: StringId; media?: StringId[]; asset_part_units: { _id?: StringId; asset_part_unit: StringId; qty: number; asset_part?: StringId; asset_part_name?: string; comment?: string; }[]; integration_meta?: { [key: string]: any }; asset_part_units_count?: number; total_asset_part_units_qty?: number; company_namespace: string[]; } export interface UpdateBody { _id?: StringId; creator?: AdminOrRep; editor?: AdminOrRep; sync_id?: string; status?: | "pending" | "approved" | "processing" | "rejected" | "processed" | "failed"; transaction_processed?: boolean; warehouse?: StringId; warehouse_name?: string; teams?: StringId[]; time?: number; business_day?: string; visit_id?: string; serial_number?: SerialNumber; description?: string; custom_status?: StringId; signature?: StringId; media?: StringId[]; asset_part_units?: { _id?: StringId; asset_part_unit: StringId; qty: number; asset_part?: StringId; asset_part_name?: string; comment?: string; splitted_from?: StringId; }[]; asset_part_units_count?: number; total_asset_part_units_qty?: number; integration_meta?: { [key: string]: any }; failed_reasons?: { code: string; message: string; [key: string]: any }[]; isResubmitted?: boolean; note?: string; stage?: number; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; } type PopulatedKeys = | "asset_part_unit" | "warehouse" | "teams" | "custom_status" | "meadia" | "signature"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; search?: string; // serial_number.formatted serial_number?: string[] | string; "serial_number.formatted"?: string[] | string; sync_id?: string[] | string; warehouse?: StringId[] | StringId; creator_type?: string[] | string; "creator.type"?: string[] | string; rep?: StringId | StringId[]; admin?: StringId | StringId[]; creator?: StringId | StringId[]; "creator._id"?: StringId[] | StringId; teams?: StringId[] | StringId; visit_id?: string[] | string; custom_status?: StringId[] | StringId; "asset_part_units.asset_part_unit"?: StringId[] | StringId; asset_part_unit?: StringId[] | StringId; from_time?: number; to_time?: number; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; populatedKeys?: PopulatedKeys[]; sortBy?: { field: "_id" | "time" | "createdAt" | "updatedAt"; type: "asc" | "desc"; }[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = StringId; export type Params = { withCycle?: boolean; validityCheck?: boolean; populatedKeys?: PopulatedKeys[]; [key: string]: any; // integration_meta. }; export type Result = (Data | PopulatedDoc) & { cycle?: Cycle.Schema; validityCheck?: ValidityCheck; }; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type Params = { updateStatus: true }; export type Body = { readQuery: [{ key: "_id"; operator: "in"; value: StringId[] }]; writeQuery: { key: "custom_status"; command: "set"; value: StringId }; }; export type Result = { nFound: number; nModified: number }; } } export namespace Cart { export type Promo = Promotion.Schema & { details: Promotion.Schema["details"] & { promotions_enabled?: boolean }; applied: { doesApply: boolean; appliedCount: number; limit_reached: boolean; is_prospective: boolean; rounds_status: ("full" | "partial" | "none")[]; last_round_buy_success: boolean; used: boolean; bulk_get_limit_values: number[]; }; promoApplicableCount: number; }; export interface Data { _id: StringId; type: "invoice" | "proforma"; processable?: boolean; product_source_msl?: "all_products" | "client" | "rep"; failure_reasons: string[]; external_serial_number?: string; qr_code_tlv?: string; skip_promos?: boolean; skipped_promotions: { _id: string; name: string; ref: string }[]; client_id: StringId; client_name: string; comment?: string; return_comment?: string; bypass_freshness_window_code_entered?: boolean; promotion_freshness_window_exceeded?: boolean; creator: { _id: string; type: "rep" | "client" | "admin"; rep?: string; admin?: string; client?: string; name?: string; }; implemented_by?: { _id: string; type: "rep" | "client" | "admin"; rep?: string; admin?: string; client?: string; name?: string; }; latest: boolean; version?: number; time?: number; issue_date: string; delivery_date?: string; currency: string; serial_number?: SerialNumber; geo_tag: { type: "Point"; coordinates: number[] }; sync_id: string; address?: { [key: string]: any }; company_namespace: string[]; promotions: Promo[]; priceLists: PriceListItem.PriceListItemSchema[]; visit_id?: string; teams: string[]; converter?: { _id: string; type: "rep" | "client" | "admin"; rep?: string; admin?: string; client?: string; name?: string; }; converted_proforma_serial_number?: SerialNumber; converted_proforma_return_serial_number?: SerialNumber; proforma_reference?: string; converted_at?: number; exclude_return_items?: boolean; returned_from?: string; returned_to?: string; returned_from_serial_number?: SerialNumber; returned_to_serial_number?: SerialNumber; partiall_returned_from?: string; partiall_returned_from_serial_number?: SerialNumber; due_date?: string; return_serial_number?: SerialNumber; origin_warehouse?: string; msl_sales?: string; route?: string; paymentsData: { invoice_value: number; paid: number; balance: number; payments: { payment_serial_number?: SerialNumber; payment_id?: string; invoice_serial_number?: SerialNumber; return_serial_number?: SerialNumber; fullinvoice_id?: string; view_serial_number?: SerialNumber; type: "invoice" | "payment" | "return_invoice"; amount: number; }[]; }; consumption: { status: "consumed" | "unconsumed" | "partially_consumed"; remainder: number; }; subtotal?: number; discount_amount?: number; discount_amount_float?: number; taxable_subtotal?: number; net_total?: number; tax_amount?: number; tax_amount_after_deduction_float?: number; tax_amount_after_deduction_float_rounded_sum?: number; tax_amount_after_deduction_float_rounded?: number; total?: number; total_float?: number; total_float_rounded?: number; total_float_rounded_sum?: number; total_before_tax?: number; /** * `total_before_tax + totalDeductionBeforeTax`: net of tax and before the * cart (header) deduction. Net of tax for inclusive-tax lines too, unlike * `taxable_subtotal`. */ total_before_deduction_and_tax?: number; taxable_amount_float?: number; taxable_amount_float_rounded_sum?: number; taxable_amount_float_rounded?: number; pre_subtotal?: number; pre_discount_amount?: number; pre_discount_amount_float?: number; pre_taxable_subtotal?: number; pre_net_total?: number; pre_tax_amount?: number; pre_tax_amount_after_deduction_float?: number; pre_tax_amount_after_deduction_float_rounded?: number; pre_tax_amount_after_deduction_float_rounded_sum?: number; pre_total?: number; pre_total_float?: number; pre_total_float_rounded?: number; pre_total_float_rounded_sum?: number; pre_total_before_tax?: number; pre_total_before_deduction_and_tax?: number; pre_taxable_amount_float?: number; pre_taxable_amount_float_rounded?: number; pre_taxable_amount_float_rounded_sum?: number; return_subtotal?: number; return_discount_amount?: number; return_discount_amount_float?: number; return_taxable_subtotal?: number; return_net_total?: number; return_tax_amount?: number; return_tax_amount_after_deduction_float?: number; return_tax_amount_after_deduction_float_rounded?: number; return_tax_amount_after_deduction_float_rounded_sum?: number; return_total?: number; return_total_float?: number; return_total_float_rounded?: number; return_total_float_rounded_sum?: number; return_total_before_tax?: number; return_total_before_deduction_and_tax?: number; return_taxable_amount_float?: number; return_taxable_amount_float_rounded?: number; return_taxable_amount_float_rounded_sum?: number; deductionRatio?: number; deductionFixed?: number; totalDeductedTax?: number; totalDeductedTaxFloat?: number; totalDeduction?: number; totalDeductionFloat?: number; totalDeductionBeforeTax?: number; totalDeductionBeforeTaxFloat?: number; totalAfterDeduction?: number; totalAfterDeductionFloat?: number; lines_discount?: number; lines_discount_float?: number; taxes: { [key: string]: any }; overwriteDeductionFixed?: number; overwriteTaxExempt?: boolean; tax_exempt?: boolean; overwriteDeductionRatio?: number; shipping_zone?: { [key: string]: any }; payment_method?: { [key: string]: any }; shipping_price?: number; shipping_tax?: number; shipping_charge?: number; payment_charge?: number; total_with_charges?: number; payment?: { amount?: number }; workorder?: string; asset?: string; asset_unit?: string; signature?: string; createdAt: Date; updatedAt: Date; items: (Item.Schema & { notes?: { [key: string]: any } })[]; return_items?: (Item.Schema & { notes?: { [key: string]: any } })[]; invoice_payment_type: "cash" | "credit"; total_items_base_unit_qty?: number; total_items_qty?: number; total_return_items_base_unit_qty?: number; total_return_items_qty?: number; cart?: { [key: string]: any }; __v?: number; } export interface CreateBody { type: "invoice" | "proforma"; processable?: boolean; failure_reasons: string[]; external_serial_number?: string; product_source_msl?: "all_products" | "client" | "rep"; skip_promos?: boolean; skipped_promotions: { _id: string; name: string; ref: string }[]; client_id: StringId; client_name: string; comment?: string; return_comment?: string; creator: { _id: string; type: "rep" | "client" | "admin"; rep?: string; admin?: string; client?: string; name?: string; }; implemented_by?: { _id: string; type: "rep" | "client" | "admin"; rep?: string; admin?: string; client?: string; name?: string; }; latest: boolean; version?: number; time?: number; issue_date: string; delivery_date?: string; currency: string; serial_number?: SerialNumber; geo_tag: { type: "Point"; coordinates: number[] }; sync_id: string; address?: { [key: string]: any }; company_namespace: string[]; promotions: Promo[]; priceLists: PriceListItem.PriceListItemSchema[]; visit_id?: string; teams: string[]; converter?: { _id: string; type: "rep" | "client" | "admin"; rep?: string; admin?: string; client?: string; name?: string; }; bypass_freshness_window_code_entered?: boolean; promotion_freshness_window_exceeded?: boolean; converted_proforma_serial_number?: SerialNumber; converted_proforma_return_serial_number?: SerialNumber; proforma_reference?: string; converted_at?: number; exclude_return_items?: boolean; returned_from?: string; returned_to?: string; returned_from_serial_number?: SerialNumber; returned_to_serial_number?: SerialNumber; partiall_returned_from?: string; partiall_returned_from_serial_number?: SerialNumber; due_date?: string; return_serial_number?: SerialNumber; origin_warehouse?: string; msl_sales?: string; route?: string; paymentsData: { invoice_value: number; paid: number; balance: number; payments: { payment_serial_number?: SerialNumber; payment_id?: string; invoice_serial_number?: SerialNumber; return_serial_number?: SerialNumber; fullinvoice_id?: string; view_serial_number?: SerialNumber; type: "invoice" | "payment" | "return_invoice"; amount: number; }[]; }; consumption: { status: "consumed" | "unconsumed" | "partially_consumed"; remainder: number; }; subtotal?: number; discount_amount?: number; discount_amount_float?: number; taxable_subtotal?: number; net_total?: number; tax_amount?: number; tax_amount_after_deduction_float?: number; tax_amount_after_deduction_float_rounded_sum?: number; tax_amount_after_deduction_float_rounded?: number; total?: number; total_float?: number; total_float_rounded?: number; total_float_rounded_sum?: number; total_before_tax?: number; /** * `total_before_tax + totalDeductionBeforeTax`: net of tax and before the * cart (header) deduction. Net of tax for inclusive-tax lines too, unlike * `taxable_subtotal`. */ total_before_deduction_and_tax?: number; taxable_amount_float?: number; taxable_amount_float_rounded_sum?: number; taxable_amount_float_rounded?: number; pre_subtotal?: number; pre_discount_amount?: number; pre_discount_amount_float?: number; pre_taxable_subtotal?: number; pre_net_total?: number; pre_tax_amount?: number; pre_tax_amount_after_deduction_float?: number; pre_tax_amount_after_deduction_float_rounded?: number; pre_tax_amount_after_deduction_float_rounded_sum?: number; pre_total?: number; pre_total_float?: number; pre_total_float_rounded?: number; pre_total_float_rounded_sum?: number; pre_total_before_tax?: number; pre_total_before_deduction_and_tax?: number; pre_taxable_amount_float?: number; pre_taxable_amount_float_rounded?: number; pre_taxable_amount_float_rounded_sum?: number; return_subtotal?: number; return_discount_amount?: number; return_discount_amount_float?: number; return_taxable_subtotal?: number; return_net_total?: number; return_tax_amount?: number; return_tax_amount_after_deduction_float?: number; return_tax_amount_after_deduction_float_rounded?: number; return_tax_amount_after_deduction_float_rounded_sum?: number; return_total?: number; return_total_float?: number; return_total_float_rounded?: number; return_total_float_rounded_sum?: number; return_total_before_tax?: number; return_total_before_deduction_and_tax?: number; return_taxable_amount_float?: number; return_taxable_amount_float_rounded?: number; return_taxable_amount_float_rounded_sum?: number; deductionRatio?: number; deductionFixed?: number; totalDeductedTax?: number; totalDeductedTaxFloat?: number; totalDeduction?: number; totalDeductionFloat?: number; totalDeductionBeforeTax?: number; totalDeductionBeforeTaxFloat?: number; totalAfterDeduction?: number; totalAfterDeductionFloat?: number; lines_discount?: number; lines_discount_float?: number; taxes: { [key: string]: any }; overwriteDeductionFixed?: number; overwriteTaxExempt?: boolean; tax_exempt?: boolean; overwriteDeductionRatio?: number; shipping_zone?: { [key: string]: any }; payment_method?: { [key: string]: any }; shipping_price?: number; shipping_tax?: number; shipping_charge?: number; payment_charge?: number; total_with_charges?: number; payment?: { amount?: number }; workorder?: string; asset?: string; asset_unit?: string; signature?: string; createdAt: Date; updatedAt: Date; items: (Item.Schema & { notes?: { [key: string]: any } })[]; return_items?: (Item.Schema & { notes?: { [key: string]: any } })[]; invoice_payment_type: "cash" | "credit"; total_items_base_unit_qty?: number; total_items_qty?: number; total_return_items_base_unit_qty?: number; total_return_items_qty?: number; cart?: { [key: string]: any }; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; client_id?: StringId | StringId[]; "creator._id"?: StringId | StringId[]; type?: Data["type"] | Data["type"][]; "implemented_by._id"?: StringId | StringId[]; sync_id?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Params = { [key: string]: any }; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = { _id?: StringId | StringId[]; client_id?: StringId | StringId[]; "creator._id"?: StringId | StringId[]; type?: Data["type"] | Data["type"][]; }; export type Result = { success: boolean }; } } export namespace OcrInvoiceJobTemplate { export interface ProductMatchStage { model: "products" | "productvariations" | "ocrInvoiceJobPages"; model_key: | "name" | "barcode" | "sku" | "ai_json_data.barcode" | "ai_json_data.code" | "ai_json_data.description"; operator: "eq"; ai_json_key: "barcode" | "code" | "description"; condition: "learn_ignorance"; warning_message: string; is_warning: boolean; } export interface MeasureUnitMatchStage { model: "measureunits"; quick_action: "product_default" | "base_measure_unit"; condition: "eq_product_default" | "in_product_family"; model_key: "name"; operator: "eq"; ai_json_key: "measure_unit"; warning_message: string; is_warning: boolean; } export interface ClientMatchingStage { model: "clients" | "ocrInvoiceJobPages"; condition?: "in_current_template"; model_key: "name" | "ai_invoice_json.client_name"; operator: "eq"; ai_json_key: "client_name"; warning_message?: string; is_warning?: boolean; } export interface CartOptions { overwrite_price: boolean; client_override?: boolean; product_matching_stages: ProductMatchStage[]; measure_unit_matching_stages: MeasureUnitMatchStage[]; client_matching_stages: ClientMatchingStage[]; } export interface Data { _id: StringId; name: string; company_namespace: string[]; disabled: boolean; document_scan_listed: boolean; client?: StringId; doc_type: "pdf" | "image" | "fixed-length-text"; preparation_option?: { rotate?: boolean; convert_to_image: boolean; lang?: { en?: boolean; ar?: boolean; }; }; cart_option?: CartOptions; ai_json_parsing_model: "gpt-4o-mini" | "gpt-4o" | "fixed-length-text"; ai_vision_model: "gpt-4o-mini" | "gpt-4o" | "local_vision" | "fixed-length-text"; visible_columns: { key: | "product_name" | "variant_name" | "product_sku" | "product_barcode" | "variant_barcode" | "variant_sku" | "price" | "qty" | "measure_unit" | "total_amount" | "total" | "code"; visible: boolean; }[]; ai_parsing_prompt_amendment?: string; ai_vision_prompt_amendment?: string; ai_parsing_prompt_overwrite?: string; ai_vision_prompt_overwrite?: string; enable_ai_parsing_prompt_amendment?: boolean; enable_ai_vision_prompt_amendment?: boolean; enable_ai_parsing_prompt_overwrite?: boolean; enable_ai_vision_prompt_overwrite?: boolean; always_merge_pages_for_job?: boolean; trim_barcode_zero_from_left?: boolean; bypass_human_review?: boolean; fixed_length_text_layout_definition?: StringId; createdAt: Date; updatedAt: Date; } export type PopulatedDoc = Data & { client_populated?: Pick; fixed_length_text_layout_definition_populated?: OcrInvoiceFixedLengthTextLayoutDefinition.Data; }; export interface CreateBody { name: string; company_namespace: string[]; document_scan_listed: boolean; client?: StringId; doc_type: "pdf" | "image" | "fixed-length-text"; preparation_option?: { rotate?: boolean; convert_to_image: boolean; lang?: { en?: boolean; ar?: boolean; }; }; cart_option?: CartOptions; ai_json_parsing_model: "gpt-4o-mini" | "gpt-4o" | "fixed-length-text"; ai_vision_model: "gpt-4o-mini" | "gpt-4o" | "local_vision" | "fixed-length-text"; visible_columns: { key: | "product_name" | "variant_name" | "product_sku" | "product_barcode" | "variant_barcode" | "variant_sku" | "price" | "qty" | "measure_unit" | "total_amount" | "total" | "code"; visible: boolean; }[]; ai_parsing_prompt_amendment?: string; ai_vision_prompt_amendment?: string; ai_parsing_prompt_overwrite?: string; ai_vision_prompt_overwrite?: string; enable_ai_parsing_prompt_amendment?: boolean; enable_ai_vision_prompt_amendment?: boolean; enable_ai_parsing_prompt_overwrite?: boolean; enable_ai_vision_prompt_overwrite?: boolean; always_merge_pages_for_job?: boolean; trim_zero_from_first?: boolean; } export interface UpdateBody { name: string; company_namespace: string[]; document_scan_listed: boolean; client?: StringId; preparation_option?: { rotate?: boolean; convert_to_image: boolean; lang?: { en?: boolean; ar?: boolean; }; }; cart_option?: CartOptions; ai_json_parsing_model: "gpt-4o-mini" | "gpt-4o" | "fixed-length-text"; ai_vision_model: "gpt-4o-mini" | "gpt-4o" | "local_vision" | "fixed-length-text"; visible_columns: { key: | "product_name" | "variant_name" | "product_sku" | "product_barcode" | "variant_barcode" | "variant_sku" | "price" | "qty" | "measure_unit" | "total_amount" | "total" | "code"; visible: boolean; }[]; ai_parsing_prompt_amendment?: string; ai_vision_prompt_amendment?: string; ai_parsing_prompt_overwrite?: string; ai_vision_prompt_overwrite?: string; enable_ai_parsing_prompt_amendment?: boolean; enable_ai_vision_prompt_amendment?: boolean; enable_ai_parsing_prompt_overwrite?: boolean; enable_ai_vision_prompt_overwrite?: boolean; always_merge_pages_for_job?: boolean; trim_zero_from_first?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; client?: string[] | string; disabled?: boolean; doc_type?: string[] | string; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Result = Data & PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } } export namespace OcrInvoiceJobGroup { export interface Data { _id: StringId; name: string; sync_id: string; company_namespace: string[]; disabled: boolean; template: StringId; client: StringId | Pick; doc_type: "pdf" | "image"; media: string[]; creator: AdminOrRep; status: | "initiated" | "failed" | "incomplete" | "partially_completed" | "completed" | "in_progress"; time: number; visit_id?: StringId; geo_tag: GeoTag; } export interface PopulatedDoc { _id: StringId; name: string; sync_id: string; company_namespace: string[]; disabled: boolean; template: StringId; template_populated: OcrInvoiceJobTemplate.Data; client: StringId; client_populated: Pick; doc_type: "pdf" | "image"; media: StringId[]; media_populated: PopulatedMediaStorage[]; creator: AdminOrRep; status: | "initiated" | "failed" | "incomplete" | "partially_completed" | "completed" | "in_progress"; time: number; visit_id?: StringId; geo_tag: GeoTag; } export interface CreateBody { sync_id: string; name: string; company_namespace: string[]; template: StringId; client: StringId; media: StringId[]; creator?: AdminOrRep; time: number; visit_id?: StringId; geo_tag?: GeoTag; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; client?: string[] | string; disabled?: boolean; doc_type?: string[] | string; template?: StringId[] | StringId; visit_id?: StringId[] | StringId; from_time?: number; to_time?: number; status?: string[]; rep?: StringId[] | StringId; admin?: StringId[] | StringId; "creator._id"?: StringId[] | StringId; "creator.type"?: string[] | string; search?: string; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Result = Data & PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } } export namespace OcrInvoiceJob { export type StepCode = "ai-api-js" | "python-utilities" | "job-handler"; export type TaskCode = | "create-job-pages" | "photo-json-extraction" | "photo-text-extraction" | "pdf-text-extraction" | "text-json-parsing" | "pdf-image-conversion" | "pdf-image-text-ocr" | "finalize"; export interface Task { code: TaskCode; options: {}; } export type Step = { code: StepCode; tasks: Task[]; }; export interface PhotoTextExtractionTask extends Task { code: "photo-text-extraction"; options: {}; } export interface PhotoJsonExtractionTask extends Task { code: "photo-json-extraction"; options: { ai_model: "gpt-4o-mini" | "gpt-4o" }; } export interface PdfTextExtractionTask extends Task { code: "pdf-text-extraction"; options: {}; } export interface PdfImageConversionTask extends Task { code: "pdf-image-conversion"; options: {}; } export interface PdfImageTextOcrTask extends Task { code: "pdf-image-text-ocr"; options: {}; } export interface TextJsonParsingTask extends Task { code: "text-json-parsing"; options: { ai_model: "gpt-4o-mini" | "gpt-4o" }; } export interface FinalizeTask extends Task { code: "finalize"; options: {}; } export interface CreateJobPagesTask extends Task { code: "create-job-pages"; options: {}; } export type AiApiJsStep = { code: "ai-api-js"; tasks: ( PhotoTextExtractionTask | PhotoJsonExtractionTask | TextJsonParsingTask )[]; }; export type PythonUtilitiesStep = { code: "python-utilities"; tasks: ( PdfTextExtractionTask | PdfImageConversionTask | PdfImageTextOcrTask )[]; }; export type JobHandlerStep = { code: "job-handler"; tasks: (FinalizeTask | CreateJobPagesTask | TextJsonParsingTask)[]; }; export type PlanStep = AiApiJsStep | JobHandlerStep | PythonUtilitiesStep; type PlanOptions = { early_page_generation?: boolean; }; export type Plan = { steps: PlanStep[]; options: PlanOptions; }; export interface Data { _id: StringId; company_namespace: string[]; disabled: boolean; template: StringId; client: StringId; doc_type: "pdf" | "image"; convert_to_image?: boolean; rotate?: boolean; file_media: StringId; text_media?: StringId; pages_count?: number; createdAt: Date; updatedAt: Date; job_group: StringId; planner?: Plan; status: | "pending" | "initiated" | "incomplete" | "in_progress" | "completed" | "failed"; creator: AdminOrRep; error_message?: any; } export interface PopulatedDoc { _id: StringId; company_namespace: string[]; disabled: boolean; template: StringId; template_populated: Pick; client: StringId; client_populated: Pick; doc_type: "pdf" | "image"; convert_to_image?: boolean; rotate?: boolean; file_media: StringId | PopulatedMediaStorage; file_media_populated: PopulatedMediaStorage; text_media?: StringId; pages_count?: number; createdAt: Date; updatedAt: Date; job_group: StringId; job_group_populated: Pick; planner?: Plan; status: | "pending" | "initiated" | "incomplete" | "in_progress" | "completed" | "failed"; creator: AdminOrRep; error_message?: any; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; disabled?: boolean; template?: StringId[] | StringId; client?: StringId[] | StringId; doc_type?: string[] | string; job_group?: StringId[] | StringId; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Result = Data & PopulatedDoc; } } export namespace OcrInvoiceJobPage { export interface AIInvoiceJsonSchema { new_page?: boolean; issue_date?: string; reference?: string; client_name?: string; items: [ { barcode?: string; code?: string; description?: string; quantity?: number; unit_price?: number; total?: number; measure_unit?: string; total_amount?: number; tax_amount?: number; discount_amount?: number; }, ]; total_amount?: number; total_tax?: number; } export interface CartAnnotationErrorType { message: string; key: | "items.variant.listed_price" | "items.overwrite_price" | "items.tax" | "items.measure_unit" | "items.qty" | "items.variant.variant_sku" | "items.variant.variant_barcode" | "items.variant.product_barcode" | "items.variant.product_sku" | "items.cart_line_total" | "items.cart_line_amount" | "items.variant.product_id" | "items.variant.variant_id" | "total" | "tax_total" | "issue_date" | "external_serial_number" | "client"; code: "missing" | "not_equal" | "exists" | "invalid_date" | "custom_warning"; } export interface CartAnnotationItem { ai_json_data?: { barcode?: string; description?: string; qty?: number; measure_unit?: string; code?: string; unit_price?: number; total?: number; total_amount?: number; tax_amount?: number; discount_amount?: number; }; overwrite_price?: number; client_id: StringId; qty: number; variant?: { product_id?: string; product_name?: string; product_sku?: string; product_barcode?: string; variant_id?: string; variant_name?: string; variant_sku?: string; variant_barcode?: string; listed_price?: number; }; measure_unit?: { parent: string; name: string; factor: number; disabled: boolean; company_namespace: string[]; }; tax?: { name: string; rate: number; type: "inclusive" | "additive" | "N/A"; ubl_tax_details?: { tax_code: { type: String; enum: ["Z", "O", "S", "E"] }; reason: { type: String }; reason_code: { type: String }; }; disabled: boolean; }; warnings?: CartAnnotationErrorType[]; _errors?: CartAnnotationErrorType[]; status?: "red" | "green" | "orange"; cart_line_total?: number; cart_line_amount?: number; ignore?: boolean; } export interface CartAnnotation { issue_date: string; external_serial_number?: string; total: number; tax_total: number; cart_total: number; cart_tax_total: number; cart_total_before_tax: number; items: CartAnnotationItem[]; warnings?: CartAnnotationErrorType[]; _errors?: CartAnnotationErrorType[]; status?: "red" | "orange" | "green"; } export interface Data { _id: string; company_namespace: string[]; disabled: boolean; job: StringId; template: StringId; page_number: number; text?: string; media_url?: string; proforma?: StringId; cart?: Cart.Data; cart_annotation?: CartAnnotation; ai_invoice_json?: AIInvoiceJsonSchema; error_message?: any; client: StringId; status?: | "pending" | "in_progress" | "converted" | "failed" | "ready_to_convert" | "incomplete" | "merged"; last_page: boolean; creator: AdminOrRep; editor?: AdminOrRep; createdAt: Date; updatedAt: Date; page_usage?: { input_tokens: number; output_tokens: number; weighted_input_tokens: number; weighted_output_tokens: number; total_weighted_tokens: number; ai_model?: "gpt-4o" | "gpt-4o-mini"; }; } export interface PopulatedDoc { _id: StringId; company_namespace: string[]; disabled: boolean; job: StringId; job_populated: OcrInvoiceJob.Data & { job_group_populated: OcrInvoiceJobGroup.Data; }; template: StringId; template_populated: Pick; page_number: number; text?: string; media_url?: string; proforma?: StringId; proforma_populated?: Pick< Proforma.ProformaSchema, "serial_number" | "_id" >; cart?: Cart.Data; cart_annotation?: CartAnnotation; ai_invoice_json?: AIInvoiceJsonSchema; error_message?: any; client: StringId; client_populated: Pick; status?: | "pending" | "in_progress" | "converted" | "failed" | "ready_to_convert" | "incomplete" | "merged"; last_page: boolean; creator: AdminOrRep; editor?: AdminOrRep; createdAt: Date; updatedAt: Date; page_usage?: { input_tokens: number; output_tokens: number; weighted_input_tokens: number; weighted_output_tokens: number; total_weighted_tokens: number; ai_model?: "gpt-4o" | "gpt-4o-mini"; }; } export interface UpdateBody { disabled: boolean; cart_annotation?: CartAnnotation; client: StringId; cart?: Cart.Data; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; job?: StringId | StringId[]; template?: StringId | StringId[]; page_number?: number; proforma?: StringId | StringId[]; status?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Result = Data & PopulatedDoc; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } } export namespace OcrInvoiceFixedLengthTextLayoutDefinition { export interface Data { _id: StringId; name: string; company_namespace: string[]; disabled: boolean; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; company_namespace?: string[]; disabled?: boolean; } export interface UpdateBody { _id?: StringId; name?: string; company_namespace?: string[]; disabled?: boolean; createdAt?: Date; updatedAt?: Date; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; disabled?: boolean | boolean[]; search?: string; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace OcrInvoiceFixedLengthTextLayoutDefinitionField { export interface Data { _id: StringId; name: string; layout_definition: StringId; disabled: boolean; data_type: "Text" | "Number" | "Date"; position: number; length: number; remarks?: string; decimal?: number; date_format?: string; default_ai_json_key?: | "issue_date" | "reference" | "client_name" | "barcode" | "code" | "description" | "tax_amount" | "discount_amount" | "quantity" | "unit_price" | "total" | "measure_unit" | "total_amount"; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; layout_definition: StringId; disabled?: boolean; data_type: "Text" | "Number" | "Date"; position: number; length: number; remarks?: string; decimal?: number; date_format?: string; default_ai_json_key?: | "issue_date" | "reference" | "client_name" | "barcode" | "code" | "description" | "tax_amount" | "discount_amount" | "quantity" | "unit_price" | "total" | "measure_unit" | "total_amount"; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; name?: string; layout_definition?: StringId; disabled?: boolean; data_type?: "Text" | "Number" | "Date"; position?: number; length?: number; remarks?: string; decimal?: number; date_format?: string; default_ai_json_key?: | "issue_date" | "reference" | "client_name" | "barcode" | "code" | "description" | "tax_amount" | "discount_amount" | "quantity" | "unit_price" | "total" | "measure_unit" | "total_amount"; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; } type PopulatedKeys = "layout_definition"; export type PopulatedDoc = Data & { layout_definition_populated?: OcrInvoiceFixedLengthTextLayoutDefinition.Data; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; layout_definition?: StringId | StringId[]; name?: string | string[]; disabled?: boolean | boolean[]; search?: string; sortBy?: { field: "_id" | "position"; type: "asc" | "desc"; }[]; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace ActivityAiSalesOrder { export interface Data { _id: string; creator: RepCreator; editor?: RepCreator; teams: StringId[]; tags: StringId[]; time: number; client?: StringId; client_name?: string; visit?: StringId; visit_id?: string; route?: string; sync_id: string; template_id: StringId; jo_group_id?: StringId; media: StringId[]; geo_tag?: GeoTag; geoPoint?: GeoPoint; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; time_zone?: string; job_start_time?: number; job_end_time?: number; job_duration?: number; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PopulatedDoc { _id: string; creator: RepCreator; editor?: RepCreator; teams: StringId[]; teams_populated: Pick[]; tags: StringId[]; tags_populated: Pick[]; time: number; client?: StringId; client_populated?: Pick< Client.ClientSchema, "name" | "client_code" | "_id" >; client_name?: string; visit?: string; visit_populated?: Visit.VisitSchema; visit_id?: string; route?: StringId; route_populated?: Pick; sync_id: string; template_id: StringId; jo_group_id?: StringId; jo_group_id_populated?: Pick< OcrInvoiceJobGroup.Data, "name" | "status" | "_id" >; media: StringId[]; media_populated: PopulatedMediaStorage[]; geo_tag?: GeoTag; geoPoint?: GeoPoint; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; time_zone?: string; job_start_time?: number; job_end_time?: number; job_duration?: number; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { creator: RepCreator; teams: StringId[]; tags: StringId[]; time: number; client?: StringId; client_name?: string; visit?: StringId; visit_id?: string; route?: string; sync_id: string; template_id: StringId; media: StringId[]; geo_tag?: GeoTag; geoPoint?: GeoPoint; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; time_zone?: string; job_start_time?: number; job_end_time?: number; job_duration?: number; company_namespace: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; job?: StringId | StringId[]; template?: StringId | StringId[]; page_number?: number; proforma?: StringId | StringId[]; status?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Result = Data & PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } } export namespace Settings { export type Separator = "," | " " | "." | "'"; export interface EmailFilter { id?: string; key: string; operator: "eq" | "ne" | "in" | "nin" | "gt" | "gte" | "lt" | "lte"; value: any[]; } export interface SalesSettings { currency: string; name_on_invoice?: string; invoice_footer?: string; logo?: string; logo_media?: StringId | PopulatedMediaStorage; tax_number?: string; default_payment_type?: "cash" | "credit"; saudi_law?: boolean; handle_integrated_client_balance?: boolean; dot_separator?: Separator; thousands_separator?: Separator; number_of_digits_after_dot_separator?: 0 | 1 | 2 | 3; hide_line_item_tax?: boolean; line_total_key?: "line_total" | "total_before_tax" | "lineTotalAfterDeduction"; return_invoice_title?: string; return_invoice_local_title?: string; invoice_title?: string; invoice_local_title?: string; proforma_title?: string; proforma_local_title?: string; show_total_in_words?: boolean; address_1?: string; address_2?: string; prevent_negative_convert_to_invoice_stock?: boolean; prevent_negative_mobile_transfer_stock: boolean; empty_proforma_cart_at_visit_start_by_same_creator?: boolean; empty_proforma_cart_at_visit_start_by_any_creator?: boolean; empty_fullinvoice_cart_at_visit_start_by_same_creator?: boolean; empty_fullinvoice_cart_at_visit_start_by_any_creator?: boolean; enforce_serial_number_by_server?: boolean; invoice_advanced_serial_number_format?: { format: { year_format?: "YYYY" | "YY"; month_format?: "M" | "MM" | "MMM" | "MMMM"; day_format?: "D" | "DD"; counter_length_fixed?: boolean; counter_length?: number; id_format: string; }; counter: number; }; activate_advanced_serial_number?: boolean; enable_variant_batches_at_invoice?: boolean; enable_variant_batches_at_proforma?: boolean; enable_variant_batches_at_return_invoice?: boolean; prevent_negative_transfer_stock?: boolean; currency_subunit?: string; local_currency?: string; local_currency_subunit?: string; currency_factor?: 100 | 1000; print_payment_allowance_period_in_days?: number; freshness_window_in_minutes: number; bypass_freshness_window_code: string; invoice_delivery_mode: "transactional" | "non_transactional" | "optional"; default_invoice_delivery_mode: "transactional" | "non_transactional"; invoice_source_msl: { level: "client" | "rep"; active: boolean }[]; proforma_source_msl: { level: "all_products" | "client" | "rep"; active: boolean; }[]; transfer_source_msl: { level: "all_products" | "rep"; active: boolean }[]; } export interface WorkorderSettings { workorder_teams_follow_assigned_to?: boolean; workorder_teams_follow_client?: boolean; workorder_request_teams_follow_client?: boolean; send_email_at_contract_expiry?: boolean; send_email_at_contract_near_expiry?: boolean; send_email_at_contract_installment_due?: boolean; send_email_at_contract_installment_near_due?: boolean; contract_near_expiry_days: number; contract_installment_near_due_days: number; workorder_near_due_days?: number; } export interface Data { _id: string; company_namespace: string[]; live_location: { active: boolean; from?: string; to?: string }; use_original_image_compression?: boolean; use_client_specific_sales_settings?: boolean; use_client_specific_sales_settings_for_payment?: boolean; use_client_specific_sales_settings_for_client_statement?: boolean; disable_ubl_integration_for_return_invoice?: boolean; sales: SalesSettings; geofencing: { visit_start: boolean; visit_end: boolean; radius: number; visit_strict: boolean; }; mail_list: { invoice_sales: { name: string; email: string; filters?: EmailFilter[]; }[]; mocking: { name: string; email: string }[]; sales_order: { name: string; email: string; filters?: EmailFilter[] }[]; photo: { name: string; email: string; filters?: EmailFilter[] }[]; live_location: { name: string; email: string; filters?: EmailFilter[]; }[]; location_off: { name: string; email: string; filters?: EmailFilter[]; }[]; location_on: { name: string; email: string; filters?: EmailFilter[] }[]; contract_expiry: { name: string; email: string }[]; contract_near_expiry: { name: string; email: string }[]; contract_installment_due: { name: string; email: string }[]; contract_installment_near_due: { name: string; email: string }[]; }; promotions: { enforcement_mode: "all_in_inventory" | "all" | "gift_in_inventory" | "gift" | "custom"; apply_hidden_price: boolean; apply_all_promotions: boolean; applying_sort: { [key: string]: -1 | 1 }[]; force_cash_only: boolean; allow_manual_discounts?: boolean; manual_discounts_limit_percentage: number; manual_discounts_limit_value?: number; promotions_enabled: boolean; round_discounted_price: boolean; enable_pull_remote_cart: boolean; enable_promotion_freshness_window: boolean; enable_usage_limits: boolean; }; teams_shared_collections: string[]; days_of_work: | "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday"; signUpMethod: "email" | "phone"; calculate_target_for_absent_days: boolean; calculate_target_for_non_working_days?: boolean; disable_module_custom_validator: boolean; activate_ubl_integration: boolean; last_activate_ubl_integration_time?: number; visit: { manual_product_line_selection: boolean }; custom_status: { use_custom_status_transfer?: boolean; use_system_status_transfer?: boolean; use_custom_status_payment?: boolean; use_system_status_payment?: boolean; use_custom_status_fullinvoice?: boolean; use_system_status_fullinvoice?: boolean; use_custom_status_proforma?: boolean; use_system_status_proforma?: boolean; use_custom_status_workorder?: boolean; use_system_status_workorder?: boolean; }; business_apps: { code: string; services: { permission: StringId; teams_shared: "shared" | "unshared"; }[]; }[]; form: { overwrite_serial_number?: boolean; allow_create_v1: boolean }; workorder?: WorkorderSettings; notifications?: { calendar_update?: boolean; transfer_update?: boolean; cycle_update?: boolean; client_update?: boolean; approval_request_update?: boolean; workorder_update?: boolean; workorder_start?: boolean; workorder_near_due?: boolean; activity_note?: boolean; activity_form?: boolean; activity_photo?: boolean; activity_audit?: boolean; activity_task?: boolean; activity_availability?: boolean; activity_planogram?: boolean; activity_shelfsahre?: boolean; activity_checkout_display?: boolean; activity_secondary_display?: boolean; }; asset_part?: { prevent_negative_asset_part_inventory: boolean }; default_lang?: "en" | "ar"; second_lang?: "en" | "ar"; report_value_delimiter?: "|" | "," | " " | "." | "-"; rep_settings?: { rep_start_day_specific_time_frame_start: string; rep_start_day_specific_time_frame_end: string; }; rep_permissions?: { rep_must_start_day_within_specific_time_frame: boolean; }; allow_assigning_non_creator_teams_when_creating_client?: boolean; enable_email_mfa: boolean; enable_whatsapp_mfa: boolean; enable_authenticator_mfa: boolean; minimum_accepted_mfa: number; end_of_day_mode: "fixed_time" | "shift_based"; automatic_end_day_minutes_after_shift_end: number; start_day_outside_active_zone_action: "monitor" | "warning" | "block"; start_visit_outside_active_zone_action: "monitor" | "warning" | "block"; work_outside_active_zone_action: "monitor" | "warning" | "block"; no_active_zone_action: "allow" | "block"; use_accuracy_radius_near_zone_boundary: boolean; zone_boundary_grace_minutes: number; createdAt: Date; updatedAt: Date; } export type PopulatedDoc = Data & { business_apps: { code: string; services: { permission: StringId | { name: string; _id: StringId }; teams_shared: "shared" | "unshared"; }[]; }[]; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; job?: StringId | StringId[]; template?: StringId | StringId[]; page_number?: number; proforma?: StringId | StringId[]; status?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Result = Data; } export interface UpdateBody { live_location?: { active: boolean; from?: string; to?: string }; use_original_image_compression?: boolean; use_client_specific_sales_settings?: boolean; use_client_specific_sales_settings_for_payment?: boolean; use_client_specific_sales_settings_for_client_statement?: boolean; disable_ubl_integration_for_return_invoice?: boolean; sales?: SalesSettings; geofencing?: { visit_start: boolean; visit_end: boolean; radius: number; visit_strict: boolean; }; mail_list?: { invoice_sales: { name: string; email: string; filters?: EmailFilter[]; }[]; mocking: { name: string; email: string }[]; sales_order: { name: string; email: string; filters?: EmailFilter[] }[]; photo: { name: string; email: string; filters?: EmailFilter[] }[]; live_location: { name: string; email: string; filters?: EmailFilter[]; }[]; location_off: { name: string; email: string; filters?: EmailFilter[]; }[]; location_on: { name: string; email: string; filters?: EmailFilter[] }[]; contract_expiry: { name: string; email: string }[]; contract_near_expiry: { name: string; email: string }[]; contract_installment_due: { name: string; email: string }[]; contract_installment_near_due: { name: string; email: string }[]; }; promotions?: { enforcement_mode: "all_in_inventory" | "all" | "gift_in_inventory" | "gift" | "custom"; apply_hidden_price: boolean; apply_all_promotions: boolean; applying_sort: { [key: string]: -1 | 1 }[]; force_cash_only: boolean; allow_manual_discounts: boolean; manual_discounts_limit_percentage: number; manual_discounts_limit_value: number; promotions_enabled: boolean; round_discounted_price: boolean; enable_pull_remote_cart?: boolean; enable_promotion_freshness_window?: boolean; enable_usage_limits?: boolean; }; teams_shared_collections?: string[]; days_of_work?: | "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday"; signUpMethod?: "email" | "phone"; calculate_target_for_absent_days?: boolean; calculate_target_for_non_working_days?: boolean; disable_module_custom_validator?: boolean; activate_ubl_integration?: boolean; last_activate_ubl_integration_time?: number; visit?: { manual_product_line_selection: boolean }; custom_status?: { use_custom_status_transfer?: boolean; use_system_status_transfer?: boolean; use_custom_status_payment?: boolean; use_system_status_payment?: boolean; use_custom_status_fullinvoice?: boolean; use_system_status_fullinvoice?: boolean; use_custom_status_proforma?: boolean; use_system_status_proforma?: boolean; use_custom_status_workorder?: boolean; use_system_status_workorder?: boolean; }; business_apps?: { code: string; services: { permission: string; teams_shared: "shared" | "unshared"; }[]; }[]; form?: { overwrite_serial_number?: boolean; allow_create_v1: boolean }; workorder?: WorkorderSettings; notifications?: { calendar_update: boolean; transfer_update: boolean; cycle_update: boolean; client_update: boolean; approval_request_update: boolean; workorder_update: boolean; workorder_start: boolean; workorder_near_due: boolean; activity_note: boolean; activity_form: boolean; activity_photo: boolean; activity_audit: boolean; activity_task: boolean; activity_availability: boolean; activity_planogram: boolean; activity_shelfsahre: boolean; activity_checkout_display: boolean; activity_secondary_display: boolean; }; asset_part?: { prevent_negative_asset_part_inventory: boolean }; default_lang?: "en" | "ar"; second_lang?: "en" | "ar"; report_value_delimiter?: "|" | "," | " " | "." | "-"; rep_settings?: { rep_start_day_specific_time_frame_start: string; rep_start_day_specific_time_frame_end: string; }; rep_permissions?: { rep_must_start_day_within_specific_time_frame: boolean; }; first_business_day_in_week?: "Sun" | "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat"; allow_assigning_non_creator_teams_when_creating_client?: boolean; enable_email_mfa: boolean; enable_whatsapp_mfa: boolean; enable_authenticator_mfa: boolean; minimum_accepted_mfa: number; end_of_day?: string; time_zone?: string; end_of_day_mode?: "fixed_time" | "shift_based"; automatic_end_day_minutes_after_shift_end?: number; start_day_outside_active_zone_action?: "monitor" | "warning" | "block"; start_visit_outside_active_zone_action?: "monitor" | "warning" | "block"; work_outside_active_zone_action?: "monitor" | "warning" | "block"; no_active_zone_action?: "allow" | "block"; use_accuracy_radius_near_zone_boundary?: boolean; zone_boundary_grace_minutes?: number; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } } export namespace MailUnsubsrcibe { export interface Data { message: string; success?: boolean; } export namespace Get { export type ID = string; export type Result = { message: string }; } export namespace Create { export type Params = { token: string; }; export type Result = { message: string; success: boolean }; } } export namespace ApprovalRequest { export interface Data { _id: StringId; app_code: string; document_id?: StringId; document_type: "client" | "visit" | "client-line"; sync_id: string; method?: "create" | "update" | "delete" | "patch"; visit_id?: string; type: | "skip_job_at_visit_end" | "end_visit_out_of_geofence" | "skip_visit_from_route" | "create_client" | "update_client" | "delete_client" | "update_client_line"; subtype?: | "client_details" | "client_assigned_to" | "client_location" | "client_credit_limit"; implementation_type: "create_doc" | "update_doc" | "delete_doc" | "no_implementation"; creator: AdminOrRepOrTenant; editor?: AdminOrRepOrTenant; status: "pending" | "approved" | "processing" | "rejected"; implementation_status: "pending" | "failed" | "success"; implementation_error?: any; teams?: StringId[]; payload: { body?: { type: | "skip_job_at_visit_end" | "end_visit_out_of_geofence" | "skip_visit_from_route" | "create_client" | "update_client" | "delete_client"; [key: string]: any; } & Client.CreateBody; writeQuery?: { key: string; command: "set" | "addToSet" | "pull"; value: any; }[]; }; meta?: { form?: { _id: StringId; name: string }; business_day?: string; client?: StringId; route?: StringId; original_doc?: ClientLine.Data[]; [ket: string]: any; }; history?: { editor?: AdminOrRepOrTenant; status: "pending" | "approved" | "processing" | "rejected"; diff: { [key: string]: any }; createdAt: Date; updatedAt: Date; }[]; comment?: string; media?: StringId[]; time: number; geoPoint?: GeoPoint; accuracy?: number; serial_number: SerialNumber; disabled: boolean; approved_time?: number; rejected_time?: number; processing_time?: number; pending_time?: number; reference_name?: string; reference_local_name?: string; last_approved_approval_request?: StringId; last_approved_approval_request_serial_number?: SerialNumber; last_approved_approval_request_createdAt?: Date; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedDoc = Data & { cycle?: Cycle.Schema & { approval?: string | Approval.Data }; }; export interface CreateBody { document_id?: StringId; document_type: "client" | "visit" | "client-line"; sync_id: string; method?: "create" | "update" | "delete" | "patch"; visit_id?: string; type: | "skip_job_at_visit_end" | "end_visit_out_of_geofence" | "skip_visit_from_route" | "create_client" | "update_client" | "delete_client" | "update_client_line"; subtype?: | "client_details" | "client_assigned_to" | "client_location" | "client_credit_limit"; implementation_type: "create_doc" | "update_doc" | "delete_doc" | "no_implementation"; creator?: AdminOrRepOrTenant; status?: "pending"; implementation_status?: "pending"; teams?: StringId[]; payload?: { body?: { type: | "skip_job_at_visit_end" | "end_visit_out_of_geofence" | "skip_visit_from_route" | "create_client" | "update_client" | "delete_client"; [key: string]: any; } & Client.CreateBody; writeQuery?: { key: string; command: "set" | "addToSet" | "pull"; value: any; }[]; }; meta?: { form?: { _id: StringId; name: string }; business_day?: string; client?: StringId; route?: StringId; [ket: string]: any; }; history?: { editor?: AdminOrRepOrTenant; status: "pending" | "approved" | "processing" | "rejected"; diff: { [key: string]: any }; createdAt: Date; updatedAt: Date; }[]; comment?: string; media?: StringId[]; time?: number; geoPoint?: GeoPoint; accuracy?: number; serial_number?: SerialNumber; disabled?: boolean; pending_time?: number; reference_name?: string; reference_local_name?: string; last_approved_approval_request?: StringId; last_approved_approval_request_serial_number?: SerialNumber; last_approved_approval_request_createdAt?: Date; company_namespace: string[]; } export interface UpdateBody { _id?: StringId; app_code?: string; document_id?: StringId; document_type?: "client" | "visit" | "client-line"; sync_id?: string; method?: "create" | "update" | "delete" | "patch"; visit_id?: string; type?: | "skip_job_at_visit_end" | "end_visit_out_of_geofence" | "skip_visit_from_route" | "create_client" | "update_client" | "delete_client" | "update_client_line"; subtype?: | "client_details" | "client_assigned_to" | "client_location" | "client_credit_limit"; implementation_type?: "create_doc" | "update_doc" | "delete_doc" | "no_implementation"; creator?: AdminOrRepOrTenant; editor?: AdminOrRepOrTenant; teams?: StringId[]; status: "pending" | "approved" | "processing" | "rejected"; implementation_status?: "pending" | "failed" | "success"; implementation_error?: any; payload?: { body?: { type: | "skip_job_at_visit_end" | "end_visit_out_of_geofence" | "skip_visit_from_route" | "create_client" | "update_client" | "delete_client"; [key: string]: any; } & Client.CreateBody; writeQuery?: { key: string; command: "set" | "addToSet" | "pull"; value: any; }[]; }; meta?: { form?: { _id: StringId; name: string }; business_day?: string; client?: StringId; route?: StringId; [ket: string]: any; }; history?: { editor?: AdminOrRepOrTenant; status: "pending" | "approved" | "processing" | "rejected"; diff: { [key: string]: any }; createdAt: Date; updatedAt: Date; }[]; comment?: string; media?: StringId[]; time?: number; geoPoint?: GeoPoint; accuracy?: number; serial_number?: SerialNumber; disabled?: boolean; approved_time?: number; rejected_time?: number; processing_time?: number; pending_time?: number; reference_name?: string; reference_local_name?: string; last_approved_approval_request?: StringId; last_approved_approval_request_serial_number?: SerialNumber; last_approved_approval_request_createdAt?: Date; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; } type PopulatedKeys = Client.PopulatedKeys | Visit.PopulatedKeys; export namespace Find { export type Params = DefaultPaginationQueryParams & { nodeCycles?: StringId[] | StringId; _id?: StringId[] | StringId; search?: string; // serial_number.formatted serial_number?: string[] | string; "serial_number.formatted"?: string[] | string; sync_id?: string[] | string; creator?: StringId[] | StringId; // creator_type?: Data["creator"]["type"] | Data["creator"]["type"][]; "creator._id"?: StringId[] | StringId; "creator.type"?: string | string[]; type?: Data["type"][] | Data["type"]; subtype?: Data["subtype"][] | Data["subtype"]; document_type?: Data["document_type"][] | Data["document_type"]; document_id?: StringId | StringId[]; implementation_type?: Data["implementation_type"][] | Data["implementation_type"]; implementation_status?: Data["implementation_status"][] | Data["implementation_status"]; teams?: StringId[] | StringId; status?: Data["status"][] | Data["status"]; from_time?: number; to_time?: number; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; visit_id?: string | string[]; "meta.client": StringId | StringId[]; "meta.route": StringId | StringId[]; "meta.business_day": string | string[]; "meta.form._id": StringId | StringId[]; sortBy?: { field: "_id"; type: "asc" | "desc" }[]; withCycle?: boolean; populatedKeys?: ["approval"]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = StringId; export type Params = { withCycle?: boolean; validityCheck?: boolean; originalDoc_populatedKeys?: PopulatedKeys[]; withOriginalDoc?: boolean; populatedKeys?: ["approval"]; [key: string]: any; // integration_meta. }; export type Result = Data & { cycle?: Cycle.Schema & { approval?: string | Approval.Data }; original_doc?: Client.ClientSchema | Visit.VisitSchema; }; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace SafeInvoiceSerialCounter { export interface UpdateBody { counter: number; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Settings.Data; } } export namespace ClientLocation { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; local_name?: string; client: StringId; description?: string; address?: string; contacts?: StringId[]; disabled: boolean; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[]; cover_photo?: StringId; integration_meta?: { [key: string]: any }; company_namespace: string[]; geoPoint?: GeoPoint; createdAt: string; updatedAt: string; } export interface CreateBody { creator?: AdminOrRep; name: string; local_name?: string; client: StringId; description?: string; address?: string; contacts?: StringId[]; disabled: boolean; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[]; cover_photo?: StringId; integration_meta?: { [key: string]: any }; geoPoint?: GeoPoint; } export interface UpdateBody { editor?: AdminOrRep; name?: string; local_name?: string; client?: StringId; description?: string; address?: string; contacts?: StringId[]; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[]; cover_photo?: StringId; integration_meta?: { [key: string]: any }; geoPoint?: GeoPoint; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; local_name?: string; name: string; client: | StringId | (Pick< Client.ClientSchema, "name" | "client_code" | "contacts" | "_id" > & { contacts: StringId[] | Pick[]; }); description?: string; address?: string; contacts?: StringId[] | ClientContact.ClientContactSchema[]; disabled: boolean; customFields?: { [key: string]: string | number | boolean | StringId }; media?: StringId[] | PopulatedMediaStorage[]; cover_photo?: StringId | PopulatedMediaStorage; integration_meta?: { [key: string]: any }; company_namespace: string[]; geoPoint?: GeoPoint; createdAt: string; updatedAt: string; } type PopulatedKeys = "client" | "contacts" | "media" | "cover_photo" | "customFields"; export namespace Find { export type Params = DefaultPaginationQueryParams & { name?: string | string[]; client?: StringId | StringId[]; _id?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; search?: string; sortBy?: { field: "name" | "client"; type: "asc" | "desc"; }[]; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; }; export type Result = Data & PopulatedDoc; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace WorkorderPortalLink { export interface Data { _id: StringId; name?: string; group_code?: string; description?: string; workorder_portal?: StringId; assets?: StringId[]; asset_units?: StringId[]; client?: StringId; client_location?: StringId; creator: AdminOrRepOrTenant; editor?: AdminOrRepOrTenant; teams?: StringId[]; disabled: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { name?: string; group_code?: string; description?: string; workorder_portal?: StringId; assets?: StringId[]; asset_units?: StringId[]; client?: StringId; client_location?: StringId; creator: AdminOrRepOrTenant; teams?: StringId[]; disabled?: boolean; } export interface PatchBody { count: number; name?: string; group_code?: string; company_namespace: string[]; } export interface UpdateBody { name?: string; group_code?: string; description?: string; workorder_portal?: StringId; assets?: StringId[]; asset_units?: StringId[]; client?: StringId; client_location?: StringId; editor?: AdminOrRepOrTenant; teams?: StringId[]; disabled?: boolean; } export interface PopulatedDoc { _id: StringId; name?: string; group_code?: string; description?: string; workorder_portal?: StringId; workorder_portal_populated?: WorkorderPortal.PopulatedDoc; assets?: StringId[]; assets_populated?: Asset.Data[]; asset_units?: StringId[]; asset_units_populated?: AssetUnit.Data[]; client?: StringId; client_populated?: Client.ClientSchema; client_location?: ClientLocation.Data; client_location_populated?: ClientLocation.Data; creator: AdminOrRepOrTenant; editor?: AdminOrRepOrTenant; teams?: Team.TeamSchema[]; teams_populated?: Team.TeamSchema[]; disabled: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; } type PopulatedKeys = | "workorder_portal" | "assets" | "asset_units" | "client" | "client_location" | "teams"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; group_code?: string | string[]; workorder_portal?: StringId | StringId[]; assets?: StringId | StringId[]; asset_units?: StringId | StringId[]; client?: StringId | StringId[]; client_location?: StringId | StringId[]; teams?: StringId | StringId[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; search?: string; from__id?: StringId; to__id?: StringId; sortBy?: { field: "link_id" | "createdAt" | "updatedAt" | "_id"; type: "asc" | "desc"; }[]; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; }; export type Result = Data & PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type ID = StringId; export type Body = PatchBody; export type Result = Data[]; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace AssetType { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; color: string; local_name?: string; disabled: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { creator?: AdminOrRep; name: string; local_name?: string; color: string; disabled?: boolean; integration_meta?: { [key: string]: any }; } export interface UpdateBody { editor?: AdminOrRep; name?: string; local_name?: string; color?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; search?: string; name?: string | string[]; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; sortBy?: { field: "color" | "name" | "_id"; type: "asc" | "desc" }[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace Asset { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; local_name?: string; description?: string; barcode?: string; model?: string; manufacturer?: string; year?: string; asset_types: StringId[]; location: StringId; customFields?: { [key: string]: string | number | boolean | StringId }; disabled: boolean; integration_meta?: { [key: string]: any }; media?: StringId[]; cover_photo?: StringId; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { creator?: AdminOrRep; name: string; local_name?: string; description?: string; barcode?: string; model?: string; manufacturer?: string; year?: string; asset_types: StringId[]; location: StringId; customFields?: { [key: string]: string | number | boolean | StringId }; disabled?: boolean; media?: StringId[]; cover_photo?: StringId; integration_meta?: { [key: string]: any }; } export interface UpdateBody { editor?: AdminOrRep; name?: string; local_name?: string; description?: string; barcode?: string; model?: string; manufacturer?: string; year?: string; asset_types?: StringId[]; location?: StringId; customFields?: { [key: string]: string | number | boolean | StringId }; disabled?: boolean; media?: StringId[]; cover_photo?: StringId; integration_meta?: { [key: string]: any }; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; local_name?: string; description?: string; barcode?: string; model?: string; manufacturer?: string; year?: string; asset_types: StringId[] | AssetType.Data[]; location: | StringId | ClientLocation.Data | (ClientLocation.Data & { client?: Pick< Client.ClientSchema, "name" | "_id" | "client_code" | "local_name" >; }); media?: StringId[] | PopulatedMediaStorage[]; cover_photo?: StringId | PopulatedMediaStorage; customFields?: { [key: string]: string | number | boolean | StringId }; disabled: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; } type PopulatedKeys = | "asset_types" | "location" | "media" | "cover_photo" | "locationClient" | "customFields"; export namespace Find { export type Params = DefaultPaginationQueryParams & { name?: string | string[]; _id?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; asset_types?: StringId | StringId[]; location?: StringId | StringId[]; from_createdAt?: number; to_createdAt?: number; search?: string; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; sortBy?: { field: "barcode" | "name" | "model" | "_id"; type: "asc" | "desc"; }[]; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; }; export type Result = Data & PopulatedDoc; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace AssetUnit { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; asset: StringId; location?: StringId; local_name?: string; description?: string; serial_nu?: string; customFields?: { [key: string]: string | number | boolean | StringId }; disabled: boolean; integration_meta?: { [key: string]: any }; media?: StringId[]; cover_photo?: StringId; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { creator?: AdminOrRep; name: string; asset: StringId; location?: StringId; local_name?: string; description?: string; serial_nu?: string; customFields?: { [key: string]: string | number | boolean | StringId }; integration_meta?: { [key: string]: any }; media?: StringId[]; cover_photo?: StringId; } export interface UpdateBody { editor?: AdminOrRep; name?: string; asset?: StringId; location?: StringId; local_name?: string; description?: string; serial_nu?: string; customFields?: { [key: string]: string | number | boolean | StringId }; integration_meta?: { [key: string]: any }; media?: StringId[] | string[]; cover_photo?: StringId; } type assetPopulated = | StringId | Asset.Data | (Asset.Data & { location?: ClientLocation.Data }) | (Asset.Data & { location?: | ClientLocation.Data | (ClientLocation.Data & { client: Pick< Client.ClientSchema, "name" | "client_code" | "_id" >; }); }); type locationPopulated = | StringId | ClientLocation.Data | (ClientLocation.Data & { client: Pick; }); export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; asset: assetPopulated; location?: locationPopulated; local_name?: string; description?: string; serial_nu?: string; customFields?: { [key: string]: string | number | boolean | StringId }; disabled: boolean; integration_meta?: { [key: string]: any }; media?: StringId[] | PopulatedMediaStorage[]; cover_photo?: StringId | PopulatedMediaStorage; company_namespace: string[]; createdAt: string; updatedAt: string; } type PopulatedKeys = | "asset" | "location" | "locationClient" | "assetLocation" | "assetLocationClient" | "media" | "cover_photo" | "customFields"; export namespace Find { export type Params = DefaultPaginationQueryParams & { name?: string | string[]; _id?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; asset?: StringId | StringId[]; location?: StringId | StringId[]; from_createdAt?: number; to_createdAt?: number; search?: string; sortBy?: { field: "asset" | "name" | "_id"; type: "asc" | "desc" }[]; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; }; export type Result = Data & PopulatedDoc; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace WorkorderCategory { export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; name: string; local_name?: string; description?: string; disabled: boolean; integration_meta?: { [key: string]: any }; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { creator?: AdminOrRep; name: string; local_name?: string; description?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; creator?: AdminOrRep; editor?: AdminOrRep; name?: string; local_name?: string; description?: string; disabled?: boolean; integration_meta?: { [key: string]: any }; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { name?: string | string[]; _id?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; search?: string; sortBy?: { field: "_id" | "name"; type: "asc" | "desc" }[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Params = {}; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace Contract { export type ContractStatus = "open" | "closed" | "canceled"; export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; title?: string; serial_number: SerialNumber; external_serial_number?: string; start_time: number; end_time: number; amount?: number; client: StringId; status?: ContractStatus; disabled: boolean; locations?: { _id: StringId; assets?: StringId[]; asset_units?: StringId[]; }[]; media?: StringId[]; renewed_from?: StringId; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { sync_id: string; creator?: AdminOrRep; title?: string; serial_number?: SerialNumber; external_serial_number?: string; start_time: number; end_time: number; amount?: number; client: StringId; status?: ContractStatus; disabled?: boolean; locations?: { _id: StringId; assets?: StringId[]; asset_units?: StringId[]; }[]; media?: StringId[]; renewed_from?: StringId; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; creator?: AdminOrRep; editor?: AdminOrRep; sync_id?: string; title?: string; serial_number?: SerialNumber; external_serial_number?: string; start_time?: number; end_time?: number; amount?: number; client?: StringId; status?: ContractStatus; disabled?: boolean; locations?: { _id: StringId; assets?: StringId[]; asset_units?: StringId[]; }[]; media?: StringId[]; renewed_from?: StringId; company_namespace?: string[]; createdAt?: string; updatedAt?: string; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; title?: string; serial_number: SerialNumber; external_serial_number?: string; start_time: number; end_time: number; amount?: number; client: StringId; client_populated?: Pick< Client.ClientSchema, "name" | "client_code" | "_id" | "local_name" >; status?: ContractStatus; disabled: boolean; locations?: { _id: StringId | Pick; assets?: StringId[] | Pick[]; asset_units?: StringId[] | Pick[]; }[]; media?: StringId[]; media_populated?: PopulatedMediaStorage[]; renewed_from?: StringId; renewed_from_populated?: Data; company_namespace: string[]; createdAt: string; updatedAt: string; } type PopulatedKeys = | "locations.asset_units" | "locations.assets" | "locations._id" | "client" | "media" | "renewed_from"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; search?: string; // "serial_number.formatted" sortBy?: { field: "_id"; type: "asc" | "desc" }[]; status?: ContractStatus | ContractStatus[]; client?: StringId | StringId[]; from_start_time?: number; to_start_time?: number; from_end_time?: number; to_end_time?: number; from_amount?: number; to_amount?: number; renewed_from?: StringId | StringId[]; populatedKeys?: PopulatedKeys[]; expired?: boolean; near_expiry?: boolean; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = Data & PopulatedDoc; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace ContractInstallment { export type ContractInstallmentStatus = "paid" | "unpaid"; export interface Data { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; media?: StringId[]; serial_number: SerialNumber; external_serial_number?: string; due_time: number; pay_time?: number; amount?: number; contract: StringId; status: ContractInstallmentStatus; disabled: boolean; is_renewed?: boolean; bulk_uuid?: string; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { sync_id: string; creator?: AdminOrRep; serial_number?: SerialNumber; external_serial_number?: string; due_time: number; pay_time?: number; amount?: number; contract: StringId; status?: ContractInstallmentStatus; disabled?: boolean; is_renewed?: boolean; bulk_uuid?: string; media?: StringId[]; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; creator?: AdminOrRep; editor?: AdminOrRep; sync_id?: string; media?: StringId[]; serial_number?: SerialNumber; external_serial_number?: string; due_time?: number; pay_time?: number; amount?: number; contract?: StringId; status?: ContractInstallmentStatus; disabled?: boolean; is_renewed?: boolean; bulk_uuid?: string; company_namespace?: string[]; createdAt?: string; updatedAt?: string; } export interface PopulatedDoc { _id: StringId; creator: AdminOrRep; editor?: AdminOrRep; sync_id: string; media?: StringId[]; serial_number: SerialNumber; external_serial_number?: string; due_time: number; pay_time?: number; amount?: number; contract: StringId; status: ContractInstallmentStatus; disabled: boolean; is_renewed?: boolean; bulk_uuid?: string; company_namespace: string[]; createdAt: string; updatedAt: string; media_populated?: PopulatedMediaStorage[]; contract_populated?: Pick; } type PopulatedKeys = "contract" | "media"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; search?: string; // "serial_number.formatted" sortBy?: { field: "_id"; type: "asc" | "desc" }[]; status?: ContractInstallmentStatus | ContractInstallmentStatus[]; contract?: StringId | StringId[]; from_due_time?: number; to_due_time?: number; due_time?: number; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: Data[] & PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = Data & PopulatedDoc; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace CustomField { export type CustomFieldType = | "date" | "string" | "photo" | "number" | "phone" | "email" | "url" | "long_text" | "custom_list" | "media"; export type CustomFieldModule = | "clients" | "asset" | "asset-unit" | "client-location" | "workorder-request" | "rep" | "asset-part"; export interface Data { _id: StringId; editor: Admin; name: string; local_name?: string; module: CustomFieldModule; key: string; type: CustomFieldType; custom_list?: StringId; disabled: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { editor?: Admin; name: string; local_name?: string; module: CustomFieldModule; key?: string; type: CustomFieldType; custom_list?: StringId; disabled?: boolean; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; editor?: Admin; name?: string; local_name?: string; module?: CustomFieldModule; key?: string; type?: CustomFieldType; custom_list?: StringId; disabled?: boolean; company_namespace?: string[]; createdAt?: string; updatedAt?: string; } export type PopulatedDoc = Data & { custom_list_populated?: CustomList.CustomListSchema & { sources?: { source_id: StringId; source_name: string; company_namespace: string[]; photo?: string; source_local_name?: string; thumbnail?: string; position?: number; sku?: string; barcode?: string; sv_measureUnit?: string; groups?: string[]; }[]; }; }; type PopulatedKeys = "custom_list"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; search?: string; name?: string | string[]; module?: CustomFieldModule | CustomFieldModule[]; type?: CustomFieldType | CustomFieldType[]; disabled?: boolean; populatedKeys?: PopulatedKeys[]; with_custom_list_sources?: boolean; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export interface Params { populatedKeys?: PopulatedKeys[]; with_custom_list_sources?: boolean; } export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace ActivityPhoto { export interface Data { _id: string; photo?: string; media: string[]; caption?: string; photo_meta: { device_orientation?: 1 | 2 | 3 | 4; height?: 1 | 2 | 3 | 4; width?: 1 | 2 | 3 | 4; }; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; createdAt: string; updatedAt: string; } } export namespace ActivityNote { export interface Data { _id: string; content: string; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; createdAt: string; updatedAt: string; } } export namespace ActivityTask { export interface Data { _id: string; start_photo?: string; end_photo?: string; start_media?: string[]; end_media?: string[]; caption?: string; start_photo_meta?: { device_orientation?: 1 | 2 | 3 | 4; height?: 1 | 2 | 3 | 4; width?: 1 | 2 | 3 | 4; }; end_photo_meta?: { device_orientation?: 1 | 2 | 3 | 4; height?: 1 | 2 | 3 | 4; width?: 1 | 2 | 3 | 4; }; start_time: number; end_time: number; total_time?: string; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; createdAt: string; updatedAt: string; } } export namespace ActivityAudit { export interface Inventory { store_qun?: number; shelf_qun?: number; shelf_price?: number; exp_date: number; photo?: string; media?: string[]; caption?: string; photo_meta?: { device_orientation?: 1 | 2 | 3 | 4; height?: 1 | 2 | 3 | 4; width?: 1 | 2 | 3 | 4; }; note?: string; } export interface AuditItem { product_name: string; product_id: string; product_sub_category?: string; product_category?: string; productCategory?: string; productSubCategory?: string[]; product_sku?: string; product_barcode?: string; audit_time: number; inventories: Inventory[]; note?: string; } export interface Data { _id: string; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; audits: AuditItem[]; createdAt: string; updatedAt: string; } } export namespace ActivityAvailability { export interface Data { _id: string; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; msl_id: string; products_available: { product_id: string; available: boolean; }[]; photos?: string[]; media?: StringId[]; createdAt: string; updatedAt: string; } } export namespace ActivityCheckoutDisplay { export interface Data { _id: string; msl_id: string; checkout_count: number; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; createdAt: string; updatedAt: string; } } export namespace ActivityFeedback { export interface Data { _id: string; visit_id: string; visit_UUID: string; feed_back_option: string; route?: string; teams?: string[]; company_namespace: string[]; createdAt: string; updatedAt: string; } } export namespace ActivityFormResult { export interface Data { _id: string; serial_number?: SerialNumber; form_id: string; results: { [key: string]: any }; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; workorder?: string; asset?: string; asset_unit?: string; createdAt: string; updatedAt: string; } } export namespace AvailableField { export interface Data { patch_filter_key: string; patch_filter_slug: | "activity-storecheck" | "client" | "variant" | "product" | "product-group" | "product-brand" | "product-category" | "product-sub-category" | "measureunits" | "rep" | "tag" | "client-channel" | "paymentterms" | "speciality" | "activity-form-v2-result" | "bi-bucket"; code: string; // unique key formula_key?: string; field_type: | "activity_attribute" | "source_attribute" | "template_field" | "calculated_field"; data_type: | "Separator" | "timestamp" | "String" | "Number" | "Boolean" | "Date" | "Image" | "coords" | "Text" | "Media" | "Heading" | "List" | "Phone" | "Email" | "Signature" | "DateTime" | "YesNo" | "ProductBarcodeScan" | "BarcodeScan" | "GeoPoint"; key: string; field_id?: string; isArray: boolean; array_delimiter?: string; label: string; manipulator_function?: string; lookup?: { from: string; select: string; unwind: boolean; filter?: { as: string; cond: any; }; }; granularity?: Granularity; current_granularity?: Granularity; } } export namespace ActivityItemStatus { export type ItemStatus = | "current_user" | "non_user" | "generic_user" | "competitor_user" | "other"; export interface Item { product: string; product_name: string; status: ItemStatus; item_status_type?: string; feedback?: string; note?: string; feedback_current_user?: number; previous_status?: ItemStatus; previous_status_id?: string; previous_user?: string; previous_user_name?: string; previous_time?: number; } export interface Data { _id: string; items: Item[]; geoPoint: GeoPoint; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job?: boolean; job_id?: string; job_category_id?: string; job_start_time?: number; job_end_time?: number; job_duration?: number; disabled?: boolean; createdAt: string; updatedAt: string; } export interface CreateBody { items: Item[]; geoPoint: GeoPoint; time: number; tags?: string[]; visit_id: string; user: string; client: string; client_name: string; user_name: string; sync_id: string; route?: string; teams?: string[]; company_namespace: string[]; } export interface UpdateBody { _id?: string; items?: Item[]; geoPoint?: GeoPoint; time?: number; tags?: string[]; visit_id?: string; user?: string; client?: string; client_name?: string; user_name?: string; sync_id?: string; route?: string; teams?: string[]; company_namespace?: string[]; } export type PopulatedKeys = "teams" | "user" | "client" | "route" | "visit_id"; export type ActivityItemStatusWithPopulatedKeysSchema = Data & { teams_populated?: Team.TeamSchema[] | string[]; user_populated?: Rep.RepSchema | string; client_populated?: Client.ClientSchema | string; route_populated?: Route.RouteSchema | string; visit_id_populated?: Visit.VisitSchema | string; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string[] | string; disabled?: boolean; from_updatedAt?: string; from_time?: number; to_time?: number; client?: string; user?: string; teams?: string[]; route?: string; populatedKeys?: PopulatedKeys[]; from__id?: string; to__id?: string; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; [key: string]: any; }; export interface Result extends DefaultPaginationResult { data: ActivityItemStatusWithPopulatedKeysSchema[]; } } export namespace Get { export type ID = string; export interface Params {} export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } } export namespace ItemStatusType { export interface Data { _id: StringId; name: string; local_name?: string; is_default: boolean; disabled: boolean; company_namespace: string[]; creator: AdminCreator; editor?: AdminCreator; createdAt: Date; updatedAt: Date; __v?: number; } export interface CreateBody { name: string; local_name?: string; is_default?: boolean; } export interface UpdateBody { name?: string; local_name?: string; is_default?: boolean; disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; disabled?: boolean; is_default?: boolean; sortBy?: { field: "_id"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace ActivityPlanogram { export interface Data { _id: string; msl_id: string; media?: string[]; actual_planogram_imgs?: string[]; does_planogram_comply: boolean; planogram_reason?: string; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; createdAt: string; updatedAt: string; } } export namespace ActivitySecondaryDisplay { export interface Data { _id: string; secondary_count: number; msl_id: string; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; createdAt: string; updatedAt: string; } } export namespace ActivityShelfshare { export interface Data { _id: string; msl_length: number; total_msl_length: number; msl_id: string; geo_tag: GeoTag; time: number; tags?: string[]; visit_id: string; user: string; client: string; visit?: string; client_name: string; user_name: string; sync_id: string; route?: string; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; teams?: string[]; reviewed_by: ActivityReview[]; network_state?: number; admin_notes: ActivityAdminNote[]; comments: ActivityComment[]; company_namespace: string[]; job_start_time?: number; job_end_time?: number; job_duration?: number; createdAt: string; updatedAt: string; } } // export namespace ActivityStorecheck { // export type FieldType = // | "Text" // | "String" // | "Date" // | "Image" // | "Boolean" // | "Number" // | "List" // | "Separator" // | "Heading" // | "Media"; // export type Source = // | "product" // | "variant" // | "product-category" // | "product-sub-category" // | "product-brand" // | "product-group"; // export interface GeoTag { // lat?: number; // lng?: number; // formatted_address?: string; // } // export interface GeoPoint { // type: "Point"; // coordinates: [number, number]; // } // interface Result { // source_id: string; // source_name: string; // divisions: Division[]; // } // export interface Entry { // entry_id: string; // source: Source; // results: Result[]; // } // interface Division { // fields: Field[]; // } // interface Field { // _id?: string; // name: string; // type: FieldType; // isArray: boolean; // isRequired?: boolean; // is_calculated_field?: boolean; // formula_key?: string; // parent_field?: string; // custom_list?: string | CustomList.Data | StringId; // field_id: string | StringId; // result: any[]; // result_custom_list_ids?: any[]; // calculation_status?: "success" | "failed"; // calculation_error?: string | any[]; // company_namespace?: string[]; // } // export interface Data { // _id: string; // company_namespace: string[]; // client: string; // client_name: string; // sync_id: string; // time_zone: string; // template_id: string; // visit?: string; // visit_id?: string; // battery_level?: number; // user: string; // user_name: string; // time: number; // geo_tag?: GeoTag; // geoPoint: GeoPoint; // teams?: string[]; // route?: string; // tags?: string[]; // entries: Entry[]; // platform?: string; // version_name?: string; // device_brand?: string; // device_os?: string; // device_os_version?: string; // device_model?: string; // identifier?: number; // device_id?: string; // device_unique_id?: string; // network_state?: number; // serial_number?: SerialNumber; // job_start_time?: number; // job_end_time?: number; // job_duration?: number; // createdAt: Date; // updatedAt: Date; // } // } export namespace Reminder { export interface Data { _id: string; name: string; creator: AdminOrRep; from: number; to: number; visibility: "reps" | "teams" | "public"; clients: string[]; reps: string[]; teams: string[]; content: string; disabled: boolean; photo?: string; cover_photo?: string; sync_id: string; company_namespace: string[]; createdAt: Date; updatedAt: Date; } } export namespace Permission { export interface Data { _id: string; disabled: boolean; path: EndPoints; name: string; scope: "repzoCare" | "repzoSystem" | "customer"; code: number; admin: { m_find: boolean; m_get: boolean; m_create: boolean; m_update: boolean; m_remove: boolean; }; rep: { m_find: boolean; m_get: boolean; m_create: boolean; m_update: boolean; m_remove: boolean; }; client: { m_find: boolean; m_get: boolean; m_create: boolean; m_update: boolean; m_remove: boolean; }; guest: { m_find: boolean; m_get: boolean; m_create: boolean; m_update: boolean; m_remove: boolean; }; tenant: { m_find: boolean; m_get: boolean; m_create: boolean; m_update: boolean; m_remove: boolean; }; group: | "Basic" | "Froms" | "Schedule" | "Pre Sales" | "Sales" | "Live Location" | "Omni" | "Bulk" | "Audit trail" | "System" | "Media" | "Store Check"; teams_shared: "shared" | "unshared" | "optional"; server: "sv" | "sso" | "report"; createdAt: Date; updatedAt: Date; } } export namespace Module { export type PermissionGroup = | "Basic" | "Froms" | "Schedule" | "Pre Sales" | "Sales" | "Live Location" | "Omni" | "Bulk" | "Audit trail" | "System" | "Media" | "Store Check" | "Client Dashboard" | "Virtual Admin" | "Customer Care" | "Marketplace" | "E-Tax"; export interface Data { _id: string; name: string; services: (string | Permission.Data)[]; defaultState: boolean; permission_groups: PermissionGroup[]; createdAt: Date; updatedAt: Date; } } export namespace CompanyNamespace { export type CompanyStatus = "trial" | "subscription"; export type CompanyIndustry = "fmcg" | "pharma" | "service" | "omni"; export interface Data { _id: string; company_name: string; legal_name: string; name_space: string; active_account: boolean; guest_mode: boolean; disabled?: boolean; logo?: string; created_by: Admin; address?: string; company_owner?: string; phone?: string; country: string; country_code: string; status: CompanyStatus; total_seats_sold: number; organization_name?: string; smsSenderID?: string; company_group: string; time_zone: string; integration_priority_index: number; banks_list: string; modules: { module: string | Module.Data; active: boolean; }[]; excluded_modules: string[]; industry: CompanyIndustry; end_of_day: string; trial_ends_at: number; subscription_status?: "trial" | "initiated" | "active" | "grace" | "limited" | "blocked"; grace_until: number | null; limited_until: number | null; workspace: string; default_business_app: string; allowed_business_apps: string[]; is_sandbox: boolean; parent_namespace?: string; grace_duration_days: number; limited_duration_days: number; billing_email: string; maxio_customer_id?: string; maxio_saving_plan_id?: string | null; maxio_standard_plan_id?: string | null; saving_plan_id?: string | null; standard_plan_id?: string | null; business_add_on_ids?: string[] | null; subscription_type?: "company-namespace" | "company-group"; min_billing_reps: number; min_billing_admins: number; min_billing_users: number; max_billing_reps: number; max_billing_admins: number; max_billing_users: number; allow_treating_invoice_as_proforma_for_etax?: boolean; createdAt: Date; updatedAt: Date; } } export namespace AuthenticateAdmin { export type MfaMethod = "email" | "whatsapp" | "authenticator" | "recovery_codes"; interface Subscription_data { name_space: string; grace_until: number; subscription_status: CompanyNamespace.Data["subscription_status"]; } interface LoginResponse { access_token: string; refresh_token: string; login_status: "success"; name: string; teams: string[]; photo?: string; permissions: UserPermissions; admin: string; owner: boolean; country: string; status: CompanyNamespace.Data["status"]; industry: CompanyNamespace.Data["industry"]; time_zone: string; is_test: boolean; strong_password: boolean; exp: number; // timestamp modules: string[]; app_code: string; country_code: string[]; COMPANYGROUPS: { [key: string]: any }; // Company_group, subscription_data: Subscription_data[]; suspended: boolean; nameSpace: string[]; assessment_enforcement_state: "suggest" | "enforce" | "ignore"; repzo_internal_user: boolean; allow_treating_invoice_as_proforma_for_etax: boolean; mfa_method?: MFA_Method; settings_mfa: { enable_email_mfa: boolean; enable_whatsapp_mfa: boolean; enable_authenticator_mfa: boolean; minimum_accepted_mfa: number; can_skip: boolean; suggest_mfa: MFA_Method[]; }; admin_mfa: Pick< Admin.Data, | "email_mfa_enabled" | "whatsapp_mfa_enabled" | "authenticator_mfa_enabled" | "recovery_codes_mfa_enabled" >; } interface MFAPendingResponse { login_status: "pending"; mfa_token: string; mfa_methods: ( | { method: "email"; masked_email: string; blocked_until: number | null; } | { method: "whatsapp"; masked_phone: string; blocked_until: number | null; } | { method: "authenticator"; blocked_until: number | null } | { method: "recovery_codes"; blocked_until: number | null } )[]; } export type Data = LoginResponse | MFAPendingResponse; } export namespace AuthenticateRep { export interface Data { access_token: string; refresh_token: string; login_status: "success"; teams: string[]; permissions: Rep.Data["permissions"]; rep: string; identifier: number; exp: number; // timestamp modules: string[]; realm_token: string; app_code: string; country: string; country_code: string[]; is_test: boolean; suspended: boolean; nameSpace: string[]; allow_treating_invoice_as_proforma_for_etax: boolean; } } export namespace Authenticate { export type Data = AuthenticateAdmin.Data | AuthenticateRep.Data; } // export namespace AppsManagement { // export interface Data { // _id: StringId; // name: string; // minimum_build_number?: { platform: string; value: number }[]; // expiring_build_number?: { // platform: string; // value: number; // expires_on: number; // is_severe: boolean; // }[]; // days_since_latest_assessment_to_enforce: number; // days_since_latest_assessment_to_suggest: number; // test_company_namespaces?: string[]; // createdAt: Date; // updatedAt: Date; // } // export interface CreateBody { // name: string; // minimum_build_number?: { platform: string; value: number }[]; // expiring_build_number?: { // platform: string; // value: number; // expires_on: number; // is_severe: boolean; // }[]; // days_since_latest_assessment_to_enforce: number; // days_since_latest_assessment_to_suggest: number; // test_company_namespaces?: string[]; // } // export interface UpdateBody { // _id?: StringId; // name?: string; // minimum_build_number?: { platform: string; value: number }[]; // expiring_build_number?: { // platform: string; // value: number; // expires_on: number; // is_severe: boolean; // }[]; // days_since_latest_assessment_to_enforce?: number; // days_since_latest_assessment_to_suggest?: number; // test_company_namespaces?: string[]; // createdAt?: Date; // updatedAt?: Date; // } // export namespace Find { // export type Params = DefaultPaginationQueryParams & { // _id?: StringId[] | StringId; // search?: string; // name?: string[] | string; // test_company_namespaces?: string[] | string; // }; // export interface Result extends DefaultPaginationResult { // data: Data[]; // } // } // export namespace Get { // export type ID = string; // export type Params = { [key: string]: any }; // export type Result = Data; // } // export namespace Create { // export type Body = CreateBody; // export type Result = Data; // } // export namespace Update { // export type ID = string; // export type Body = UpdateBody; // export type Result = Data; // } // } export namespace ResetCompanyNamespace { export type Services = // | "admin" | "rep" | "client" | "product" | "teams" | "tag" | "warehouse" | "msl" | "msl_product" | "job_category" | "role" | "user_role" | "availability_msl" | "media" | "reminder" | "approval" | "custom_field" | "custom_status" | "return_reason" | "feedback_option" | "promotion" | "route" | "address" | "payment_term" | "speciality" | "client_channel" | "client_contact" | "client_location" | "client_status" | "tax" | "measureunits" | "measureunit_family" | "variant" | "brand" | "product_group" | "product_category" | "product_subcategory" | "product_modifier_group" | "product_modifier" | "price_list" | "price_list_item" | "asset" | "asset_unit" | "asset_type" | "workorder_category" | "workorder_request" | "workorder" | "workorder_alarm" | "comments_thread" | "thumbnail_storage" | "media_storage" | "form" | "banner" | "payment_method" | "shipping_zone" | "shipping_method" | "active_client" | "transaction" | "ledger_payment" | "ledger_goods" | "transfer" | "payment" | "refund" | "receiving_material" | "full_invoice" | "cart" | "cart_history" | "proforma" | "settlement" | "adjust_account" | "adjust_inventory" | "cycle" | "check" | "failed_linking_txn" | "failed_adjust_account" | "failed_adjust_inventory" | "failed_cart" | "failed_emails" | "failed_invoices" | "failed_payments" | "failed_proforma_invoices" | "failed_receiving_material" | "failed_refund" | "failed_settlement" | "failed_transfer" | "failed_transaction" | "failed_set_txn_alarm" | "target_group" | "target_rule" | "target_result" | "target_result_history" | "widget_dashboard" | "widget" | "line" | "classification_line" | "line_target" | "client_line" | "day" | "visit" | "activity_audit" | "activity_availability" | "activity_checkout_display" | "activity_feedback" | "activity_form_result" | "activity_note" | "activity_photo" | "activity_planogram" | "activity_secondary_display" | "activity_shelfshare" | "activity_task" | "item_status" | "item_status_type" | "job_result" | "click" | "events_log" | "activity_storecheck" | "custom_list" | "custom_list_item" | "storecheck_template" | "preset" | "retail_execution_previous_result" | "retail_execution_report_view" | "calendar" | "plan" | "integration_app" | "integration_action_log" | "integration_command_log" | "integration_trigger" | "scheduled_email" | "territory" | "territory_level" | "territory_template" | "notifications_center" | "bulk_import" | "email_history" | "big_report" | "history" | "bulk_export" | "generate_rule" | "workorder_portal" | "workorder_portal_link" | "print_workorder_portal_link" | "print_workorder_portal_link_options" | "quick_convert_to_pdf" | "variant_batch" | "form_v2" | "activity_form_v2" | "unSynced_log" | "aiApiHistory" | "bulk_convert_proforma" | "approval_request" | "workflow" | "workflow_version" | "workflow_execution" | "ocr_invoice_job" | "ocr_invoice_job_template" | "ocr_invoice_job_page" | "inventory_adjustment_reason" | "supplier" | "product_audit_trace" | "contract" | "contract_installment" | "old_activity_form_v2" | "old_activity_storecheck" | "bi_view" | "bi_bucket" | "old_bi_bucket" | "bi_view_buckets_total" | "bi_view_instance" | "bi_view_version" | "blank_photo_rep" | "failed_bi_bucket_log" | "failed_consume_bi_alarm" | "failed_set_bi_alarm" | "oauth2_tokens" | "report_ubl_invoice" | "client_ubl_info" | "invoice_alert" | "login_device" | "asset_part_type" | "asset_part" | "asset_part_unit" | "asset_part_transaction" | "asset_part_receival" | "asset_part_transfer" | "return_asset_part_unit" | "store_asset_part_unit" | "activity_ai_sales_order" | "ocr_invoice_job_group" // | "ai_api_limits" // | "ai_api_history" // | "ai_history" | "ubl_health_check" | "ubl_integration" | "ubl_connection_attempts" | "ai_object_detection_dataset" | "ai_object_detection_label" | "ai_object_detection_task" | "ai_object_detection_model" | "ai_object_detection_model_version" | "promotions_group" | "module_custom_validator" | "report_view" | "report_view_favorite" | "report_view_favorite" | "report_view_default" | "clm_presentation" | "clm_sequence" | "clm_slide" | "clm_feedback_activity" | "data_file_warehouse" | "data_session" | "ai_chat_session" | "ai_chat_message"; type ServiceOptionMap = { [key in Services]: { checked: boolean; prevent_delete_without?: Services[]; }; }; type Status = | "initiated" | "building_report_in_progress" | "building_report_completed" | "building_report_failed" | "reset_in_progress" | "reset_success" | "reset_failed"; interface Detail { timestamp: number; content: string; meta?: any; } type Action = { service: Services; model: RepzoModel; method: "delete" | "update"; update_command?: any; query?: any; estimated_count: number; }; export interface CreateBody { creator?: Admin; nameSpace: string; // company_namespace: string[]; services: ServiceOptionMap; is_test_reset?: boolean; } export interface Data { _id: StringId; creator: Admin; executor?: Admin; company_namespace: string[]; services: ServiceOptionMap; actions: Action[]; message: string; status: Status; clients?: string[]; reps?: string[]; to?: number; is_test_reset?: boolean; createdAt: Date; updatedAt: Date; expired?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId[] | StringId; search?: string; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; creator?: StringId[] | StringId; "creator._id"?: StringId[] | StringId; executor?: StringId[] | StringId; "executor._id"?: StringId[] | StringId; status?: Data["status"] | Data["status"][]; is_test_reset?: boolean; sortBy?: { field: "_id" | "status"; type: "asc" | "desc"; }[]; }; export interface Result extends DefaultPaginationResult { data: (Data & { expired?: boolean })[]; } } export namespace Get { export type ID = string; export type Params = { [key: string]: any }; export type Result = Data & { expired?: boolean }; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Result = Data; } export namespace Options { export type Params = { options: true }; export type Result = ServiceOptionMap; } } export namespace TestResetCompanyNamespace { export namespace Options { export type Params = ResetCompanyNamespace.Options.Params; export type Result = ResetCompanyNamespace.Options.Result; } export namespace Find { export type Params = ResetCompanyNamespace.Find.Params; export type Result = ResetCompanyNamespace.Find.Result; } export namespace Get { export type ID = string; export type Params = ResetCompanyNamespace.Get.Params; export type Result = ResetCompanyNamespace.Get.Result; } export namespace Create { export type Body = Omit< ResetCompanyNamespace.Create.Body, "is_test_reset" >; export type Result = ResetCompanyNamespace.Create.Result; } export namespace Update { export type ID = string; export type Result = ResetCompanyNamespace.Update.Result; } } export namespace TimelineTimeList { export const activity_types = [ "day", "client", "visit", "payment", "activity-photo", "activity-audit", "activity-availability", "activity-checkout-display", "activity-feedback", "activity-form-result", "activity-form-v2-result", "activity-item-status", "activity-note", "activity-planogram", "activity-secondary-display", "activity-shelfshare", "activity-storecheck", "activity-task", "approval-request", "asset-part-receival", "asset-part-transfer", "asset", "asset-part", "asset-unit", "reminders", "return-asset-part-unit", "store-asset-part-unit", "refund", "settlement", "void-settlement", "convert-proforma", "transfer", "proforma", "receiving-material", "void-invoice", "fullinvoices", "workorder", "workorder-request", "return-whole-invoice", "cycle", "clm-feedback-activity", "void-settlement", ] as const; type ActivityType = (typeof activity_types)[number]; export interface Data { _id: StringId; company_namespace: string[]; activity_type: ActivityType; activity_id: StringId | StringId[]; time: number; business_day?: string; user: { _id: StringId; type: "admin" | "rep"; name?: string; rep?: StringId; admin?: StringId; }; action: Method; teams?: StringId[]; visit_id?: string; sync_id?: string; client?: StringId; client_name?: string; geoPoint?: { coordinates: [number, number]; type: "Point" }; battery_level?: string; version_name?: string; platform?: string; device_id?: string; device_unique_id?: string; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; details: | VisitDetails | DayDetails | PaymentDetails | RefundDetails | ActivityPhotoDetails | ActivityAuditDetails | ActivityNoteDetails | ActivityTaskDetails | ActivityAvailabilityDetails | ActivityCheckoutDisplayDetails | ActivityFeedbackDetails | ActivityFormResultDetails | ActivityFormV2ResultDetails | ActivityItemStatusDetails | ActivityPlanogramDetails | ActivitySecondaryDisplayDetails | ActivityShelfshareDetails | ActivityStorecheckDetails | ApprovalRequestDetails | AssetPartReceivalDetails | AssetPartTransferDetails | AssetDetails | AssetPartDetails | AssetUnitDetails | ReminderDetails | ReturnAssetPartUnitDetails | StoreAssetPartUnitDetails | SettlementDetails | VoidSettlementDetails | ConvertProformaDetails | TransferDetails | ReceivingMaterialDetails | FullInvoiceDetails | ProformaDetails | WorkorderDetails | WorkorderRequestDetails | ReturnWholeInvoiceDetails | VoidInvoiceDetails | CycleDetails | ClientDetails | CLMFeedbackActivity; createdAt: Date; updatedAt: Date; } export type VisitDetails = { activity_type: "visit"; activities: ( | ActivityAuditVisitDetails | ActivityPhotoVisitDetails | ActivityAvailabilityVisitDetails | ActivityNoteVisitDetails | ActivityTaskVisitDetails | ActivityPlanogramVisitDetails | ActivityShelfshareVisitDetails | ActivitySecondaryDisplayVisitDetails | ActivityCheckoutDisplayVisitDetails | ActivityItemStatusVisitDetails | ActivityFormResultVisitDetails | ActivityFormV2ResultVisitDetails | ActivityStorecheckVisitDetails | ActivityFeedbackVisitDetails | ApprovalRequestVisitDetails | AssetPartReceivalVisitDetails | AssetPartTransferVisitDetails | ReturnAssetPartUnitVisitDetails | StoreAssetPartUnitVisitDetails | PaymentVisitDetails | RefundVisitDetails | ConvertProformaVisitDetails | FullInvoiceVisitDetails | ProformaVisitDetails | ReturnWholeInvoiceVisitDetails | VoidInvoiceVisitDetails | CLMFeedbackActivityVisitDetails )[]; feed_back_option?: StringId; feed_back_option_label?: string; visit_reason_name?: string; } & Pick< Visit.Data, | "closed_by_system" | "geoPoint" | "start_time" | "end_time" | "total_time" | "start_out_of_geofence" | "end_out_of_geofence" | "auto_closed_by_geofence" | "auto_closed_by_geofence_reason" | "client_geo_location" | "delta_distance" | "visit_reason" | "visit_note" >; // CLMFeedbackActivity ******************************************************************** export type CLMFeedbackActivity = { activity_type: "clm-feedback-activity"; activity_id: StringId; } & Pick< CLMFeedbackActivity.Data, | "presentation" | "presentation_name" | "time" | "duration_on_presentation_ms" | "completion_status" >; export type CLMFeedbackActivityVisitDetails = { activity_type: "clm-feedback-activity"; activity_id: StringId; } & Pick< CLMFeedbackActivity.Data, | "presentation" | "presentation_name" | "time" | "duration_on_presentation_ms" | "completion_status" | "time" >; // ActivityPhoto ******************************************************************** export type ActivityPhotoDetails = { activity_type: "activity-photo"; media_populated: PopulatedMediaStorage[]; } & Pick; export type ActivityPhotoVisitDetails = { activity_type: "activity-photo"; activity_id: StringId; media_populated: PopulatedMediaStorage[]; } & Pick; // ActivityAudit ******************************************************************** export type ActivityAuditDetails = { activity_type: "activity-audit"; audits_length: number; }; export type ActivityAuditVisitDetails = { activity_type: "activity-audit"; activity_id: StringId; audits_length: number; } & Pick; // ActivityAvailability ******************************************************************** export type ActivityAvailabilityDetails = { activity_type: "activity-availability"; products_available_length: number; msl_name: string; media_populated?: PopulatedMediaStorage[]; } & Pick; export type ActivityAvailabilityVisitDetails = { activity_type: "activity-availability"; activity_id: StringId; products_available_length: number; msl_name: string; media_populated?: PopulatedMediaStorage[]; } & Pick; // ActivityNote ******************************************************************** export type ActivityNoteDetails = { activity_type: "activity-note" } & Pick< ActivityNote.Data, "content" >; export type ActivityNoteVisitDetails = { activity_type: "activity-note"; activity_id: StringId; } & Pick; // ActivityTask ******************************************************************** export type ActivityTaskDetails = { activity_type: "activity-task"; start_media_populated?: PopulatedMediaStorage[]; end_media_populated?: PopulatedMediaStorage[]; } & Pick; export type ActivityTaskVisitDetails = { activity_type: "activity-task"; activity_id: StringId; start_media_populated?: PopulatedMediaStorage[]; end_media_populated?: PopulatedMediaStorage[]; } & Pick; // ActivityPlanogram ******************************************************************** export type ActivityPlanogramDetails = { activity_type: "activity-planogram"; msl_name: string; media_populated?: PopulatedMediaStorage[]; } & Pick; export type ActivityPlanogramVisitDetails = { activity_type: "activity-planogram"; activity_id: StringId; msl_name: string; media_populated?: PopulatedMediaStorage[]; } & Pick< ActivityPlanogram.Data, "media" | "planogram_reason" | "time" | "msl_id" >; // ActivityShelfshare ******************************************************************** export type ActivityShelfshareDetails = { activity_type: "activity-shelfshare"; results: (Pick< ActivityShelfshare.Data, "msl_length" | "total_msl_length" | "msl_id" > & { activity_id: StringId; msl_name: string })[]; }; export type ActivityShelfshareVisitDetails = { activity_type: "activity-shelfshare"; activity_id: StringId[]; time: number; results: (Pick< ActivityShelfshare.Data, "msl_length" | "total_msl_length" | "msl_id" > & { activity_id: StringId; msl_name: string })[]; }; // ActivitySecondaryDisplay ******************************************************************** export type ActivitySecondaryDisplayDetails = { activity_type: "activity-secondary-display"; results: (Pick< ActivitySecondaryDisplay.Data, "secondary_count" | "msl_id" > & { activity_id: StringId; msl_name: string })[]; }; export type ActivitySecondaryDisplayVisitDetails = { activity_type: "activity-secondary-display"; activity_id: StringId[]; time: number; results: (Pick< ActivitySecondaryDisplay.Data, "secondary_count" | "msl_id" > & { activity_id: StringId; msl_name: string })[]; }; // ActivityCheckoutDisplay ******************************************************************** export type ActivityCheckoutDisplayDetails = { activity_type: "activity-checkout-display"; results: (Pick< ActivityCheckoutDisplay.Data, "checkout_count" | "msl_id" > & { activity_id: StringId; msl_name: string })[]; }; export type ActivityCheckoutDisplayVisitDetails = { activity_type: "activity-checkout-display"; activity_id: StringId[]; time: number; results: (Pick< ActivityCheckoutDisplay.Data, "checkout_count" | "msl_id" > & { activity_id: StringId; msl_name: string })[]; }; // ActivityItemStatus ******************************************************************** export type ActivityItemStatusDetails = { activity_type: "activity-item-status"; items_length?: number; }; export type ActivityItemStatusVisitDetails = { activity_type: "activity-item-status"; activity_id: StringId; items_length?: number; } & Pick; // ActivityFormResult ******************************************************************** export type ActivityFormResultDetails = { activity_type: "activity-form-result"; form_name?: string; } & Pick; export type ActivityFormResultVisitDetails = { activity_type: "activity-form-result"; activity_id: StringId; form_name?: string; } & Pick; // ActivityFormV2Result ******************************************************************** export type ActivityFormV2ResultDetails = { activity_type: "activity-form-v2-result"; form_name?: string; } & Pick; export type ActivityFormV2ResultVisitDetails = { activity_type: "activity-form-v2-result"; activity_id: StringId; form_name?: string; } & Pick; // ActivityStorecheck ******************************************************************** export type ActivityStorecheckDetails = { activity_type: "activity-storecheck"; template_name?: string; } & Pick< ActivityStorecheck.ActivityStoreCheckWithPopulatedKeysSchema, "template_id" | "serial_number" >; export type ActivityStorecheckVisitDetails = { activity_type: "activity-storecheck"; activity_id: StringId; template_name?: string; } & Pick< ActivityStorecheck.ActivityStoreCheckWithPopulatedKeysSchema, "template_id" | "serial_number" | "time" >; // ActivityFeedback ******************************************************************** export type ActivityFeedbackDetails = { activity_type: "activity-feedback"; feed_back_option_label?: string; } & Pick; export type ActivityFeedbackVisitDetails = { activity_type: "activity-feedback"; activity_id: StringId; time?: number; feed_back_option_label?: string; } & Pick; // ApprovalRequest ******************************************************************** export type ApprovalRequestDetails = { activity_type: "approval-request"; } & Pick< ApprovalRequest.Data, "serial_number" | "type" | "subtype" | "creator" | "comment" | "status" >; export type ApprovalRequestVisitDetails = { activity_type: "approval-request"; activity_id: StringId; } & Pick< ApprovalRequest.Data, | "serial_number" | "type" | "subtype" | "time" | "creator" | "comment" | "status" >; // Reminder ******************************************************************** export type ReminderDetails = { activity_type: "reminders"; cover_photo_populated?: PopulatedMediaStorage; } & Pick; // Asset ******************************************************************** export type AssetDetails = { activity_type: "asset"; asset_types?: string; } & Pick; // AssetUnit ******************************************************************** export type AssetUnitDetails = { activity_type: "asset-unit"; asset?: string; } & Pick; // AssetPart ******************************************************************** export type AssetPartDetails = { activity_type: "asset-part" } & Pick< AssetPart.Data, "name" >; // AssetPartReceival ******************************************************************** export type AssetPartReceivalDetails = { activity_type: "asset-part-receival"; } & Pick< AssetPartReceival.Data, | "serial_number" | "warehouse" | "warehouse_name" | "asset_parts_count" | "total_asset_parts_qty" >; export type AssetPartReceivalVisitDetails = { activity_type: "asset-part-receival"; activity_id: StringId; } & Pick< AssetPartReceival.Data, | "serial_number" | "warehouse" | "warehouse_name" | "time" | "asset_parts_count" | "total_asset_parts_qty" >; // AssetPartTransfer ******************************************************************** export type AssetPartTransferDetails = { activity_type: "asset-part-transfer"; } & Pick< AssetPartTransfer.Data, | "serial_number" | "from" | "from_name" | "to" | "to_name" | "asset_part_units_count" | "total_asset_part_units_qty" >; export type AssetPartTransferVisitDetails = { activity_type: "asset-part-transfer"; activity_id: StringId; } & Pick< AssetPartTransfer.Data, | "serial_number" | "from" | "from_name" | "to" | "to_name" | "asset_part_units_count" | "total_asset_part_units_qty" | "time" >; // ReturnAssetPartUnit ******************************************************************** export type ReturnAssetPartUnitDetails = { activity_type: "return-asset-part-unit"; } & Pick< ReturnAssetPartUnit.Data, | "serial_number" | "warehouse" | "warehouse_name" | "asset_part_units_count" | "total_asset_part_units_qty" >; export type ReturnAssetPartUnitVisitDetails = { activity_type: "return-asset-part-unit"; activity_id: StringId; } & Pick< ReturnAssetPartUnit.Data, | "serial_number" | "warehouse" | "warehouse_name" | "asset_part_units_count" | "total_asset_part_units_qty" | "time" >; // StoreAssetPartUnit ******************************************************************** export type StoreAssetPartUnitDetails = { activity_type: "store-asset-part-unit"; } & Pick< StoreAssetPartUnit.Data, | "serial_number" | "warehouse" | "warehouse_name" | "asset_part_units_count" | "total_asset_part_units_qty" >; export type StoreAssetPartUnitVisitDetails = { activity_type: "store-asset-part-unit"; activity_id: StringId; } & Pick< StoreAssetPartUnit.Data, | "serial_number" | "warehouse" | "warehouse_name" | "asset_part_units_count" | "total_asset_part_units_qty" | "time" >; // Payment ******************************************************************** export type PaymentDetails = { activity_type: "payment" } & Pick< Payment.Data, "amount" | "serial_number" | "paytime" | "currency" | "payment_type" >; export type PaymentVisitDetails = { activity_type: "payment"; activity_id: StringId; } & Pick< Payment.Data, "amount" | "serial_number" | "currency" | "payment_type" | "time" >; // Refund ******************************************************************** export type RefundDetails = { activity_type: "refund" } & Pick< Refund.Data, "amount" | "serial_number" | "paytime" | "currency" | "transaction_type" >; export type RefundVisitDetails = { activity_type: "refund"; activity_id: StringId; } & Pick< Refund.Data, "amount" | "serial_number" | "currency" | "transaction_type" | "time" >; // Settlement ******************************************************************** export type SettlementDetails = { activity_type: "settlement" } & Pick< Settlement.Data, | "amount" | "serial_number" | "paytime" | "origin" | "payment_type" | "currency" >; // VoidSettlement ******************************************************************** export type VoidSettlementDetails = { activity_type: "void-settlement"; } & Pick< Settlement.Data, | "amount" | "serial_number" | "paytime" | "origin" | "payment_type" | "currency" | "returned_from" | "returned_from_serial_number" | "returned_to_serial_number" >; // ConvertProforma ******************************************************************** export type ConvertProformaDetails = { activity_type: "convert-proforma"; proforma_reference: FullInvoice.Data["proforma_reference"]; proforma_serial_number: Proforma.Data["serial_number"]; invoice_serial_number: FullInvoice.Data["serial_number"]; total: FullInvoice.Data["total"]; currency: FullInvoice.Data["currency"]; }; export type ConvertProformaVisitDetails = { activity_type: "convert-proforma"; activity_id: StringId; proforma_serial_number: Proforma.Data["serial_number"]; invoice_serial_number: FullInvoice.Data["serial_number"]; time: number; proforma_reference: FullInvoice.Data["proforma_reference"]; total: FullInvoice.Data["total"]; currency: FullInvoice.Data["currency"]; }; // Transfer ******************************************************************** export type TransferDetails = { activity_type: "transfer"; from_name: string; to_name: string; } & Pick< Transfer.Data, "type" | "serial_number" | "from" | "to" | "items_count" | "comment" >; // ReceivingMaterial ******************************************************************** export type ReceivingMaterialDetails = { activity_type: "receiving-material"; to_name: string; supplier_name?: string; } & Pick< ReceivingMaterial.Data, "serial_number" | "to" | "items_count" | "comment" | "supplier" >; // FullInvoice ******************************************************************** export type FullInvoiceDetails = { activity_type: "fullinvoices" } & Pick< FullInvoice.Data, | "total" | "serial_number" | "currency" | "issue_date" | "due_date" | "external_serial_number" >; export type FullInvoiceVisitDetails = { activity_type: "fullinvoices"; activity_id: StringId; } & Pick< FullInvoice.Data, | "total" | "serial_number" | "currency" | "time" | "issue_date" | "due_date" | "external_serial_number" >; // Proforma ******************************************************************** export type ProformaDetails = { activity_type: "proforma" } & Pick< Proforma.Data, | "total" | "serial_number" | "currency" | "issue_date" | "external_serial_number" >; export type ProformaVisitDetails = { activity_type: "proforma"; activity_id: StringId; } & Pick< Proforma.Data, | "total" | "serial_number" | "currency" | "time" | "issue_date" | "external_serial_number" >; // Workorder ******************************************************************** export type WorkorderDetails = { activity_type: "workorder"; media_populated?: PopulatedMediaStorage[]; } & Pick< Workorder.Data, | "name" | "serial_number" | "due_date" | "status" | "description" | "priority" | "media" >; // WorkorderRequest ******************************************************************** export type WorkorderRequestDetails = { activity_type: "workorder-request"; media_populated?: PopulatedMediaStorage[]; } & Pick< WorkorderRequest.Data, "name" | "media" | "description" | "priority" | "status" >; // ReturnWholeInvoice ******************************************************************** export type ReturnWholeInvoiceDetails = { activity_type: "return-whole-invoice"; returned_from_serial_number: FullInvoice.Data["returned_from_serial_number"]; } & Pick; export type ReturnWholeInvoiceVisitDetails = { activity_type: "return-whole-invoice"; activity_id: StringId; returned_from_serial_number: FullInvoice.Data["returned_from_serial_number"]; } & Pick< FullInvoice.Data, "returned_from" | "returned_to_serial_number" | "time" >; // VoidInvoice ******************************************************************** export type VoidInvoiceDetails = { activity_type: "void-invoice"; returned_from_serial_number: FullInvoice.Data["returned_from_serial_number"]; } & Pick; export type VoidInvoiceVisitDetails = { activity_type: "void-invoice"; activity_id: StringId; returned_from_serial_number: FullInvoice.Data["returned_from_serial_number"]; } & Pick< FullInvoice.Data, "returned_from" | "returned_to_serial_number" | "time" >; // Cycle ******************************************************************** export type CycleDetails = { activity_type: "cycle"; stage_name?: string; } & Pick< Cycle.Data, "document_type" | "serial_number" | "document_id" | "status" >; // Client ******************************************************************** export type ClientDetails = { activity_type: "client" } & Pick< Client.Data, | "name" | "client_code" | "local_name" | "lat" | "lng" | "location_verified" >; // Day ******************************************************************** export type StartDayDetails = { activity_type: "day"; startTime: string; } & Pick< Day.Data, "day" | "open" | "created_by_system" | "start_geoPoint" | "timeZone" >; export type EndDayDetails = { activity_type: "day"; startTime: string; endTime: string; } & Pick< Day.Data, | "day" | "open" | "breaksTime" | "created_by_system" | "timeInVisits" | "end_geoPoint" | "start_geoPoint" | "travelTimeBetweenVisists" | "totalTravelTime" | "breaksTime" | "timeOnDuty" | "timeZone" >; export type DayDetails = StartDayDetails | EndDayDetails; export type PopulatedDoc = Data & { client_populated?: Pick< Client.Data, | "_id" | "name" | "client_code" | "local_name" | "lat" | "lng" | "location_verified" | "chain" | "channel" | "city" | "state" | "country" | "tags" | "customFields" | "teams" >; client_name?: string; client_code?: string; client_local_name?: string; client_lat?: number; client_lng?: number; client_location_verified?: boolean; user_profile_photo?: string | null; client_customFields?: { [key: string]: any }; chain?: StringId; chain_name?: string; chain_populated?: { _id: StringId; name: string }; channel?: StringId; channel_name?: string; channel_populated?: { _id: StringId; name: string }; area_tags?: StringId[]; area_tags_populated?: { _id?: StringId[]; name?: string[] }; area_tags_names?: string[]; client_tags?: StringId[]; client_tags_populated?: { _id?: StringId[]; name?: string[] }; client_tags_names?: string[]; city?: string; state?: string; country?: string; rep_populated?: Pick< Rep.Data, "_id" | "name" | "username" | "customFields" >; rep_username?: string; rep_customFields: { [key: string]: any }; teams_populated?: { _id?: StringId[]; name?: string[] }; teams?: string[]; admin_populated?: { _id: StringId; name: string }; }; export type SortingKeys = "_id"; export namespace Find { export type Params = DefaultPaginationQueryParams & { visit_mode?: boolean; admin?: StringId | StringId[]; rep?: StringId | StringId[]; sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; _id?: StringId | StringId[]; "user._id"?: StringId | StringId[]; user?: StringId | StringId[]; "user.type"?: Data["user"]["type"] | Data["user"]["type"][]; user_type?: Data["user"]["type"] | Data["user"]["type"][]; from_createdAt?: number; to_createdAt?: number; teams?: StringId | StringId[]; activity_type?: Data["activity_type"] | Data["activity_type"][]; action?: Data["action"] | Data["action"][]; visit_id?: string | string[]; activity_id?: StringId | StringId[]; time?: number; from_time?: number; to_time?: number; sync_id?: string | string[]; client?: StringId | StringId[]; "details.activities.activity_type"?: | VisitDetails["activities"][0]["activity_type"] | VisitDetails["activities"][0]["activity_type"][]; chain?: StringId | StringId[]; channel?: StringId | StringId[]; city?: string | string[]; region?: string | string[]; state?: string | string[]; country?: string | string[]; tags?: StringId | StringId[]; CLIENT_TAGS?: StringId | StringId[]; AREA_TAGS?: StringId | StringId[]; with_media?: boolean; with_client_customFields?: boolean; with_client_details?: boolean; with_chain?: boolean; with_channel?: boolean; with_area_tags?: boolean; with_tags?: boolean; with_client_tags?: boolean; with_teams?: boolean; with_rep_details?: boolean; with_rep_customFields?: boolean; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } } export namespace SalesAnalyticsReport { export const groupBy_options = [ "client", "rep", "issue_date", "due_date", "serial_number", "product", "variant", "brand", "category", "status", "promotion_type", "class", "measureunit", "promotion", "chain", "channel", "city", "region", "country", "route", "teams", ] as const; export type GroupByOption = (typeof groupBy_options)[number]; export const promotion_type_options = ["get", "buy"] as const; export type PromotionTypeOption = (typeof promotion_type_options)[number]; export const class_options = ["invoice", "return"] as const; export type ClassOption = (typeof class_options)[number]; export const status_options = ["unpaid", "partially_paid", "paid"] as const; export type StatusOption = (typeof status_options)[number]; export const sortBy_field_options = ["_id", "time"] as const; export type SortByFieldOption = (typeof sortBy_field_options)[number]; export const sortBy_type_options = ["asc", "desc"] as const; export type SortByTypeOption = (typeof sortBy_type_options)[number]; export interface SortByOption { field: SortByFieldOption; type: SortByTypeOption; } export interface Data { _id?: string; [key: string]: any; } export type CreateBody = GenericQuery< SalesAnalyticsReportSortedKey, SalesAnalyticsReportFilter, SalesAnalyticsGroupByIDs, SalesAnalyticsFieldAccumulators, SalesAnalyticsReportProjectionKey, 1 >; export namespace Find { export type Params = DefaultPaginationQueryParams & { from_issue_date?: string; to_issue_date?: string; from_due_date?: string; to_due_date?: string; from_createdAt?: string; to_createdAt?: string; from_updatedAt?: string; to_updatedAt?: string; client?: StringId | StringId[]; rep?: StringId | StringId[]; creator?: StringId | StringId[]; teams?: StringId | StringId[]; status?: StatusOption | StatusOption[]; promotion?: StringId | StringId[]; product?: StringId | StringId[]; variant?: StringId | StringId[]; category?: StringId | StringId[]; sub_category?: StringId | StringId[]; brand?: StringId | StringId[]; product_groups?: StringId | StringId[]; class?: ClassOption | ClassOption[]; with_brand?: boolean; with_category?: boolean; with_product_groups?: boolean; with_sub_category?: boolean; with_product_details?: boolean; with_variant_details?: boolean; with_teams?: boolean; with_promotions?: boolean; promotion_type?: PromotionTypeOption; with_balance?: boolean; groupBy?: GroupByOption | GroupByOption[]; from_price?: number; to_price?: number; export?: string; chain?: StringId | StringId[]; channel?: StringId | StringId[]; CLIENT_TAGS?: StringId | StringId[]; AREA_TAGS?: StringId | StringId[]; tags?: StringId | StringId[]; country?: string | string[]; state?: string | string[]; city?: string | string[]; with_chain?: boolean; with_channel?: boolean; with_tags?: boolean; with_client_details?: boolean; admin?: StringId | StringId[]; tax?: StringId | StringId[]; with_original_price?: boolean; with_route?: boolean; route?: StringId | StringId[]; with_external_serial_number?: boolean; with_workorder?: boolean; with_client_customFields?: boolean; with_rep_details?: boolean; with_rep_customFields?: boolean; sortBy?: SortByOption[]; includeDocumentsCount?: boolean; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Create { export type Params = DefaultPaginationQueryParams & { from_issue_date?: string; to_issue_date?: string; from_due_date?: string; to_due_date?: string; from_createdAt?: string; to_createdAt?: string; from_updatedAt?: string; to_updatedAt?: string; client?: StringId | StringId[]; rep?: StringId | StringId[]; creator?: StringId | StringId[]; teams?: StringId | StringId[]; status?: StatusOption | StatusOption[]; promotion?: StringId | StringId[]; product?: StringId | StringId[]; variant?: StringId | StringId[]; category?: StringId | StringId[]; sub_category?: StringId | StringId[]; brand?: StringId | StringId[]; product_groups?: StringId | StringId[]; class?: ClassOption | ClassOption[]; with_brand?: boolean; with_category?: boolean; with_product_groups?: boolean; with_sub_category?: boolean; with_product_details?: boolean; with_variant_details?: boolean; with_teams?: boolean; with_promotions?: boolean; promotion_type?: PromotionTypeOption; with_balance?: boolean; groupBy?: GroupByOption | GroupByOption[]; from_price?: number; to_price?: number; export?: string; chain?: StringId | StringId[]; channel?: StringId | StringId[]; CLIENT_TAGS?: StringId | StringId[]; AREA_TAGS?: StringId | StringId[]; tags?: StringId | StringId[]; country?: string | string[]; state?: string | string[]; city?: string | string[]; with_chain?: boolean; with_channel?: boolean; with_tags?: boolean; with_client_details?: boolean; admin?: StringId | StringId[]; tax?: StringId | StringId[]; with_original_price?: boolean; with_route?: boolean; route?: StringId | StringId[]; with_external_serial_number?: boolean; with_workorder?: boolean; with_client_customFields?: boolean; with_rep_details?: boolean; with_rep_customFields?: boolean; sortBy?: SortByOption[]; includeDocumentsCount?: boolean; }; export type Body = CreateBody; export interface Result extends DefaultPaginationResult { data: Data[]; columns: ReportColumn[]; keys: ReportKey[]; } } } export namespace WorkorderAgenda { export interface Workorder { name: string; client: string; client_populated: { _id: string; name: string; local_name: string; client_code: string; }; createdAt: Date; } export interface PlanedWorkorder extends Workorder { _id: null; status: null; is_planned: true; due_date: null; start_date: null; parent_workorder: string; } export interface OriginWorkorder extends Workorder { _id: string; status: Workorder.Data["status"]; is_planned: false; due_date: number; start_date: number; parent_workorder: null; } export interface Data { day: string; day_total_result?: number; day_current_count?: number; day_total_pages?: number; workorders: (OriginWorkorder | PlanedWorkorder)[]; planned_workorders: number; done_workorders: number; inprogress_workorders: number; overdue_workorders: number; open_workorders: number; onhold_workorders: number; cancelled_workorders: number; } export namespace Find { export type Params = DefaultPaginationQueryParams & { from_due_date: number; to_due_date: number; client?: StringId[]; disabled: boolean; day_per_page?: number; day_page?: number; day?: string; client_location?: StringId[]; workorder_categories?: StringId[]; status?: Workorder.Data["status"] | Workorder.Data["status"][]; priority_human?: Workorder.Data["priority_human"] | Workorder.Data["priority_human"][]; assets?: StringId[]; asset_units?: StringId[]; contract?: StringId[]; assigned_to?: StringId[]; from_createdAt?: number; to_createdAt?: number; _id: StringId | StringId[]; }; export interface Result extends AgendaPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Params = DefaultPaginationQueryParams & { client?: StringId[]; disabled: boolean; client_location?: StringId[]; workorder_categories?: StringId[]; status?: Workorder.Data["status"] | Workorder.Data["status"][]; priority_human?: Workorder.Data["priority_human"] | Workorder.Data["priority_human"][]; assets?: StringId[]; asset_units?: StringId[]; contract?: StringId[]; assigned_to?: StringId[]; from_createdAt?: number; to_createdAt?: number; _id: StringId | StringId[]; }; export interface Result extends DefaultPaginationQueryParams { data: Data["workorders"]; } } } export namespace ModuleCustomValidator { export interface NumberValidation { data_type?: "number"; regex?: string; required?: boolean; min?: number; max?: number; precision?: number; enum?: number[]; division_factor?: number; multiply_factor?: number; none_zero?: boolean; is_timestamp?: boolean; unique?: boolean; ignore_disabled_in_unique?: boolean; allow_unique?: boolean; } export interface ReferenceValidation { data_type?: "reference"; is_array?: false; required?: boolean; } export interface ArrayReferenceValidation { data_type?: "reference"; is_array?: true; required?: boolean; array_min_length?: number; array_max_length?: number; } export interface TextValidation { data_type?: "text"; regex?: string; required?: boolean; min?: number; max?: number; enum?: string[]; unique?: boolean; ignore_disabled_in_unique?: boolean; allow_unique?: boolean; } interface BasicData { creator: AdminCreator; editor?: AdminCreator; _id?: string; module: RepzoModel; key: string; origin_type: "system_field" | "custom_field"; disabled: boolean; scope: "all" | "rep" | "admin"; ai_custom_error?: string; custom_error?: string; teams?: string[]; full_key_path?: string; company_namespace: string[]; } type NumberData = BasicData & { data_type: "number"; validation: NumberValidation; }; type TextData = BasicData & { data_type: "text"; validation: TextValidation; }; type ReferenceData = BasicData & { data_type: "reference"; reference_module: string; validation: ArrayReferenceValidation | ReferenceValidation; }; export type Data = ReferenceData | NumberData | TextData; export interface BasicCreateBody { creator: AdminCreator; module: RepzoModel; key: string; origin_type: "system_field" | "custom_field"; scope: "all" | "rep" | "admin"; ai_custom_error?: string; custom_error?: string; teams?: string[]; } export type CreateBody = BasicCreateBody & (ReferenceData | NumberData | TextData); export interface BasicUpdateBody { editor?: AdminCreator; module?: RepzoModel; key?: string; origin_type?: "system_field" | "custom_field"; scope?: "all" | "rep" | "admin"; ai_custom_error?: string; custom_error?: string; teams?: string[]; } export type UpdateBody = BasicCreateBody & (ReferenceData | NumberData | TextData); export namespace Find { export type Params = DefaultPaginationQueryParams & { module?: RepzoModel | RepzoModel[]; key?: string | string[]; data_type?: Data["data_type"] | Data["data_type"][]; origin_type?: Data["origin_type"] | Data["origin_type"][]; scope?: Data["scope"] | Data["scope"][]; disabled?: boolean; _id?: StringId | StringId[]; teams?: StringId | StringId[]; reference_module?: RepzoModel | RepzoModel[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace NotificationsCenter { export type Command = | "update-categories" | "update-clients" | "bulk-update-clients" | "update-inventory" | "update-measureunitFamilies" | "update-measureunits" | "update-pricelistItems" | "update-pricelists" | "update-products" | "update-rep" | "update-salesmsl" | "update-settings" | "update-geo-zone" | "update-tags" | "update-taxes" | "update-transfer" | "update-warehouses" | "update-jobCategories" | "update-plans" | "update-workorders" | "update-commentsThread" | "update-approval-request" | "update-variant-batch" | "update-asset-part-type" | "update-asset-part" | "update-asset-part-unit" | "update-custom-status" | "update-module-custom-validator" | "update-feedback-options" | "update-customfields" | "update-speciality" | "update-clm-presentation" | "update-clm-sequence" | "update-clm-slide" | "update-promotions" | "ai-chat-navigate" | "ai-chat-api-call" | "ai-chat-message-update" | "ai-chat-message-amend" | "update-delivery-note" | "update-item-status-type"; export interface Data { _id: StringId; command: Command; executed?: boolean; listed?: boolean; payload?: { endpoint?: string; message?: { ar?: string; en?: string }; photo?: string; media?: StringId[]; type?: string; }; read?: boolean; realmId?: StringId; time?: number; toast?: { ar?: string; en?: string }; teams?: StringId[]; docs_ids?: StringId[]; user?: AdminOrRep; visible?: boolean; meta?: { [key: string]: any }; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedDoc = Data & { cycle?: Cycle.Schema & { payload?: Data["payload"] & { media?: PopulatedMediaStorage[] }; }; }; export interface CreateBody { command: Command; executed?: boolean; listed?: boolean; payload?: { endpoint?: string; message?: { ar?: string; en?: string }; photo?: string; media?: StringId[]; type?: string; }; read?: boolean; realmId?: StringId; time?: number; toast?: { ar?: string; en?: string }; teams?: StringId[]; docs_ids?: StringId[]; user?: AdminOrRep; visible?: boolean; meta?: { [key: string]: any }; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; command?: Command; executed?: boolean; listed?: boolean; payload?: { endpoint?: string; message?: { ar?: string; en?: string }; photo?: string; media?: StringId[]; type?: string; }; read?: boolean; realmId?: StringId; time?: number; toast?: { ar?: string; en?: string }; teams?: StringId[]; docs_ids?: StringId[]; user?: AdminOrRep; visible?: boolean; meta?: { [key: string]: any }; company_namespace?: string[]; createdAt?: Date; updatedAt?: Date; } export interface PatchBody { executed?: boolean; command?: Data["command"] | Data["command"][]; } type PopulatedKeys = "media"; export namespace Find { export type Params = DefaultPaginationQueryParams & { command?: Command | Command[]; "user._id"?: StringId | StringId[]; executed?: boolean; populatedKeys?: PopulatedKeys[]; [key: string]: any; // integration_meta. }; export interface Result extends DefaultPaginationResult { data: Data[] | PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; [key: string]: any; }; export type Result = Data | PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type Body = PatchBody; export interface Result { status: "success"; message: "0 updated "; } } } export namespace ReportColumnGroup { export interface Data { _id: StringId; name: string; position: number; disabled: boolean; report_types: ReportType[]; createdAt: number; updatedAt: number; } export interface CreateBody { name: string; position?: number; report_types: ReportType[]; } export interface UpdateBody { name?: string; position?: number; report_types?: ReportType[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; disabled?: boolean; position?: number; report_types?: ReportType | ReportType[]; search?: string; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Params = {}; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Params = {}; export type Result = Data; } } export namespace ReportColumn { export interface Data { _id: StringId; disabled: boolean; key: string; name: string; position: number; selectable: boolean; show: "default" | "hide" | "show"; totals_key?: string; report_types: ReportType[]; column_group?: StringId; default_show?: boolean; createdAt?: Date; updatedAt?: Date; } export interface CreateBody { key: string; name: string; report_types: ReportType[]; position?: number; selectable?: boolean; show?: "default" | "hide" | "show"; totals_key?: string; column_group?: StringId; default_show?: boolean; } export interface UpdateBody { disabled: boolean; key: string; name: string; report_types: ReportType[]; position?: number; selectable?: boolean; show?: "default" | "hide" | "show"; totals_key?: string; column_group?: StringId; default_show?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; disabled?: boolean; position?: number; report_types?: ReportType | ReportType[]; column_group?: StringId | StringId[]; populatedKeys?: "column_group"[]; }; export interface Result extends DefaultPaginationResult { data: (Data & { column_group_populated?: ReportColumnGroup.Data })[]; } } export namespace Get { export type ID = StringId; export type Params = {}; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Params = {}; export type Result = Data; } } export namespace ReportSort { export interface Data { _id: StringId; disabled: boolean; key: string; name: string; selectable?: boolean; report_types: ReportType[]; createdAt?: Date; updatedAt?: Date; } export interface CreateBody { key: string; name: string; selectable?: boolean; report_types: ReportType[]; } export interface UpdateBody { key?: string; name?: string; selectable?: boolean; report_types?: ReportType[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; disabled?: boolean; key?: string | string[]; selectable?: boolean; report_types?: ReportType | ReportType[]; from_createdAt?: Date; to_updatedAt?: Date; search?: string; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Params = {}; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Params = {}; export type Result = Data; } } export namespace ReportFilter { export type AccumulatorOperator = | "sum" | "count" | "avg" | "max" | "min" | "first" | "last" | "addToSet" | "push"; export type AccumulatorLabel = | "Sum" | "Count" | "Average" | "Max" | "Min" | "First" | "Last" | "Unique" | "ALL"; export interface Accumulator { operator: AccumulatorOperator; label?: AccumulatorLabel; } export interface Field { label: string; key: string; accumulator: Accumulator[]; } export interface GroupData { id_label: string; id: string; fields: Field[]; } export interface StaticData { label: string; value: string; } export type DataType = "string" | "number" | "array" | "boolean"; export type InputType = "string" | "list" | "checkbox" | "date" | "number" | "group_by"; export type Operator = | "eq" | "ne" | "gt" | "lt" | "gte" | "lte" | "in" | "nin" | "between" | "today" | "yesterday" | "last_seven_days" | "last_thirty_days" | "last_month" | "last_three_months" | "last_six_months" | "last_twelve_months"; export type DateFormat = "s" | "YYYY-MM-DD" | "YYYY-MM-DD HH:mm:ssZ" | "ISO"; export interface Data { _id: string; label: string; key: string; render_key: string; filter_key: string; is_multi_select?: boolean; is_static?: boolean; type: DataType; input_type: InputType; operators?: Operator[]; date_format?: DateFormat; searchable?: boolean; report_types: ReportType[]; endpoint?: string; static_data?: StaticData[]; group_data: GroupData[]; filter_group: StringId; is_popular?: boolean; createdAt?: Date; updatedAt?: Date; } export interface CreateBody { label: string; key: string; render_key: string; filter_key: string; report_types: ReportType[]; filter_group: StringId; type: DataType; input_type: InputType; is_multi_select?: boolean; is_static?: boolean; operators?: Operator[]; date_format?: DateFormat; searchable?: boolean; endpoint?: string; static_data?: StaticData[]; group_data: GroupData[]; is_popular?: boolean; } export interface UpdateBody { label?: string; key?: string; render_key?: string; filter_key?: string; filter_group?: StringId; report_types?: ReportType[]; type?: DataType; input_type?: InputType; is_multi_select?: boolean; is_static?: boolean; operators?: Operator[]; date_format?: DateFormat; searchable?: boolean; endpoint?: string; static_data?: StaticData[]; group_data: GroupData[]; is_popular?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { report_types?: ReportType | ReportType[]; from_createdAt?: Date; to_updatedAt?: Date; search?: string; is_popular?: boolean; populatedKeys?: ["filter_group"]; }; export interface Result extends DefaultPaginationResult { data: (Data & { filter_group_populated?: ReportFilterGroup.Data })[]; } } export namespace Get { export type ID = StringId; export type Params = {}; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = Partial; export type Result = Data; } } export namespace SafeCrud { interface Body { collection: "company"; filters?: { [key: string]: any }; } interface CompanyBody extends Body { collection: "company"; filters?: { name_space?: string | string[] }; } interface CompanyResult { _id: StringId; name_space: string; allow_treating_invoice_as_proforma_for_etax?: boolean; } type Data = CompanyResult; export namespace Create { export type Body = CompanyBody; export interface Result extends DefaultPaginationResult { data: Data[]; } } } export namespace PaymentMethod { export type PaymentMethodType = "online" | "offline"; export type PaymentMethodAccountType = "cash"; export interface Data { _id: StringId; name: string; local_name?: string; type: PaymentMethodType; account_type: PaymentMethodAccountType; fee?: number; rate?: number; disabled: boolean; logo?: StringId; rep_auto_settled?: boolean; creator: Admin; editor?: Admin; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { name: string; local_name?: string; type: PaymentMethodType; account_type: PaymentMethodAccountType; fee?: number; rate?: number; disabled?: boolean; logo?: StringId; rep_auto_settled?: boolean; creator?: Admin; company_namespace?: string[]; } export interface UpdateBody { _id?: StringId; name?: string; local_name?: string; type?: PaymentMethodType; account_type?: PaymentMethodAccountType; fee?: number; rate?: number; disabled?: boolean; logo?: StringId; rep_auto_settled?: boolean; creator?: Admin; editor?: Admin; company_namespace?: string[]; createdAt?: string; updatedAt?: string; } export type PopulatedDoc = Data & { logo_populated?: PopulatedMediaStorage; }; type PopulatedKeys = "logo"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; search?: string; name?: string | string[]; disabled?: boolean; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Params = {}; export type Result = Data; } } export namespace ReportFilterGroup { export interface Data { _id: StringId; name: string; position: number; disabled: boolean; report_types: ReportType[]; createdAt: string; updatedAt?: string; } export interface CreateBody { name: string; position?: number; report_types: ReportType[]; } export interface UpdateBody { name?: string; position?: number; report_types?: ReportType[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; disabled?: boolean; position?: number; search?: string; report_types?: ReportType | ReportType[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Params = {}; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Params = {}; export type Result = Data; } } export namespace ReportView { export interface ColumnViewSettings { key: string; position: number; width: number; is_pinned: boolean; } export interface Data { _id?: string; name: string; disabled: boolean; creator: Admin; editor: Admin; column_view_settings?: ColumnViewSettings[]; position?: number; payload?: { maxAnyOfLength?: number; anyOf: { criteria: { key: string; operator: string; value: any; }[]; }[]; options?: { page?: number; limit?: number; sort?: { key: string; type: "asc" | "desc" }[]; totals_summary?: "all" | "page" | "none"; }; group?: { _id: string; fields: { key: string; accumulator: | "sum" | "min" | "max" | "avg" | "first" | "last" | "addToSet" | "push"; }[]; }[]; columns?: ReportColumn.Data[]; projection?: { key: string; label: string }[]; }; is_public: boolean; report_view_type: "kanban" | "table" | "agenda"; paramsQuery?: { [key: string]: any }; report_type: ReportType; company_namespace: string[]; teams?: string[]; copied_from?: StringId; metadata?: any; createdAt?: Date; updatedAt?: Date; } export interface CreateBody { name: string; column_view_settings?: ColumnViewSettings[]; position?: number; payload?: { maxAnyOfLength?: number; anyOf: { criteria: { key: string; operator: string; value: any; }[]; }[]; options?: { page?: number; limit?: number; sort?: { key: string; type: "asc" | "desc" }[]; totals_summary?: "all" | "page" | "none"; }; group?: { _id: string; fields: { key: string; accumulator: | "sum" | "min" | "max" | "avg" | "first" | "last" | "addToSet" | "push"; }[]; }[]; columns?: ReportColumn.Data[]; projection?: { key: string; label: string }[]; }; is_public?: boolean; report_view_type: "kanban" | "table" | "agenda"; paramsQuery?: { [key: string]: any }; metadata?: any; } export interface UpdateBody { name?: string; column_view_settings?: ColumnViewSettings[]; position?: number; payload?: { maxAnyOfLength?: number; anyOf: { criteria: { key: string; operator: string; value: any; }[]; }[]; options?: { page?: number; limit?: number; sort?: { key: string; type: "asc" | "desc" }[]; totals_summary?: "all" | "page" | "none"; }; group?: { _id: string; fields: { key: string; accumulator: | "sum" | "min" | "max" | "avg" | "first" | "last" | "addToSet" | "push"; }[]; }[]; columns?: ReportColumn.Data[]; projection?: { key: string; label: string }[]; }; is_public?: boolean; report_view_type?: "kanban" | "table" | "agenda"; paramsQuery?: { [key: string]: any }; metadata?: any; } export namespace Find { export type Params = DefaultPaginationQueryParams & { name?: string | string[]; disabled?: boolean; is_public?: boolean; report_view_type?: ("kanban" | "table" | "agenda")[]; report_type?: ReportType | ReportType[]; mine_views?: boolean; teams?: StringId | StringId[]; search?: string; mine_or_public_views?: boolean; populatedKeys?: ("teams" | "copied_from")[]; with_favorite?: boolean; with_default?: boolean; }; export interface Result extends DefaultPaginationResult { data: (Data & { is_favorite?: boolean; is_default?: boolean; teams_populated: Pick; copied_from_populated?: ReportView.Data; report_view_favorite_id?: StringId; report_view_default_id?: StringId; })[]; } } export namespace Get { export type ID = StringId; export type Params = { populatedKeys?: ("teams" | "copied_from")[]; with_favorite?: boolean; with_default?: boolean; }; export type Result = Data & { is_favorite?: boolean; is_default?: boolean; teams_populated: Pick; copied_from_populated?: ReportView.Data; report_view_favorite_id?: StringId; report_view_default_id?: StringId; }; } export namespace Create { export type params = { add_to_favorite?: boolean; set_as_default?: boolean; }; export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Params = {}; export type Result = Data; } } export namespace ReportViewFavorite { export interface Data { _id?: string; user: Admin; report_view: StringId; report_type: ReportType; company_namespace: string[]; createdAt?: Date; updatedAt?: Date; } export interface CreateBody { user?: Admin; report_view: StringId; report_type?: ReportType; } export type populateDoc = Data & { report_view_populated?: ReportView.Data; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; "user._id"?: StringId | StringId[]; report_view?: StringId | StringId[]; report_type?: ReportType | ReportType[]; populatedKeys?: "report_view"[]; }; export interface Result extends DefaultPaginationResult { data: populateDoc[]; } } export namespace Get { export type ID = StringId; export type Params = { populatedKeys?: "report_view"[] }; export type Result = populateDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Params = {}; export type Result = { acknowledged: boolean; deletedCount: number; }; } } export namespace ReportViewDefault { export interface Data { _id?: string; user: Admin; report_view: StringId; report_type: ReportType; company_namespace: string[]; createdAt?: Date; updatedAt?: Date; } export interface CreateBody { user?: Admin; report_view: StringId; report_type?: ReportType; } export type populateDoc = Data & { report_view_populated?: ReportView.Data; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; "user._id"?: StringId | StringId[]; report_view?: StringId | StringId[]; report_type?: ReportType | ReportType[]; populatedKeys?: "report_view"[]; }; export interface Result extends DefaultPaginationResult { data: populateDoc[]; } } export namespace Get { export type ID = StringId; export type Params = { populatedKeys?: "report_view"[] }; export type Result = populateDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Params = {}; export type Result = { acknowledged: boolean; deletedCount: number; }; } } export namespace CopyReportView { export namespace Update { export type ID = StringId; export type Body = {}; export type Result = ReportView.Data & { copied_from: StringId }; } } export namespace CLMPresentation { export interface Data { _id: StringId; company_namespace: string[]; name: string; disabled: boolean; teams: StringId[]; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name: string; disabled?: boolean; teams?: StringId[]; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { teams_populated?: Pick[]; sequences_count?: number; slides_count?: number; cover_slide?: PopulatedMediaStorage & { ContentLength?: number }; }; type PopulatedKeys = "teams"; type SortingKeys = "_id" | "createdAt" | "updatedAt"; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; search?: string; name?: string | string[]; disabled?: boolean; teams?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: StringId; to__id?: StringId; with_counts?: boolean; with_cover?: boolean; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; with_counts?: boolean; with_cover?: boolean; }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace CLMSequence { export interface Data { _id: StringId; company_namespace: string[]; name: string; presentation: StringId; product: StringId; disabled: boolean; position: number; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name: string; presentation: StringId; product: StringId; disabled?: boolean; position: number; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { presentation_populated?: Pick[]; product_populated?: Pick< Product.Data, "name" | "_id" | "local_name" | "barcode" | "sku" >[]; }; type PopulatedKeys = "presentation" | "product"; type SortingKeys = "_id" | "position"; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; search?: string; product?: StringId | StringId[]; presentation?: StringId | StringId[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: StringId; to__id?: StringId; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace CLMSlide { export interface Data { _id: StringId; company_namespace: string[]; sequence: StringId; presentation: StringId; photo_media: StringId; is_book_mark?: boolean; book_mark_key_message?: string; disabled: boolean; position: number; is_cover?: boolean; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; sequence: StringId; presentation?: StringId; photo_media: StringId; is_book_mark?: boolean; book_mark_key_message?: string; disabled?: boolean; position: number; is_cover?: boolean; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { presentation_populated?: CLMPresentation.Data; sequence_populated?: Pick< CLMSequence.Data, "position" | "_id" | "product" | "presentation" >[]; photo_media_populated?: PopulatedMediaStorage & { ContentLength?: number; }; }; type PopulatedKeys = "presentation" | "sequence" | "photo_media"; type SortingKeys = "_id" | "position" | "is_book_mark"; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; search?: string; sequence?: StringId | StringId[]; presentation?: StringId | StringId[]; is_book_mark?: boolean | boolean[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: StringId; to__id?: StringId; is_cover?: boolean; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace CLMFeedbackActivity { export interface Data { _id: StringId; geo_tag: GeoTag; geoPoint?: GeoPoint; time: number; tags?: StringId[]; visit_id: string; visit?: StringId; creator: { _id: StringId; type: "rep"; name?: string; rep?: StringId }; client: StringId; client_name: string; sync_id: string; teams?: StringId[]; route?: StringId; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; job_start_time?: number; job_end_time?: number; job_duration?: number; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; completion_status: "ended" | "canceled"; presentation: StringId; presentation_name: string; duration_on_presentation_ms: number; result: { sequence: StringId; duration_on_sequence_ms: number; sequence_landing_count: number; slides: { slide: StringId; feedback: "positive" | "negative" | "notProvided"; zoom: boolean; duration_on_slide_ms: number; slide_landing_count: number; is_book_mark?: boolean; book_mark_key_message?: string; }[]; }[]; } export interface CreateBody { geo_tag: GeoTag; geoPoint: GeoPoint; time: number; tags?: StringId[]; visit_id: string; visit?: StringId; creator?: { _id: StringId; type: "rep"; name?: string; rep?: StringId }; client: StringId; client_name: string; sync_id: string; teams?: StringId[]; route?: StringId; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; job_start_time?: number; job_end_time?: number; job_duration?: number; company_namespace?: string[]; completion_status: "ended" | "canceled"; presentation: StringId; presentation_name: string; duration_on_presentation_ms?: number; result?: { sequence: StringId; duration_on_sequence_ms: number; sequence_landing_count: number; slides: { slide: StringId; feedback: "positive" | "negative" | "notProvided"; zoom: boolean; duration_on_slide_ms: number; slide_landing_count: number; is_book_mark?: boolean; book_mark_key_message?: string; }[]; }[]; interactions: { interaction_time: number; interaction_type: | "slide_landing" | "slide_leaving" | "sequence_landing" | "sequence_leaving" | "zoom" | "feedback_given" | "presentation_play" | "presentation_end" | "presentation_cancel"; interaction_detail: "in" | "out" | "positive" | "negative" | "notProvided" | null; // required for zoom and feedback_given, null for other slide?: StringId; // optional for presentation_play, presentation_end, presentation_cancel, required for other sequence?: StringId; // optional for presentation_play, presentation_end, presentation_cancel, required for other sequence_name?: string; // optional }[]; } export interface CLMActivityInteraction { _id: StringId; interaction_time: number; interaction_type: | "slide_landing" | "slide_leaving" | "sequence_landing" | "sequence_leaving" | "zoom" | "feedback_given" | "presentation_play" | "presentation_end" | "presentation_cancel"; interaction_detail: "in" | "out" | "positive" | "negative" | "notProvided" | null; // required for zoom and feedback_given, null for other slide?: StringId; // optional for presentation_play, presentation_end, presentation_cancel, required for other sequence?: StringId; // optional for presentation_play, presentation_end, presentation_cancel, required for other presentation: StringId; clmFeedBackActivity?: StringId; sync_id: string; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; } export type PopulatedDoc = Data & { client_populated?: Pick< Client.Data, "_id" | "name" | "local_name" | "client_code" >[]; visit_populated?: Visit.Data; route_populated?: Pick; teams_populated?: Pick[]; tags_populated?: Pick[]; presentation_populated?: Pick; }; type PopulatedKeys = "client" | "visit" | "route" | "teams" | "tags" | "presentation"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys | PopulatedKeys[]; from_time?: number; to_time?: number; _id?: StringId | StringId[]; presentation?: StringId | StringId[]; client?: StringId | StringId[]; tags?: StringId | StringId[]; CLIENT_TAGS?: StringId | StringId[]; AREA_TAGS?: StringId | StringId[]; teams?: StringId | StringId[]; route?: StringId | StringId[]; creator?: StringId | StringId[]; creator_id?: StringId | StringId[]; creator_type?: StringId | StringId[]; "creator._id"?: StringId | StringId[]; "creator.type"?: StringId | StringId[]; visit_id?: string | string[]; visit?: StringId | StringId[]; sync_id?: string | string[]; from_updatedAt?: number; to_updatedAt?: number; from__id?: StringId; to__id?: StringId; sortBy?: { field: "_id"; type: "asc" | "desc" }[]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } } export namespace CLMFetch { export namespace Find { export type Params = { type: "presentation" | "sequence" | "slide"; me?: boolean; client?: StringId | StringId[]; presentation_disabled?: boolean; sequence_disabled?: boolean; } & ( | CLMPresentation.Find.Params | CLMSequence.Find.Params | CLMSlide.Find.Params ); export type Result = | CLMPresentation.Find.Result | CLMSequence.Find.Result | CLMSlide.Find.Result; } } export namespace CompareInvoiceToWarehouse { export type Data = Proforma.Data & { items?: Proforma.Data["items"][0] & { comparison: { same_variant_line_reduction?: number[]; qty_before: number; qty_after: number; measureunit_qty_before: number; measureunit_qty_after: number; }; }; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { proforma?: StringId[]; warehouses?: StringId[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; comment?: string; totals?: number; number_of_negative_items?: number; } } } export namespace Reauth { export interface Result { access_token: string; refresh_token: string; login_status: "success"; teams: StringId[]; populated_teams?: Pick[]; permissions: Rep.Data["permissions"]; rep: StringId; identifier: number; exp: number; // timestamp modules: string[]; realm_token: string; app_code: string; country: string; country_code: string[]; is_test: boolean; suspended: boolean; nameSpace: string[]; allow_treating_invoice_as_proforma_for_etax: boolean; time_zone: string; EOD: string; allow_offline_day: boolean; } } export namespace PrintSetting { export type ImageSize = "original" | "small" | "medium" | "large" | "extra"; export type QrCodeSize = "small" | "medium" | "large"; export type Alignment = "right" | "left" | "center"; export interface InvoiceFontsWithSizes { style_name: InvoiceFontStyles; size: number; } export interface ItemImage { view_item_image?: boolean; item_image_source?: "variant" | "product"; item_image_size?: ImageSize; } export interface User { _id: string; type: "admin" | "rep"; name?: string; admin?: string; } // Workorder Print Settings export interface WorkorderBasicDetails { creator?: boolean; workorder_categories?: boolean; client_name?: boolean; description?: boolean; local_name?: boolean; client_location?: boolean; assigned_to?: boolean; media?: boolean; cover_photo?: boolean; status?: boolean; assets?: boolean; asset_units?: boolean; priority_human?: boolean; due_date?: boolean; start_date?: boolean; forms?: boolean; comments?: boolean; createdAt?: boolean; } export interface WorkorderClientDetails { withClientDetails?: boolean; basicClientDetails?: { client_code?: boolean; client_local_name?: boolean; client_tags?: boolean; area_tags?: boolean; client_channel?: boolean; is_chain?: boolean; teams?: boolean; product_groups?: boolean; contacts?: boolean; createdAt?: boolean; customFields?: boolean; }; sales?: { price_list?: boolean; payment_type?: boolean; credit_limit?: boolean; payment_term?: boolean; }; contact_info?: { contact_name?: boolean; client_info?: boolean; email?: boolean; website?: boolean; }; } export interface WorkorderAssetDetails { withAssetsDetails?: boolean; media?: boolean; local_name?: boolean; description?: boolean; asset_types?: boolean; location?: boolean; model?: boolean; manufacturer?: boolean; year?: boolean; barcode?: boolean; customFields?: boolean; createdAt?: boolean; cover_photo?: boolean; } export interface WorkorderAssetUnitDetails { withAssetUnitsDetails?: boolean; media?: boolean; local_name?: boolean; description?: boolean; serial_number?: boolean; asset?: boolean; location?: boolean; customFields?: boolean; createdAt?: boolean; cover_photo?: boolean; } export interface WorkorderDetails { document_type: "workorder"; number_of_comments?: number; compressed_media_size?: ImageSize; basicDetails?: WorkorderBasicDetails; clientDetails?: WorkorderClientDetails; assetDetails?: WorkorderAssetDetails; assetUnitDetails?: WorkorderAssetUnitDetails; } // Form Result Settings export interface FormResultDetails { document_type: "form"; compressed_media_size?: ImageSize; } // Invoice Print Settings export interface InvoiceBasicDetails { created_at?: boolean; created_by?: boolean; tax_number?: boolean; name_on_invoice?: boolean; client_code?: boolean; client_name?: boolean; client_local_name?: boolean; client_address?: boolean; client_phone?: boolean; client_tax_number?: boolean; client_cell_phone?: boolean; issue_date?: boolean; due_date?: boolean; invoice_status?: boolean; company_logo?: boolean; serial_number?: boolean; advanced_serial_number?: boolean; external_serial_number?: boolean; comment?: boolean; qr_code?: boolean; custom_status?: boolean; payments_data?: boolean; media?: boolean; address?: boolean; remaining_balance?: boolean; invoice_header?: string; invoice_notes?: string; client_balance?: boolean; origin_serial_number?: boolean; origin_advanced_serial_number?: boolean; workorder_serial_number?: boolean; workorder_name?: boolean; workorder_local_name?: boolean; total_items_base_unit_qty?: boolean; total_items_qty?: boolean; total_return_items_base_unit_qty?: boolean; total_return_items_qty?: boolean; } export interface InvoiceLineItemDetails { sku?: boolean; barcode?: boolean; product_name?: boolean; variant_name?: boolean; measureunit?: boolean; qty?: boolean; price?: boolean; discount_amount?: boolean; line_total?: boolean; return_reason?: boolean; base_unit_qty?: boolean; original_price?: boolean; total_original_price?: boolean; item_image?: ItemImage; batch_number?: boolean; batch_expiry?: boolean; batch_qty?: boolean; } export interface InvoiceMobileDetails { logo_height?: number | string; logo_width?: number | string; align_logo?: Alignment; align_invoice_header?: Alignment; font_styles?: InvoiceFontsWithSizes[]; hide_invoice_payment_type?: boolean; invoice_header?: string; client_balance?: boolean; } export interface InvoiceDetails { document_type: "invoice"; compressed_media_size?: ImageSize; logo_size?: ImageSize; qr_code_size?: QrCodeSize; basicDetails?: InvoiceBasicDetails; lineItemDetails?: InvoiceLineItemDetails; mobileDetails?: InvoiceMobileDetails; } // Proforma Print Settings export interface ProformaBasicDetails { created_at?: boolean; created_by?: boolean; tax_number?: boolean; name_on_invoice?: boolean; client_code?: boolean; client_name?: boolean; client_local_name?: boolean; client_address?: boolean; client_phone?: boolean; client_tax_number?: boolean; client_cell_phone?: boolean; issue_date?: boolean; order_status?: boolean; company_logo?: boolean; serial_number?: boolean; external_serial_number?: boolean; comment?: boolean; custom_status?: boolean; media?: boolean; address?: boolean; invoice_header?: string; invoice_notes?: string; total_items_base_unit_qty?: boolean; total_items_qty?: boolean; total_return_items_base_unit_qty?: boolean; total_return_items_qty?: boolean; } export interface ProformaLineItemDetails { product_name?: boolean; variant_name?: boolean; sku?: boolean; barcode?: boolean; measureunit?: boolean; qty?: boolean; price?: boolean; line_total?: boolean; note?: boolean; base_unit_qty?: boolean; item_image?: ItemImage; return_reason?: boolean; original_price?: boolean; total_original_price?: boolean; batch_number?: boolean; batch_expiry?: boolean; batch_qty?: boolean; } export interface ProformaMobileDetails { logo_height?: number | string; logo_width?: number | string; align_logo?: Alignment; font_styles?: InvoiceFontsWithSizes[]; align_invoice_header?: Alignment; hide_invoice_payment_type?: boolean; invoice_header?: string; } export interface ProformaDetails { document_type: "proforma"; compressed_media_size?: ImageSize; logo_size?: ImageSize; basicDetails?: ProformaBasicDetails; lineItemDetails?: ProformaLineItemDetails; mobileDetails?: ProformaMobileDetails; } // Settlement Print Settings export interface SettlementBasicDetails { creator?: boolean; settlement_date?: boolean; company_logo?: boolean; serial_number?: boolean; note?: boolean; amount?: boolean; payment_type?: boolean; checks?: boolean; rep?: boolean; totals?: boolean; media?: boolean; } export interface SettlementCheckDetails { bank_name?: boolean; branch_name?: boolean; drawer_name?: boolean; client_name?: boolean; check_number?: boolean; pay_time?: boolean; rep_name?: boolean; check_date?: boolean; } export interface SettlementDetails { document_type: "settlement"; compressed_media_size?: ImageSize; basicDetails?: SettlementBasicDetails; checkDetails?: SettlementCheckDetails; } // Union type for all details export type Details = | WorkorderDetails | FormResultDetails | InvoiceDetails | ProformaDetails | SettlementDetails; // Main PrintSetting Schema export interface Data { _id: string; creator: User; editor?: User; document_type: PrintTypes; details: Details; company_namespace: string[]; createdAt: Date; updatedAt: Date; __v?: number; } export interface CreateBody { document_type: PrintTypes; details: Details; } export interface UpdateBody { details?: Partial
; } export namespace Find { export type Params = DefaultPaginationQueryParams & { document_type?: PrintTypes | PrintTypes[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } } export namespace PdfTemplateGallery { export interface Data { _id: string; html_media?: string | MediaDoc; settings?: { [key: string]: any }; cover_photo?: string | MediaDoc; name: string; locale: "en" | "ar"; ai_prompt?: string; document_type: PrintTypes; disabled: boolean; createdAt: string; updatedAt: string; } export interface CreateBody { html_media?: string; settings?: { [key: string]: any }; cover_photo?: string; name: string; locale: "en" | "ar"; ai_prompt?: string; document_type: PrintTypes; disabled?: boolean; } export interface UpdateBody { html_media?: string; settings?: { [key: string]: any }; cover_photo?: string; name?: string; locale?: "en" | "ar"; ai_prompt?: string; document_type?: PrintTypes; } export type PopulatedDoc = Data & { html_media_populated?: MediaDoc; cover_photo_populated?: MediaDoc; }; type PopulatedKeys = "html_media" | "cover_photo"; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string | string[]; name?: string; locale?: "en" | "ar"; document_type?: PrintTypes; disabled?: boolean; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace PdfTemplate { export interface Data { _id: string; html_media?: string | MediaDoc; settings?: { [key: string]: any }; cover_photo?: string | MediaDoc; name: string; is_default: boolean; creator: AdminCreator; editor?: AdminCreator; locale: "en" | "ar"; pdf_template_gallery?: string; publish_time?: number | null; document_type: PrintTypes; disabled: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; } export interface CreateBody { html_media?: string; settings?: { [key: string]: any }; cover_photo?: string; name: string; is_default?: boolean; locale: "en" | "ar"; pdf_template_gallery?: string; publish_time?: number | null; document_type: PrintTypes; } export interface UpdateBody { html_media?: string; settings?: { [key: string]: any }; cover_photo?: string; name?: string; is_default?: boolean; locale?: "en" | "ar"; pdf_template_gallery?: string; publish_time?: number | null; document_type?: PrintTypes; } export type PopulatedDoc = Data & { html_media_populated?: MediaDoc; cover_photo_populated?: MediaDoc; pdf_template_gallery_populated?: PdfTemplateGallery.Data; }; type PopulatedKeys = "html_media" | "cover_photo" | "pdf_template_gallery"; export namespace Find { export type Params = DefaultPaginationQueryParams & { name?: string | string[]; locale?: "en" | "ar" | ("en" | "ar")[]; document_type?: PrintTypes | PrintTypes[]; is_default?: boolean; pdf_template_gallery?: string | string[]; publish_time?: number | (number | null)[]; disabled?: boolean; _id?: string | string[]; "creator._id"?: string | string[]; "editor._id"?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace OptionalBusinessAppService { export namespace Find { export interface Result { code: string; services: { permission: StringId; name: string; default_teams_shared: "shared" | "unshared"; }[]; } } export namespace Create { export interface Result { code: string; services: { permission: StringId; name: string; teams_shared: "shared" | "unshared"; }[]; } } } export namespace PdfMergeField { export interface Data { _id: string; document_type: PrintTypes; key: string; description?: string; label?: string; is_array: boolean; type: "string" | "number" | "media" | "date" | "boolean" | "object"; has_children?: boolean; format?: string; required: boolean; sample_value?: any; children?: Data[]; createdAt?: Date; updatedAt?: Date; } export interface CreateBody { document_type: PrintTypes; key: string; description?: string; label?: string; is_array: boolean; type: "string" | "number" | "media" | "date" | "boolean" | "object"; has_children?: boolean; format?: string; required: boolean; sample_value?: any; children?: Data[]; } export interface UpdateBody { document_type?: PrintTypes; key?: string; description?: string; label?: string; is_array?: boolean; type?: "string" | "number" | "media" | "date" | "boolean" | "object"; has_children?: boolean; format?: string; required?: boolean; sample_value?: any; children?: Data[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: string | string[]; document_type?: PrintTypes | PrintTypes[]; key?: string; label?: string; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = string; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace PromotionUsage { export interface Data { usage_per: "promo" | "client" | "rep"; promo: StringId; rep?: StringId; client?: StringId; count: number; } export namespace Find { export type Params = DefaultPaginationQueryParams & { [key: string]: any; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } } export namespace LatestSerial { export interface Data { refund: number; payment: number; transfer: number; proforma: number; returns: number; return_proforma: number; invoice: number; settlement: number; formResult: number; workorder: number; approval_request: number; } export namespace Find { export type Params = DefaultPaginationQueryParams & { repidentifier: number; [key: string]: any; }; export type Result = Data; } } export namespace FormV2 { export interface Visibility { operator: "and" | "or"; conditions: { division_id: string; field_id: string; type: "Boolean" | "List" | "YesNo"; // FieldType; custom_list?: string | CustomList.Data; operator: "lte" | "lt" | "gte" | "gt" | "eq" | "ne" | "in" | "nin"; value: any[]; }[]; } export const fieldType_enums = [ "Text", // Long Text "String", // Short Text "Phone", // phone "Email", // email "Date", // Date // "Boolean", // No need any more in this form "Number", // Number "List", // List => custom List with ref or template (Allow multi, not only for media) "Separator", // Separator "Heading", // Heading "Media", // Media + phone + Image "Signature", // signature "DateTime", // timestamp "YesNo", // Yes/No/NA (with disable N/A option ) "ProductBarcodeScan", // String "BarcodeScan", // String "GeoPoint", // { coordinates: [0, 0], type: "Point" } ] as const; export type FormV2FieldType = (typeof fieldType_enums)[number]; interface FieldPrintSettings { three_inch: { grid_column?: 1 | 2; alignment?: "right" | "left" | "center"; border_width?: number; label_font_size?: number; value_font_size?: number; media_height?: number | string; media_width?: number | string; align_media?: "right" | "left" | "center"; label_value_spacing?: number; is_hidden?: boolean; }; } interface UsedField { code: string; key: string; data_type: AvailableField.Data["data_type"]; field_type: | "template_field" // | "calculated_field" | "source_attribute" | "activity_attribute"; label: string; isArray?: boolean; formula_key: string; field_id?: string; example_value: AvailableField.Data["data_type"]; manipulator_function?: string; lookup?: { from?: string; localField?: string; foreignField?: string; as?: string; select?: string; unwind?: boolean; filter?: { input?: string; as: string; cond: any; }; }; } export interface Field { _id?: string; name: string; local_name?: string; description?: string; local_description?: string; type: FormV2FieldType; isArray?: boolean; isRequired?: boolean; disabled?: boolean; formula_key?: string; scoring_enabled?: boolean; required_for_completion?: boolean; visibility?: Visibility; default_value?: any[]; custom_list?: string | CustomList.Data; is_na_allowed?: boolean; score_accumulator_type?: "max" | "sum"; yes_score?: number; no_score?: number; na_score?: number; exist_score?: number; media?: (string | MediaDoc)[]; invisible: boolean; parent_field?: string; custom_list_element?: string; force_live_photo?: boolean; min?: number; max?: number; is_integer?: boolean; styles?: "check_list" | "toggle_yes_no_na" | "toggle_yes_no" | "buttons"; field_print_settings?: FieldPrintSettings; is_calculated_field?: boolean; formula?: string; used_fields?: UsedField[]; } interface Division { _id: string; name: string; local_name?: string; description?: string; local_description?: string; disabled?: boolean; min_questions_to_answer_for_completion?: number; min_score_for_completion?: number; visibility?: Visibility; fields: Field[]; } interface PrintSettings { three_inch: { grid_columns?: 1 | 2; logo_height?: number | string; logo_width?: number | string; align_logo?: "right" | "left" | "center"; space_y?: number; }; A_four: { banner_media?: string | MediaDoc; banner_height: number; banner_width: number; align_banner: "right" | "left" | "center"; header_label_font_size: number; header_value_font_size: number; align_header: "right" | "left" | "center"; division_name_font_size: number; align_division: "right" | "left" | "center"; grid_columns: 1 | 2 | 3 | 4; space_y: number; field_label_size: number; field_value_size: number; footer_media?: string | MediaDoc; align_footer_media: "right" | "left" | "center"; footer_media_height: number; footer_media_width: number; footer_details: string; align_footer_details: "right" | "left" | "center"; compressed_media_size: "original" | "small" | "medium" | "large" | "extra"; view_custom_list_element: boolean; }; } export interface Data { _id: string; disabled: boolean; name: string; local_name?: string; description?: string; local_description?: string; copied_from?: string; scoring_enabled?: boolean; completion_rules_enabled?: boolean; min_questions_to_answer_for_completion?: number; min_score_for_completion?: number; divisions: Division[]; company_namespace: string[]; print_settings?: PrintSettings; client_can_view_template: boolean; createdAt: Date; updatedAt: Date; } export interface CreateBody { disabled?: boolean; name: string; local_name?: string; description?: string; local_description?: string; copied_from?: string; scoring_enabled?: boolean; completion_rules_enabled?: boolean; min_questions_to_answer_for_completion?: number; min_score_for_completion?: number; divisions: Division[]; company_namespace?: string[]; print_settings?: PrintSettings; client_can_view_template?: boolean; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { presentation_populated?: CLMPresentation.Data; sequence_populated?: Pick< CLMSequence.Data, "position" | "_id" | "product" | "presentation" >[]; photo_media_populated?: PopulatedMediaStorage & { ContentLength?: number; }; }; type PopulatedKeys = "custom_list" | "media" | "banner_media" | "footer_media"; type SortingKeys = "_id" | "position" | "updatedAt"; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; search?: string; name?: string; scoring_enabled?: boolean | boolean[]; completion_rules_enabled?: boolean | boolean[]; disabled?: boolean; client_can_view_template?: boolean; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc & { can_edit_types?: boolean }; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace ActivityFormV2Result { export const fieldType_enums = [ "Text", // Long Text "String", // Short Text "Phone", // phone "Email", // email "Date", // Date // "Boolean", // No need any more in this form "Number", // Number "List", // List => custom List with ref or template (Allow multi, not only for media) "Separator", // Separator "Heading", // Heading "Media", // Media + phone + Image "Signature", // signature "DateTime", // timestamp "YesNo", // Yes/No/NA (with disable N/A option ) "ProductBarcodeScan", // String "BarcodeScan", // String "GeoPoint", // { coordinates: [0, 0], type: "Point" } ] as const; export type FormV2FieldType = (typeof fieldType_enums)[number]; export interface FieldResult { _id?: string; field_id: string; name: string; type: FormV2FieldType; isArray?: boolean; isRequired?: boolean; custom_list?: string; formula_key?: string; is_calculated_field?: boolean; calculation_status?: "success" | "failed"; calculation_error?: any[]; score?: number; is_completed?: boolean; result: | string[] | number[] | ["yes"] | ["no"] | ["na"] | [] | { coordinates: [number, number]; type: "Point" }[] | { _id: string; value: string | number; type: "Number" | "String"; score?: number; }[]; } export interface DivisionResult { _id?: string; division_id: string; name: string; score?: number; is_completed?: boolean; fields: FieldResult[]; } export interface Data { _id: StringId; creator: AdminOrRepOrTenantOrClient; editor?: AdminOrRepOrTenantOrClient; serial_number: SerialNumber; teams: StringId[]; tags: StringId[]; time: number; client?: StringId; client_name?: string; visit?: StringId; visit_id?: string; route?: StringId; workorder?: StringId; sync_id: string; status?: "pending" | "approved" | "processing" | "rejected"; // mobile data geo_tag?: GeoTag; geoPoint?: GeoPoint; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; time_zone?: string; job_start_time?: number; job_end_time?: number; job_duration?: number; form_id: StringId; results: DivisionResult[]; score?: number; is_completed: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { creator: AdminOrRepOrTenantOrClient; serial_number?: SerialNumber; teams?: StringId[]; tags?: StringId[]; time?: number; client?: StringId; client_name?: string; visit?: StringId; visit_id?: string; route?: StringId; workorder?: StringId; sync_id: string; geo_tag?: GeoTag; geoPoint?: GeoPoint; platform?: string; version_name?: string; battery_level?: number; device_brand?: string; device_os?: string; device_os_version?: string; device_model?: string; identifier?: number; device_id?: string; device_unique_id?: string; network_state?: number; time_zone?: string; job_start_time?: number; job_end_time?: number; job_duration?: number; form_id: StringId; results: DivisionResult[]; score?: number; is_completed?: boolean; status?: "pending" | "approved" | "processing" | "rejected"; company_namespace?: string[]; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { presentation_populated?: CLMPresentation.Data; sequence_populated?: Pick< CLMSequence.Data, "position" | "_id" | "product" | "presentation" >[]; photo_media_populated?: PopulatedMediaStorage & { ContentLength?: number; }; cycle?: Cycle.Data; }; type PopulatedKeys = | "custom_list" | "client" | "workorder" | "visit" | "route" | "form_id" | "teams" | "tags" | "media"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; search?: string; from_time?: number; to_time?: number; client?: StringId | StringId[]; tags?: StringId | StringId[]; CLIENT_TAGS?: StringId | StringId[]; AREA_TAGS?: StringId | StringId[]; form_id?: StringId | StringId[]; teams?: StringId | StringId[]; route?: StringId | StringId[]; is_completed?: boolean; from_score?: number; to_score?: number; score?: number | number[]; "creator._id"?: StringId | StringId[]; "creator.type"?: Data["creator"]["type"] | Data["creator"]["type"][]; visit_id?: string | string[]; visit?: StringId | StringId[]; workorder?: StringId | StringId[]; "serial_number.formatted"?: string | string[]; status?: Data["status"] | Data["status"][]; nodeCycles?: StringId[] | StringId; withCycle?: boolean; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; withCycle?: boolean; }; export type Result = PopulatedDoc & { can_edit_types?: boolean }; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody & { isResubmitted?: boolean; note?: string; stage?: number; }; export type Result = Data; } export namespace Patch { export type Params = { updateStatus: true }; export type Body = { readQuery: [{ key: "_id"; operator: "in"; value: StringId[] }]; writeQuery: { key: "status"; command: "set"; value: "approved" | "rejected"; }; }; export type Result = { nFound: number; nModified: number }; } } export namespace LineClassification { export interface Data { _id: StringId; name: string; local_name?: string; disabled: boolean; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name: string; local_name?: string; disabled?: boolean; } export type UpdateBody = Partial; export namespace Find { export type Params = DefaultPaginationQueryParams & { search?: string; _id?: StringId | StringId[]; disabled?: boolean | boolean[]; name?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Params = { [key: string]: any }; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type Body = PatchAction.UpdateBody; export interface Result { nFound: number; nModified: number; } } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace Line { export interface Data { _id: StringId; name: string; local_name?: string; disabled: boolean; icon?: string; icon_media?: StringId; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name: string; local_name?: string; disabled?: boolean; icon?: string; icon_media?: StringId; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { icon_media: StringId | MediaDoc; }; type PopulatedKeys = "icon_media"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys | PopulatedKeys[]; search?: string; _id?: StringId | StringId[]; name?: string | string[]; disabled?: boolean | boolean[]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { export type Body = PatchAction.UpdateBody; export interface Result { nFound: number; nModified: number; } } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace ClientLine { export interface Data { _id: StringId; client: StringId; classification: StringId; line: StringId; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; client: StringId; classification: StringId; line: StringId; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { client: StringId | Client.Data; classification: StringId | LineClassification.Data; line: StringId | Line.Data; }; type PopulatedKeys = "client" | "classification" | "line"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; client?: StringId | StringId[]; line?: StringId | StringId[]; classification?: StringId | StringId[]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace ScheduledEmails { export const reports = [ "storecheck-checkout", "storecheck-freshness", "storecheck-outofstock", "storecheck-planogram", "storecheck-pricing", "storecheck-secondary", "storecheck-shelfshare", "storecheck-stock", "visit-report", "schedule-report", "target-result", "item-status-report", "time-clock-report", "frequency-report", "retail-execution-report", "receiving-material", "proforma", "adjust-account", "unvisited-report", "legacy-jobs-report", "sales-analytics-report", "pre-sales-analytics-report", "inventory-analytics-report", "inventory-transaction-report", "activity-form-result", "workorder-report", "planned-workorder-report", "statement-report", "coverage-report", "activity-note-report", "activity-audit", "activity-photo", "activity-task", "activity-feedback", "media-storage-report", "client-balance-report", "rep-balance-report", "activity-form-v2-report", "payment-report", "financial-transaction-report", "nps-assessment-report", "accounts-balance-as-of-report", "inventory-balance-as-of-report", "product-audit-trace", "bi-view-calc", "events-log", "approval-request-report", "contract-report", "contract-installment-report", "asset-part-unit-report", "ageing-summary-report", "client-target-sheet", "frequency-report-v2", "fullinvoice-report", "bulk-export", ] as const; interface NamingKey { key: string; value: string; type: "string" | "number" | "boolean"; isArray?: boolean; } export interface Data { _id: StringId; name: string; creator: { _id: StringId; name: string; type: "admin"; admin?: StringId }; nextEmailSendingTime: number; lang?: string; report_method?: "find" | "create"; report: (typeof reports)[number]; emails: string[]; disabled: boolean; full_cycle?: boolean; time_period_tense?: "last" | "current"; every: "day" | "week" | "month" | "once"; time_day?: | "00:00" | "02:00" | "04:00" | "06:00" | "07:00" | "08:00" | "10:00" | "12:00" | "14:00" | "16:00" | "18:00" | "20:00" | "22:00"; day_week?: "Sun" | "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat"; day_month?: number; filter: { [key: string]: any }; processed?: boolean; tries?: number; lastSuccessfulProcess?: number; lastSuccessfulEmail?: number; links: { link: string; bucket_name?: string; region?: string; key?: string; media?: StringId[]; contentLength?: number; }[]; _errors: any[]; export_type: "excel" | "json" | "zip" | "parquet"; buildingAt?: Date; readyAt?: Date; queuedAt?: Date; state: "queued" | "ready" | "building" | "failed" | "deleted" | "updated"; template?: StringId; report_view?: StringId; compressed_media_size?: "original" | "small" | "medium" | "large" | "extra"; file_naming?: NamingKey[]; group_naming?: NamingKey[]; bi_view?: StringId; row_count?: number; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { company_namespace?: string[]; name: string; creator: { _id: StringId; name: string; type: "admin"; admin?: StringId }; lang?: string; report_method?: Data["report_method"]; report: (typeof reports)[number]; emails: string[]; disabled?: boolean; full_cycle?: boolean; time_period_tense?: Data["time_period_tense"]; every: Data["every"]; time_day?: Data["time_day"]; day_week?: Data["day_week"]; day_month?: number; filter: { [key: string]: any }; export_type: Data["export_type"]; template?: StringId; report_view?: StringId; compressed_media_size?: Data["compressed_media_size"]; file_naming?: NamingKey[]; group_naming?: NamingKey[]; bi_view?: StringId; } export type UpdateBody = Partial; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; search?: string; disabled?: boolean; every?: Data["every"] | Data["every"][]; report?: Data["report"] | Data["report"][]; "creator._id"?: StringId | StringId[]; report_view?: StringId | StringId[]; export_type?: Data["export_type"] | Data["export_type"][]; state?: Data["state"] | Data["state"][]; template?: StringId | StringId[]; time_period_tense?: Data["time_period_tense"] | Data["time_period_tense"][]; full_cycle?: boolean; row_count?: number | number[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = string; export type Params = {}; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace DataFileWarehouse { export const dataFileWarehouseReports = [ "storecheck-checkout", "storecheck-freshness", "storecheck-outofstock", "storecheck-planogram", "storecheck-pricing", "storecheck-secondary", "storecheck-shelfshare", "storecheck-stock", "visit-report", "item-status-report", "receiving-material", "proforma", "adjust-account", "legacy-jobs-report", "sales-analytics-report", "pre-sales-analytics-report", "inventory-analytics-report", "inventory-transaction-report", "activity-note-report", "activity-audit", "activity-photo", "activity-task", "activity-feedback", "payment-report", "financial-transaction-report", "product-audit-trace", "events-log", "approval-request-report", "contract-report", "asset-part-unit-report", "contract-installment-report", // "ageing-summary-report", "fullinvoice-report", "product", "variant", "category", "subCategory", "rep", "tag", "warehouse", "productGroup", "speciality", "measureunit", "measureunitFamily", "promotions", "supplier", "routes", "rules", "routesWithClients", "availabilityMsl", "availabilityMslWithProducts", "mslWithVariants", "jobCategories", "jobs", "plans", "planWithRules", "targetRulesWithClients", "rulesWithRoutes", "targetRulesWithReps", "priceListItems", "assets", "assetUnits", "reminders", "clientLocation", "variantBatch", "banksList", "targetRule", // "contracts", // "contractInstallment", "lineTarget", "assetPartTypes", "assetParts", // "customListItems", "clientLineClassification", "retailExecutionPresets", "clientBalance", "repBalance", "clientUblInfo_JO", "clientUblInfo_SA", // "admins", "clients", ] as const; export interface Data { _id: StringId; company_namespace: string[]; name_space: string; teams: StringId[]; creator: AdminOrRepOrTenantOrClient; report: (typeof dataFileWarehouseReports)[number]; data_type: "static" | "report"; timespan: "years" | "months" | "days"; start_year: number; end_year: number; start_month: number; end_month: number; start_day: number; end_day: number; time_zone: string; offset_EOD: string; // "03:00" status: "pending" | "queued" | "ready" | "building" | "failed"; partial_status: "partial" | "full"; from: number; to: number; scheduled_email?: StringId; media?: StringId; link?: string; row_count?: number; disabled: boolean; readyAt?: number; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name_space?: string; teams?: StringId[]; creator?: AdminOrRepOrTenantOrClient; report: (typeof dataFileWarehouseReports)[number]; data_type: "static" | "report"; timespan: "years" | "months" | "days"; start_year: number; end_year: number; start_month: number; end_month: number; start_day: number; end_day: number; time_zone?: string; offset_EOD?: string; partial_status: "partial" | "full"; from: number; to: number; disabled?: boolean; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { scheduled_email?: ScheduledEmails.Data; media?: PopulatedMediaStorage; }; type PopulatedKeys = "scheduled_email" | "media"; type SortingKeys = "_id" | "updatedAt" | "createdAt"; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; report?: Data["report"] | Data["report"][]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; scheduled_email?: StringId | StringId[]; row_count?: number | number[]; teams?: StringId | StringId[]; "creator._id"?: StringId | StringId[]; "creator.type"?: Data["creator"]["type"] | Data["creator"]["type"][]; status?: Data["status"] | Data["status"][]; data_type?: Data["data_type"] | Data["data_type"][]; partial_status?: Data["partial_status"] | Data["partial_status"][]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace DataSession { export interface Data { _id: StringId; company_namespace: string[]; ai_chat_session: StringId; sync_id: string; teams: StringId[]; creator: AdminOrRepOrTenantOrClient; from: string; to: string; time: number; reports: DataFileWarehouse.Data["report"][]; data_file_warehouse_ids: StringId[]; status: "pending" | "ready" | "building" | "failed"; createdAt: string; updatedAt: string; } export interface CreateBody { company_namespace?: string[]; ai_chat_session: StringId; sync_id: string; teams?: StringId[]; creator?: AdminOrRepOrTenantOrClient; from: string; to: string; time?: number; reports: DataFileWarehouse.Data["report"][]; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { data_file_warehouse_ids?: DataFileWarehouse.Data[]; }; type PopulatedKeys = "data_file_warehouse_ids"; type SortingKeys = "_id" | "createdAt" | "updatedAt"; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; ai_chat_session?: StringId | StringId[]; from?: string; to?: string; reports?: DataFileWarehouse.Data["report"] | DataFileWarehouse.Data["report"][]; teams?: StringId | StringId[]; data_file_warehouse_ids?: StringId | StringId[]; status?: Data["status"] | Data["status"][]; sync_id?: string | string[]; from__id?: StringId | StringId[]; to__id?: StringId | StringId[]; "creator._id"?: StringId | StringId[]; "creator.type"?: Data["creator"]["type"] | Data["creator"]["type"][]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace Admin { export interface Data { _id: StringId; email: string; name: string; phone?: string; disabled: boolean; profile_photo?: string; notification_id?: string; password: string; owner?: boolean; repzo_internal_user?: boolean; can_reset_namespace?: boolean; permissions: { client: { can_view_list?: boolean; can_add?: boolean; can_edit?: boolean; can_verify?: boolean; can_disable?: boolean; can_enable?: boolean; can_export_client?: boolean; can_reset_location?: boolean; }; representative: { can_change_password?: boolean; can_change_permission?: boolean; can_edit?: boolean; can_add?: boolean; can_view_list?: boolean; }; settings: { can_view_settings?: boolean; }; sales: { edit_purchase_order?: boolean; approve_purchase_order?: boolean; approve_invoice?: boolean; cancelled_invoice?: boolean; cancelled_purchase_order?: boolean; }; reports: { purchase_order?: boolean; invoice?: boolean; visit?: boolean; note?: boolean; photo?: boolean; task?: boolean; representative?: boolean; client_coverage_by_tag?: boolean; client_coverage_by_area?: boolean; client_coverage?: boolean; route?: boolean; audit?: boolean; frequency?: boolean; unvisit?: boolean; can_view_reports?: boolean; }; timeline: { can_view_timeline?: boolean; }; form: { can_view_form_report?: boolean; can_create_form?: boolean; can_delete_form?: boolean; can_view_form?: boolean; }; product: { can_view_list?: boolean; can_add?: boolean; can_edit?: boolean; can_disable?: boolean; }; home: { can_view?: boolean }; }; teams: StringId[]; media?: StringId[]; cover_photo?: StringId; company_namespace: string[]; company_group: string; ai_administrator?: boolean; abilities: { ability: StringId; m_read: boolean; m_create: boolean; m_update: boolean; m_remove: boolean; }[]; last_login_time?: number; // Email MFA email_mfa_enabled: boolean; email_mfa_activate_time?: number; email_otp_blocked_until?: number; // WhatsApp MFA whatsapp_mfa_enabled: boolean; whatsapp_mfa_activate_time?: number; whatsapp_phone?: string; whatsapp_otp_blocked_until?: number; // Authenticator MFA authenticator_mfa_enabled: boolean; authenticator_mfa_activate_time?: number; authenticator_mfa_secret?: string; authenticator_otp_blocked_until?: number; // Recovery codes recovery_codes_mfa_enabled: boolean; recovery_codes_mfa_activate_time?: number; recovery_codes_otp_blocked_until?: number; recovery_codes?: string[]; recovery_codes_used?: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { email: string; name: string; password: string; phone?: string; disabled?: boolean; profile_photo?: string; notification_id?: string; owner?: boolean; permissions?: Data["permissions"]; teams?: StringId[]; media?: StringId[]; cover_photo?: StringId; company_namespace?: string[]; company_group?: string; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { media?: PopulatedMediaStorage[]; cover_photo?: PopulatedMediaStorage; abilities?: (Data["abilities"][0] & { ability: StringId | { name: string; _id: StringId }; })[]; role?: { _id: StringId; name: string }; }; type PopulatedKeys = "media" | "cover_photo" | "abilities"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; disabled?: boolean; teams?: StringId | StringId[]; name?: string | string[]; email?: string | string[]; search?: string; repzo_internal_user?: boolean; company_namespace?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys | PopulatedKeys[] }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Globalize { export type ID = StringId; export type Params = { globalize: true }; export type Body = {}; export type Result = { success: boolean }; } export namespace Remove { export type ID = string; export type Result = Data; } } export namespace VisitReason { export interface Data { _id: StringId; company_namespace: string[]; name: string; disabled: boolean; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name: string; disabled?: boolean; } export type UpdateBody = Partial; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; search?: string; name?: string | string[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace TargetRule { export type RuleType = | "rep-visit" | "time-clock" | "rep-photo" | "rep-invoice" | "rep-proforma" | "item-status" | "rep-payment"; export type Period = "daily" | "weekly" | "monthly" | "quarterly" | "yearly"; export interface Point { ratio: number; points: number; } export interface RepVisitFilter { filter: | "chain" | "channel" | "country" | "city" | "state" | "client" | "photoTag" | "clientTag" | "areaTag" | "from_total_time" | "to_total_time" | "from_call_total_time" | "to_call_total_time" | "feedback" | "activity" | "speciality"; value: any[]; photoCount?: number; } export interface RepVisitDetails { type?: "rep-visit"; filter: RepVisitFilter[]; limit?: number; aggregation_key: "count" | "count-distinct" | "duration"; period: Period; required_target: { type: "absolute" | "assigned_to"; value: number; }; } export interface TimeClockFilter { filter: | "from_startTime" | "to_startTime" | "from_endTime" | "to_endTime" | "from_timeOnDuty" | "to_timeOnDuty" | "from_breaksTime" | "to_breaksTime" | "from_timeInVisits" | "to_timeInVisits" | "from_totalTravelTime" | "to_totalTravelTime" | "from_travelTimeBetweenVisists" | "to_travelTimeBetweenVisists" | "from_scheduled" | "to_scheduled" | "from_unscheduled" | "to_unscheduled" | "from_missed" | "to_missed" | "closed_by_system"; value: any; } export interface TimeClockDetails { type?: "time-clock"; filter: TimeClockFilter[]; aggregation_key: | "count" | "timeOnDuty" | "breaksTime" | "timeInVisits" | "totalTravelTime" | "travelTimeBetweenVisists" | "scheduled" | "unscheduled" | "missed"; period: Period; limit?: number; required_target: { type: "absolute"; value: number; }; } export interface RepPhotoFilter { filter: | "chain" | "channel" | "country" | "city" | "state" | "client" | "photoTag" | "clientTag" | "areaTag" | "speciality"; value: any[]; } export interface RepPhotoDetails { type?: "rep-photo"; filter: RepPhotoFilter[]; limit?: number; aggregation_key: "count" | "count-distinct"; period: Period; required_target: { type: "absolute" | "assigned_to"; value: number; }; } export interface ItemStatusFilter { filter: | "teams" | "route" | "client" | "chain" | "channel" | "country" | "city" | "state" | "clientTag" | "areaTag" | "speciality" | "product" | "category" | "sub_category" | "brand" | "product_group" | "status" | "previous_status" | "item_status_type"; value: any[]; } export interface ItemStatusDetails { type?: "item-status"; filter: ItemStatusFilter[]; limit?: number; aggregation_key: "count" | "prescriptions"; period: Period; required_target: { type: "absolute"; value: number; }; } export interface RepPaymentFilter { filter: | "route" | "payment_type" | "status" | "client" | "chain" | "channel" | "country" | "city" | "clientTag" | "areaTag" | "teams" | "from_amount" | "to_amount" | "speciality" | "custom_status"; value: any[]; } export interface RepPaymentDetails { type?: "rep-payment"; filter: RepPaymentFilter[]; limit?: number; aggregation_key: "count" | "count-distinct" | "amount"; period: Period; required_target: { type: "absolute"; value: number; }; } export interface RepInvoiceFilter { filter: | "client" | "chain" | "channel" | "country" | "city" | "state" | "clientTag" | "areaTag" | "teams" | "product" | "variant" | "category" | "sub_category" | "brand" | "product_group" | "status" | "speciality" | "custom_status" | "from_base_unit_qty" | "to_base_unit_qty"; value: any[]; } export interface RepInvoiceDetails { type?: "rep-invoice"; filter: RepInvoiceFilter[]; limit?: number; aggregation_key: | "count" | "total" | "pre_total" | "return_total" | "count-distinct" | "qty"; period: Period; required_target: { type: "absolute"; value: number; }; } export interface RepProformaDetails { type?: "rep-proforma"; filter: RepInvoiceFilter[]; limit?: number; aggregation_key: | "count" | "total" | "pre_total" | "return_total" | "count-distinct" | "qty"; period: Period; required_target: { type: "absolute"; value: number; }; } export type Details = | RepVisitDetails | TimeClockDetails | RepPhotoDetails | ItemStatusDetails | RepPaymentDetails | RepInvoiceDetails | RepProformaDetails; export interface Data { _id: StringId; name: string; points: Point[]; allowOverOne?: boolean; type: RuleType; disabled: boolean; targets_group?: StringId; company_namespace: string[]; details: Details; cycle?: any; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name: string; type: RuleType; details: Details; points?: Point[]; allowOverOne?: boolean; targets_group?: StringId; disabled?: boolean; } export type UpdateBody = Partial; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; search?: string; name?: string | string[]; type?: RuleType | RuleType[]; targets_group?: StringId | StringId[]; "details.period"?: Period | Period[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace Plan { export interface Editor { _id: StringId; type: "admin" | "rep"; rep?: StringId; admin?: StringId; name?: string; } export interface BuildListItem { calendar?: StringId; route?: StringId; client?: StringId; note?: string; from?: string; to?: string; visit_reason?: StringId; visit_note?: string; } export interface BuildEntry { day: string; list: BuildListItem[]; } export interface Data { _id: StringId; name: string; editor?: Editor; startsAt?: string; endsAt?: string; build: BuildEntry[]; sync_id: string; calendars?: StringId[]; disabled: boolean; builtAt: number; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name: string; startsAt?: string; endsAt?: string; build?: BuildEntry[]; sync_id: string; calendars?: StringId[]; disabled?: boolean; builtAt?: number; } export type UpdateBody = Partial; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; search?: string; name?: string | string[]; disabled?: boolean; myDailyPlan?: boolean; timezone?: string; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Params = { populatedKeys?: string | string[] }; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace Calendar { export type CalendarType = "weekly" | "weeklyGroup"; export interface User { _id: StringId; type: "admin" | "rep"; rep?: StringId; admin?: StringId; name?: string; } export interface ClientEntry { client: StringId; from?: string; to?: string; visit_reason?: StringId; visit_note?: string; } export interface WeeklyDetails { type?: "weekly"; days: Day[]; every: number; } export interface DaysGroup { days: Day[]; } export interface WeeklyGroupDetails { type?: "weeklyGroup"; daysGroups: DaysGroup[]; groupSize: number; } export type Details = WeeklyDetails | WeeklyGroupDetails; export interface Data { _id: StringId; name: string; type: CalendarType; details: Details; creator: User; editor: User; routes?: StringId[]; sync_id: string; clients?: ClientEntry[]; occurrences?: number; startsAt: string; endsAt?: string; disabled: boolean; note?: string; visit_reason?: StringId; visit_note?: string; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; name: string; type: CalendarType; details: Details; sync_id: string; startsAt: string; endsAt?: string; routes?: StringId[]; clients?: ClientEntry[]; occurrences?: number; disabled?: boolean; note?: string; visit_reason?: StringId; visit_note?: string; } export type UpdateBody = Partial; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; search?: string; name?: string | string[]; type?: CalendarType | CalendarType[]; rep?: StringId | StringId[]; plan?: StringId | StringId[]; visit_reason?: StringId | StringId[]; groupSize?: number; from_groupSize?: number; to_groupSize?: number; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Params = { populatedKeys?: string | string[] }; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Params = { assignTo?: StringId; assignedToMe?: boolean; }; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace LineTarget { export type UserType = "rep" | "client"; export interface User { _id: StringId; name?: string; type?: UserType; rep?: StringId; client?: StringId; } export interface Data { _id: StringId; line: StringId; target: number; classification: StringId; user?: User; company_namespace: string[]; createdAt: string; updatedAt: string; __v?: number; } export interface CreateBody { company_namespace?: string[]; line: StringId; target: number; classification: StringId; user?: User; } export type UpdateBody = Partial; type PopulatedKeys = "client" | "rep" | "classification" | "line"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; line?: StringId | StringId[]; classification?: StringId | StringId[]; "user._id"?: StringId | StringId[]; rep?: StringId | StringId[]; client?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Params = { populatedKeys?: PopulatedKeys | PopulatedKeys[] }; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId | null; export type Params = { all?: boolean }; export interface Result { deletedCount: number; success: number; } } } export namespace BulkImport { type BulkImportType = | "insertTags" | "insertClients" | "insertReps" | "updateReps" | "updateClients" | "insertProducts" | "insertVariants" | "updateProducts" | "updateVariants" | "updateCategories" | "updateSubCategories" | "insertCategories" | "insertSubCategories" | "insertAvailabilityMsl" | "updateAvailabilityMsl" | "updateAvailabilityMslWithProducts" | "updateMslWithVariants" | "insertJobCategories" | "updateJobCategories" | "updateJobs" | "insertJobs" | "updateTags" | "insertRoutes" | "updateRoutes" | "updateRoutesWithClients" | "insertPlans" | "updatePlans" | "updatePlansWithRules" | "weeklyGroupRules" | "weeklyRules" | "updateRulesWithRoutes" | "updateTargetRulesWithClients" | "updateTargetRulesWithReps" | "insertTransfers" | "adjustAccounts" | "insertRules" | "updateRules" | "insertInvoices" | "insertWarehouses" | "updateWarehouses" | "insertProductGroups" | "updateProductGroups" | "updatePriceListItems" | "updateMeasureunit" | "insertMeasureunit" | "insertMeasureunitFamily" | "updateMeasureunitFamily" | "insertLineTarget" | "clientLineClassification" | "updateLineTarget" | "insertReceivingMaterials" | "insertRetailExecutionPresets" | "updateRetailExecutionPresets" | "insertCustomListItems" | "updateCustomListItems" | "insertAssets" | "updateAssets" | "insertAssetUnits" | "updateAssetUnits" | "insertSpeciality" | "updateSpeciality" | "insertClientLocation" | "updateClientLocation" | "deleteLineTarget" | "updatePromotions" | "insertReminders" | "updateReminders" | "insertVariantBatch" | "updateVariantBatch" | "insertSettlements" | "updateClientUblInfo" | "insertSuppliers" | "updateSuppliers" | "insertTargetRules" | "insertContractInstallments" | "updateContractInstallments" | "insertContracts" | "updateContracts" | "insertAssetPartTypes" | "updateAssetPartTypes" | "insertAssetParts" | "updateAssetParts"; interface ToBeInserted { model: Model; method?: "set" | "push"; __ref_doc?: boolean; handleSpecialProcess?: boolean; insertedDocs?: { [key: string]: any }[]; docs: { [key: string]: any }[]; } interface ToBeUpdated { model: Model; method?: "set" | "push"; __ref_doc?: boolean; key?: string; handleSpecialProcess?: boolean; docs: { [key: string]: any }[]; } interface ToBeDeleted { model: Model; method?: "set" | "push"; __ref_doc: boolean; handleSpecialProcess?: boolean; docs: { [key: string]: any }[]; } export interface Data { messages: string[]; _errors: string[]; _warnings: string[]; data: object; success: boolean; processed?: boolean; type: BulkImportType; creator: AdminOrRepOrTenantOrClient; editor?: AdminOrRepOrTenantOrClient; company_namespace: string[]; toBeInserted: ToBeInserted[]; toBeUpdated: ToBeUpdated[]; toBeDeleted: ToBeDeleted[]; second_phase_status?: "success" | "failed" | "partial"; status: | "building_report_in_progress" | "building_report_completed" | "building_report_failed" | "in_progress" | "success" | "failed" | "partial"; media?: StringId[]; _id: StringId; teams: string[]; createdAt: Date; updatedAt: Date; } export type CreateBody = FormData; export interface UpdateBody { company_namespace?: string[]; name?: string; disabled?: boolean; } export type PopulatedDoc = Data & { media?: StringId[] | MediaDoc[]; }; type PopulatedKeys = "media"; export namespace Find { export type Params = DefaultPaginationQueryParams & { populatedKeys?: PopulatedKeys | PopulatedKeys[]; processed?: boolean; success?: boolean; from_updatedAt?: number; to_updatedAt?: number; creator?: StringId | StringId[]; "creator._id"?: StringId | StringId[]; from_time?: number; to_time?: number; second_phase_status: Data["second_phase_status"] | Data["second_phase_status"][]; status?: Data["status"] | Data["status"][]; type?: Data["type"] | Data["type"][]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = StringId; export type Result = PopulatedDoc; } export namespace Create { export type Params = { type: Data["type"]; [key: string]: any }; export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Result = Data; } } export namespace BulkExport { export type BulkExportType = | "clients" | "products" | "variants" | "categories" | "subCategories" | "availabilityMsl" | "availabilityMslWithProducts" | "reps" | "mslWithVariants" | "jobCategories" | "jobs" | "tags" | "routes" | "routesWithClients" | "plans" | "planWithRules" | "targetRulesWithClients" | "rulesWithRoutes" | "targetRulesWithReps" | "adjustAccount" | "rules" | "warehouses" | "productGroups" | "priceListItems" | "measureunit" | "measureunitFamily" | "lineTarget" | "clientLineClassification" | "retailExecutionPresets" | "promotions" | "customListItems" | "assets" | "assetUnits" | "speciality" | "clientLocation" | "reminders" | "admins" | "companyGroup" | "company" | "variantBatch" | "banksList" | "clientUblInfo" | "supplier" | "contractInstallment" | "targetRule" | "contracts" | "assetPartTypes" | "assetParts" | "clientUblInfo_JO" | "clientUblInfo_SA" | "nameSpaceFreshnessWindowCodes"; export interface Data { _id: StringId; creator: AdminOrRepOrTenantOrClient; type: BulkExportType; status: "processing" | "success" | "fail"; messages: any[]; _errors: any[]; start_time: number; end_time?: number; bucket_name?: string; region?: string; key?: string; link?: string; media?: StringId[]; teams: string[]; export_type: "excel" | "parquet"; row_count?: number; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { export_type?: "excel" | "parquet"; columns?: { [key: string]: any }; name?: string; creator?: AdminOrRepOrTenantOrClient; company_namespace?: string[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; type?: BulkExportType; status?: Data["status"] | Data["status"][]; export?: boolean; export_type?: "excel" | "parquet"; from_updatedAt?: number; to_updatedAt?: number; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Create { export type Params = { type: BulkExportType; [key: string]: any }; export type Body = CreateBody; export type Result = Data; } } export namespace DeliveryNote { interface User { _id: string; name?: string; type: "admin" | "rep"; admin?: string; rep?: string; } type DeliveryNoteItem = { item_index: number; variant: { product_id: StringId; product_name: string; variant_id: | StringId | (Pick< Variant.Data, "_id" | "name" | "local_name" | "sku" | "barcode" > & { product: Pick< Product.Data, "_id" | "name" | "local_name" | "sku" | "barcode" >; }); variant_name: string; variant_local_name?: string; variant_img?: string; variant_cover_photo?: StringId; product_local_name?: string; product_img?: string; product_cover_photo?: StringId; product_sku?: string; product_barcode?: string; variant_sku?: string; variant_barcode?: string; }; } & Pick< Item.Data, | "_id" | "qty" | "measureunit" | "base_unit_qty" | "modifiers_groups" | "company_namespace" | "variant_batches" >; export interface Data { _id: StringId; company_namespace: string[]; serial_number: SerialNumber; status: | "pending" // when create | "processing" // after first transfer | "approved" // action from client | "rejected" // action from client | "canceled" // action from rep/admin to disabled the delivery note | "failed"; // when create but the items was reserved to another delivery-notes transaction_processed: boolean; qty_reserved: boolean; client_id: StringId; client_name: string; warehouse_id: StringId; warehouse_name: string; creator: User; editor?: User; implemented_by?: User; time?: number; teams: StringId[]; assigned_to: StringId[]; sync_id: string; visit_id?: string; client_geo_location?: { lat: number; lng: number }; network_state?: number; platform?: string; version_name?: string; battery_level?: number; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; invoice_id?: StringId; invoice_serial_number?: SerialNumber; proforma_id?: StringId; proforma_serial_number?: SerialNumber; active_transfer_id?: StringId; active_transfer_serial_number?: SerialNumber; items_count?: number; total_items_base_unit_qty?: number; total_measure_unit_qty?: number; items: DeliveryNoteItem[]; process_time?: number; failed_reasons?: { code: string; message: string }[]; signature?: StringId; note?: string; media?: StringId[]; integration_meta?: Record; create_transfer?: boolean; to_warehouse?: StringId; createdAt: Date; updatedAt: Date; } export interface CreateBody { company_namespace: string[]; serial_number?: SerialNumber; status?: "pending" | "approved" | "rejected"; transaction_processed?: boolean; qty_reserved?: boolean; client_id: StringId; client_name: string; warehouse_id: StringId; warehouse_name: string; creator?: User; implemented_by?: User; time?: number; teams?: StringId[]; assigned_to?: StringId[]; sync_id: string; visit_id?: string; client_geo_location?: { lat: number; lng: number }; network_state?: number; platform?: string; version_name?: string; battery_level?: number; time_zone?: string; identifier?: number; device_id?: string; device_unique_id?: string; invoice_id?: StringId; invoice_serial_number?: SerialNumber; proforma_id?: StringId; proforma_serial_number?: SerialNumber; active_transfer_id?: StringId; active_transfer_serial_number?: SerialNumber; items_count?: number; total_items_base_unit_qty?: number; total_measure_unit_qty?: number; items: DeliveryNoteItem[]; integration_meta?: Record; create_transfer?: boolean; to_warehouse?: StringId; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { client_populated?: Pick< Client.Data, "_id" | "name" | "client_code" | "local_name" >[]; warehouse_populated?: Pick[]; assigned_to_populated?: Pick[]; teams_populated?: Pick[]; invoice_id_populated?: Pick< FullInvoice.Data, | "_id" | "serial_number" | "return_serial_number" | "external_serial_number" | "advanced_serial_number" >[]; proforma_id_populated?: Pick< Proforma.Data, | "_id" | "serial_number" | "return_serial_number" | "external_serial_number" >[]; active_transfer_id_populated?: Pick< Transfer.Data, "_id" | "serial_number" | "status" >[]; media_populated?: PopulatedMediaStorage[]; signature_populated?: PopulatedMediaStorage; cycle?: Cycle.Schema & { approval?: string | Approval.Data }; }; type PopulatedKeys = | "variant_id" | "client_id" | "warehouse_id" | "assigned_to" | "teams" | "invoice_id" | "proforma_id" | "active_transfer_id" | "media" | "signature"; type SortingKeys = "_id" | "createdAt" | "updatedAt" | "time"; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; withCycle?: boolean; status?: Data["status"] | Data["status"][]; client_id?: StringId | StringId[]; warehouse_id?: StringId | StringId[]; teams?: StringId | StringId[]; assigned_to?: StringId | StringId[]; sync_id?: string | string[]; "serial_number.formatted"?: string | string[]; transaction_processed?: boolean; qty_reserved?: boolean; invoice_id?: StringId | StringId[]; proforma_id?: StringId | StringId[]; active_transfer_id?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; from_time?: number; to_time?: number; "creator._id"?: StringId | StringId[]; "creator.type"?: User["type"] | User["type"][]; "items.variant.product_id"?: StringId | StringId[]; "items.variant.variant_id"?: StringId | StringId[]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; withCycle?: boolean; }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } } export namespace Reservation { interface User { _id: StringId; name?: string; type: "admin" | "rep"; admin?: StringId; rep?: StringId; } interface Source { _id: StringId; type: "proforma" | "invoice"; serial_number: SerialNumber; invoice?: StringId; proforma?: StringId; } interface Item { item_index: number; _id: StringId; variant: { product_id: StringId | Product.Data; product_name: string; variant_id: StringId | Variant.Data; variant_name: string; variant_local_name?: string; variant_img?: string; variant_cover_photo?: StringId; product_local_name?: string; product_img?: string; product_cover_photo?: StringId; product_sku?: string; product_barcode?: string; variant_sku?: string; variant_barcode?: string; }; measureunit: { _id: StringId; parent: StringId; name: string; factor: number; disabled: boolean; company_namespace: string[]; }; qty: number; base_unit_qty?: number; } export interface Data { _id: StringId; company_namespace: string[]; serial_number: SerialNumber; qty_reserved: boolean; warehouse_id: StringId; warehouse_name: string; client_id?: StringId; client_name?: string; creator: User; editor?: User; time?: number; teams?: StringId[]; sync_id: string; type: "free" | "automated"; status: "active" | "revoked" | "cancelled"; source?: Source; items_count?: number; total_items_base_unit_qty?: number; total_measure_unit_qty?: number; items: Item[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { company_namespace: string[]; serial_number?: SerialNumber; qty_reserved?: boolean; warehouse_id: StringId; warehouse_name: string; client_id?: StringId; client_name?: string; creator?: User; time?: number; teams?: StringId[]; sync_id: string; type: "free" | "automated"; status?: "active" | "revoked" | "cancelled"; source?: Source; items_count?: number; total_items_base_unit_qty?: number; total_measure_unit_qty?: number; items: Item[]; } export type UpdateBody = Partial; export type PopulatedDoc = Data & { client_populated?: Pick< Client.Data, "_id" | "name" | "client_code" | "local_name" >[]; warehouse_populated?: Pick[]; teams_populated?: Pick[]; }; type PopulatedKeys = "client_id" | "warehouse_id" | "teams"; // | "variant_id" type SortingKeys = "_id"; export namespace Find { export type Params = DefaultPaginationQueryParams & { sortBy?: { field: SortingKeys; type: "asc" | "desc" }[]; populatedKeys?: PopulatedKeys | PopulatedKeys[]; _id?: StringId | StringId[]; status?: Data["status"] | Data["status"][]; client_id?: StringId | StringId[]; warehouse_id?: StringId | StringId[]; teams?: StringId | StringId[]; sync_id?: string | string[]; "serial_number.formatted"?: string | string[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; "creator._id"?: StringId | StringId[]; "creator.type"?: User["type"] | User["type"][]; "items.variant.product_id"?: StringId | StringId[]; "items.variant.variant_id"?: StringId | StringId[]; type?: Data["type"] | Data["type"][]; "source.type"?: Source["type"] | Source["type"][]; "source._id"?: StringId | StringId[]; "source.serial_number.formatted"?: string | string[]; }; export interface Result extends DefaultPaginationResult { data: PopulatedDoc[]; } } export namespace Get { export type ID = string; export type Params = { populatedKeys?: PopulatedKeys[]; withCycle?: boolean; }; export type Result = PopulatedDoc; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } } export namespace AiObjectDetectionDataset { export interface Data { _id: StringId; /** Unique per namespace (compound unique index on `company_namespace` + `name`). */ name: string; /** `ai-object-detection-label` ids that make up the dataset. */ dataset_labels: StringId[]; /** `ai-object-detection-model` used by default when training/predicting on this dataset. */ default_model?: StringId; /** Pinned `ai-object-detection-model-version`. `null`/absent = "latest" → resolved to the model's `current_model_version` at inference time. */ default_model_version?: StringId | null; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = "dataset_labels" | "default_model" | "default_model_version"; /** Populated refs are emitted under `_populated`; the original field keeps the id(s). */ export interface DataWithPopulatedKeys extends Data { dataset_labels_populated?: AiObjectDetectionLabel.Data[]; default_model_populated?: AiObjectDetectionModel.Data | null; default_model_version_populated?: AiObjectDetectionModelVersion.Data | null; } export interface CreateBody { name: string; dataset_labels: StringId[]; default_model?: StringId; /** Version `_id` to pin, or `"latest"` / `""` / `null` to track the model's `current_model_version` (the sentinel is normalized to `null` server-side, never cast to an ObjectId). */ default_model_version?: StringId | "latest" | null; company_namespace?: string[]; } export interface UpdateBody { name?: string; dataset_labels?: StringId[]; default_model?: StringId; /** Send `"latest"` / `""` / `null` to actively CLEAR a previously pinned version. */ default_model_version?: StringId | "latest" | null; /** Set `true` to soft-delete. */ disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; /** Datasets containing any of the given label ids. */ dataset_labels?: StringId | StringId[]; default_model?: StringId | StringId[]; default_model_version?: StringId | StringId[]; /** Case-insensitive regex match on `name`. */ search?: string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = DataWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace AiObjectDetectionModel { /** Free-form Ultralytics train args; the HUB endpoint reads `train_settings[0].epochs` / `.imgsz`. */ export interface TrainSettings { epochs?: number; imgsz?: number; batch?: number; [key: string]: any; } /** Free-form predict args; inference reads `predict_settings[0].conf` / `.iou` / `.agnostic_nms` as defaults. */ export interface PredictSettings { conf?: number; iou?: number; agnostic_nms?: boolean; [key: string]: any; } export interface Data { _id: StringId; /** Must match `^[a-zA-Z_][a-zA-Z0-9_\s]*$`; unique per namespace. */ name: string; train_settings?: TrainSettings[]; predict_settings?: PredictSettings[]; /** Resolution target for every unpinned ("latest") reference. Auto-advanced (forward-only) to the newest version whose weights upload completes. */ current_model_version?: StringId; /** Validation split ratio, exclusive range (0.05, 0.4). Default 0.25. */ validation_size?: number; /** Test split ratio, exclusive range (0, 0.2). Default 0.05. */ test_size?: number; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = "current_model_version"; /** The version document with its weight / train-data / confusion-matrix media refs populated in place (no `_populated` suffix on the nested keys). */ export type PopulatedCurrentModelVersion = Omit< AiObjectDetectionModelVersion.Data, | "weight_best" | "weight_last" | "train_data" | "confusion_matrix" | "confusion_matrix_normalized" > & { weight_best?: MediaStorage.MediaStorageSchema | null; weight_last?: MediaStorage.MediaStorageSchema | null; train_data?: MediaStorage.MediaStorageSchema | null; confusion_matrix?: MediaStorage.MediaStorageSchema | null; confusion_matrix_normalized?: MediaStorage.MediaStorageSchema | null; }; export interface DataWithPopulatedKeys extends Data { current_model_version_populated?: PopulatedCurrentModelVersion | null; } export interface CreateBody { name: string; train_settings?: TrainSettings[]; predict_settings?: PredictSettings[]; /** Normally left unset — the server advances it when a version finishes training. */ current_model_version?: StringId; validation_size?: number; test_size?: number; company_namespace?: string[]; } export type UpdateBody = Partial< Omit >; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; current_model_version?: StringId | StringId[]; /** Case-insensitive regex match on `name`. */ search?: string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = DataWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace AiObjectDetectionModelVersion { /** Lifecycle of the async dataset-prep job, then `trained` once `ul-hub` receives the weights. */ export type Status = | "initiated" | "setting_alarm_completed" | "building_folder_in_progress" | "building_folder_failed" | "building_yaml_file_in_progress" | "building_yaml_file_completed" | "stream_tasks_in_progress" | "stream_tasks_failed" | "compress_folder_in_progress" | "compress_folder_failed" | "uploading_zip_to_s3_in_progress" | "uploading_zip_to_s3_failed" | "zip_file_completed" | "trained"; /** `smart` = only `manual` / `auto_edited` annotation groups; `all` also includes untouched `auto` groups. */ export type TaskSelectionMode = "smart" | "all"; /** Creator stamp taken from the JWT; only admins create versions. */ export interface Creator { _id: StringId; type: "admin"; admin?: StringId; name?: string; } /** Per-label box count written into the YOLO label files (class balance of the export). */ export interface AnnotationPerLabel { label_id: StringId; name: string; size?: number; } /** Free-form Ultralytics train args; the HUB endpoint reads `train_settings[0].epochs` / `.imgsz`. */ export interface TrainSettings { epochs?: number; imgsz?: number; batch?: number; [key: string]: any; } /** Best-epoch (highest mAP50-95, the epoch `best.pt` was saved from) roll-up snapshotted when training completes. */ export interface Metrics { mAP50?: number; mAP50_95?: number; precision?: number; recall?: number; /** `_index` of the best epoch. */ best_epoch?: number; epochs_reported?: number; } /** Architecture cost as Ultralytics reports it. */ export interface ModelStats { parameters?: number; GFLOPs?: number; speed_PyTorch_ms?: number; } export interface Data { _id: StringId; /** Server-assigned, 1-based, increments per model within the namespace. */ version_code: number; model: StringId; dataset: StringId[]; /** Server-derived: union of the selected datasets' `dataset_labels`. */ dataset_labels: StringId[]; status?: Status; /** Reserved flag; the split logic currently clamps shortfalls at 0 regardless. Default `false`. */ suppress_exceeding_sizes: boolean; /** Media id of the YOLO dataset zip produced by the prep job. */ train_data?: StringId; creator: Creator; task_selection_mode: TaskSelectionMode; /** Tasks that produced an image + label file in the zip. */ tasks_size?: number; validation_size?: number; test_size?: number; train_settings?: TrainSettings[]; /** Sorted by `size` descending. */ annotations_per_label?: AnnotationPerLabel[]; /** Boxes written into the label files. */ annotations_size?: number; /** Training artifacts uploaded after the run (media ids). */ confusion_matrix_normalized?: StringId; /** Media id of the run's `args.yaml`. */ args?: StringId; confusion_matrix?: StringId; F1_curve?: StringId; labels_correlogram?: StringId; labels?: StringId; P_curve?: StringId; PR_curve?: StringId; R_curve?: StringId; results_csv?: StringId; results?: StringId; val_batch0_labels?: StringId; val_batch0_pred?: StringId; /** Base weights the run starts from (e.g. `yolov8n.pt` or a weights URL). */ initial_weight: string; /** Media id of `best.pt` — set by the `ul-hub` weights upload. */ weight_best?: StringId; /** Media id of `last.pt`. */ weight_last?: StringId; metrics?: Metrics; model_stats?: ModelStats; disabled: boolean; /** Adapted errors pushed by the async prep pipeline. */ _errors?: any[]; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = | "model" | "train_data" | "dataset" | "dataset_labels" | "confusion_matrix_normalized" | "args" | "confusion_matrix" | "F1_curve" | "labels_correlogram" | "labels" | "P_curve" | "PR_curve" | "R_curve" | "results_csv" | "results" | "val_batch0_labels" | "val_batch0_pred" | "weight_best" | "weight_last"; /** Populated refs are emitted under `_populated`; the original field keeps the id(s). */ export interface DataWithPopulatedKeys extends Data { model_populated?: AiObjectDetectionModel.Data | null; dataset_populated?: AiObjectDetectionDataset.Data[]; dataset_labels_populated?: AiObjectDetectionLabel.Data[]; train_data_populated?: MediaStorage.MediaStorageSchema | null; confusion_matrix_normalized_populated?: MediaStorage.MediaStorageSchema | null; args_populated?: MediaStorage.MediaStorageSchema | null; confusion_matrix_populated?: MediaStorage.MediaStorageSchema | null; F1_curve_populated?: MediaStorage.MediaStorageSchema | null; labels_correlogram_populated?: MediaStorage.MediaStorageSchema | null; labels_populated?: MediaStorage.MediaStorageSchema | null; P_curve_populated?: MediaStorage.MediaStorageSchema | null; PR_curve_populated?: MediaStorage.MediaStorageSchema | null; R_curve_populated?: MediaStorage.MediaStorageSchema | null; results_csv_populated?: MediaStorage.MediaStorageSchema | null; results_populated?: MediaStorage.MediaStorageSchema | null; val_batch0_labels_populated?: MediaStorage.MediaStorageSchema | null; val_batch0_pred_populated?: MediaStorage.MediaStorageSchema | null; weight_best_populated?: MediaStorage.MediaStorageSchema | null; weight_last_populated?: MediaStorage.MediaStorageSchema | null; } export interface CreateBody { /** `ai-object-detection-model` id (must exist in the namespace). */ model: StringId; /** One or more `ai-object-detection-dataset` ids. */ dataset: StringId[]; /** Ignored — the server recomputes it as the union of the datasets' `dataset_labels`. */ dataset_labels?: StringId[]; initial_weight: string; /** Default `all`. */ task_selection_mode?: TaskSelectionMode; suppress_exceeding_sizes?: boolean; train_settings?: TrainSettings[]; validation_size?: number; test_size?: number; company_namespace?: string[]; } /** Label projection returned by `create` (`select: ["name"]`). */ export interface LabelRef { _id: StringId; name: string; } /** `create` returns the new version with `dataset`, `model` and `dataset_labels` populated in place (status is still `initiated` in the response). */ export type CreateResult = Omit< Data, "dataset" | "model" | "dataset_labels" > & { dataset: AiObjectDetectionDataset.Data[]; model: AiObjectDetectionModel.Data; dataset_labels: LabelRef[]; }; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; /** Accepted by the backend but the schema has no `name` field — effectively a no-op. */ name?: string | string[]; model?: StringId | StringId[]; version_code?: number | number[]; /** Versions pinning any of the given dataset ids. */ dataset?: StringId | StringId[]; dataset_labels?: StringId | StringId[]; /** Regex on `name` — no-op for this schema (see `name`). */ search?: string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = DataWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = CreateResult; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace AiObjectDetectionModelVersionEpoch { /** Ultralytics loss components for one epoch. */ export interface LossMetrics { /** Bounding-box regression loss. */ box_loss?: number; /** Classification loss. */ cls_loss?: number; /** Distribution focal loss. */ dfl_loss?: number; } /** Validation metrics for one epoch. The `_B` suffix is Ultralytics' own — the Box (detection) task. */ export interface PerformanceMetrics { precision_B?: number; recall_B?: number; /** mAP at IoU 0.50 — the lenient, headline number. */ mAP50_B?: number; /** mAP averaged over IoU 0.50:0.95 — the strict number `best.pt` is selected on. */ mAP50_95_B?: number; } /** Architecture cost; Ultralytics reports it only on some epochs. */ export interface ModelStats { /** Total weight count. */ parameters?: number; /** Forward-pass cost per image. */ GFLOPs?: number; /** Per-image PyTorch inference latency measured during validation. */ speed_PyTorch_ms?: number; } /** One training epoch as ingested by `ul-hub-v1-models` (keys de-slashed: `train/box_loss` → `train_loss_metrics.box_loss`). */ export interface Data { _id: StringId; /** 0-based epoch number; unique per `model_version`. */ _index: number; model_version: StringId; /** Payload kind reported by the trainer. Only `metrics` today. */ type: "metrics"; train_loss_metrics?: LossMetrics; val_loss_metrics?: LossMetrics; performance_metrics?: PerformanceMetrics; model_stats?: ModelStats; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface PerformanceRollup { mAP50?: number; mAP50_95?: number; precision?: number; recall?: number; } /** Derived on read from the returned series. */ export interface Summary { /** Epochs reported so far — less than the configured `epochs` while a run is in flight. */ epochs_reported: number; /** `_index` of the highest-mAP50-95 epoch — what `best.pt` holds. */ best_epoch?: number; best?: PerformanceRollup; /** Last reported epoch — diverges from `best` when the run overfit. */ final?: PerformanceRollup; /** Carried on the last epoch that reported it. */ model_stats?: ModelStats; /** val − train (box+cls+dfl) at the final epoch; positive and growing = overfitting. */ final_generalization_gap?: number; } export namespace Find { /** Not paginated — `per_page` / `page` / `sort` are ignored; the whole run is returned in `_index` order. */ export interface Params { /** Required — 400 without it. */ model_version: StringId | StringId[]; _id?: StringId | StringId[]; /** Filter to specific epoch index(es). */ _index?: number | number[]; type?: "metrics"; disabled?: boolean; } export interface Result { /** Every reported epoch, ascending by `_index`. */ data: Data[]; total_result: number; summary: Summary; } } export namespace Get { export type ID = StringId; export type Result = Data; } } export namespace AiObjectDetectionModelVersionTrainAgent { export interface Step { /** A ready-to-run shell / Python snippet (may span multiple lines). */ code_message: string; } /** The bootstrap script for training one model version on a self-hosted agent. */ export interface Data { /** Ordered: (1) pin-install ultralytics, (2) point the HUB client at Repzo and train, (3) upload the run's plots + `args.yaml`. */ steps: Step[]; /** The pinned ultralytics release the snippet installs (`8.4.114`, the last one shipping `ultralytics.hub`). */ ultralytics_version?: string; } export namespace Get { /** The `ai-object-detection-model-version` id to generate the snippet for. */ export type ID = StringId; export type Result = Data; } } export namespace AiObjectDetectionLabel { /** Expected physical front-face size of the labelled item, in centimetres (each axis 0.1–500). */ export interface PhysicalSize { w_cm?: number; h_cm?: number; } export interface Data { _id: StringId; /** Unique per namespace. Must match `^[a-zA-Z_][a-zA-Z0-9_\s]*$`. */ name: string; disabled: boolean; /** Reference crop (media-storage id). Linked to the label on create/update so the upload is not treated as orphaned media. */ media_photo?: StringId; variants?: StringId[]; products?: StringId[]; product_categories?: StringId[]; product_subcategories?: StringId[]; product_brands?: StringId[]; product_groups?: StringId[]; /** Annotation hot-key: exactly one lower-case letter or digit, excluding `i`, `o` and `_`. */ keyboard_shortcut?: string; /** Sibling family for the dims reclassifier — detections are only re-labelled BETWEEN labels sharing a group. */ label_group?: StringId; /** Optional; labels without dims are skipped by the reclassifier. Set manually or via the label-report `mode=dims` analyzer. */ physical_size?: PhysicalSize; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = | "label_group" | "media_photo" | "variants" | "products" | "product_categories" | "product_subcategories" | "product_brands" | "product_groups"; export interface DataWithPopulatedKeys extends Data { label_group_populated?: AiObjectDetectionLabelGroup.Data; media_photo_populated?: MediaStorage.MediaStorageSchema; variants_populated?: Variant.VariantSchema[]; products_populated?: Product.ProductSchema[]; product_categories_populated?: Category.CategorySchema[]; product_subcategories_populated?: SubCategory.SubCategorySchema[]; product_brands_populated?: Brand.BrandSchema[]; product_groups_populated?: ProductGroup.ProductGroupSchema[]; } export interface CreateBody { name: string; media_photo?: StringId; variants?: StringId[]; products?: StringId[]; product_categories?: StringId[]; product_subcategories?: StringId[]; product_brands?: StringId[]; product_groups?: StringId[]; keyboard_shortcut?: string; label_group?: StringId; physical_size?: PhysicalSize; company_namespace?: string[]; } export type UpdateBody = Partial< Omit >; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; /** Exact match (single value or list). Use `search` for a substring match. */ name?: string | string[]; /** Case-insensitive regex on `name`. */ search?: string; disabled?: boolean; label_group?: StringId | StringId[]; variants?: StringId | StringId[]; products?: StringId | StringId[]; product_categories?: StringId | StringId[]; product_subcategories?: StringId | StringId[]; product_brands?: StringId | StringId[]; product_groups?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = DataWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; /** The label after soft-deletion (`disabled: true`). Rejected while any dataset still lists the label. */ export type Result = Data; } } export namespace AiObjectDetectionLabelGroup { /** * A family of sibling labels the detector confuses (size / flavour variants of one * product line). The dims reclassifier only ever moves a detection BETWEEN labels of * one group. Labels join a group through `AiObjectDetectionLabel.Data.label_group`. */ export interface Data { _id: StringId; /** Unique per namespace among non-deleted groups. */ name: string; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; company_namespace?: string[]; } export type UpdateBody = Partial< Omit >; export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; /** Exact match (single value or list). Use `search` for a substring match. */ name?: string | string[]; /** Case-insensitive regex on `name`. */ search?: string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export interface Params { /** * A group that still has live member labels is rejected (400, with * `{ assigned_labels, requires_force: true }`) unless `force: true`, which first * unsets `label_group` on those labels and then soft-deletes the group. */ force?: boolean; } export type Result = Data; } } export namespace AiObjectDetectionCategory { /** * One AUTO-ANALYSIS recipe: which model / version to run and the full analyze-session * settings. A category with N settings produces N analyses per received session. */ export interface ModelSetting { /** Sub-document id (server-assigned). */ _id?: StringId; /** `ai-object-detection-model` id. Always required — it resolves the "latest" version when `model_version` is unset. */ model: StringId; /** Pinned `ai-object-detection-model-version` id. Unset = "latest" → resolved to `model.current_model_version` at analysis time. */ model_version?: StringId; /** Analyze-session settings (SceneMathConfig + `conf`/`iou`, walk, `reclassify_*`, `size_gate*`, `build_point_cloud`, ...). Unset keys fall back to scene-math defaults. */ config?: { [key: string]: any }; } /** Wire shape accepted on create/update: `model_version` may be the UI sentinel `"latest"`, `""` or `null`, all normalised to unset. */ export interface ModelSettingBody { _id?: StringId; model: StringId; model_version?: StringId | "latest" | null; config?: { [key: string]: any }; } /** * A detection CATEGORY groups what a capture session is ABOUT: the model settings to * auto-analyze it with, and the labels that matter for the jobs & metrics built on top. * The mobile app picks one before calibration; a session received WITH a category is * auto-analyzed once per `model_settings` item after its upload completes. */ export interface Data { _id: StringId; /** Unique per namespace among non-deleted categories. */ name: string; model_settings: ModelSetting[]; /** `ai-object-detection-label` ids this category tracks — inputs for later jobs/metrics. */ labels: StringId[]; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = "labels" | "model_settings.model" | "model_settings.model_version"; /** Nested populations are applied IN PLACE (mongoose `populate` on `model_settings.model[_version]`), not under a `_populated` key. */ export interface ModelSettingWithPopulatedKeys extends Omit< ModelSetting, "model" | "model_version" > { model: StringId | AiObjectDetectionModel.Data; model_version?: StringId | AiObjectDetectionModelVersion.Data; } export interface DataWithPopulatedKeys extends Omit< Data, "model_settings" > { model_settings: ModelSettingWithPopulatedKeys[]; labels_populated?: AiObjectDetectionLabel.Data[]; } export interface CreateBody { name: string; /** Each item must name a `model` (400 otherwise); `model_version` optional (absent = latest). */ model_settings?: ModelSettingBody[]; labels?: StringId[]; company_namespace?: string[]; } export interface UpdateBody { name?: string; model_settings?: ModelSettingBody[]; labels?: StringId[]; /** Soft-delete flag — set `true` to disable via update (bypasses the session guard on remove). */ disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; /** Exact match (single value or list). Use `search` for a substring match. */ name?: string | string[]; /** Case-insensitive regex on `name`. */ search?: string; /** Categories tracking any of the given label id(s). */ labels?: StringId | StringId[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; export interface Params { /** * A category still referenced by live sessions is rejected (400, with * `{ assigned_sessions, requires_force: true }`) unless `force: true`, which first * unsets `category` on those sessions and then soft-deletes the category. */ force?: boolean; } export type Result = Data; } } export namespace AiObjectDetectionSegment { /** * A SEGMENT is a named label set used by share-of-shelf metrics ("our brand", * "competitor X", "energy drinks"). A metric references segments and may override a * segment's labels for that metric only — the segment stays the reusable default. */ export interface Data { _id: StringId; /** Unique per namespace among live segments. */ name: string; description?: string; /** Member `ai-object-detection-label` ids. Empty = placeholder the metric must override. */ labels: StringId[]; disabled: boolean; /** Server-stamped from the caller's token on create. */ creator?: AdminOrRepOrTenantOrClient; /** Server-stamped from the caller's token on update / remove. */ editor?: AdminOrRepOrTenantOrClient; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = "labels"; export interface DataWithPopulatedKeys extends Data { labels_populated?: AiObjectDetectionLabel.Data[]; } export interface CreateBody { /** Required and must be non-blank (400 otherwise). */ name: string; description?: string; labels?: StringId[]; company_namespace?: string[]; } /** PUT re-validates the body: `name` must be present and non-blank even on a partial change. */ export interface UpdateBody { name: string; description?: string; labels?: StringId[]; disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; /** Exact match (single value or list). Use `search` for a substring match. */ name?: string | string[]; /** Case-insensitive regex on `name`. */ search?: string; /** Segments containing any of these label id(s). */ labels?: StringId | StringId[]; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; /** Soft-delete; rejected (400 naming the metrics) while an active share-of-shelf metric still references the segment. */ export type Result = Data; } } export namespace AiObjectDetectionLabelReport { /** Dataset subset a task is routed to (`auto` fills train or val at build time; `ignore` is excluded). */ export type Subset = "train" | "val" | "test" | "auto" | "ignore"; /** Annotation-group provenance: model output, human-drawn, or model output edited by a human. */ export type AnnotationState = "auto" | "manual" | "auto_edited"; /** Per-annotation label provenance. */ export type LabelState = "auto" | "manual"; /** Which group states count as training-eligible: `all` = manual|auto|auto_edited (model default), `smart` = manual|auto_edited. */ export type StateMode = "all" | "smart"; /** YOLO-style pixel box on the frame image. */ export interface Box { x1: number; y1: number; x2: number; y2: number; } export interface ItemGroup { usable: boolean; confirmed: boolean; annotation_state?: AnnotationState; /** Detector that produced the group: a trained model version or a zero-shot VLM. */ engine?: "trained" | "zero_shot"; /** `ai-object-detection-model-version` id when `engine` is `trained`. */ model_version?: StringId; } /** One annotation of the requested label inside the requested dataset — the `items[]` row. */ export interface Data { /** `ai-object-detection-task` id the annotation belongs to. */ task_id: StringId; /** Public URL of the task's frame image. */ image_url?: string; /** Image width (task `shape[0]`, falling back to the media doc). */ image_w?: number; /** Image height (task `shape[1]`, falling back to the media doc). */ image_h?: number; /** Subset from THIS dataset's `task_dataset` entry. */ subset?: Subset; box: Box; confidence?: number; label_state: LabelState; group: ItemGroup; /** `usable && confirmed && state ∈ mode set` AND subset ∈ {train, auto}. */ included_in_training: boolean; /** `usable && confirmed && state ∈ mode set` AND subset ∈ {val, auto}. */ included_in_val: boolean; /** Internal eligibility flag (`usable && confirmed && state ∈ mode set`) the pipeline leaves on the row. */ _qualifies?: boolean; } /** Distribution of the label's annotations across the WHOLE dataset (not affected by item filters). */ export interface Summary { annotations_total: number; /** Distinct tasks carrying the label. */ tasks_total: number; subset_train: number; subset_val: number; subset_test: number; subset_auto: number; subset_ignore: number; state_manual: number; state_auto: number; state_auto_edited: number; usable_count: number; confirmed_count: number; training_eligible: number; val_eligible: number; } /** Default mode response (`?dataset=&label=`): annotation health summary + paginated, filterable items. */ export interface ReportResult { summary: Summary; items: Data[]; mode: StateMode; /** Count of items after the item filters (the paginated stream). */ total_result: number; current_page: number; per_page: number; total_pages: number; } /** One measured annotation considered by the smart dims analyzer. */ export interface DimsSample { /** `ai-object-detection-task` id. */ task: StringId; /** Parent `ai-object-detection-session` id (session frames only). */ session?: StringId; frame_id?: number; createdAt: Date; /** Measured physical width (cm). */ w_cm: number; /** Measured physical height (cm). */ h_cm: number; confidence?: number; /** 0..1 depth confidence of the placement. */ depth_confidence?: number; label_state: LabelState; /** Modified z-score of `w_cm` (2 dp); `null` when the MAD is 0 and the value differs from the median. */ z_w: number | null; z_h: number | null; /** Kept for the proposal (not an outlier and depth confidence ≥ `min_depth_confidence`). */ kept: boolean; reject_reason: "low_depth_confidence" | "outlier" | null; } export interface DimsStats { /** Samples collected. */ n: number; /** Samples with depth confidence ≥ `min_depth_confidence`. */ n_qualified: number; /** Samples kept after outlier rejection. */ n_kept: number; /** Median over qualified samples, 1 dp (cm). */ median_w_cm: number; median_h_cm: number; /** Median absolute deviation over qualified samples, 2 dp (cm). */ mad_w_cm: number; mad_h_cm: number; /** Mean of kept samples (1 dp); `null` when fewer than `min_samples` were kept. */ proposed: { w_cm: number; h_cm: number } | null; } /** `?mode=dims&label=` response — the label screen's SMART DIMS ANALYZER. */ export interface DimsResult { label: Pick< AiObjectDetectionLabel.Data, "_id" | "name" | "physical_size" | "label_group" > | null; /** Effective parameters after defaults/clamping. */ params: { sample: number; z_threshold: number; min_depth_confidence: number; min_samples: number; }; stats: DimsStats; samples: DimsSample[]; } export namespace Find { /** Default mode: per-dataset annotation health for one label. */ export interface ReportParams { /** Eligibility predicate; defaults to `all`. Any value other than `smart`/`dims` is treated as `all`. */ mode?: StateMode; /** `ai-object-detection-dataset` id (required, ObjectId). */ dataset: StringId; /** `ai-object-detection-label` id (required, ObjectId). */ label: StringId; /** Item filter — one value or a list. */ subset?: Subset | Subset[]; /** Item filter on `group.annotation_state`. */ annotation_state?: AnnotationState | AnnotationState[]; /** Item filter on the annotation's `label_state`. */ label_state?: LabelState | LabelState[]; /** Item filter on `group.usable`. */ usable?: boolean; /** Item filter on `group.confirmed`. */ confirmed?: boolean; /** Item filter: only rows included in training (`train`) or validation (`val`). */ included?: "train" | "val"; /** Page size for `items` (capped by the server's pagination max). */ per_page?: number; /** 1-based page for `items`. */ page?: number; } /** Smart dims analyzer — label-scoped, no dataset. */ export interface DimsParams { mode: "dims"; /** `ai-object-detection-label` id (required, ObjectId). */ label: StringId; /** Most recent measured annotations to consider. Default 100, clamped to 1..500. */ sample?: number; /** Modified z-score cut-off on either axis. Default 3.5. */ z_threshold?: number; /** Minimum depth confidence for a sample to count. Default 0.5. */ min_depth_confidence?: number; /** Minimum kept samples before a proposal is made. Default 8. */ min_samples?: number; } export type Params = ReportParams | DimsParams; /** `ReportResult` for the default mode, `DimsResult` when `mode === "dims"`. */ export type Result = ReportResult | DimsResult; } } export namespace AiObjectDetectionSettings { /** * Free-form bag of ANALYZE knobs (numbers / booleans only). Known keys are the * scene engine's `SceneMathConfig` (see `AiObjectDetectionInference.SceneMathConfig`) * plus a few the analyze endpoint reads directly (e.g. `inference_concurrency`). * The server does NOT filter keys — only values are validated: each knob must be a * finite number or a boolean; `null`/`undefined` knobs are skipped ("fall back to * the engine default"); anything else is rejected with 400. Capped at 200 keys. */ export type AnalyzeConfig = AiObjectDetectionInference.SceneMathConfig & { /** Parallel per-frame inference calls during a session analysis run. */ inference_concurrency?: number; [knob: string]: number | boolean | undefined; }; /** * The stored Mongo document (exactly one per namespace, unique index on * `company_namespace`). Never returned as-is — every method answers the projected * `Data` shape below. */ export interface Document { _id: StringId; company_namespace: string[]; disabled: boolean; /** Partial knob bag (see `AnalyzeConfig`). */ analyze_config?: AnalyzeConfig; createdAt: Date; updatedAt: Date; } /** Response shape of EVERY method (find / get / create / update / patch / remove). */ export interface Data { /** `null` while the namespace has never saved defaults. */ _id: StringId | null; /** `true` = nothing saved for this namespace; clients fall back to the engine defaults. */ is_default: boolean; /** The saved partial knob bag (`{}` when `is_default`). */ analyze_config: AnalyzeConfig; /** When the defaults were last saved; `null` when `is_default`. */ updatedAt: Date | null; } export interface CreateBody { /** Required — the server rejects a missing / non-object bag with 400. */ analyze_config: AnalyzeConfig; /** * Optional tenant namespace override for SDK callers. NOTE: this endpoint keys * its single document from the caller's token namespace and does not read the * body's `company_namespace`. */ company_namespace?: string[]; } /** PUT / PATCH accept exactly the create body — they upsert the same single document. */ export type UpdateBody = { analyze_config: AnalyzeConfig; }; export namespace Find { /** NOT paginated — the namespace's single defaults document. Never 404s. */ export type Result = Data; } export namespace Get { /** Ignored — one logical document per namespace (the dashboard sends `defaults`). */ export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; /** The fresh read after the upsert. */ export type Result = Data; } export namespace Update { /** Ignored — the namespace keys the document. */ export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { /** Identical to update/create (upsert of the single document; no id, no query). */ export type Body = UpdateBody; export type Result = Data; } export namespace Remove { /** Ignored — any value works (the dashboard sends `defaults`). */ export type ID = StringId; /** The empty default state: `{ _id: null, is_default: true, analyze_config: {}, updatedAt: null }`. */ export type Result = Data; } } export namespace AiObjectDetectionDetectionSettings { /** * Two-tier frame limit. `warn` = guidance shown on the device, frame still usable; * `error` = frame excluded from election (but it still counts toward the coverage * total). `warn` is always the softer bound. */ export interface WarnError { warn: number; error: number; } export type CaptureMode = "stack_elect" | "continuous" | "burst"; export type CaptureResolution = "medium" | "high" | "max"; export interface CaptureConfig { /** Default `stack_elect`. */ mode: CaptureMode; /** Capture rate, frames per second. Default 4. */ rate_hz: number; /** Default `max`. */ resolution: CaptureResolution; /** Seconds before a stack-elect capture times out. Default 30. */ stack_timeout_s: number; /** Show the sweep guide overlay. Default true. */ sweep_guide: boolean; /** Default true. */ torch: boolean; /** Default true. */ exposure_lock: boolean; } export interface FrameConfig { /** Variance-of-Laplacian sharpness floor: `warn` = live-guidance floor, `error` = election hard floor ("blur limit"). Default `{ warn: 200, error: 50 }`. */ min_sharpness: WarnError; /** Degrees. Default `{ warn: 18, error: 30 }`. */ max_yaw_delta_deg: WarnError; /** Degrees. Default `{ warn: 15, error: 28 }`. */ max_pitch_delta_deg: WarnError; /** Degrees. Default `{ warn: 12, error: 25 }`. */ max_roll_delta_deg: WarnError; /** Metres. Default `{ warn: 0.8, error: 1.5 }`. */ max_depth_variation_m: WarnError; /** Metres — `error` is the NEARER bound (worse). Default `{ warn: 0.5, error: 0.3 }`. */ min_distance_m: WarnError; /** Metres — `error` is the FARTHER bound (worse). Default `{ warn: 2.0, error: 3.0 }`. */ max_distance_m: WarnError; /** 0..100. Default `{ warn: 60, error: 35 }`. */ min_tracking_score: WarnError; } export interface ElectionConfig { /** Stop electing at this union coverage (0..1). Default 0.985. */ cover_target: number; /** Ignore gains under this fraction of a median footprint. Default 0.02. */ sliver_frac: number; /** Redundancy penalty exponent (score = quality · gain^exp). Default 1.5. */ gain_exp: number; /** Quality geometric-mean weight — sharpness. Default 0.4. */ w_sharp: number; /** Quality geometric-mean weight — depth. Default 0.3. */ w_depth: number; /** Quality geometric-mean weight — tracking. Default 0.2. */ w_track: number; /** Quality geometric-mean weight — lux. Default 0.1. */ w_lux: number; } /** Average-quality verdict bands; below `acceptable` = rejected. Default `{ excellent: 0.8, good: 0.65, acceptable: 0.45 }`. */ export interface SessionScoreBands { excellent: number; good: number; acceptable: number; } export interface SessionConfig { /** Reject when the device-reported covered area (m²) is below this. Default 0.5. */ coverage_target_m2: number; /** When false, a spatial jump (after removing error frames) rejects the session. Default false. */ allow_jump: boolean; /** Elected-count budget: ceil(total_area / avg_frame_area × allowance); more elected frames than that rejects the session. Default 1.6. */ elected_allowance: number; score: SessionScoreBands; } /** The full, MERGED detection config the mobile app pulls on session start (defaults deep-merged with the namespace overrides). */ export interface DetectionConfig { capture: CaptureConfig; frame: FrameConfig; election: ElectionConfig; session: SessionConfig; } /** * Deep-partial overrides. Objects merge recursively over the engine defaults; * scalars replace. Unknown keys are kept by the merge so the config can grow. */ export interface DetectionConfigOverrides { capture?: Partial; frame?: { [K in keyof FrameConfig]?: Partial }; election?: Partial; session?: Partial> & { score?: Partial; }; } /** * The stored Mongo document (exactly one per namespace, unique index on * `company_namespace`). Never returned as-is — reads answer the projected `Data`. */ export interface Document { _id: StringId; company_namespace: string[]; disabled: boolean; /** Partial overrides over the engine defaults. */ config?: DetectionConfigOverrides; createdAt: Date; updatedAt: Date; } /** Response shape of find / get / create / update / patch. */ export interface Data { /** `null` while the namespace has never saved overrides. */ _id: StringId | null; /** `true` = no overrides saved; `config` is the pure engine default. */ is_default: boolean; /** Merged result: namespace overrides deep-merged over the engine defaults. */ config: DetectionConfig; /** The raw saved overrides (`{}` when `is_default`). */ overrides: DetectionConfigOverrides; /** When the overrides were last saved; `null` when `is_default`. */ updatedAt: Date | null; } export interface CreateBody { /** * Required (400 when missing / not an object). REPLACES the stored overrides * object wholesale — it is not merged into previously saved overrides — so send * the complete set of overrides you want kept. */ config: DetectionConfigOverrides; /** * Optional tenant namespace override for SDK callers. NOTE: this endpoint keys * its single document from the caller's token namespace and does not read the * body's `company_namespace`. */ company_namespace?: string[]; } /** PUT / PATCH accept exactly the create body — they upsert the same single document. */ export type UpdateBody = { config: DetectionConfigOverrides; }; export namespace Find { /** NOT paginated — the namespace's merged config. Never 404s. */ export type Result = Data; } export namespace Get { /** Ignored — one logical document per namespace. */ export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; /** The fresh merged read after the upsert. */ export type Result = Data; } export namespace Update { /** Ignored — the namespace keys the document. */ export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { /** Identical to update/create (upsert of the single document; no id, no query). */ export type Body = UpdateBody; export type Result = Data; } export namespace Remove { /** Ignored — any value works. */ export type ID = StringId; /** Reset acknowledgement: `is_default: true` plus the pure engine defaults. Note: NO `_id` / `overrides` / `updatedAt` in this response. */ export interface Result { is_default: true; config: DetectionConfig; } } } export namespace AiObjectDetectionInference { /** Detector selection on the request. */ export type Engine = "auto" | "trained" | "zero_shot"; /** The detector that actually ran. */ export type ResolvedEngine = "trained" | "zero_shot"; /** Zero-shot VLMs the server accepts (`zero_shot_model`); unknown names are rejected with 400. */ export type ZeroShotModel = | "qwen/qwen3-vl-8b-instruct" | "qwen/qwen3-vl-32b-instruct" | "qwen/qwen3-vl-235b-a22b-instruct" | "qwen/qwen2.5-vl-72b-instruct"; export type ExplainPart = | "class_scores" | "heatmap" | "gradcam" | "feature_maps" | "embeddings" | "confusion_matrix" | "all"; export type EmbedMethod = "auto" | "umap" | "tsne" | "pca"; /** Why a detection could NOT be placed in world coordinates. */ export type IgnoreReason = | "no_pose" | "no_intrinsics" | "no_depth" | "empty_depth_region" | "insufficient_depth_pixels" | "behind_shelf"; /** * Every knob of the AR scene engine (`scene-math.ts` SceneMathConfig). All optional; * the engine default is given per field. Inference honours the depth-sampling knobs * (`min_depth_m` … `shelf_tolerance_m`), the dims-reclassifier knobs and the size-gate * knobs; the clustering / plane-merge / shelf / point-cloud knobs are consumed by * `ai-object-detection-session-analysis` and are accepted-but-ignored here. The same * bag is what `ai-object-detection-settings` stores as the namespace analyze defaults. */ export interface SceneMathConfig { /** Base world distance (m) to merge two detections into one object. Default 0.08. */ cluster_eps_m?: number; /** Extra merge radius (m) when labels match. Default 0.02. */ class_agree_bonus_m?: number; /** A scene object absorbs at most ONE detection per frame. Default true. */ block_same_frame?: boolean; /** Ignore depth samples below this (m). Default 0.05. */ min_depth_m?: number; /** Ignore depth samples above this (m). Default 6. */ max_depth_m?: number; /** Minimum ARKit depth-confidence (0/1/2) to keep a pixel. Default 1. */ conf_threshold?: number; /** Percentile of bbox depths to take — front-biased. Default 30. */ front_percentile?: number; /** Depth-gate slack (m) beyond the frame's `distance_to_shelf_m`. Default 0.3. */ shelf_tolerance_m?: number; /** Same-label 2D IoU at/above this = duplicate box within one frame. Default 0.92. */ same_frame_iou_thresh?: number; /** Same-label world distance (m) below this = same physical spot within one frame. Default 0.02. */ same_frame_min_separation_m?: number; /** Drop detections under this detector confidence (0 = off). Default 0. */ min_detection_confidence?: number; /** Drop when the front face is smaller than this (cm). Default 0.5. */ min_object_size_cm?: number; /** Drop when the front face is larger than this (cm). Default 500. */ max_object_size_cm?: number; /** Use plane-projection matching across frames. Default true. */ plane_merge?: boolean; /** Min projected-rect IoU to merge. Default 0.1. */ plane_merge_iou?: number; /** Max |plane-depth difference| (m) — the "virtual object depth". Default 0.25. */ plane_merge_depth_delta_m?: number; /** Dims reclassifier master switch — re-label an auto detection to a sibling label whose expected dims fit its measured size better. Default false. */ reclassify_labels?: boolean; /** E(original) ≤ this keeps the detected label outright. Default 0.15. */ reclassify_keep_dev?: number; /** A sibling must fit within this to steal the detection. Default 0.15. */ reclassify_target_dev?: number; /** Base margin E(orig) − E(best) must exceed. Default 0.06. */ reclassify_min_margin?: number; /** Margin × (1 + scale · detector_conf); 0 = ignore confidence. Default 0.5. */ reclassify_conf_margin_scale?: number; /** Weight of the SIZE mismatch in the fit score. Default 1.0. */ reclassify_weight_scale?: number; /** Weight of the SHAPE (aspect) mismatch in the fit score. Default 0.5. */ reclassify_weight_aspect?: number; /** Skip detections whose depth confidence is below this. Default 0.5. */ reclassify_min_depth_confidence?: number; /** Post-walk: merge overlapping same-group clusters via the plane test. Default true. */ group_consensus_merge?: boolean; /** Size gate master switch — flag detections measuring beyond their label's expected dims. Default true. */ size_gate?: boolean; /** Per-axis allowance: reject when measured w or h > (1 + this) × expected. Default 0.35. */ size_gate_dims_allowance?: number; /** Area allowance: reject when measured w·h > (1 + this) × expected area. Default 0.35. */ size_gate_area_allowance?: number; /** Skip gating detections whose depth confidence is below this. Default 0.5. */ size_gate_min_depth_confidence?: number; /** Shelf composition (boards → stacks → objects) master switch. Default true. */ shelf_analysis?: boolean; /** Min horizontal overlap ratio (of the narrower) to belong to the same column. Default 0.5. */ shelf_support_min_overlap?: number; /** Bottom-density window half-width (m) when finding candidate levels. Default 0.06. */ shelf_gap_split_m?: number; /** Min vertical distance (m) between two shelf boards. Default 0.12. */ shelf_min_spacing_m?: number; /** Measurement slack (m) for stacked boxes. Default 0.035. */ shelf_stack_max_penetration_m?: number; /** Depth gap (m) separating front/back rows within a shelf. Default 0.15. */ shelf_row_split_m?: number; /** A level needs at least this many stacks to be a shelf. Default 1. */ shelf_min_stacks?: number; /** Build + store the voxel point cloud on analysis runs. Default true. */ build_point_cloud?: boolean; /** Depth-grid stride — every Nth pixel. Default 2. */ pc_stride?: number; /** Voxel edge (m) for downsampling. Default 0.02. */ pc_voxel_size_m?: number; /** RANSAC: planes to peel off at most. Default 4. */ ransac_max_planes?: number; /** RANSAC: stop below this inlier share. Default 0.05. */ ransac_min_inlier_ratio?: number; /** RANSAC: point-to-plane inlier distance (m). Default 0.02. */ ransac_distance_thresh_m?: number; } /** The action request — `POST /ai-object-detection-inference`. */ export interface CreateBody { /** The `ai-object-detection-task` to infer on (must belong to the caller's namespace and carry `file_media` with a public URL). */ task_id: StringId; /** Model version `_id`. When set, resolves the lambda model + label order directly and bypasses the task's dataset / default-model requirement. */ model_version?: StringId; /** Object-detection model `_id`. Used directly as the lambda model id when given (its `current_model_version` supplies the label order). */ model?: StringId; /** Default `auto`: trained when a model resolves, else falls back to zero-shot (when configured) ONLY on the dataset path; explicit `model`/`model_version` stay strict. */ engine?: Engine; /** Zero-shot VLM override. */ zero_shot_model?: ZeroShotModel; /** Detection confidence threshold. Defaults to the model's `predict_settings[0].conf`, else 0.25. */ conf?: number; /** NMS IoU threshold (0..1). Defaults to the model's `predict_settings[0].iou`, else 0.7. */ iou?: number; /** Class-agnostic NMS (trained engine only). Defaults to the model's `predict_settings[0].agnostic_nms`, else false. */ agnostic_nms?: boolean; /** Default true — persist the mapped predictions as a fresh `auto` annotation group on the task (replacing only the unconfirmed auto group from the same source). */ save?: boolean; /** Explainable-AI opt-in (trained engine only): calls the diagnosis lambda and returns `xai`; when saved, XAI is persisted on the group. Never fails the prediction. */ explain?: boolean; /** Subset of XAI parts. Omit / empty / `["all"]` = every part; unknown names are dropped. */ explain_parts?: ExplainPart[]; /** Candidate classes per detection in `class_scores`. Default 5 (min 1). */ explain_topk?: number; /** Top-K cap on per-detection Grad-CAM maps. Default 20; 0 disables them. */ explain_gradcam_detections?: number; /** 2D projection for the embeddings scatter. Default `auto`. */ explain_embed_method?: EmbedMethod; /** XAI backfill for the EXISTING detections (implies `explain`; trained engine + `save` only): the detector is skipped and XAI is grafted onto the task's saved unconfirmed auto group of the resolved version. Falls through to a full inference when no such group exists. 400 when the resolved engine is zero-shot. */ explain_only?: boolean; /** Back-projection / reclassifier / size-gate tuning for AR session frames. Omit for the engine defaults. */ config?: SceneMathConfig; /** Optional tenant namespace override for SDK callers. NOTE: the server takes the namespace from the caller's token and does not read this field. */ company_namespace?: string[]; } /** Raw detector box: pixel corners on the original image plus YOLO-normalized center/size (0..1). */ export interface PredictionBox { x1: number; y1: number; x2: number; y2: number; x_center: number; y_center: number; width: number; height: number; } /** One raw detector result (`images[0].results[]` of the Ultralytics lambda; zero-shot replies are normalized to the same shape with `class: -1`). Passed through unchanged. */ export interface Prediction { name: string; class: number; confidence: number; box: PredictionBox; [key: string]: any; } /** A mapped detection — the same schema as a task annotation (`AiObjectDetectionTask.Annotation`). World fields appear only for placed AR frames; `ignore_reason` names why placement failed. */ export type Annotation = AiObjectDetectionTask.Annotation; export interface XaiBox { x1: number; y1: number; x2: number; y2: number; } export interface XaiCandidate { class: number; name: string; score: number; } /** Per-detection top-k class scores of the pre-NMS anchor that produced the detection. `index` = position in `predictions`. */ export interface XaiClassScore { index: number; class: number; name: string; confidence: number; /** Detection box in original-image pixels (xyxy). */ box: XaiBox; /** Top-k candidate classes of the winning anchor, best first. */ candidates: XaiCandidate[]; /** IoU between the detection box and the matched pre-NMS anchor box. */ match_iou?: number; } /** EigenCAM activation heatmap ("where did the model look"). RGBA PNG, alpha = activation. */ export interface XaiHeatmap { png_base64: string; method: "eigencam"; layers?: string; width: number; height: number; } /** One detection's own Grad-CAM map ("why THIS box, this class"). `index` = position in `predictions`. */ export interface XaiGradcamDetection { index: number; class: number; name: string; confidence: number; /** Detection box in original-image pixels (xyxy). */ box: XaiBox; match_iou?: number; png_base64: string; method?: "gradcam"; layers?: string; target?: string; width: number; height: number; } /** TRUE gradient Grad-CAM ("what evidence drove the detections"). RGBA PNG, alpha = activation. */ export interface XaiGradcam { png_base64: string; method: "gradcam"; layers?: string; /** What was backpropagated (the Grad-CAM objective). */ target?: string; /** Input size of the gradient pass (capped, default 960). */ imgsz?: number; width: number; height: number; per_detection?: XaiGradcamDetection[]; /** Present when detections were truncated to the top-K. */ per_detection_note?: string; } /** One per-stage feature-map grid (ultralytics visualize=True), downscaled JPEG. */ export interface XaiFeatureMap { /** Network stage, e.g. `stage12_C2f`. */ stage: string; jpg_base64: string; } export interface XaiEmbeddingPoint { /** Position of the detection in `predictions`. */ index: number; class: number; name: string; confidence: number; /** Projected coordinate, min-max normalized to [0, 1]. */ x: number; /** Projected coordinate, min-max normalized to [0, 1]. */ y: number; } export interface XaiEmbeddings { /** The projection that actually ran (`none` for a single point). */ method: "umap" | "tsne" | "pca" | "none"; /** What the caller asked for (differs from `method` on fallback). */ requested_method?: EmbedMethod; layer?: string; /** Dimensionality of the pooled embedding before projection. */ embedding_dim?: number; points: XaiEmbeddingPoint[]; } /** Training-time confusion-matrix image URLs of the model version. */ export interface XaiConfusionMatrix { url: string | null; normalized_url: string | null; source: "training_artifacts"; } /** * Raw diagnosis-lambda Explainable-AI payload (passthrough). Any part can be * missing — its failure reason is then appended to `notes`. When the diagnosis * detections do not align with `predictions`, the index-bearing parts * (`class_scores`, `gradcam.per_detection`, `embeddings.points`) are dropped and * a note explains why. */ export interface Xai { /** The parts that were requested. */ parts?: string[]; /** YOLO class index (stringified) → class name, from the model weights. */ class_names?: { [classIndex: string]: string }; notes?: string[]; class_scores?: XaiClassScore[]; heatmap?: XaiHeatmap; gradcam?: XaiGradcam; feature_maps?: XaiFeatureMap[]; embeddings?: XaiEmbeddings; confusion_matrix?: XaiConfusionMatrix | null; } /** The action response (`Create.Result`). There is no stored document for this service. */ export interface Data { task_id: StringId; /** The detector that actually ran. */ engine: ResolvedEngine; /** The VLM used when `engine` is `zero_shot`, else `null`. */ zero_shot_model: ZeroShotModel | null; /** Resolved model `_id`; `null` for zero-shot runs. */ model: StringId | null; /** Resolved model version `_id`, or `null`. */ model_version: StringId | null; /** Public URL of the task image that was inferred. */ image_url: string; /** `[height, width]` of the inferred image (detector-reported). `null` on an `explained_existing` response; may be absent if the detector omits it. */ shape?: number[] | null; /** The confidence threshold that was applied. */ conf: number; /** Whether the annotation group (or the grafted XAI) was persisted on the task. */ saved: boolean; /** Present (true) when `explain_only` grafted XAI onto the existing group — no detector ran: `predictions` is empty, `shape`/`placed_count`/`unplaced_count`/`unmapped` are `null`, and `annotations` echoes the existing group's annotations. */ explained_existing?: true; annotations_count: number; /** Annotations placed in world coordinates (0 for non-session tasks). `null` on `explained_existing`. */ placed_count: number | null; /** Annotations left 2D-only — each carries an `ignore_reason`. `null` on `explained_existing`. */ unplaced_count: number | null; /** Predictions that could not be mapped to a label. `null` on `explained_existing`. */ unmapped: number | null; annotations: Annotation[]; /** Raw detector predictions (passthrough). */ predictions: Prediction[]; /** Present only when `explain`/`explain_only` ran on the trained engine and the diagnosis lambda succeeded, else `null`. */ xai: Xai | null; /** The saved task document when the group was persisted, else `null`. */ task: AiObjectDetectionTask.Data | null; } export namespace Create { export type Body = CreateBody; export type Result = Data; } } export namespace AiObjectDetectionTask { export type Subset = "train" | "val" | "test" | "auto" | "ignore"; /** Provenance of a whole annotation group. */ export type AnnotationState = "auto" | "manual" | "auto_edited"; /** Provenance of a single box. */ export type LabelState = "auto" | "manual"; /** Which detector produced a group: a trained model version (default) or a zero-shot VLM. */ export type Engine = "trained" | "zero_shot"; /** Why a detection could NOT be placed in world coordinates (unset when placed). */ export type IgnoreReason = | "no_pose" | "no_intrinsics" | "no_depth" | "empty_depth_region" | "insufficient_depth_pixels" | "behind_shelf"; export type ReclassificationReason = "dims_match_sibling" | "group_consensus" | "manual"; /** * Mutually-exclusive review status used by the `annotation_status` find filter: * `pending` = not annotated (or no groups); `confirmed` = annotated and the leading * group is confirmed; `manual` / `auto_edited` = annotated, unconfirmed leading group * with that state; `auto` = every remaining annotated, unconfirmed leading group. */ export type AnnotationStatus = "pending" | "confirmed" | "manual" | "auto_edited" | "auto"; /** Normalized box. Inference / the dashboard store YOLO center-size here: `x1` = cx, `y1` = cy, `x2` = w, `y2` = h. */ export interface Box { x1: number; x2: number; y1: number; y2: number; } /** Back-projected centroid in world coordinates, metres. */ export interface WorldPosition { x: number; y: number; z: number; } /** Physical front-face size, centimetres (`w` = world-horizontal, `h` = vertical). */ export interface WorldSize { w: number; h: number; } /** Size-gate provenance — set when the measured size exceeded the label's expected dims beyond the allowance. */ export interface SizeRejectDetail { exceeded?: "width" | "height" | "area"; measured_w_cm?: number; measured_h_cm?: number; expected_w_cm?: number; expected_h_cm?: number; /** measured / (expected × (1 + allowance)) for the tripped check. */ ratio?: number; } export interface Annotation { _id?: StringId; box: Box; /** Default 0.25. */ confidence?: number; /** `ai-object-detection-label` `_id`. */ label_id: StringId; label_state: LabelState; /** Snapshot of the box geometry world placement last ran for; a box that no longer matches it is re-placed on the next save. */ placed_box?: Box; world_position?: WorldPosition; world_size?: WorldSize; /** Metres — front-biased percentile (default p30) of the depth pixels over the whole bbox. */ depth_at_center?: number; /** Normalized 0..1 depth confidence. */ depth_confidence?: number; /** detection_conf × depth_conf × tracking, 0..1. */ placement_confidence?: number; /** Link to the analysis object (`objects[]._id` on `ai-object-detection-session-analysis`) this detection was clustered into. */ cluster_id?: StringId; ignore_reason?: IgnoreReason; /** When the dims reclassifier moved this annotation to a sibling label, the FIRST original label is kept here. */ original_label?: StringId; reclassification_reason?: ReclassificationReason; /** Flagged (never deleted) when the measured size exceeded the label's expected dims; cleared when a later run passes it. */ size_rejected?: boolean; size_reject_detail?: SizeRejectDetail; } export interface XaiBox { x1?: number; y1?: number; x2?: number; y2?: number; } export interface XaiCandidate { class?: number; name?: string; score?: number; } /** Per-detection top-k class scores; `index` references the inference `predictions[]`, not `annotations[]`. */ export interface XaiClassScore { index?: number; class?: number; name?: string; confidence?: number; box?: XaiBox; match_iou?: number; candidates?: XaiCandidate[]; } export interface XaiEmbeddingPoint { index?: number; class?: number; name?: string; confidence?: number; /** [0, 1] */ x?: number; /** [0, 1] */ y?: number; } export interface XaiFeatureMap { /** Network stage, e.g. `stage12_C2f`. */ stage?: string; /** Media ref of the stage grid JPEG. */ media?: StringId; /** publicUrl snapshot of `media`. */ url?: string; } /** One detection's own Grad-CAM map ("why THIS box, this class"). */ export interface XaiGradcamDetection { index?: number; class?: number; name?: string; confidence?: number; box?: XaiBox; match_iou?: number; /** Media ref of this detection's RGBA PNG map. */ media?: StringId; /** publicUrl snapshot of `media`. */ url?: string; width?: number; height?: number; } export interface XaiEmbeddings { /** The projection that actually ran. */ method?: "umap" | "tsne" | "pca" | "none"; /** What the caller asked for. */ requested_method?: "auto" | "umap" | "tsne" | "pca"; layer?: string; embedding_dim?: number; points?: XaiEmbeddingPoint[]; } export interface XaiConfusionMatrix { url?: string; normalized_url?: string; source?: "training_artifacts"; } /** * Explainable-AI results persisted on a group produced with `explain: true`. * Images live in media storage (refs + `*_url` publicUrl snapshots), never inline. * `computed_at` marks real persisted XAI (withheld when no image could be stored). */ export interface GroupXai { /** Which XAI parts were requested. */ parts?: string[]; /** Media ref of the EigenCAM RGBA PNG (alpha = activation). */ heatmap_media?: StringId; heatmap_url?: string; /** e.g. `eigencam`. */ heatmap_method?: string; heatmap_width?: number; heatmap_height?: number; /** Media ref of the gradient Grad-CAM RGBA PNG. */ gradcam_media?: StringId; gradcam_url?: string; gradcam_width?: number; gradcam_height?: number; gradcam_per_detection?: XaiGradcamDetection[]; feature_maps?: XaiFeatureMap[]; class_scores?: XaiClassScore[]; embeddings?: XaiEmbeddings; /** Training-time confusion-matrix image URLs of the model version. */ confusion_matrix?: XaiConfusionMatrix; /** Reasons for any XAI part that could not be produced or persisted. */ notes?: string[]; /** Epoch ms when the XAI results were persisted. */ computed_at?: number; } /** Per-group session inference metadata (session inference only). */ export interface SessionInference { /** Dominant shelf plane this frame contributed to. */ plane_normal?: number[]; /** This group provided the winning detection. */ is_winner_in_cluster?: boolean; cross_frame_overlap_pct?: number; } export interface AnnotationGroup { _id?: StringId; /** `ai-object-detection-model-version` `_id`. */ model_version?: StringId; engine?: Engine; /** The zero-shot VLM used, e.g. `qwen/qwen3-vl-8b-instruct`. */ zero_shot_model?: string; /** Opt-out training flag. Default true. */ usable?: boolean; /** Epoch ms — set to now on create when missing. */ time?: number; /** Epoch ms — server-stamped on every update. */ edit_time?: number; annotation_state?: AnnotationState; /** Default false. Server-set true for `manual` / `auto_edited` groups. */ confirmed?: boolean; /** Server-stamped from the JWT when the group is confirmed and does not already carry a valid confirmer. */ confirmed_by?: AdminOrRep; /** Server-set to `model_version` for `auto` groups on create. */ annotated_by_model_version_code?: StringId; annotations?: Annotation[]; /** Link to the session's `inference_runs[]._id` (session inference only). */ inference_run?: StringId; session_inference?: SessionInference; xai?: GroupXai; } export interface TaskDataset { _id?: StringId; /** `ai-object-detection-dataset` `_id`. */ dataset: StringId; subset: Subset; } export interface Intrinsics { fx?: number; fy?: number; cx?: number; cy?: number; } export interface Distortion { k1?: number; k2?: number; k3?: number; p1?: number; p2?: number; } export interface Tracking { state?: "NORMAL" | "LIMITED" | "LOST"; score?: number; drift_m?: number; velocity_mps?: number; } export interface ImageStats { iso?: number; shutter?: number; lux?: number; /** Variance-of-Laplacian focus measure (higher = sharper). */ sharpness?: number; } /** Depth-map presence + confidence fractions (election input). */ export interface DepthSummary { width?: number; height?: number; conf_high?: number; conf_medium?: number; conf_low?: number; } /** Per-frame AR context, present only on session frames. */ export interface FrameMeta { /** Session-scoped frame counter. */ frame_id?: number; /** Device epoch ms. */ ts?: number; /** 16 floats, 4x4 pose matrix, column-major. */ pose?: number[]; /** 3 floats, degrees. */ euler_ypr?: number[]; intrinsics?: Intrinsics; distortion?: Distortion; tracking?: Tracking; /** Shelf-distance gate (m) used when back-projecting this frame's detections. */ distance_to_shelf_m?: number; /** CW degrees the sensor image was rotated to produce the stored image (0/90/180/270). */ image_rotation_deg?: number; image_stats?: ImageStats; depth_summary?: DepthSummary; depth_source?: "lidar" | "estimated" | "none"; /** Nearest depth sample, metres. */ min_distance_depth?: number; /** Farthest depth sample, metres. */ max_distance_depth?: number; /** Depth span (max − min), metres. */ depth_variation?: number; /** Camera euler at capture, degrees. */ yaw_degree?: number; pitch_degree?: number; roll_degree?: number; /** Variance-of-Laplacian focus measure. */ frame_sharpness?: number; /** Device validator verdict for the frame at capture time. */ capture_tier?: "good" | "warn" | "error"; /** Epoch ms of the app's last successful detection-settings poll. */ detection_settings_polled_at?: number; /** App build that captured the frame. */ app_version?: string; } export interface Data { _id: StringId; /** `media-storage` `_id` of the image. */ file_media: StringId; shape?: number[]; annotation_groups?: AnnotationGroup[]; task_dataset?: TaskDataset[]; /** Server-stamped on create. */ creator?: AdminOrRep; /** Server-stamped on update. */ editor?: AdminOrRep; /** Server-derived: true when any confirmed group has annotations. */ annotated: boolean; /** Parent `ai-object-detection-session` `_id` (session frames only). */ session?: StringId; frame_meta?: FrameMeta; /** Media `_id` of the raw float32 depth blob (session frames only). */ depth_media?: StringId; /** Media `_id` of the raw uint8 confidence blob (session frames only). */ confidence_media?: StringId; /** `[width, height]` of the depth blob. */ depth_shape?: number[]; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } /** * Accepted `populatedKeys[]`. Top-level refs (`file_media`, `session`, `depth_media`, * `confidence_media`) land under `_populated` while the ref stays an id; * nested paths (everything under `task_dataset.` / `annotation_groups.`) populate * INLINE, replacing the id with the document. */ export type PopulatedKeys = | "file_media" | "task_dataset.dataset" | "annotation_groups.model_version" | "annotation_groups.annotations.label_id" | "annotation_groups.annotations.original_label" | "annotation_groups.annotated_by_model_version_code" | "annotation_groups.xai.heatmap_media" | "annotation_groups.xai.gradcam_media" | "annotation_groups.xai.gradcam_per_detection.media" | "annotation_groups.xai.feature_maps.media" | "session" | "depth_media" | "confidence_media"; export interface AnnotationPopulated extends Omit< Annotation, "label_id" | "original_label" > { label_id: StringId | AiObjectDetectionLabel.Data; original_label?: StringId | AiObjectDetectionLabel.Data; } export interface GroupXaiPopulated extends Omit< GroupXai, | "heatmap_media" | "gradcam_media" | "gradcam_per_detection" | "feature_maps" > { heatmap_media?: StringId | MediaStorage.MediaStorageSchema; gradcam_media?: StringId | MediaStorage.MediaStorageSchema; gradcam_per_detection?: (Omit & { media?: StringId | MediaStorage.MediaStorageSchema; })[]; feature_maps?: (Omit & { media?: StringId | MediaStorage.MediaStorageSchema; })[]; } export interface AnnotationGroupPopulated extends Omit< AnnotationGroup, | "model_version" | "annotated_by_model_version_code" | "annotations" | "xai" > { model_version?: StringId | AiObjectDetectionModelVersion.Data; annotated_by_model_version_code?: StringId | AiObjectDetectionModelVersion.Data; annotations?: AnnotationPopulated[]; xai?: GroupXaiPopulated; } export interface TaskDatasetPopulated extends Omit { dataset: StringId | AiObjectDetectionDataset.Data; } /** Find / Get row: `Data` plus the `*_populated` companions and inline-populated nested refs (only when the matching `populatedKeys[]` was requested). */ export interface DataWithPopulatedKeys extends Omit< Data, "annotation_groups" | "task_dataset" > { annotation_groups?: AnnotationGroupPopulated[]; task_dataset?: TaskDatasetPopulated[]; file_media_populated?: MediaStorage.MediaStorageSchema; session_populated?: AiObjectDetectionSession.Data; depth_media_populated?: MediaStorage.MediaStorageSchema; confidence_media_populated?: MediaStorage.MediaStorageSchema; } /** * An annotation group as sent on create. `annotation_state` is REQUIRED — a group * without a valid one is rejected with 400 "Invalid annotation state". `manual` / * `auto_edited` are marked `confirmed` (+ `confirmed_by` from the JWT); `auto` * copies `model_version` into `annotated_by_model_version_code`. `time` defaults to now. */ export interface CreateAnnotationGroup extends Omit< AnnotationGroup, | "annotation_state" | "confirmed_by" | "edit_time" | "annotated_by_model_version_code" > { annotation_state: AnnotationState; } export interface CreateBody { /** Required — `media-storage` `_id` of the image. */ file_media: StringId; shape?: number[]; annotation_groups?: CreateAnnotationGroup[]; task_dataset?: TaskDataset[]; session?: StringId; frame_meta?: FrameMeta; depth_media?: StringId; confidence_media?: StringId; depth_shape?: number[]; /** Optional tenant namespace override for SDK callers (otherwise injected from the session). */ company_namespace?: string[]; } /** * PUT body. `annotation_groups` REPLACES the stored array wholesale — resend every * group to keep (with its `_id`). `editor` is server-stamped, `annotated` re-derived, * `edit_time` restamped per group; a confirmed group keeps its existing `confirmed_by`. * Human (`manual` / `auto_edited`) boxes whose geometry changed are re-placed in * world coordinates on save (session frames), and a real content change schedules * a session re-analysis. Set `disabled: true` to soft-delete. */ export type UpdateBody = Partial< Omit< Data, | "_id" | "createdAt" | "updatedAt" | "company_namespace" | "creator" | "editor" | "annotated" > >; /** Filters honoured by find (and by the bulk patch). Date bounds are epoch ms (or date strings). */ export interface FilterParams { _id?: StringId | StringId[]; /** Tasks (frames) belonging to a session `_id`. */ session?: StringId | StringId[]; /** Session-scoped frame counter. */ "frame_meta.frame_id"?: number | number[]; /** Tasks belonging to a dataset `_id`. */ "task_dataset.dataset"?: StringId | StringId[]; /** Whether the task has any confirmed annotations. */ annotated?: boolean; /** Omitted / false = active tasks only; true = disabled tasks only. */ disabled?: boolean; from_createdAt?: number; to_createdAt?: number; from_updatedAt?: number; to_updatedAt?: number; } export namespace Find { export type Params = DefaultPaginationQueryParams & FilterParams & { /** Only tasks with at least one annotation (in any group) referencing the given label id(s) — surfaces candidate crops for a label's reference photo. */ annotated_label?: StringId | StringId[]; /** Mutually-exclusive review status filter (applied before counting / pagination). Invalid values → 400. */ annotation_status?: AnnotationStatus; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export interface Params { populatedKeys?: PopulatedKeys[]; } /** 400 (not 404) when the id is unknown in the caller's namespace. */ export type Result = DataWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Patch { /** Query filters selecting the tasks to bulk-update (e.g. `{ session }` for "approve all auto"). No pagination / population. */ export type Params = FilterParams; export interface WriteQuery { /** Dotted document path, e.g. `annotation_groups.0.confirmed`. */ key: string; /** `set` → `$set`; `addToSet` → `$addToSet: { $each: value }`; `pull` → `$pull: { $in: value }`. */ command: "set" | "addToSet" | "pull"; value: any; } export type Body = { writeQuery: WriteQuery[]; }; export interface Result { /** Matched documents. */ nFound: number; /** Modified documents. */ nModified: number; } } export namespace Remove { export type ID = StringId; /** The task after soft-deletion (`disabled: true`). */ export type Result = Data; } } export namespace AiObjectDetectionSession { /** Lifecycle FSM. `uploaded` is written by the device's upload-complete marker, `infer_in_progress`/`inferred`/`failed` by analysis runs; `rearbitrating` is reserved/legacy (no writer). */ export type SessionStatus = | "open" | "uploaded" | "infer_in_progress" | "inferred" | "rearbitrating" | "failed"; /** Articulated election verdict derived from `session_score` against the namespace detection-settings score bands. */ export type SessionVerdict = "excellent" | "good" | "acceptable" | "rejected"; export interface Device { platform?: string; os?: string; model?: string; app_version?: string; ar_engine?: "ARKit" | "ARCore"; } export interface CaptureSettings { /** AR frame capture rate the app was set to (Hz). */ rate_hz?: number; recording_enabled?: boolean; target_distance_m?: number; /** Camera format preference active during capture. */ resolution?: "medium" | "high" | "max" | string; } /** Floor lock measured on-device at capture entry; absent when the rep skipped the floor point. Height above floor of any world point = y - y_world. */ export interface Ground { /** Floor height (world Y), metres. */ y_world?: number; /** Gated depth samples behind the median. */ samples?: number; /** Interquartile spread of the samples, metres (lock quality). */ spread_m?: number; /** Camera height above the floor at lock time, metres. */ camera_height_m?: number; } /** A frame excluded from an election because it violated the error-tier limits. */ export interface ElectionExcluded { task?: StringId; /** e.g. `sharpness`, `tracking`, `too_near`, `too_far`, `yaw_delta`, `pitch_delta`, `roll_delta`. */ violations?: string[]; } /** Legacy scene plane (from the removed in-session build_scene flow). */ export interface Plane { _id?: StringId; kind?: "shelf" | "floor" | "wall"; /** 3-float plane normal. */ normal?: number[]; /** Plane equation constant in Ax+By+Cz+d=0. */ d?: number; inliers?: number; bounds?: { min?: number[]; max?: number[] }; } export interface PointCloudStats { n_points?: number; voxel_size_m?: number; bbox_min?: number[]; bbox_max?: number[]; } /** Legacy scene-level outputs; retained for older data, no longer written. */ export interface Scene { planes?: Plane[]; /** `media.mediaStorages` id of the .ply / .npy point cloud. */ point_cloud_media?: StringId; point_cloud_stats?: PointCloudStats; /** Coordinate system the world positions are reported in. */ world_frame?: "arkit" | "arcore" | "normalized"; } /** Legacy cross-frame fused object (fused output now lives on `ai-object-detection-session-analysis`). */ export interface SessionObject { _id?: StringId; label_id?: StringId; /** How many frames contributed to this object. */ cluster_size?: number; world_position?: { x?: number; y?: number; z?: number }; world_orientation?: { yaw?: number; pitch?: number; roll?: number }; bbox_3d?: { min?: number[]; max?: number[] }; /** Fused 0..1 placement confidence. */ placement_confidence?: number; winning_task?: StringId; winning_annotation_id?: StringId; contributing_tasks?: StringId[]; /** Weights / tiebreak rationale. */ arbitration?: any; } /** Legacy per-run inference record (analysis runs are now their own documents). */ export interface InferenceRun { _id?: StringId; model_version?: StringId; started_at?: number; finished_at?: number; /** Clustering params, RANSAC config. */ config?: any; status?: "pending" | "success" | "failed"; triggered_by?: AdminOrRep; notes?: string; } export interface Data { _id: StringId; company_namespace: string[]; disabled: boolean; /** Device-generated session id (4-char); unique per namespace among active rows. Election clones carry a `-E` suffix. */ session_id?: string; /** Provenance: set when this session was materialized from an election over another session's frames. */ source_session?: StringId; device?: Device; /** `clients` _id of the scanned store (stamped by the frame intake). */ client?: StringId; /** `ai-object-detection-category` _id picked on the device; drives the auto-analysis fired by the upload-complete marker. */ category?: StringId; /** `ai-object-detection-mission` _id the session was started FROM ("SCAN THIS MISSION"); attribution anchor for mission results. */ mission?: StringId; /** `representatives` _id sent on the frames (defaults to the rep in the token). */ rep?: StringId; /** DEVICE visit id (`visits.visit_id`) the scan happened in — stored as-is, never resolved to a server ref. */ visit_id?: string; /** `sv.routes` _id of the visit's route. */ route?: StringId; /** Business day of the scan, `YYYY-MM-DD` — as sent by the device, else stamped once from the capture time. */ business_day?: string; /** IANA timezone of the device at capture. */ time_zone?: string; capture_settings?: CaptureSettings; /** Device-computed swept shelf area, m² (includes quality-rejected attempts, so it cannot be recomputed server-side). */ coverage_m2?: number; ground?: Ground; /** Camera height above the locked floor while shooting, metres (the rep's standing eye level). Server self-heals it from poses when missing. */ eye_level_m?: number; /** The rep tapped Skip on the floor point (deliberate skip vs a lock that never converged). */ ground_skipped?: boolean; /** 'gravity' on both ARKit/ARCore — recorded, not assumed. */ world_alignment?: string; /** Election evaluation: average frame quality, 0..1. */ session_score?: number; session_verdict?: SessionVerdict; /** e.g. `coverage_below_target`, `jump_detected`, `too_many_elected`. */ rejection_reasons?: string[]; election_excluded?: ElectionExcluded[]; status: SessionStatus; _errors?: any[]; /** Incremented by the frame intake. */ frames_total: number; /** Frames that passed validation (incremented by the frame intake). */ frames_accepted: number; /** Frames materialized as tasks (incremented by the frame intake). */ tasks_count: number; /** Refreshed on every successful analysis run. */ detections_count: number; /** Refreshed on every successful analysis run. */ objects_count: number; scene?: Scene; objects?: SessionObject[]; inference_runs?: InferenceRun[]; /** The rep/admin who scanned (server-stamped on create). */ creator?: AdminOrRep; /** Server-stamped on update. */ editor?: AdminOrRep; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = | "client" | "category" | "inference_runs.model_version" | "objects.label_id" | "scene.point_cloud_media"; export interface InferenceRunWithPopulatedKeys extends Omit< InferenceRun, "model_version" > { /** Populated in place when `inference_runs.model_version` is requested. */ model_version?: StringId | AiObjectDetectionModelVersion.Data; } export interface SessionObjectWithPopulatedKeys extends Omit< SessionObject, "label_id" > { /** Populated in place when `objects.label_id` is requested. */ label_id?: StringId | AiObjectDetectionLabel.Data; } export interface SceneWithPopulatedKeys extends Omit< Scene, "point_cloud_media" > { /** Populated in place when `scene.point_cloud_media` is requested. */ point_cloud_media?: StringId | MediaStorage.MediaStorageSchema; } /** `client` / `category` keep their ids and add `_populated`; the nested keys are populated in place. */ export interface DataWithPopulatedKeys extends Omit< Data, "inference_runs" | "objects" | "scene" > { client_populated?: Client.ClientSchema; category_populated?: AiObjectDetectionCategory.Data; inference_runs?: InferenceRunWithPopulatedKeys[]; objects?: SessionObjectWithPopulatedKeys[]; scene?: SceneWithPopulatedKeys; } /** Explicit/manual session creation (sessions are normally upserted by the frame intake). `creator` and counters are server-managed. */ export interface CreateBody { session_id?: string; source_session?: StringId; device?: Device; client?: StringId; category?: StringId; mission?: StringId; rep?: StringId; visit_id?: string; route?: StringId; business_day?: string; time_zone?: string; capture_settings?: CaptureSettings; coverage_m2?: number; ground?: Ground; eye_level_m?: number; ground_skipped?: boolean; world_alignment?: string; /** Defaults to `open`. */ status?: SessionStatus; company_namespace?: string[]; } /** PUT accepts any stored field; `editor` is server-stamped. Set `disabled: true` to soft-delete. */ export type UpdateBody = Partial< Omit< Data, | "_id" | "createdAt" | "updatedAt" | "company_namespace" | "creator" | "editor" > >; /** Filter keys honoured by `find` and by the bulk `patch`. */ export type FilterParams = { _id?: StringId | StringId[]; session_id?: string | string[]; status?: SessionStatus | SessionStatus[]; client?: StringId | StringId[]; category?: StringId | StringId[]; rep?: StringId | StringId[]; visit_id?: string | string[]; route?: StringId | StringId[]; "creator._id"?: StringId | StringId[]; "inference_runs.model_version"?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; /** Regex on `name` — sessions carry no `name`, so this matches nothing; listed only because the shared query helper honours it. */ search?: string; /** Include disabled (soft-deleted) sessions. */ disabled?: boolean; }; export interface WriteQuery { key: string; command: "set" | "addToSet" | "pull"; value: any; } export namespace Find { export type Params = DefaultPaginationQueryParams & FilterParams & { populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = DataWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } /** Bulk update: `writeQuery[]` is applied to every session matching the query filters. */ export namespace Patch { export type Params = FilterParams; export type Body = { writeQuery: WriteQuery[] }; export type Result = { nFound: number; nModified: number }; } export namespace Remove { export type ID = StringId; export interface Params { /** When `true`, also soft-delete the session's child tasks (default: tasks are kept as training data). */ cascade?: boolean; } export type Result = Data; } } export namespace ActivityAiObjectDetectionSessionFrame { export interface Device { platform?: string; os?: string; model?: string; app_version?: string; ar_engine?: "ARKit" | "ARCore"; } export interface CaptureSettings { rate_hz?: number; recording_enabled?: boolean; target_distance_m?: number; resolution?: "medium" | "high" | "max" | string; } /** Floor lock from the capture entry phase (skippable on the device). */ export interface Ground { y_world?: number; samples?: number; spread_m?: number; camera_height_m?: number; } /** Per-frame AR metadata carried in `meta_inline` (JSON). Fields map onto the materialized task's `frame_meta`; camelCase device aliases (`trackingScore`, `eulerYPR`, `imageStats`, `driftM`, `velocityMps`, `imageRotationDeg`, `depth.{width,height,minM,maxM,distanceToShelfM,confidence}`) are also tolerated. */ export interface MetaInline { /** Device-generated session id (4-char). Required here or as the top-level `session_id`. */ session_id?: string; /** Fallback `media.mediaStorages` _id of the frame image when not sent top-level. */ media_id?: string; /** Session-scoped frame counter. */ frame_id?: number; /** Device epoch (ms). */ ts?: number; /** 16-float 4x4 pose matrix, column-major. */ pose?: number[]; /** 3-float yaw/pitch/roll in degrees. */ euler_ypr?: number[]; intrinsics?: { fx: number; fy: number; cx: number; cy: number }; distortion?: { k1?: number; k2?: number; k3?: number; p1?: number; p2?: number; }; tracking?: { state?: "NORMAL" | "LIMITED" | "LOST"; /** 0..1 (a 0..100 device value is normalized). */ score?: number; drift_m?: number; velocity_mps?: number; }; /** Shelf-distance gate (metres) captured at the frame. */ distance_to_shelf_m?: number; image_stats?: { iso?: number; shutter?: number; lux?: number; /** Variance-of-Laplacian focus measure; -1 = unmeasured. */ sharpness?: number; }; /** Depth-map summary from the device (width/height + confidence fractions persist on `frame_meta.depth_summary`). */ depth?: { width?: number; height?: number; minM?: number; maxM?: number; distanceToShelfM?: number; confidence?: { high?: number; medium?: number; low?: number }; }; depth_source?: "lidar" | "estimated" | "none"; /** [width, height] of the depth blob. */ depth_shape?: number[]; /** [width, height] of the image. */ image_shape?: number[]; /** Nearest depth sample in the frame, metres (app >= 0.39.0). */ min_distance_depth?: number; /** Farthest depth sample in the frame, metres. */ max_distance_depth?: number; /** Depth span (max - min), metres. */ depth_variation?: number; yaw_degree?: number; pitch_degree?: number; roll_degree?: number; /** Variance-of-Laplacian focus measure (higher = sharper). */ frame_sharpness?: number; /** Device validator verdict for the frame at capture time. */ capture_tier?: "good" | "warn" | "error"; /** Epoch ms of the app's last successful detection-settings poll before this frame. */ detection_settings_polled_at?: number; /** Degrees the sensor image was rotated CW to produce the stored image. */ image_rotation_deg?: number; /** Applied to the session on first frame; `app_version` is also persisted per frame. */ device?: Device; /** Applied to the session on first frame. */ capture_settings?: CaptureSettings; /** Device-computed swept shelf area for the whole session so far, m² (upserted onto the session via $max). */ coverage_m2?: number; /** 'gravity' on both ARKit and ARCore. */ world_alignment?: string; ground?: Ground; /** Camera height above the locked floor while shooting, metres. */ eye_level_m?: number; /** True when the rep tapped Skip on the floor point. */ ground_skipped?: boolean; /** `ai-object-detection-category` _id picked on the device (non-fatal when it no longer exists). */ category?: string; /** `ai-object-detection-mission` _id the session was started FROM (non-fatal when it no longer exists). */ mission?: string; /** Alias of the top-level `visit_id` (the top-level field wins). */ visit_id?: string; /** Alias of the top-level `route`. */ route?: string; /** Alias of the top-level `business_day`. */ business_day?: string; /** Alias of the top-level `time_zone`. */ time_zone?: string; /** Completion marker — a frameless POST sent once the upload queue drains. */ session_complete?: boolean | string; } export interface FrameGeoTag { lat: number; lng: number; formatted_address?: string; extra?: any; } /** The stored activity frame document (collection `ai.objectDetectionSessionFrames`). The image, `frame_meta` and depth/confidence media live on the referenced `task`. Not readable through this service — query tasks by `?session=` instead. */ export interface Data { _id: StringId; company_namespace: string[]; /** `clients` _id the captured shelf belongs to. */ client: StringId; /** `representatives` _id of the capturing rep. */ rep?: StringId; /** Parent `ai-object-detection-session` _id. */ session: StringId; /** Device-generated session id. */ session_id?: string; /** The materialized `ai-object-detection-task` _id. */ task?: StringId; /** DEVICE visit id (`visits.visit_id`), stored as-is. */ visit_id?: string; /** `sv.routes` _id. */ route?: StringId; /** `YYYY-MM-DD`. */ business_day?: string; time_zone?: string; geo_tag?: FrameGeoTag; /** Device epoch ms of the capture. */ time?: number; creator?: AdminOrRep; createdAt: Date; updatedAt: Date; } /** JSON-equivalent of the multipart frame intake. For a FRAME post `client`, `media_id` (top-level or in `meta_inline`) and `session_id` (top-level or in `meta_inline`) are required; for the COMPLETION marker only `session_id` + `session_complete: true`. */ export interface CreateBody { /** `media.mediaStorages` _id of the pre-uploaded RGB frame image (becomes the task's `file_media`). */ media_id?: StringId; /** Fallback device session id when not present inside `meta_inline`. */ session_id?: string; /** Per-frame AR metadata — JSON string or already-parsed object. */ meta_inline?: string | MetaInline; /** Alias for `meta_inline`. */ meta?: string | MetaInline; /** `clients` _id the captured shelf belongs to (must exist and not be disabled in the namespace). */ client?: StringId; /** `representatives` _id of the capturing rep; defaults to the rep in the token. */ rep?: StringId; /** DEVICE visit id (`visits.visit_id`) the scan happened in — stored as-is on the frame and the parent session. */ visit_id?: string; /** `sv.routes` _id of the visit's route. */ route?: StringId; /** `YYYY-MM-DD` (rejected otherwise). When absent the session is stamped once from the capture time under the rep's stamping context. */ business_day?: string; /** IANA timezone of the device at capture. */ time_zone?: string; /** `{ lat, lng, formatted_address? }` — JSON string in multipart bodies; `lat`/`lng` must be numeric. */ geo_tag?: string | { lat?: number; lng?: number; formatted_address?: string }; /** Device epoch ms of the capture. */ time?: number | string; /** Completion-marker mode (alias of `meta_inline.session_complete`). */ session_complete?: boolean | string; company_namespace?: string[]; } /** Response of a frame post. */ export interface FrameResult { /** The parent session `_id`. */ session: StringId; session_id: string; /** The materialized task `_id`. */ task: StringId; /** The activity frame document `_id`. */ frame: StringId; frame_id?: number; client: StringId; /** Media id of the frame image (= `media_id`). */ file_media: StringId; /** Media id of the uploaded depth blob, if a `depth` file part was sent. */ depth_media?: StringId; /** Media id of the uploaded confidence blob, if a `confidence` file part was sent. */ confidence_media?: StringId; } /** Whether the category auto-analysis was fired by the completion marker. */ export interface AutoAnalysisResult { triggered: boolean; /** Present when not triggered: `no_category`, `category_has_no_model_settings`, `session_verdict_rejected`, `error`. */ reason?: string; category?: StringId; /** Number of category `model_settings` items queued (run serially in the background). */ runs?: number; } /** Response of a `session_complete: true` (frameless) post. */ export interface SessionCompleteResult { session: StringId; session_id: string; status: "uploaded"; auto_analysis: AutoAnalysisResult; } export namespace Create { export type Body = CreateBody; export type Result = FrameResult | SessionCompleteResult; } } export namespace AiObjectDetectionSessionAnalysis { /** `pending` (opened) → `in_progress` (background job started) → `success` | `failed` (`_errors`). */ export type AnalysisStatus = "pending" | "in_progress" | "success" | "failed"; /** Fusion / composition tuning knobs (`SceneMathConfig`). Every key is optional — omit for the server defaults. */ export interface SceneMathConfig { /** Run-level alias of the top-level `inference_concurrency` (1..10, default 4); the top-level field wins. */ inference_concurrency?: number; /** Base world distance to merge detections into one object (default 0.08 m). */ cluster_eps_m?: number; /** Extra merge radius when labels match (default 0.02 m). */ class_agree_bonus_m?: number; /** A scene object absorbs at most ONE detection per frame (default true). */ block_same_frame?: boolean; /** Ignore depth below this (default 0.05 m). */ min_depth_m?: number; /** Ignore depth above this (default 6 m). */ max_depth_m?: number; /** Min ARKit depth-confidence to keep a pixel: 0/1/2 (default 1). */ conf_threshold?: number; /** Percentile of bbox depths to take, front-biased (default 30). */ front_percentile?: number; /** Depth gate slack beyond `distance_to_shelf_m` (default 0.30 m). */ shelf_tolerance_m?: number; /** Same-frame gate: same-label 2D IoU at/above this = duplicate box (default 0.92). */ same_frame_iou_thresh?: number; /** Same-frame gate: same-label world distance below this = same spot (default 0.02 m). */ same_frame_min_separation_m?: number; /** Same-frame gate: drop detections under this detector confidence (default 0 = off). */ min_detection_confidence?: number; /** Same-frame gate: drop implausibly small front faces (default 0.5 cm). */ min_object_size_cm?: number; /** Same-frame gate: drop implausibly large front faces (default 500 cm). */ max_object_size_cm?: number; /** Cross-frame matcher: consensus-plane projection matching (default true). */ plane_merge?: boolean; /** Min projected-rect IoU to merge (default 0.1). */ plane_merge_iou?: number; /** Max plane-depth difference to merge, metres (default 0.25). */ plane_merge_depth_delta_m?: number; /** Dims reclassifier master switch (default false). */ reclassify_labels?: boolean; reclassify_keep_dev?: number; reclassify_target_dev?: number; reclassify_min_margin?: number; reclassify_conf_margin_scale?: number; reclassify_weight_scale?: number; reclassify_weight_aspect?: number; reclassify_min_depth_confidence?: number; /** Post-walk merge of overlapping same-group clusters (default true; only with `reclassify_labels`). */ group_consensus_merge?: boolean; /** Physical size gate master switch (default true). */ size_gate?: boolean; size_gate_dims_allowance?: number; size_gate_area_allowance?: number; size_gate_min_depth_confidence?: number; /** Shelf composition master switch (default true). */ shelf_analysis?: boolean; shelf_support_min_overlap?: number; shelf_gap_split_m?: number; shelf_min_spacing_m?: number; shelf_stack_max_penetration_m?: number; shelf_row_split_m?: number; shelf_min_stacks?: number; /** Build + store the voxel point cloud and RANSAC shelf planes (default true). */ build_point_cloud?: boolean; pc_stride?: number; pc_voxel_size_m?: number; ransac_max_planes?: number; ransac_min_inlier_ratio?: number; ransac_distance_thresh_m?: number; } export interface Vec3 { x?: number; y?: number; z?: number; } /** 2D box (YOLO-normalized cx, cy, w, h as stored by the backend). */ export interface Box2D { x1?: number; y1?: number; x2?: number; y2?: number; } export interface ArbitrationScore { task_id?: StringId; annotation_id?: StringId; frame_id?: number; score?: number; winner?: boolean; /** Six normalized inputs of the weighted view score. */ inputs?: { det?: number; depth?: number; track?: number; center?: number; size?: number; agree?: number; }; } /** Winner-selection rationale (mixed-type field on the model). */ export interface Arbitration { strategy?: string; weights?: { [factor: string]: number }; scores?: ArbitrationScore[]; [key: string]: any; } /** A concluded object on the shelf (one per cross-frame cluster). */ export interface AnalysisObject { /** Contributing task annotations carry this id in their `cluster_id` after the run succeeds. */ _id: StringId; label_id?: StringId; label_name?: string; /** `kept` = single facing, `merged` = several facings fused. */ state?: "kept" | "merged"; /** Fused placement confidence, 0..1. */ confidence?: number; /** Centroid in world coordinates, metres. */ world?: Vec3; /** Physical front-face size, centimetres. */ size?: { w?: number; h?: number }; /** Distance from the camera, metres. */ depth?: number; /** Metres above the device-locked floor; null when the rep skipped the floor point. */ height_above_ground_m?: number | null; /** Facing rotation about world-Y, radians; null when the winning task lacks a pose. */ yaw?: number | null; /** How many facings/frames contributed. */ cluster_size?: number; bbox_3d?: { min?: number[]; max?: number[] }; winning_task?: StringId; winning_annotation_id?: StringId; /** Winner's 2D crop region on `winning_image_media`. */ winning_box?: Box2D; /** `media.mediaStorages` id of the winning frame image (crop source). */ winning_image_media?: StringId; contributing_tasks?: StringId[]; arbitration?: Arbitration; } /** Per-label conclusion — detection counts by outcome. */ export interface ConcludedLabel { _id?: StringId; label_id?: StringId; label_name?: string; /** Detections placed as a single facing. */ kept: number; /** Detections fused into multi-facing objects. */ merged: number; /** Detections that could not be placed. */ ignored: number; /** Detections removed by same-frame quality gates. */ dropped: number; /** Detections dropped by the physical-size gate. */ size_rejected: number; /** Resulting objects (kept + merged clusters). */ object_count: number; } /** A detection that could not be placed in world coordinates. */ export interface IgnoredDetection { _id?: StringId; task?: StringId; annotation_id?: StringId; label_id?: StringId; frame_id?: number; /** `no_pose`, `no_intrinsics`, `no_depth`, `empty_depth_region`, `insufficient_depth_pixels`, `behind_shelf`, or `not_placed`. */ reason?: string; } export type LedgerDisposition = | "new_object" | "re_observation" | "dropped_same_frame" | "size_rejected" | "unplaced"; /** Audit trail of ONE detection through the fusion pipeline — where it went and why. */ export interface DetectionLedgerEntry { _id?: StringId; task?: StringId; annotation_id?: StringId; label_id?: StringId; label_name?: string; frame_id?: number; disposition?: LedgerDisposition; /** Machine cause: `first_observation`, `re_observation`, `duplicate_box_in_frame`, `same_spot_in_frame`, `below_min_confidence`, `implausible_size`, `size_gate`, or an unplaced reason. */ reason?: string; /** Human-readable explanation, ready to render. */ detail?: string; /** The `objects[]._id` this detection created or merged into. */ object_id?: StringId; /** For same-frame drops — the stronger sibling that was kept. */ kept_by_annotation_id?: StringId; /** For re-observations — world distance to the object, metres. */ matched_distance_m?: number; world?: Vec3; box?: Box2D; confidence?: number; placement_confidence?: number; } /** Fusion funnel counters — the "where did the detections go" summary. */ export interface AnalysisFunnel { tasks?: number; /** Frames whose boxes came from a confirmed HUMAN annotation group. */ tasks_manual?: number; detections_total?: number; unplaced?: number; size_rejected?: number; frames?: number; detections_placed?: number; dropped_same_frame?: number; re_observations?: number; new_objects?: number; /** After the group-consensus merge. */ clusters_final?: number; } /** Which annotation group each frame contributed (human truth first). */ export interface FrameSource { _id?: StringId; task?: StringId; group_id?: StringId; annotation_state?: "auto" | "manual" | "auto_edited"; model_version?: StringId; /** Lets the UI flag analyses older than a frame's latest correction. */ edit_time?: number; } /** Per-stage config hashes; staleness is a fingerprint diff. */ export interface StageFingerprints { detect: string; fuse: string; compose: string; } export interface ComposedStack { /** 0 = leftmost as the shopper sees the shelf. */ index?: number; u_from?: number; u_to?: number; y_from?: number; y_to?: number; /** Plane depth of the stack (m; larger = closer to the shopper). */ s?: number; /** 0 = front row (closest to the shopper). */ row?: number; /** Refs into `objects[]._id`, ordered bottom-up. */ object_ids?: StringId[]; } export interface ComposedShelf { /** 0 = the lowest shelf. */ index?: number; /** Board level (world Y, metres). */ y_world?: number; /** Shelf level above the device-locked floor; null when not locked. */ height_above_ground_m?: number | null; u_from?: number; u_to?: number; /** Median plane depth of member stacks (metres). */ s?: number; stacks?: ComposedStack[]; } /** Planogram structure (shelves → stacks → objects) composed from the fused objects' world geometry. */ export interface ShelfComposition { /** Orthonormal basis: `n` = horizontal unit normal toward the shopper, `u` = up × n (shopper's right). */ plane?: { n?: number[]; u?: number[] }; orientation?: "shopper" | string; shelves?: ComposedShelf[]; /** Objects that didn't land on a shelf level (hook walls, sparse levels). */ unshelved?: { object_id?: StringId; reason?: string }[]; } /** Bounded shelf plane peeled off the voxel cloud by RANSAC. */ export interface ShelfPlane { normal?: number[]; /** A point on the plane (inlier centroid), metres. */ point?: number[]; extent_min?: number[]; extent_max?: number[]; inlier_count?: number; /** Inliers / cloud points, 0..1. */ inlier_ratio?: number; } /** Scene-level outputs — all best-effort (omitted when they can't be computed). */ export interface AnalysisScene { /** Dominant plane over all placed detections (legacy single plane). */ plane?: { normal?: number[]; d?: number; centroid?: number[]; inliers?: number; }; /** RANSAC shelf planes, strongest first. */ planes?: ShelfPlane[]; /** Voxel point cloud metadata; the packed Float32 `[x,y,z,r,g,b,w]` blob lives in `media` (bin). */ point_cloud?: { media?: StringId; num_points?: number; voxel_size_m?: number; aabb_min?: number[]; aabb_max?: number[]; }; } export interface Data { _id: StringId; company_namespace: string[]; disabled: boolean; /** The analyzed `ai-object-detection-session` _id. */ session: StringId; /** `ai-object-detection-model-version` _id used to infer not-yet-placed tasks. */ model_version?: StringId; config?: SceneMathConfig; status: AnalysisStatus; /** Epoch ms. */ started_at?: number; /** Epoch ms. */ finished_at?: number; /** Liveness heartbeat (epoch ms) refreshed by the background run; a pending/in_progress run without one for 15 min is auto-failed by the next create. */ heartbeat_at?: number; tasks_total: number; /** Tasks inferred during this run (not previously placed). */ tasks_inferred: number; /** Detections kept (single facings). */ kept_count: number; /** Detections merged into objects. */ merged_count: number; /** Detections that could not be placed. */ ignored_count: number; /** Detections dropped by the physical-size gate. */ size_rejected_count: number; /** Same-frame quality-gate drops. */ dropped_count: number; /** Resulting objects (kept + merged). */ objects_count: number; objects?: AnalysisObject[]; concluded_labels?: ConcludedLabel[]; ignored?: IgnoredDetection[]; /** Per-detection fusion audit trail (one entry per analyzed annotation). */ detections?: DetectionLedgerEntry[]; funnel?: AnalysisFunnel; frame_sources?: FrameSource[]; stage_fingerprints?: StageFingerprints; /** Present unless `config.shelf_analysis: false` or nothing was placed (null after a compose recompute that produced nothing). */ shelf_composition?: ShelfComposition | null; scene?: AnalysisScene; _errors?: any[]; /** Who triggered the run (server-stamped). */ creator?: AdminOrRep; editor?: AdminOrRep; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = | "session" | "model_version" | "objects.label_id" | "objects.winning_image_media" | "concluded_labels.label_id"; export interface AnalysisObjectWithPopulatedKeys extends Omit< AnalysisObject, "label_id" | "winning_image_media" > { label_id?: StringId | AiObjectDetectionLabel.Data; winning_image_media?: StringId | MediaStorage.MediaStorageSchema; } export interface ConcludedLabelWithPopulatedKeys extends Omit< ConcludedLabel, "label_id" > { label_id?: StringId | AiObjectDetectionLabel.Data; } /** Every population key is applied IN PLACE (the referenced field is replaced by the populated document). */ export interface DataWithPopulatedKeys extends Omit< Data, "session" | "model_version" | "objects" | "concluded_labels" > { session: StringId | AiObjectDetectionSession.Data; model_version?: StringId | AiObjectDetectionModelVersion.Data; objects?: AnalysisObjectWithPopulatedKeys[]; concluded_labels?: ConcludedLabelWithPopulatedKeys[]; } /** `create` is the analysis TRIGGER (async) — or, with `recompute: "compose"`, a synchronous compose-only recompute of an existing analysis. */ export interface CreateBody { /** The session to analyze. Required unless `recompute` is set. */ session?: StringId; /** Model version used to infer not-yet-placed tasks; tasks inferred by a different version are re-inferred. */ model_version?: StringId; /** Optional object-detection model _id override (resolves `current_model_version` when `model_version` is absent). */ model?: StringId; /** Detector for tasks inferred during this run (default `auto`). */ engine?: "auto" | "trained" | "zero_shot"; /** Zero-shot VLM override, e.g. `qwen/qwen3-vl-8b-instruct`. */ zero_shot_model?: string; /** Detector confidence override. */ conf?: number; /** Detector NMS IoU override (0..1). */ iou?: number; /** Class-agnostic NMS override. */ agnostic_nms?: boolean; config?: SceneMathConfig; /** Re-infer EVERY task even if it already has an auto group for this version (stale-provenance escape hatch). */ force_reinference?: boolean; /** Parallel inference calls (1..10, default 4); wins over `config.inference_concurrency`. */ inference_concurrency?: number; /** `compose` re-runs ONLY the shelf composition of `analysis` with the `shelf_*` keys of `config`, synchronously and in place. */ recompute?: "compose"; /** The existing analysis _id to recompute (required with `recompute`). */ analysis?: StringId; company_namespace?: string[]; } /** PUT applies the body as an update; `editor` is server-stamped. Set `disabled: true` to soft-delete. */ export type UpdateBody = Partial< Omit< Data, | "_id" | "createdAt" | "updatedAt" | "company_namespace" | "creator" | "editor" > >; /** Filter keys honoured by `find` and by the bulk `patch`. */ export type FilterParams = { _id?: StringId | StringId[]; session?: StringId | StringId[]; model_version?: StringId | StringId[]; status?: AnalysisStatus | AnalysisStatus[]; "creator._id"?: StringId | StringId[]; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; /** Regex on `name` — analyses carry no `name`, so this matches nothing; listed only because the shared query helper honours it. */ search?: string; /** Include disabled (soft-deleted) analyses. */ disabled?: boolean; }; export interface WriteQuery { key: string; command: "set" | "addToSet" | "pull"; value: any; } export namespace Find { export type Params = DefaultPaginationQueryParams & FilterParams & { populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export interface Params { populatedKeys?: PopulatedKeys[]; } export type Result = DataWithPopulatedKeys; } export namespace Create { export type Body = CreateBody; /** Normal path: the `pending` document plus `message` (work continues in the background — poll until `status` flips). Compose recompute: the updated analysis document (no `message`). */ export type Result = Data & { message?: string }; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } /** Bulk update: `writeQuery[]` is applied to every analysis matching the query filters. */ export namespace Patch { export type Params = FilterParams; export type Body = { writeQuery: WriteQuery[] }; export type Result = { nFound: number; nModified: number }; } export namespace Remove { export type ID = StringId; export type Result = Data; } } export namespace AiObjectDetectionSessionElection { export type SessionVerdict = AiObjectDetectionSession.SessionVerdict; /** A source frame excluded from the election because it violated the namespace detection-settings ERROR tier. */ export type ElectionExcluded = AiObjectDetectionSession.ElectionExcluded; /** The NEW session materialized by an election. It is a regular `ai-object-detection-session` document (same collection) whose election fields are always set. */ export interface Data extends AiObjectDetectionSession.Data { /** The source session's `session_id` suffixed `-E` (n = 1 + prior elections of that source). */ session_id: string; /** Provenance — the source session `_id`. */ source_session: StringId; /** Average frame quality over ALL frames of the source session, 0..1 (rounded to 3 decimals). */ session_score: number; /** `rejected` when any rejection reason fired, else banded from `session_score`. */ session_verdict: SessionVerdict; /** `coverage_below_target`, `jump_detected`, `too_many_elected`. */ rejection_reasons: string[]; /** Error-tier frames dropped from the clone (they stay on the source session). */ election_excluded: ElectionExcluded[]; } export interface CreateBody { /** Source `ai-object-detection-session` _id the frames belong to. */ session: StringId; /** Task `_id`s (frames of the source session) elected in the playground — 1..500, all must belong to `session`. */ task_ids: StringId[]; /** Optional playground formula parameters, stored for provenance only (not persisted on the session model). */ config_snapshot?: { [key: string]: number | boolean }; company_namespace?: string[]; } export namespace Create { export type Body = CreateBody; /** The newly created session document (`toObject()` of the insert). */ export type Result = Data; } } export namespace AiObjectDetectionSessionInsight { /** Vocabulary kinds a question target / rollup row can refer to. */ export type TargetKind = | "label" | "label_group" | "brand" | "category" | "subcategory" | "product"; export type QuestionType = "share_of_shelf" | "blocking" | "adjacency"; /** Rollup keys of `share_of_shelf` / `blocking`: `by_label` is always present; the others only when the scene's labels link to entities of that kind. */ export type RollupKey = | "by_label" | "by_label_group" | "by_brand" | "by_category" | "by_subcategory" | "by_product"; /** All optional on input; invalid values fall back to the defaults (values are clamped). */ export interface InsightConfig { /** Echoed for contract compatibility (default 0.06) — shelf levels now come from the analysis's stored composition. */ min_shelf_gap_m: number; /** Echoed for contract compatibility (default 0.35). */ shelf_gap_height_factor: number; /** Fallback facing width (m) when a facing has no measured size (default 0.08). */ default_facing_width_m: number; /** Vertical block merge — required axis overlap (m) between adjacent-shelf runs (default 0.03)… */ block_min_overlap_m: number; /** …or this fraction of the narrower run's width, whichever is smaller (default 0.5). */ block_overlap_frac: number; } export interface InsightQuestion { type: QuestionType; /** Resolved by `id` first, then exact name, then substring, then fuzzy tokens. */ target: { kind?: TargetKind; id?: StringId; name?: string }; } export interface LabelFacings { label_id: StringId; label_name?: string; facings: number; } export interface ShareRow { key: string; kind: TargetKind; name: string; facings: number; linear_cm: number; area_cm2: number; /** 0..1 of all detected facings. */ facing_share: number; /** 0..1 of the total linear cm. */ linear_share: number; /** 0..1 of the total measured area. */ area_share: number; shelves: { shelf_index: number; facings: number; linear_cm: number; linear_share_of_shelf: number; }[]; labels: LabelFacings[]; } export interface BlockRun { shelf_index: number; /** Left edge along the shelf axis û (m). */ t0: number; t1: number; facings: number; facing_ids: StringId[]; } export interface Blocking { present: boolean; facings: number; labels_present: LabelFacings[]; blocks_count: number; /** True when every facing of the group sits in ONE contiguous block. */ is_single_block: boolean; largest_block_facings: number; /** 0..1. */ largest_block_share: number; blocks: { shelves: number[]; facings: number; runs: BlockRun[] }[]; /** Foreign labels breaking the block, ranked by interrupting facings. */ interrupters: LabelFacings[]; shelves_spanned: number[]; } /** A `blocking` rollup row (`Blocking` + identity + narrative). */ export interface BlockingRow extends Blocking { key: string; name: string; narrative: string; } export interface InsightShelf { /** 0 = bottom shelf. */ index: number; /** Board level (m, AR world frame). */ y_base_m: number; facings: number; linear_cm: number; span_cm: number; /** linear_cm / span_cm — how much of the used span is product (0..1). */ utilization: number; } export interface PlanogramFacing { id: StringId; label_id: StringId; label_name?: string; /** 1-based position left→right on the shelf. */ position: number; /** Re-based to the shelf's left-most facing (cm). */ from_cm: number; to_cm: number; w_cm: number; h_cm?: number; confidence?: number; } export interface PlanogramShelf { shelf_index: number; facings: PlanogramFacing[]; } export interface AdjacencyRow { label_id: StringId; label_name?: string; neighbors: { label_id: StringId; label_name?: string; count: number }[]; } export interface AnswerTarget { kind: TargetKind; name: string; label_ids: StringId[]; } /** One answer per question, in order. Unresolved answers carry `reason` (+ `suggestions`). */ export interface Answer { question: string | InsightQuestion; type?: QuestionType; resolved: boolean; reason?: string; suggestions?: string[]; target?: AnswerTarget; /** `ShareRow` for share_of_shelf, `Blocking` for blocking, `{ neighbors }` or `{ present: false }` for adjacency. */ result?: | ShareRow | Blocking | { neighbors: { label_id: StringId; label_name?: string; count: number; }[]; } | { present: false }; narrative?: string; } /** The insight payload — computed on read, never persisted. */ export interface Data { session: StringId; /** The analysis the numbers were derived from (latest successful one unless an explicit `analysis` was given). */ analysis: StringId; model_version?: StringId; /** Epoch ms of the analysis run's completion. */ analysis_finished_at?: number; /** Epoch ms — always freshly computed. */ computed_at: number; config_used: InsightConfig; scene: { facings_placed: number; /** Analysis objects not counted as facings (back rows / unshelved). */ objects_skipped: number; shelf_count: number; /** Unit shelf-axis direction û in the horizontal plane. */ axis: { dir_x: number; dir_z: number }; }; totals: { facings: number; linear_cm: number; area_cm2: number }; shelves: InsightShelf[]; share_of_shelf: Partial>; blocking: Partial>; /** Only with `include_objects`. */ objects?: PlanogramShelf[]; /** Only with `include_adjacency`. */ adjacency?: AdjacencyRow[]; /** Only on `create` (POST) when `questions` were sent. */ answers?: Answer[]; } /** POST body — compute the insight and answer up to 20 questions. One of `session` / `analysis` is required. */ export interface CreateBody { /** Session _id — reads its LATEST successful analysis. */ session?: StringId; /** Explicit analysis _id (must have `status: success`). */ analysis?: StringId; /** Free-text strings and/or structured questions, answered in order (max 20). */ questions?: (string | InsightQuestion)[]; config?: Partial; include_objects?: boolean; include_adjacency?: boolean; } export namespace Find { /** One of `session` / `analysis` is required. */ export type Params = { /** Session _id — reads its LATEST successful analysis. */ session?: StringId; /** Explicit analysis _id (must have `status: success`). */ analysis?: StringId; /** Add the planogram-style facing dump per shelf. */ include_objects?: boolean; /** Add label-level neighbour counts. */ include_adjacency?: boolean; }; /** A single computed payload — NOT paginated. */ export type Result = Data; } export namespace Get { /** The path id is read as a SESSION id (deep link). */ export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; /** The insight payload plus `answers[]` when questions were sent. */ export type Result = Data; } } export namespace AiObjectDetectionMetric { /** Engine registry key — selects the `args` schema, the output family and the evaluator. */ export type MetricType = | "adjacent_block" | "facings_count" | "on_shelf_availability" | "share_of_shelf"; /** Output family: fixes what a result's `answer` means and where its 0..1 `score` comes from. */ export type MetricOutputFamily = "compatibility" | "numerical" | "share_of_shelf"; /** width_cm = linear share (occupied shelf length), area_cm2 = front-face areas, facings = unit count. */ export type ShareOfShelfMeasure = "width_cm" | "area_cm2" | "facings"; /** Args for `type: "adjacent_block"` (compatibility family) — "these labels must stand together". */ export interface AdjacentBlockArgs { /** Label ids that form the block (≥ 1). */ labels: StringId[]; /** Minimum member facing count (inclusive, ≥ 0). */ from: number; /** Maximum member facing count (inclusive, ≥ from). */ to: number; /** Judge only the shopper-visible front row. Default true. */ front_row_only?: boolean; } /** Args for `type: "facings_count"` (numerical family) — how many facings of the labels does the shopper see. */ export interface FacingsCountArgs { /** Label ids to count (≥ 1). */ labels: StringId[]; /** Optional demanded count (integer ≥ 1) — score = answer ÷ target_answer (clamped to 1). Absent: non-zero answer scores 1, zero scores 0. */ target_answer?: number; /** Count only the shopper-visible front row. Default true. */ front_row_only?: boolean; } /** Args for `type: "on_shelf_availability"` (numerical family) — how much of what SHOULD be on the shelf is. */ export interface OnShelfAvailabilityArgs { /** The label ids that SHOULD be on the shelf (≥ 1). */ labels: StringId[]; /** Optional demanded count of AVAILABLE labels (integer ≥ 1, never above labels.length) — score = answer ÷ target_answer. Absent: score = availability ratio. */ target_answer?: number; /** Default FALSE — a product in a back row is still available. */ front_row_only?: boolean; } /** One segment row of a share-of-shelf metric. */ export interface ShareOfShelfSegmentArg { /** Segment id (`/ai-object-detection-segment`) — must exist, not be deleted, and appear in only one row. */ segment: StringId; /** Optional per-metric label override; empty/absent ⇒ the segment's own labels. */ labels?: StringId[]; /** The MAIN row the target_ratio is defined for — exactly one per metric (server flags the first row when none is set). */ main?: boolean; } /** Args for `type: "share_of_shelf"` (share_of_shelf family). */ export interface ShareOfShelfArgs { /** Segment rows (≥ 1); exactly one is `main`. */ segments: ShareOfShelfSegmentArg[]; /** The share the MAIN segment must reach for full score (0.001..1). */ target_ratio: number; /** Default "width_cm". */ measure?: ShareOfShelfMeasure; /** Measure only the shopper-visible front row. Default true. */ front_row_only?: boolean; /** width_cm only (default true): count each vertical pile ONCE (the bottom object books the shelf distance). false = legacy per-unit width sum. */ first_in_stack?: boolean; } /** Client-sent args — must match the metric's `type`. Unknown keys are dropped and defaults applied server-side. */ export type MetricArgs = | AdjacentBlockArgs | FacingsCountArgs | OnShelfAvailabilityArgs | ShareOfShelfArgs; /** Stored args: the client shape plus the server-stamped discriminator mirror `type` (clients never send it). */ export type StoredMetricArgs = MetricArgs & { type?: MetricType }; /** One argument declaration from the type registry (`find({ registry: true })`). */ export interface MetricArgField { key: string; type: "labels" | "number" | "integer" | "boolean" | "enum" | "segments"; required: boolean; /** Numeric bounds (number/integer). */ min?: number; max?: number; /** Default applied when an optional arg is absent. */ default?: unknown; /** labels / segments: minimum item count. */ min_items?: number; /** enum: the allowed values. */ options?: string[]; } /** One metric TYPE declaration from the registry — lets generic clients render forms without hardcoding. */ export interface MetricTypeDeclaration { type: MetricType; output: MetricOutputFamily; args: MetricArgField[]; /** Result output keys a human may override (`score`/`ratio` are always derived). */ overwritable: string[]; } export interface Data { _id: StringId; name: string; description?: string; type: MetricType; args: StoredMetricArgs; /** false pauses evaluation without losing the definition. Default true. */ enabled: boolean; /** Soft-delete flag. */ disabled: boolean; /** Server-stamped from the creating token. */ creator?: AdminOrRepOrTenantOrClient; /** Server-stamped on update / remove. */ editor?: AdminOrRepOrTenantOrClient; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; description?: string; type: MetricType; /** Validated against `type`'s schema; EVERY violation is reported in one 400. share_of_shelf rows must reference live segments. */ args: MetricArgs; enabled?: boolean; company_namespace?: string[]; } /** PUT re-validates `type` + `args` (both required — the update is a full re-definition); `_id`, `company_namespace` and `creator` are stripped server-side. */ export interface UpdateBody { type: MetricType; args: MetricArgs; name?: string; description?: string; enabled?: boolean; /** Set true to soft-delete via update. */ disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; /** Exact name match. */ name?: string | string[]; type?: MetricType | MetricType[]; enabled?: boolean; /** Case-insensitive regex on `name`. */ search?: string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; /** true ⇒ the response is a `RegistryResult` (type declarations) instead of a paginated list. */ registry?: boolean; }; export interface PaginatedResult extends DefaultPaginationResult { data: Data[]; } /** Returned when `registry: true` is passed. */ export interface RegistryResult { /** Bumped whenever a type's semantics change; results carry the version they were computed with. */ engine_version: number; types: MetricTypeDeclaration[]; } export type Result = PaginatedResult | RegistryResult; } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; /** The soft-deleted document (`disabled: true`). */ export type Result = Data; } } export namespace AiObjectDetectionMetricResult { /** Evaluation outcome of one result row. */ export type Status = "ok" | "error"; /** Computed layer for `type: "adjacent_block"` (compatibility family). */ export interface AdjacentBlockComputed { /** Internal discriminator mirror of the result's `type`. */ type?: "adjacent_block"; output: "compatibility"; /** The verdict — contiguous AND count within [from, to]. */ answer: boolean; score: number; member_count: number; cut_count: number; in_range: boolean; /** Contiguous member runs (1-based shelf / stack indices). */ blocks: { shelf: number; from_stack: number; to_stack: number; count: number; }[]; } /** Computed layer for `type: "facings_count"` (numerical family). */ export interface FacingsCountComputed { type?: "facings_count"; output: "numerical"; /** The collected facings count. */ answer: number; /** Echo of the metric's optional target — present only when set; score then = answer ÷ target_answer (clamped). */ target_answer?: number; score: number; shelves: { shelf: number; count: number }[]; } /** Computed layer for `type: "on_shelf_availability"` (numerical family). */ export interface OnShelfAvailabilityComputed { type?: "on_shelf_availability"; output: "numerical"; /** How many of the selected labels are AVAILABLE (≥ 1 facing). */ answer: number; /** answer ÷ target_answer when a target is set, else `ratio`. */ score: number; /** How many labels were selected (the denominator). */ total: number; /** answer / total — availability. */ ratio: number; target_answer?: number; /** The out-of-stock labels (names resolved at evaluation time). */ missing: { label: StringId; name?: string }[]; /** The available labels with their facing counts. */ present: { label: StringId; name?: string; facings: number }[]; } /** One segment row's outcome inside a share-of-shelf evaluation; only the MAIN row carries target/score. */ export interface SegmentOutput { segment: StringId; name: string; /** false = the segment was deleted after the metric referenced it. */ resolved: boolean; /** The row the metric's target is defined for — exactly one per metric. */ main: boolean; /** Effective labels used (override or the segment's own). */ labels: StringId[]; /** Measured quantity in the metric's measure unit. */ answer: number; /** CONFIRMED human answer override colocated in the row (effective = overwrite_answer ?? answer); present only while `confirmed_edit`. */ overwrite_answer?: number; overwrite_ratio?: number; overwrite_score?: number; /** answer / category total. */ ratio: number; /** Main row only. */ target_ratio?: number; /** Main row only — target_ratio × total. */ target_answer?: number; /** Main row only — min(1, ratio / target_ratio). */ score?: number; } /** Computed layer for `type: "share_of_shelf"` — the MAIN segment's numbers at the top level, every row in `segments[]`. */ export interface ShareOfShelfComputed { type?: "share_of_shelf"; output: "share_of_shelf"; /** The MAIN segment's measured quantity; null when nothing was measurable. */ answer: number | null; /** = the main segment's score. */ score: number; /** The considered category: the same measure over facings of ANY of the metric's segments. */ total: number; /** answer / total. */ ratio: number; target_ratio: number; /** target_ratio × total. */ target_answer: number; measure: AiObjectDetectionMetric.ShareOfShelfMeasure; /** Considered facings without a physical size (excluded from both sides). */ unmeasured: number; segments: SegmentOutput[]; } /** Machine layer — strict per-type engine output. Never editable through the API. */ export type Computed = | AdjacentBlockComputed | FacingsCountComputed | OnShelfAvailabilityComputed | ShareOfShelfComputed; /** Stored human layer for `adjacent_block` (entered values + server-derived `score`). */ export interface AdjacentBlockOverwrite { type?: "adjacent_block"; answer?: boolean; score?: number; member_count?: number; cut_count?: number; } export interface FacingsCountOverwrite { type?: "facings_count"; answer?: number; score?: number; } export interface OnShelfAvailabilityOverwrite { type?: "on_shelf_availability"; answer?: number; ratio?: number; score?: number; } export interface ShareOfShelfOverwrite { type?: "share_of_shelf"; answer?: number; total?: number; ratio?: number; score?: number; } /** Stored human layer — sparse VALUE overrides plus the server-DERIVED `ratio`/`score`. Survives recalculation. */ export type Overwrite = | AdjacentBlockOverwrite | FacingsCountOverwrite | OnShelfAvailabilityOverwrite | ShareOfShelfOverwrite; /** What a client may ENTER as an override: only the type's overwritable VALUE keys. `ratio`/`score` are rejected (derived server-side). Send `{}` to clear. */ export interface OverwriteInput { /** adjacent_block: boolean verdict; numerical / share_of_shelf types: number. */ answer?: boolean | number; /** adjacent_block only. */ member_count?: number; /** adjacent_block only. */ cut_count?: number; /** share_of_shelf only. */ total?: number; } export interface Data { _id: StringId; /** The metric definition this result was computed from. */ metric: StringId; /** The session analysis it was computed against. */ analysis: StringId; session?: StringId; /** Denormalized scan context (stamped by the evaluator): the SCANNING rep — unset for admin-scanned sessions. */ user?: StringId | null; user_name?: string | null; client?: StringId | null; client_name?: string | null; /** The scanning rep's team ids at evaluation time. */ teams?: StringId[]; /** Device visit id the scan happened in (copied from the session). */ visit_id?: string; route?: StringId; /** Business day of the scan, `YYYY-MM-DD`. */ business_day?: string; /** Metric name snapshot at evaluation time. */ name?: string; type: AiObjectDetectionMetric.MetricType; /** The type's output family (denormalized for rendering). */ output?: AiObjectDetectionMetric.MetricOutputFamily; /** Metric args snapshot at evaluation time. */ args?: AiObjectDetectionMetric.StoredMetricArgs; /** Machine layer; absent when the evaluation errored. */ computed?: Computed; /** Human layer (default `{ type }`). */ overwrite?: Overwrite; /** Human attention marker. Default false. */ flag: boolean; /** Admin review gate — the overwrite only drives the effective values while true. Default false. */ confirmed_edit: boolean; /** EFFECTIVE score 0..1 (confirmed `overwrite.score`, else `computed.score`). */ score?: number; /** EFFECTIVE answer (boolean verdict or number per family). */ answer?: boolean | number | null; /** EFFECTIVE ratio (OSA availability / SOS share); null for types without one. */ ratio?: number | null; status: Status; error?: string | null; /** Unix ms of the evaluation. */ evaluated_at?: number; engine_version?: number; /** The analysis's stage fingerprints at evaluation time — mismatch vs the analysis's current ones = stale. */ source_fingerprints?: { [key: string]: any }; creator?: AdminOrRepOrTenantOrClient; editor?: AdminOrRepOrTenantOrClient; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export type PopulatedKeys = "metric" | "analysis" | "session"; /** Populated refs replace the id IN PLACE (the backend's population map has no `new_key`). */ export type DataWithPopulatedKeys = Omit< Data, "metric" | "analysis" | "session" > & { metric: StringId | AiObjectDetectionMetric.Data; analysis: StringId | AiObjectDetectionSessionAnalysis.Data; session?: StringId | AiObjectDetectionSession.Data; }; /** POST = CALCULATE: evaluates the mission-assigned metrics of `analysis` (admin only). */ export interface CreateBody { /** The SUCCESSFUL analysis to evaluate. */ analysis: StringId; /** Optional metric-id subset — can only NARROW the mission-assigned set, never widen it. */ metrics?: StringId[]; } /** PUT = HUMAN OVERRIDE. Only these keys are writable; `computed` is immutable. */ export interface UpdateBody { /** Reps may only RAISE it (clearing is an admin review action). */ flag?: boolean; /** Sparse value overrides; a rep's override auto-raises `flag`. Any fresh overwrite resets `confirmed_edit` to false unless the same admin request confirms it. */ overwrite?: OverwriteInput; /** ADMIN-ONLY review verdict — true makes the standing overwrite effective. */ confirmed_edit?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; metric?: StringId | StringId[]; analysis?: StringId | StringId[]; session?: StringId | StringId[]; /** The scanning rep's id. */ user?: StringId | StringId[]; client?: StringId | StringId[]; teams?: StringId | StringId[]; type?: | AiObjectDetectionMetric.MetricType | AiObjectDetectionMetric.MetricType[]; flag?: boolean; status?: Status | Status[]; /** Regex on the metric-name snapshot. */ search?: string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; populatedKeys?: PopulatedKeys[]; }; export interface Result extends DefaultPaginationResult { data: DataWithPopulatedKeys[]; } } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; /** Evaluation summary + the fresh result documents of the analysis. */ export interface Result { analysis: string; /** Number of metrics evaluated. */ evaluated: number; /** Number of metrics whose evaluation or persistence failed. */ errors: number; results: Data[]; } } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; /** The soft-deleted document (admin only). */ export type Result = Data; } } export namespace AiObjectDetectionMission { /** What an assignment rule DEMANDS of a mission at a client (rolled up to the strictest on read). */ export type RequirementMode = "not_required" | "submission_required" | "completion_required"; /** One weighted metric row — the mission's composition. */ export interface MetricRowInput { metric: StringId; /** Finite number ≥ 0; the mission score is the weighted mean of the metrics' effective result scores. */ weight: number; } /** Stored row (Mongoose adds a sub-document `_id`). */ export interface MetricRow extends MetricRowInput { _id?: StringId; } export interface Data { _id: StringId; name: string; description?: string; metrics: MetricRow[]; /** Completion threshold 0..1 (default 0 = any NON-ZERO score completes; a zero score never does). */ min_score: number; /** Optional detection category a session started FROM this mission carries; null = none. */ category?: StringId | null; /** Disabled missions are skipped by evaluation and `scores_for`. Default true. */ enabled: boolean; disabled: boolean; creator?: AdminOrRepOrTenantOrClient; editor?: AdminOrRepOrTenantOrClient; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; description?: string; /** REQUIRED, ≥ 1 row; every violation is listed in one 400. */ metrics: MetricRowInput[]; /** 0..1; absent/null/"" = default 0. */ min_score?: number | null; /** Valid category id, or null/"" to leave unset. */ category?: StringId | null; enabled?: boolean; company_namespace?: string[]; } /** PUT re-runs the same validation as create — `metrics` (≥ 1 row) is required again. `category: null` explicitly CLEARS it; omitting it leaves the stored value. */ export interface UpdateBody { metrics: MetricRowInput[]; name?: string; description?: string; min_score?: number | null; category?: StringId | null; enabled?: boolean; /** Set true to soft-delete via update. */ disabled?: boolean; } /** One metric's contribution inside a `scores_for` row. */ export interface ScoreMetricRow { metric: string; /** Name snapshot from the metric result (absent when missing). */ name?: string; weight: number; /** Effective 0..1 score of the metric's result; absent when `missing`. */ score?: number; /** true = the metric has no result on this analysis (counts as 0 in the weighted mean). */ missing: boolean; } /** One enabled mission scored against an analysis (`find({ scores_for })`). */ export interface MissionScoreRow { _id: string; name: string; /** An enabled assignment rule attaches a set containing this mission to the session's client. */ assigned: boolean; /** Names of the assigned sets this mission arrived through. */ via_sets: string[]; /** Strictest demand the matched rules place on it; absent when unassigned. */ requirement_mode?: RequirementMode; /** Weighted mean 0..1 of the metrics' effective scores. */ score: number; min_score: number; /** NON-ZERO score ≥ min_score — computed at read, never stamped. */ completed: boolean; metrics: ScoreMetricRow[]; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; enabled?: boolean; /** Case-insensitive regex on `name`. */ search?: string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; /** An analysis `_id` — the response becomes `ScoresResult` (resolved mission scores for that analysis) instead of a paginated list. */ scores_for?: StringId; }; export interface PaginatedResult extends DefaultPaginationResult { data: Data[]; } /** Returned when `scores_for` is passed; assigned missions first, then by name. */ export interface ScoresResult { analysis: string; /** The analysis's session client; null when the session has none. */ client: string | null; missions: MissionScoreRow[]; } export type Result = PaginatedResult | ScoresResult; } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; /** The soft-deleted document (`disabled: true`). */ export type Result = Data; } } export namespace AiObjectDetectionMissionSet { export interface Data { _id: StringId; name: string; description?: string; /** Mission ids in this set — the unit assignment rules target. */ missions: StringId[]; /** Disabled sets are ignored by assignment resolution. Default true. */ enabled: boolean; disabled: boolean; creator?: AdminOrRepOrTenantOrClient; editor?: AdminOrRepOrTenantOrClient; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; description?: string; /** REQUIRED, ≥ 1 valid mission id; every violation is listed in one 400. */ missions: StringId[]; enabled?: boolean; company_namespace?: string[]; } /** PUT re-runs the same validation as create — `missions` (≥ 1 id) is required again. */ export interface UpdateBody { missions: StringId[]; name?: string; description?: string; enabled?: boolean; /** Set true to soft-delete via update. */ disabled?: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; enabled?: boolean; /** Case-insensitive regex on `name`. */ search?: string; disabled?: boolean; from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; /** The soft-deleted document (`disabled: true`). */ export type Result = Data; } } export namespace AiObjectDetectionMissionResults { /** The STORED outcome of one mission execution — exactly one document per (session, mission), written by the metric evaluator. */ export interface Data { _id: StringId; /** The identity unit: one scan = one execution. */ session: StringId; mission: StringId; /** The analysis this result CURRENTLY reflects — re-analysis re-points it (no duplicate rows). */ analysis: StringId; /** Denormalized scan context: the SCANNING rep (unset for admin-scanned sessions). */ user?: StringId | null; user_name?: string | null; client?: StringId | null; client_name?: string | null; teams?: StringId[]; /** Device visit id the scan happened in (copied from the session; absent without a visit). */ visit_id?: string; route?: StringId; /** Business day of the scan, `YYYY-MM-DD`. */ business_day?: string; /** Analysis time (Unix ms) ≈ the visit. */ time?: number; /** The session was STARTED FROM this mission ("SCAN THIS MISSION"). Default false. */ scanned: boolean; mission_name?: string; /** Weighted EFFECTIVE metric scores 0..1 (confirmed human overrides folded in; a demanded metric without a result counts 0). */ score?: number; /** Mission threshold snapshot (default 0). */ min_score: number; /** score reached min_score — a ZERO score never completes. */ completed: boolean; /** Mission-set names that assigned it (snapshot at evaluation time; [] when unresolved). */ via_sets: string[]; /** DERIVED — any of the mission's metric results on `analysis` carries a flag. A fresh flag reopens `resolved`. */ flagged: boolean; /** Admin review verdict — the only client-writable field. */ resolved: boolean; /** Stamped when resolved; null when un-resolved. */ resolver?: AdminOrRepOrTenantOrClient | null; /** Unix ms; null when un-resolved. */ resolved_at?: number | null; creator?: AdminOrRepOrTenantOrClient; editor?: AdminOrRepOrTenantOrClient; disabled: boolean; company_namespace: string[]; createdAt: Date; updatedAt: Date; } /** PUT accepts ONLY the admin review verdict. */ export interface UpdateBody { /** true stamps `resolver` + `resolved_at`; false clears both. */ resolved: boolean; } export namespace Find { export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; session?: StringId | StringId[]; mission?: StringId | StringId[]; analysis?: StringId | StringId[]; client?: StringId | StringId[]; /** The scanning rep's id (overridden by `rep`; a rep token is always forced to itself). */ user?: StringId | StringId[]; teams?: StringId | StringId[]; /** Device `visits.visit_id`. */ visit_id?: string | string[]; route?: StringId | StringId[]; scanned?: boolean; completed?: boolean; flagged?: boolean; resolved?: boolean; /** Window start on `time` (Unix ms). Default = 30 days before `to_time`. */ from_time?: number; /** Window end on `time` (Unix ms). Default = now. */ to_time?: number; from_createdAt?: number; to_createdAt?: number; /** Admin only: narrow to one rep (mapped to `user`); ignored unless a valid ObjectId. */ rep?: StringId; /** Regex on `name` — this model has no `name`, so it matches nothing; listed only because the shared query layer accepts it. */ search?: string; disabled?: boolean; }; /** Sorted `time` desc, `_id` desc (the `sort` param is ignored). */ export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; export interface Params { /** Admin only: the document must belong to this rep (`user`). */ rep?: StringId; } export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; /** The soft-deleted document (admin only). */ export type Result = Data; } } export namespace AiObjectDetectionAssignmentRule { /** Client attribute a rule line is checked against. `client_tag` and `area_tag` both match the client's single `tags` array. */ export type RuleConditionKey = | "client" | "client_tag" | "client_channel" | "assigned_to" | "chain" | "area_tag" | "team"; /** `in` = any overlap with the client's value(s); `nin` = no overlap (a client missing the attribute passes `nin`, fails `in`). */ export type RuleConditionOperator = "in" | "nin"; /** How often the rule DEMANDS its sets: due on every visit, or `times` completions per business day / week / month / quarter. */ export type RuleFrequencyInterval = "every_visit" | "day" | "week" | "month" | "quarter"; /** What the rule demands of a set's missions at the client. Carried by the backend, enforced by the mobile app when the rep ends the visit. */ export type RequirementMode = "not_required" | "submission_required" | "completion_required"; export interface RuleCondition { /** Mongoose subdocument id (server-generated on stored rows). */ _id?: StringId; key: RuleConditionKey; operator: RuleConditionOperator; /** Ids matching the key: clients / client-type tags / channels / reps / chain clients (isChain) / area-type tags / teams. At least one. */ value: StringId[]; } export interface RuleFrequency { interval: RuleFrequencyInterval; /** Completions required per interval (integer >= 1). Pinned to 1 for `every_visit`. */ times: number; } /** One stored `mission_sets` line. */ export interface RuleMissionSet { mission_set: StringId; requirement_mode: RequirementMode; } /** One `mission_sets` line as sent on write — `requirement_mode` defaults to `submission_required`. */ export interface RuleMissionSetInput { mission_set: StringId; requirement_mode?: RequirementMode; } /** Frequency as sent on write — absent => `every_visit`; `times` absent => 1. */ export interface RuleFrequencyInput { interval?: RuleFrequencyInterval; times?: number; } export interface Data { _id: StringId; name: string; /** The mission sets this rule assigns, one line per set (a set appears once). Never empty. */ mission_sets: RuleMissionSet[]; /** AND-ed lines; empty = applies to every client. */ conditions: RuleCondition[]; /** Always present on stored rows (normalized on write). */ frequency: RuleFrequency; /** Default true. Disabled-but-enabled rules are still skipped by the assignment read. */ enabled: boolean; disabled: boolean; /** Server-stamped from the caller's token on create. */ creator?: AdminOrRepOrTenantOrClient; /** Server-stamped from the caller's token on update / remove. */ editor?: AdminOrRepOrTenantOrClient; company_namespace: string[]; createdAt: Date; updatedAt: Date; } export interface CreateBody { name: string; /** REQUIRED, at least one line; each set may be listed once. */ mission_sets: RuleMissionSetInput[]; /** Omit or send `[]` to apply the rule to every client. Every violation is reported in one 400. */ conditions?: RuleCondition[]; frequency?: RuleFrequencyInput; /** Default true. */ enabled?: boolean; company_namespace?: string[]; } /** PUT re-runs the full create validation: `mission_sets` is REQUIRED again, an omitted `conditions` resets to `[]` (every client) and an omitted `frequency` resets to `every_visit`. */ export interface UpdateBody { name?: string; mission_sets: RuleMissionSetInput[]; conditions?: RuleCondition[]; frequency?: RuleFrequencyInput; enabled?: boolean; disabled?: boolean; } export namespace Find { /** Results are always ordered `_id` desc — `sort` / `sortPageOrder` are accepted but not applied. */ export type Params = DefaultPaginationQueryParams & { _id?: StringId | StringId[]; name?: string | string[]; enabled?: boolean; /** Rules whose `mission_sets` list this set id. */ "mission_sets.mission_set"?: StringId | StringId[]; /** Case-insensitive regex on `name`. */ search?: string; /** Omit to get active AND soft-deleted rows; `false` = active only. */ disabled?: boolean; /** ms epoch (or date string); snapped to the start of that day in the company time zone unless `exact_time`. */ from_updatedAt?: number; to_updatedAt?: number; from_createdAt?: number; to_createdAt?: number; /** Use the exact instants of the `from_*`/`to_*` bounds instead of whole days. */ exact_time?: boolean; }; export interface Result extends DefaultPaginationResult { data: Data[]; } } export namespace Get { export type ID = StringId; /** The backend answers 400 (not 404) when the id does not exist. */ export type Result = Data; } export namespace Create { export type Body = CreateBody; export type Result = Data; } export namespace Update { export type ID = StringId; export type Body = UpdateBody; export type Result = Data; } export namespace Remove { export type ID = StringId; /** Soft-delete: the row comes back with `disabled: true` and `editor` stamped. */ export type Result = Data; } } export namespace AiObjectDetectionAssignedMissions { /** What a rule demands of a set's missions: carried by the backend, enforced by the mobile app when the rep ends the visit. */ export type RequirementMode = "not_required" | "submission_required" | "completion_required"; export type RuleFrequencyInterval = "every_visit" | "day" | "week" | "month" | "quarter"; export type RuleConditionKey = | "client" | "client_tag" | "client_channel" | "assigned_to" | "chain" | "area_tag" | "team"; export type RuleConditionOperator = "in" | "nin"; export interface RuleFrequency { interval: RuleFrequencyInterval; /** Completions required per interval (1 for `every_visit`). */ times: number; } /** One rule line with its verdict against the client — the simulator renders exactly why a rule hit or missed. */ export interface AssignedRuleCondition { key: RuleConditionKey; operator: RuleConditionOperator; value: StringId[]; matched: boolean; } export interface AssignedRuleMissionSet { mission_set: StringId; /** Absent when the set is disabled / deleted. */ set_name?: string; requirement_mode: RequirementMode; } /** One enabled rule resolved against the client (matched or not). */ export interface AssignedRule { _id: StringId; name: string; /** The sets the rule assigns, each with its demand. */ mission_sets: AssignedRuleMissionSet[]; /** The STRICTEST mode across the rule's `mission_sets` lines. */ requirement_mode: RequirementMode; /** Every condition line holds (AND). Zero lines => true. */ matched: boolean; frequency: RuleFrequency; conditions: AssignedRuleCondition[]; } /** One demand a matched rule places on a mission through one of its sets. */ export interface MissionRequirement { rule: StringId; rule_name: string; set: StringId; set_name?: string; frequency: RuleFrequency; requirement_mode: RequirementMode; /** Start (ms) of the first BUSINESS day of the demand's current window; null for a visit-scoped `every_visit` demand (matched by visit id, not by time). */ window_start: number | null; /** Completions whose business day falls inside the window (visit-scoped every_visit: those stamped with the visit id). */ completions: number; /** completions >= frequency.times (visit-scoped every_visit: >= 1) — regardless of `requirement_mode`. */ satisfied: boolean; } export interface AssignedMission { _id: StringId; name: string; /** 0..1 — the weighted mission score a scan must reach to complete it. */ min_score: number; /** Optional detection category id — the mobile stamps it on the session it starts FROM this mission so the pipeline auto-analyzes it. */ category?: StringId; category_name?: string; /** Names of the matched sets that carry this mission. */ via_sets: string[]; /** The STRICTEST demand across `requirements[]` — what the mobile enforces when the rep ends the visit. */ requirement_mode: RequirementMode; /** One per matching rule x set line. */ requirements: MissionRequirement[]; /** Every requirement satisfied — mode-agnostic (the mobile combines it with `requirement_mode`). */ done: boolean; } /** The assignment read for ONE client — computed on every call from current rules / sets / stored mission results; nothing is stored. */ export interface Data { client: { _id: StringId; name: string }; /** The `rep` query param echoed back (null when not sent). */ rep: StringId | null; /** The context rep's `rep_can_redo_object_detection_missions` permission (default false); always true when no rep is in context (admin simulator). */ rep_can_redo: boolean; /** IANA time zone the business day was resolved in. */ timezone: string; /** `YYYY-MM-DD` — the CURRENT business day the windows are anchored to (rep stamping context when a rep is in scope, else the company's). */ business_day: string; /** The device visit id the read is scoped to — null when `visit` was not sent. */ visit_id: string | null; /** Every enabled rule with per-condition verdicts (matched or not). */ rules: AssignedRule[]; /** The ASSIGNED missions only (via matched rules' sets), sorted by name. */ missions: AssignedMission[]; } export namespace Find { /** Not paginated — `per_page` / `page` are ignored. */ export interface Params { /** REQUIRED — the client to resolve the rules against (400 when missing / invalid / not found). */ client: StringId; /** Count only this rep's completions and use the rep's business-day context + redo permission. Defaults to the rep token's rep, else the company context. */ rep?: StringId; /** DEVICE visit id (`visits.visit_id`) the rep is in — scopes `every_visit` demands to that visit. Not looked up (the visit may not have synced yet). */ visit?: string; } export type Result = Data; } export namespace Get { /** The CLIENT id — `GET /:id` is the same read as `GET ?client=:id`. */ export type ID = StringId; export interface Params { rep?: StringId; visit?: string; } export type Result = Data; } } export namespace ObjectDetectionAnalyticsReport { /** `metrics` = one row per metric result; `segments` = one row per unwound share-of-shelf SegmentOutput. */ export type View = "metrics" | "segments"; export type MetricType = | "adjacent_block" | "facings_count" | "on_shelf_availability" | "share_of_shelf"; /** Output family of a metric type (denormalized on every result). */ export type MetricOutput = "compatibility" | "numerical" | "share_of_shelf"; /** Unit share-of-shelf quantities are measured in. */ export type Measure = "width_cm" | "area_cm2" | "facings"; /** Filter keys — the same names grouped rows emit in `drilldown`, so a drilldown round-trips as a filter. `segment` applies to the segments view only. */ export type FilterKey = | "metric" | "type" | "output" | "flag" | "client" | "channel" | "rep" | "team" | "mission" | "segment"; /** Resolved to label ids before matching ("rows whose metric involves these labels"); each key ANDs independently. The operator is ignored (always `in`). */ export type LabelFilterKey = "label" | "label_group" | "product_brand" | "product_category"; /** Both names address the result's `createdAt`. */ export type TimeKey = "time" | "createdAt"; /** Time-bucket drilldowns: `YYYY-MM-DD` / `YYYY-MM` / ISO week `GGGG-Www` — each sets the whole time range. */ export type BucketKey = "business_day" | "month" | "week"; export type FilterOperator = "in" | "nin" | "eq" | "ne"; /** Time presets the filter UI sends without a value (company time zone). */ export type TimePreset = | "today" | "yesterday" | "last_seven_days" | "last_thirty_days" | "last_month" | "last_three_months" | "last_six_months" | "last_twelve_months"; export interface FilterCriterion { key: FilterKey; /** Default `in`. */ operator?: FilterOperator; /** 24-hex ids (cast to ObjectId) for id keys; strings for `type` / `output`; booleans (or "true") for `flag`. Non-id values on id keys are dropped. */ value: (StringId | string | boolean)[] | StringId | string | boolean; } export interface LabelCriterion { key: LabelFilterKey; operator?: "in"; value: StringId[] | StringId; } export interface TimeBetweenCriterion { key: TimeKey; operator: "between"; /** `[from_ms, to_ms]`. */ value: [number, number]; } export interface TimeBoundCriterion { key: TimeKey; operator: "gte" | "lte"; /** ms epoch. */ value: number | [number]; } export interface TimePresetCriterion { key: TimeKey; operator: TimePreset; value?: never; } export interface BucketCriterion { key: BucketKey; operator?: "eq" | "in"; /** One bucket string, e.g. `"2026-07-15"`, `"2026-07"`, `"2026-W29"`. */ value: string | [string]; } export type Criterion = | FilterCriterion | LabelCriterion | TimeBetweenCriterion | TimeBoundCriterion | TimePresetCriterion | BucketCriterion; /** `type` / `output` are metrics-view only, `segment` is segments-view only — keys not accepted by the current view are dropped silently. */ export type GroupKey = | "metric" | "type" | "output" | "client" | "channel" | "rep" | "mission" | "segment" | "business_day" | "month" | "week"; /** Sort keys the query-string `sortBy` accepts. */ export type SortField = | "_id" | "time" | "createdAt" | "score" | "answer" | "metric_name" | "client_name" | "channel_name" | "segment_name" | "segment_ratio" | "segment_answer" | "row_count" | "avg_score" | "avg_ratio" | "avg_answer"; export interface SortOption { /** `options.sort` fields must exist in the report's sort metadata (`sort_fields` of a previous response); unknown fields fall back to the default sort. */ field: SortField | (string & {}); type: "asc" | "desc"; } export interface CreateBody { /** Default `metrics`. */ view?: View; /** Only `anyOf[0].criteria` is honoured — one AND-ed group. */ anyOf?: { criteria: Criterion[] }[]; /** Group keys, e.g. `[{ _id: "channel" }, { _id: "month" }]`. Grouped rows carry `drilldown` + aggregates. */ group?: { _id: GroupKey }[]; /** Column keys to show (ungrouped rows only). */ projection?: string[]; /** Optional column override; defaults come from the report metadata (`object-detection-metrics` / `object-detection-segments`). */ columns?: ReportColumn[]; options?: { /** Rows per page (the query-string `per_page` is NOT honoured here). */ limit?: number; page?: number; /** Default: `row_count` desc when grouped, `time` desc when flat. */ sort?: SortOption[]; /** Default `none`. */ totals_summary?: "all" | "page" | "none"; }; } /** Filter-compatible ids / buckets of a grouped row — spread it as query params (or criteria) on the next call to get the detail rows. */ export interface Drilldown { metric?: StringId; type?: MetricType; output?: MetricOutput; client?: StringId; channel?: StringId; rep?: StringId; mission?: StringId; segment?: StringId; business_day?: string; month?: string; week?: string; } /** One report row. Flat rows carry the result fields; grouped rows carry `drilldown`, the aggregates and the grouped identity names / buckets. */ export interface Data { /** Metric result id — flat rows only. */ _id?: StringId; /** Result creation time (ms). */ time?: number; /** `YYYY-MM-DD` in the company time zone. */ business_day?: string; /** `YYYY-MM-DD HH:mm:ss`. */ timestamp?: string; /** `YYYY-MM`. */ month?: string; /** ISO week `GGGG-Www`. */ week?: string; metric_id?: StringId; metric_name?: string; metric_type?: MetricType; output?: MetricOutput; flag?: boolean; /** 0..1, rounded to 4 decimals. */ score?: number; client_id?: StringId; client_name?: string; channel_id?: StringId; channel_name?: string; rep_id?: StringId; rep_name?: string; /** The mission the session was STARTED FROM — absent on generic scans. */ mission_id?: StringId; mission_name?: string; teams_ids?: StringId[]; session_id?: StringId; analysis_id?: StringId; /** metrics view — effective answer (confirmed human override wins): boolean for compatibility, number otherwise. */ answer?: boolean | number | null; /** metrics view — effective ratio (availability / main-segment share). */ ratio?: number; /** segments view */ segment_id?: StringId; segment_name?: string; /** segments view — `main` = the row the target is defined for, else `context`. */ is_main?: "main" | "context"; /** segments view — measured quantity in `measure` units (2 decimals). */ segment_answer?: number; /** segments view — the segment's share 0..1 (4 decimals). */ segment_ratio?: number; /** segments view — main rows only. */ target_ratio?: number; target_answer?: number; segment_score?: number; measure?: Measure; /** grouped rows */ drilldown?: Drilldown; row_count?: number; avg_score?: number; avg_answer?: number; /** grouped, segments view — average share. */ avg_ratio?: number; /** grouped, segments view — rows where the segment is the main one. */ main_rows?: number; /** grouped, metrics view — flagged results. */ flagged?: number; /** grouped by `type` — the metric-type bucket. */ type?: MetricType; [key: string]: any; } /** Visible table columns for the current state (grouped vs flat). */ export interface AnalyticsKey { key: string; /** Translated column label. */ value: string; type: "string" | "number"; visible: boolean; } /** Present when `options.totals_summary` is `all` (fills `absolute_total`) or `page` (fills `page_total`). Labels: "Rows", "Average Score" (+ "Average Share" on segments). */ export interface Totals { absolute_total: { [label: string]: number }; page_total: { [label: string]: number }; labels: { key: string; value: string }[]; } /** Returned INSTEAD of rows when the `export` query param is set — the report is queued and emailed to the caller. */ export interface ExportResult { _id: StringId; success: boolean; msg: string; isExport: boolean; } /** Query keys honoured next to the POST body (drilldown round-trips + export). `per_page` / `page` are NOT honoured — use `options.limit` / `options.page`. */ export interface QueryParams { /** Fallback when the body has no `view`. */ view?: View; metric?: StringId | StringId[]; type?: MetricType | MetricType[]; output?: MetricOutput | MetricOutput[]; flag?: boolean; client?: StringId | StringId[]; channel?: StringId | StringId[]; rep?: StringId | StringId[]; team?: StringId | StringId[]; /** The mission the session was started from. */ mission?: StringId | StringId[]; /** Segments view only. */ segment?: StringId | StringId[]; label?: StringId | StringId[]; label_group?: StringId | StringId[]; product_brand?: StringId | StringId[]; product_category?: StringId | StringId[]; /** ms epoch — every read is time-bounded; default window = the last 30 days. */ from_time?: number; to_time?: number; /** `YYYY-MM-DD` — sets the whole range (overrides from_time / to_time). */ business_day?: string; /** `YYYY-MM`. */ month?: string; /** ISO week `GGGG-Www`. */ week?: string; /** Query-string sort (takes precedence over `options.sort`). */ sortBy?: { field: SortField; type: "asc" | "desc" }[]; /** `excel` schedules an emailed export instead of returning rows — the response is then an `ExportResult`. */ export?: "excel"; /** Subject / name of the scheduled export email (default "Detection Analytics"). */ emailSubject?: string; } export interface PaginatedResult extends DefaultPaginationResult { data: Data[]; keys: AnalyticsKey[]; /** The report's column metadata (sorted by `position`), or the `columns` override echoed back. */ columns: ReportColumn[]; totals?: Totals; /** The report's sort metadata rows — the valid `options.sort` fields. */ sort_fields: ReportSort.Data[]; } export namespace Find { /** Legacy GET — a thin adapter onto the POST read (`view` + `group` from the query, filters via the same query keys). */ export type Params = QueryParams & { /** Group keys — array or comma-separated string. */ group?: GroupKey | GroupKey[]; }; export type Result = PaginatedResult; } export namespace Create { export type Params = QueryParams; export type Body = CreateBody; export type Result = PaginatedResult; } } } export type StringId = string; export type NameSpaces = string[]; export interface Admin { _id: StringId; name?: string; type: "admin"; admin?: StringId; } export interface Rep { _id: StringId; name?: string; type: "rep"; rep?: StringId; } export interface AdminOrRep { _id: StringId; name?: string; type: "admin" | "rep"; admin?: StringId; rep?: StringId; } export interface AdminOrRepOrTenant { _id: StringId; type: "admin" | "rep" | "tenant"; name?: string; admin?: StringId; rep?: StringId; tenant?: StringId; } export interface AdminOrRepOrTenantOrClient { _id: StringId; type: "admin" | "rep" | "tenant" | "client"; name?: string; admin?: StringId; rep?: StringId; tenant?: StringId; client?: StringId; } interface ValidityCheck { valid: boolean; reasons: { message: string; code: string }[]; } export type PopulatedMediaStorage = Pick< Service.MediaStorage.MediaStorageSchema, | "_id" | "createdAt" | "ContentType" | "media_type" | "mime_type" | "publicUrl" | "type_name" | "file_name" | "media_id" | "thumbnails" | "createdAt" > & { thumbnails: Pick< Service.MediaStorage.Thumbnail, | "_id" | "ContentType" | "mime_type" | "publicUrl" | "type_name" | "file_name" | "createdAt" >[]; }; interface ActivityComment { time: number; user_name: string; user_id: string; user_type: string; comment: string; } interface ActivityReview { admin_id: string; time: number; } interface ActivityAdminNote { admin_name: string; note: string; admin_id: string; time: number; } interface UserPermissions { admin_can_edit_client_sales_data: boolean; admin_can_bypass_financial_limits_sales_order: boolean; admin_can_bypass_financial_limits_create_invoice: boolean; admin_can_only_see_his_pending_sales_orders: boolean; } export interface ReportKey { cond?: boolean; key: string; value: string; type: | "string" | "number" | "collection" | "boolean" | "photo" | "media" | "geoPoint" | "image" | string; isArray?: boolean; visible?: boolean; deepLinkModel?: Model; deepLinkKey?: string; value_key?: string; totals_key?: string; [key: string]: any; } type MFA_Method = "email" | "whatsapp" | "authenticator" | "recovery_codes"; type RepzoModel = | "socialPlatform" | "activityAiSalesOrder" | "reportUblInvoice" | "ublIntegrationSettings" | "ublIntegration" | "ublConnectionAttempts" | "quickConvertToPdf" | "warehouses" | "dayShift" | "transfers" | "transactions" | "taxes" | "productvariations" | "products" | "pricelistsitems" | "pricelists" | "payments" | "ledger_payments" | "mslsales" | "mslproducts" | "measureunits" | "measureunitfamilies" | "invoice" | "ledger_goods" | "fullinvoices" | "checks" | "clients" | "activities" | "bigReports" | "admins" /** * @deprecated representatives shall be used */ | "rep" | "representatives" | "companies" | "banks" | "bankslists" | "productcategories" | "productSubCategory" | "defaultbanklist" | "permissions" | "roles" | "shipping_method" | "availability_msl" | "tags" | "feedbacks" | "feedbackoptions" | "medias" | "visits" | "job-category" | "channel" | "teams" | "modifiersGroup" | "productbrands" | "paymentTerms" | "plan" | "modifiersGroup" | "productbrands" | "notes" | "tasks" | "photos" | "forms" | "form" | "audits" | "availability" | "form" | "widgets-filter" | "routes" | "target-result" | "widget" | "calendar" | "bulkImport" | "target-rule" | "productGroups" | "proformas" | "proforma" | "days" | "shelfShare" | "customFields" | "clientStatus" | "adjustAccount" | "librarian_widget" | "settings" | "classificationLine" | "line" | "speciality" | "lineTarget" | "clientLine" | "receivingMaterial" | "sv.activitiesstorechecks" | "storeCheckTemplate" | "retailExecutionPreset" | "promotions" | "custom-list" | "custom-list-item" | "itemStatus" | "itemStatusType" | "customStatus" | "intgAvailableCategories" | "intgAvailableApps" | "intgApps" | "returnReason" | "clientContact" | "clientLocation" | "workorderCategory" | "asset" | "assetType" | "assetUnit" | "workorder" | "mediaStorage" | "workorderRequest" | "thumbnailStorage" | "commentsThread" | "workorderPortal" | "workorderPortalLink" | "oauth2Apps" | "printWorkorderPortalLink" | "printWorkorderPortalLinkOptions" | "refunds" | "oauth2Tokens" | "businessApp" | "user_role" | "product_modifier" | "address" | "reminders" | "approval" | "refund" | "cart" | "cart_history" | "settlement" | "adjustInventory" | "cycle" | "check" | "failed_linking_txn" | "failed_svix_event" | "failed_adjust_account" | "failed_adjust_inventory" | "failed_cart" | "failed_emails" | "failed_invoices" | "failed_payments" | "failed_proforma_invoices" | "failed_receiving_material" | "failed_refund" | "failed_transfer" | "failed_transaction" | "failed_set_txn_alarm" | "failed_settlement" | "banner" | "shipping_zone" | "paymentMethod" | "target_group" | "target_result_history" | "widget_dashboard" | "secondary" | "planogram" | "checkout" | "retailExecutionPreviousResult" | "retailExecutionReportView" | "clicks" | "jobResult" | "workorderAlarm" | "intgActionLogs" | "intgCommandLogs" | "intgTrigger" | "scheduleEmail" | "territory" | "territoryLevel" | "territoryTemplate" | "activeClient" | "notificationsCenter" | "emailHistory" | "history" | "bulkExport" | "generateRule" | "asset-unit" | "client-location" | "workorder-request" | "oauth2Tokens" | "businessPlan" | "businessPlanFeature" | "modules" | "companyGroup" | "billingSubscription" | "widgetCategory" | "module-custom-validator" | "workflowTriggerOption" | "workflow" | "workflowActionOption" | "workflowActionAttributeOption" | "workflowVersion" | "workflowExecution" | "adminAbility" | "smsGateway" | "approvalRequest" | "formV2" | "activityFormV2Result" | "maxioAccountingCode" | "syncMaxioSubscriptionSummaries" | "businessAddOn" | "variantBatch" | "eventsLog" | "unSyncedLog" | "aiApiHistory" | "bulkConvertProforma" | "biView" | "biViewVersion" | "biViewInstance" | "biBucket" | "biViewBucketsTotal" | "contract" | "contractInstallment" | "clientUblInfo" | "supplier" | "ocrInvoiceJob" | "ocrInvoiceJobGroup" | "ocrInvoiceJobTemplate" | "ocrInvoiceJobPage" | "inventoryAdjustmentReason" | "productAuditTrace" | "blankPhotoRep" | "oldActivityFormV2Result" | "oldActivityStorecheck" | "oldBiBucket" | "failedBiBucketLog" | "failedConsumeBiAlarm" | "failedSetBiAlarm" | "oauth2Tokens" | "ublHealthCheck" | "invoiceAlert" | "ocrInvoiceJobPages" | "loginDevice" | "aiObjectDetectionDataset" | "aiObjectDetectionLabel" | "aiObjectDetectionModel" | "aiObjectDetectionModelVersion" | "aiObjectDetectionTask" | "assetPartType" /** * @deprecated assetPart shall be used */ | "asset-part" | "assetPart" | "assetPartUnit" | "assetPartReceival" | "assetPartTransfer" | "assetPartTransaction" | "returnAssetPartUnit" | "storeAssetPartUnit" | "aiApiLimits" | "aiHistory" | "aiModelPrices" | "promotionsGroup" | "medias";