UNPKG

@datanest-earth/nodejs-client

Version:
1,340 lines (1,319 loc) 55.1 kB
import { File as File$1 } from 'node:buffer'; type User = { uuid: string; name: string | null; email: string; initials?: string | null; }; type CompanyUserListFilters = { page?: number; search?: string; latest?: boolean; /** @deprecated Use `search` instead to be consistent with other APIs */ query?: string; } & DateRangeFilters; declare function getCompanyUsers(client: DatanestClient, params?: CompanyUserListFilters): Promise<PaginatedResponse<User>>; declare function inviteCompanyUser(client: DatanestClient, userData: { email: string; name: string | null; initials?: string | null; }): Promise<User>; declare function patchCompanyUser(client: DatanestClient, userUuid: string, userData: { email?: string; name?: string; initials?: string | null; }): Promise<User>; declare function deleteCompanyUser(client: DatanestClient, userUuid: UUID): Promise<{}>; declare function getCompanyExternalUsers(client: DatanestClient, params?: { page?: number; latest?: boolean; } & DateRangeFilters): Promise<PaginatedResponse<User>>; declare function getCompanyExternalUserProjects(client: DatanestClient, externalUserUuid: string, params?: { page?: number; } & DateRangeFilters): Promise<PaginatedResponse<Project>>; declare function purgeCompanyExternalUser(client: DatanestClient, externalUserUuid: string): Promise<PaginatedResponse<User>>; type users_User = User; declare const users_deleteCompanyUser: typeof deleteCompanyUser; declare const users_getCompanyExternalUserProjects: typeof getCompanyExternalUserProjects; declare const users_getCompanyExternalUsers: typeof getCompanyExternalUsers; declare const users_getCompanyUsers: typeof getCompanyUsers; declare const users_inviteCompanyUser: typeof inviteCompanyUser; declare const users_patchCompanyUser: typeof patchCompanyUser; declare const users_purgeCompanyExternalUser: typeof purgeCompanyExternalUser; declare namespace users { export { type users_User as User, users_deleteCompanyUser as deleteCompanyUser, users_getCompanyExternalUserProjects as getCompanyExternalUserProjects, users_getCompanyExternalUsers as getCompanyExternalUsers, users_getCompanyUsers as getCompanyUsers, users_inviteCompanyUser as inviteCompanyUser, users_patchCompanyUser as patchCompanyUser, users_purgeCompanyExternalUser as purgeCompanyExternalUser }; } type CompanyWorkflow = { workflow_id: number; workflow_title: string; company_id: number; favourite_project_uuid: null | UUID; workflow_groups: { workflow_group_id: number; title: string; has_linked_apps: boolean; has_user_specific_apps: boolean; }[]; workflow_figures: { workflow_figure_id: number; title: string; version: string; drawn_by: null | string; figure_no: string; view_size: number; checked_by: null | string; view_scale: number; basemap_index: number; has_scale_bar: boolean; view_layout_id: number; has_north_arrow: boolean; view_projection: string; figure_no_prefix: string; view_orientation: string; has_site_boundary_default: boolean; }[]; workflow_apps: { workflow_app_id: number; share_group: string; group_title: string; group_description: string; }[]; updated_at: string; created_at: string; }; type CompanyCustomRole = { custom_role_id: number; custom_role_title: string; }; /** * Get Company Workflow templates. * You can use this to help setup projects with workflows. * @param client * @returns */ declare function getCompanyWorkflows(client: DatanestClient, filters?: DateRangeFilters): Promise<PaginatedResponse<CompanyWorkflow>>; /** * Get Custom Roles for your account. * You can use this to restrict module access for certain users in project teams. * To set up custom roles please use the Company Settings -> User Access section in the Web interface. * @param client DatanestClient * @returns */ declare function getCompanyCustomRoles(client: DatanestClient): Promise<CompanyCustomRole[]>; /** * Append a workflow user to a project. * The user will also be added to the project team. * @param client DatanestClient * @param projectUuid * @param userUuidOrEmail * @param workflowAppId * @param customRoleId optional custom role id * @returns */ declare function assignProjectWorkflowAppUser(client: DatanestClient, projectUuid: UUID, userUuidOrEmail: UUID, workflowAppId: number, customRoleId?: number | null): Promise<User>; /** * Unassign a workflow user from a project. The user remains in project team. * Use teams.removeProjectTeamMember or teams.removeExternalUserToProject to * completely remove them from the project. * @param client * @param projectUuid * @param userUuidOrEmail * @returns */ declare function unassignProjectWorkflowAppUser(client: DatanestClient, projectUuid: UUID, userUuidOrEmail: UUID, workflowAppId: number): Promise<User>; type workflows_CompanyCustomRole = CompanyCustomRole; type workflows_CompanyWorkflow = CompanyWorkflow; declare const workflows_assignProjectWorkflowAppUser: typeof assignProjectWorkflowAppUser; declare const workflows_getCompanyCustomRoles: typeof getCompanyCustomRoles; declare const workflows_getCompanyWorkflows: typeof getCompanyWorkflows; declare const workflows_unassignProjectWorkflowAppUser: typeof unassignProjectWorkflowAppUser; declare namespace workflows { export { type workflows_CompanyCustomRole as CompanyCustomRole, type workflows_CompanyWorkflow as CompanyWorkflow, workflows_assignProjectWorkflowAppUser as assignProjectWorkflowAppUser, workflows_getCompanyCustomRoles as getCompanyCustomRoles, workflows_getCompanyWorkflows as getCompanyWorkflows, workflows_unassignProjectWorkflowAppUser as unassignProjectWorkflowAppUser }; } declare enum ProjectType { /** * Project with Enviro/Evalu8 module enabled */ PROJECT_TYPE_ENVIRO = 0, /** * Standard project (previously known as Maps or Figure project) */ PROJECT_TYPE_STANDARD = 1 } /** * A Datanest Project */ type Project = { uuid: UUID; project_number: string; project_name: string; project_client: string; project_type: ProjectType; workflow_id: number | null; /** Timestamp of when the workflow started importing, null if importing is complete. */ workflow_importing_at: Timestamp | null; /** Is the workflow currently importing in the background, more Apps, Auto Docs, Data Events and Figures may appear in the project */ is_workflow_importing: boolean; archived: boolean; is_confidential: boolean; is_confirmed: boolean; project_manager_uuid: null | UUID; /** * Latitude in decimal degrees (WGS84) */ latitude: null | number; /** * Longitude in decimal degrees (WGS84) */ longitude: null | number; storage_needs_calc: boolean; storage_usage_mb: number; has_soil_upload: boolean; has_water_upload: boolean; has_leachate_upload: boolean; has_soilgas_upload: boolean; has_xrf_data: boolean; has_chemical_misalignment: boolean; has_sample_merging_misalignment: boolean; has_matrice_misalignment: boolean; has_unit_misalignment: boolean; has_rpd_misalignment: boolean; has_spatial_misalignment: boolean; is_gather_non_spatial_view: boolean; is_legacy_gather_table: boolean; project_address: null | string; google_place_id: null | string; address_street: null | string; address_locality: null | string; address_city: null | string; address_state: null | string; /** * Additional fields can be configured in Company Settings -> Workflow Settings * Record null values are removed and will be undefined. */ additional: null | Record<string, string | number>; /** * Supported ISO 3166-1 alpha-2 country codes */ address_country: Country2CharCode; address_postcode: null | string; measurement_type: MeasurementType | null; enviro_processed_at: null | Timestamp; last_accessed_at: null | Timestamp; updated_at: null | Timestamp; created_at: null | Timestamp; }; /** * Minimal data required to create a project */ type ProjectCreationData = { project_number: string; project_name: string; project_client: string; /** * Full postal address */ project_address?: string; /** * Project type: Enviro = 0 or Standard = 1 * @default 1 */ project_type?: ProjectType; /** * Supported ISO 3166-1 alpha-2 country codes */ address_country: Country2CharCode; workflow_assignments?: ProjectWorkflowAssignments; /** * Additional fields can be configured in Company Settings -> Workflow Settings * Provide null to remove the field */ additional?: Record<string, string | number | null>; }; /** * By assigning a workflow a project can be pre-configured with: * Gather Apps, Auto Docs & Map Figures * Workflows can be configured to assign users to control which apps they can access * Tip: You can find company workflows and their IDs from getCompanyWorkflows in the workflows namespace */ type ProjectWorkflowAssignments = { workflow_id: number; workflow_apps?: { workflow_app_id: number; /** * Set currently assigned users to the project's app group */ user_uuids: UUID[]; }[]; }; /** * List projects with pagination * @param client Datanest REST API Client * @param page Page number * @param archived Show archived projects instead? * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function listProjects(client: DatanestClient, page?: number, archived?: boolean, filters?: { project_type?: ProjectType; workspace_uuid?: UUID; search?: string; } & DateRangeFilters): Promise<PaginatedResponse<Project>>; /** * Get a single project via UUID * @param client * @param projectUuid * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function getProject(client: DatanestClient, projectUuid: string): Promise<{ project: Project; workflow: CompanyWorkflow | null; project_link: string; collection_link: string; }>; /** * Create a Datanest Project * @param client * @param projectData * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function createProject(client: DatanestClient, projectData: ProjectCreationData & Partial<Project>): Promise<{ project: Project; project_link: string; }>; /** * Wait for a project workflow import to complete, up to a timeout * @param client * @param projectUuid * @param timeout * @throw Error Timeout waiting for project workflow to complete * @throw DatanestResponseError Request HTTP server or validation error */ declare function waitForProjectWorkflow(client: DatanestClient, projectUuid: string, timeout?: number): Promise<Project>; /** * Update properties of a project * @param client * @param projectData * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function patchProject(client: DatanestClient, projectUuid: string, projectData: Partial<ProjectCreationData>): Promise<{ project: Project; project_link: string; }>; /** * Archive a project to hide it from users, it will be automatically deleted after some time. * @param client * @param projectUuid * @param forceDelete It is recommended to use forceDelete=true when testing, by default archived projects are force deleted after 6 months. * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function archiveProject(client: DatanestClient, projectUuid: string, options?: { force_delete?: boolean; }): Promise<boolean>; /** * Restore an archived project. * @param client * @param projectUuid * @throws DatanestResponseError Request HTTP server or validation error * @returns true */ declare function restoreProject(client: DatanestClient, projectUuid: string): Promise<boolean>; type projects_Project = Project; type projects_ProjectCreationData = ProjectCreationData; type projects_ProjectType = ProjectType; declare const projects_ProjectType: typeof ProjectType; declare const projects_archiveProject: typeof archiveProject; declare const projects_createProject: typeof createProject; declare const projects_getProject: typeof getProject; declare const projects_listProjects: typeof listProjects; declare const projects_patchProject: typeof patchProject; declare const projects_restoreProject: typeof restoreProject; declare const projects_waitForProjectWorkflow: typeof waitForProjectWorkflow; declare namespace projects { export { type projects_Project as Project, type projects_ProjectCreationData as ProjectCreationData, projects_ProjectType as ProjectType, projects_archiveProject as archiveProject, projects_createProject as createProject, projects_getProject as getProject, projects_listProjects as listProjects, projects_patchProject as patchProject, projects_restoreProject as restoreProject, projects_waitForProjectWorkflow as waitForProjectWorkflow }; } type GeoJsonFeature = { type: "Feature"; geometry: { type: "Point"; coordinates: LongLat; } | { type: "Polygon"; coordinates: LongLat[][]; } | { type: "LineString"; coordinates: LongLat[]; }; bbox?: BBox; properties: Record<string, any>; }; /** Coordinates in AGS84. Order: [long, lat] */ type LongLat = [number, number]; /** * Bounding box in AGS84 coordinates. * Order: [minLong, minLat, maxLong, maxLat] */ type BBox = [number, number, number, number]; type App = { uuid: UUID; project_uuid: UUID; cloned_from_uuid: UUID; /** * Unique group identifier for imported shared app */ shared_from_group: string | null; title: string; /** * System reference slug of the app's title */ system_reference: string; /** * New item title prefix */ prefix: null | string; description: string; created_at: Timestamp; updated_at: Timestamp; deleted_at: Timestamp | null; }; type Item = { id: number; project_uuid: UUID; app_uuid: UUID; latitude: null | number; longitude: null | number; title: string; lab_title?: string | null; original_title?: string | null; geojson?: GeoJsonFeature | null; enviro_location_code: null | string; enviro_lab_report_number: null | string; enviro_start_depth: null | number; enviro_end_depth: null | number; enviro_soil_description: null | string; enviro_lab_sample_type: null | string; enviro_sampled_date: null | string; enviro_analyzed_date: null | string; enviro_duplicate_of_id: null | number; enviro_triplicate_of_id: null | number; enviro_composite_of: null | string; enviro_matrix: null | string; created_at: Timestamp; updated_at: Timestamp; deleted_at: Timestamp | null; }; type ItemWithDetails = Item & Record<string, any | any[]>; type ItemUpdatableData = { title?: string; lab_title?: string | null; original_title?: string | null; latitude?: null | number; longitude?: null | number; }; type Document = { id: number; project_uuid: UUID; /** * User who created the Document */ creator_uuid: UUID; name: string; type: 'word' | 'excel'; status: number; status_updated_at: string | null; has_been_exported: boolean; next_export_number: number; /** * Template file UUID */ file_uuid: UUID; /** * Template file name */ file_name: string; errors: { [key: number]: { message?: string; command?: string; }; } | null; }; type DataEvent = { id: number; project_uuid: UUID; label: string; is_enabled: boolean; created_at: Timestamp; updated_at: Timestamp; deleted_at: Timestamp | null; }; /** * List apps in project with pagination * @param client Datanest REST API Client * @param page Page number * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function listProjectApps(client: DatanestClient, projectUuid: UUID): Promise<{ apps: App[]; }>; /** * List items of all kinds in project with pagination * @param client Datanest REST API Client * @param page Page number * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function listProjectItems(client: DatanestClient, projectUuid: UUID, page?: number, filters?: { bbox?: BBox; include_geojson?: boolean; page?: number; /** Search for samples by title, lab title or original titles */ search?: string; /** * Filter items by master App UUID. * This can be the UUID of a master App or a UUID of a shared App. */ template_app_uuid?: UUID; } & DateRangeFilters): Promise<PaginatedResponse<Item>>; /** * Get an item's detailed data * @param client Datanest REST API Client * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function getProjectItemDetails(client: DatanestClient, projectUuid: UUID, itemId: number): Promise<ItemWithDetails>; /** * List specific app's items in project with pagination * @param client Datanest REST API Client * @param page Page number * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function listProjectAppItems(client: DatanestClient, projectUuid: UUID, appUuid: UUID, page?: number, filters?: { bbox?: BBox; include_geojson?: boolean; /** Search for samples by title, lab title or original titles */ search?: string; } & DateRangeFilters): Promise<PaginatedResponse<Item>>; /** * The app's schema describes the app's form structure of fields and sections. * @param client * @param projectUuid * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function getAppSchema(client: DatanestClient, appUuid: string): Promise<App>; type ShareGroupFilter = 'all' | 'company' | 'global'; /** * List shared app groups, app groups can include multiple Apps, Data Events and Auto Docs * @param client * @param page * @param filter Filter by share group type * @returns */ declare function listSharedAppGroups(client: DatanestClient, page?: number, filter?: ShareGroupFilter, filters?: DateRangeFilters): Promise<PaginatedResponse<{ /** * Unique group identifier for shared app group, used for importing */ share_group: string; group_title: string; /** * Scope of the shared app group */ shareable_type: string; group_description: string | null; /** * Group icon URL as a temporary S3 URL */ icon_url: string; apps: App[]; documents: Document[]; data_events: DataEvent[]; }>>; /** * Import shared app group, with its accompanying Apps, Data Events and Auto Docs * @param client * @param projectUuid * @param shareGroup * @returns */ declare function importAppGroup(client: DatanestClient, projectUuid: UUID, shareGroup: string): Promise<{ apps: App[]; documents: Document[]; data_events: DataEvent[]; }>; type ItemUpdateMeta = { /** * List of skipped section keys that were not found in the app. */ skipped_sections: string[]; /** * List of skipped field keys that were not found in the app. */ skipped_fields: string[]; }; /** * Create an Item with Gather Sections and Fields * @param client * @param projectUuid * @param appUuid * @param data * @returns */ declare function createGatherItem(client: DatanestClient, projectUuid: UUID, appUuid: UUID, data: ItemUpdatableData & Record<string, any> & { /** @internal */ _meta?: { /** @internal for testing purposes */ created_at?: Timestamp; /** @internal for testing purposes */ updated_at?: Timestamp; }; }): Promise<Item & Record<string, any> & ItemUpdateMeta>; /** * Update an Item with Gather Sections and Fields * @param client * @param projectUuid * @param itemId * @param data * @returns */ declare function updateGatherItem(client: DatanestClient, projectUuid: UUID, itemId: number, data: ItemUpdatableData & Record<string, any>): Promise<Item & Record<string, any> & ItemUpdateMeta>; /** * Delete a Gather Item * @param client * @param projectUuid * @param itemId * @returns */ declare function deleteItem(client: DatanestClient, projectUuid: UUID, itemId: number): Promise<boolean>; type gather_App = App; type gather_DataEvent = DataEvent; type gather_Document = Document; type gather_Item = Item; type gather_ItemUpdatableData = ItemUpdatableData; type gather_ItemUpdateMeta = ItemUpdateMeta; type gather_ItemWithDetails = ItemWithDetails; type gather_ShareGroupFilter = ShareGroupFilter; declare const gather_createGatherItem: typeof createGatherItem; declare const gather_deleteItem: typeof deleteItem; declare const gather_getAppSchema: typeof getAppSchema; declare const gather_getProjectItemDetails: typeof getProjectItemDetails; declare const gather_importAppGroup: typeof importAppGroup; declare const gather_listProjectAppItems: typeof listProjectAppItems; declare const gather_listProjectApps: typeof listProjectApps; declare const gather_listProjectItems: typeof listProjectItems; declare const gather_listSharedAppGroups: typeof listSharedAppGroups; declare const gather_updateGatherItem: typeof updateGatherItem; declare namespace gather { export { type gather_App as App, type gather_DataEvent as DataEvent, type gather_Document as Document, type gather_Item as Item, type gather_ItemUpdatableData as ItemUpdatableData, type gather_ItemUpdateMeta as ItemUpdateMeta, type gather_ItemWithDetails as ItemWithDetails, type gather_ShareGroupFilter as ShareGroupFilter, gather_createGatherItem as createGatherItem, gather_deleteItem as deleteItem, gather_getAppSchema as getAppSchema, gather_getProjectItemDetails as getProjectItemDetails, gather_importAppGroup as importAppGroup, gather_listProjectAppItems as listProjectAppItems, gather_listProjectApps as listProjectApps, gather_listProjectItems as listProjectItems, gather_listSharedAppGroups as listSharedAppGroups, gather_updateGatherItem as updateGatherItem }; } type ProjectAssessed = { assessed_id: number; matrix: EnviroMatrix; hq_type: null; groundwater_depth: null; replace_na_values: boolean; test_hydrocarbons: string; by_matching_units: boolean; by_standards: boolean; is_favourite: boolean; batch_number: null; from_assessed_id: null; }; type GuidelineStandard = { standard_id: number; batch: number; country: Country2CharCode; matrix: EnviroMatrix; standard_identifier: string; standard_url: string; standard: string; standard_shorthand: string | null; formatted_title: string; acronym: string; type: string; hq_type: string | null; new_revision_standard_id: null; by_standard_specific: boolean; }; type Guideline = { id: number; is_custom_guideline: boolean; is_hierarchy_only: boolean; guideline_scenario_id: number; standard_id: number; chemical_id: number; chemical_title: string; chemical_casno: string; company_standard_id: null; original_guideline_id: null; superseded_guideline_id: null; pathways: string; soil_type: null; value_min: number; value_max: number | null; value_alphanumeric: null; units: string; groundwater_depth: null | number; soil_depth: null | number; cec_value: null | number; ph_value: null | number; clay_content: null | number; produce_consumption_percentage: null | number; table_reference: null | string; }; type GuidelineScenario = { id: number; basis: string; matrix: EnviroMatrix; land_use: string; type: null; full_title: null; }; type ProjectScenario = { id: number; project_assessed_id: number; guideline_scenario_id: number; guideline_document_id: number; criteria_set_id: number | null; is_background: boolean; is_processing: boolean; is_processed: boolean; has_processing_failure: boolean; is_outdated: boolean; is_deleting: boolean; factor: number; options: { exceed_when_no_criteria: boolean; exceed_above_upper_range: boolean; dont_exceed_below_lower_range: boolean; }; assessed: ProjectAssessed | null; scenario: GuidelineScenario | null; criteria_set: CriteriaSet | null; standard: GuidelineStandard | null; }; type CriteriaSet = { title: string; matrix: EnviroMatrix; use_analyte_comments: boolean; exclude_non_detects: boolean; is_background: boolean; comments: string | null; user_uuid: string | null; is_approved: boolean; }; type EnviroMatrix = 'soil' | 'water' | 'leachate' | 'soilgas' | 'sediment'; type EnviroChemical = { id: number; casno: string; chemical_name: string; }; /** * Profile of a company's chemical aliases */ type CompanyChemicalProfile = { profile_id: number; title: string; }; type EnviroChemicalWithAliases = EnviroChemical & { casno_aliases: string[]; chemical_aliases: string[]; }; type SampleResult = { result_id: number; exceeds_background: boolean; sample_id: number; linked_sample_id: number | null; sample_custom_title: string; sample_latitude: number; sample_longitude: number; sample_lab_title: string; sample_start_depth: number | null; sample_end_depth: number | null; sample_location_code: string | null; sample_lab_report_number: string | null; sample_soil_description: string | null; sample_lab_sample_type: string | null; sample_sampled_date: string | null; sample_analyzed_date: string | null; sample_duplicate_of_id: number | null; sample_triplicate_of_id: number | null; matrix: EnviroMatrix; chemical_id: number; chemical_casno: string; chemical_title: string; units: string; unit_multiplier: number; eql: number | null; total_or_filtered: 'T' | 'F'; is_surrogate: boolean; is_internal_standard: boolean; result: number | null; lod_result: number | null; prefix: string | null; display_result: number | null; changed_result_value: number | null; changed_result_reason: string | null; pcb_value: number | null; duplicate_rpd: number | null; triplicate_rpd: number | null; lab_flags: string | null; comments: string | null; }; /** * Get all Enviro Matrices with their aliases for Datanest * @throws DatanestResponseError Request HTTP server or validation error */ declare function getAllEnviroMatrices(client: DatanestClient): Promise<{ matrices: { matrix_id: number; matrix: EnviroMatrix; aliases: string[]; }[]; }>; /** * Get all chemicals with aliases * @param filters.profile_id Filter by profile ID, by default all profile aliases are returned * @throws DatanestResponseError Request HTTP server or validation error */ declare function getAllEnviroChemicals(client: DatanestClient, page?: number, filters?: { profile_id?: number | null; } & DateRangeFilters): Promise<PaginatedResponse<EnviroChemicalWithAliases[]>>; /** * Get all chemical aliases profiles * @throws DatanestResponseError Request HTTP server or validation error */ declare function getCompanyChemicalProfiles(client: DatanestClient): Promise<{ profiles: CompanyChemicalProfile[]; }>; /** * Get active Enviro Matrices with their aliases for a specific project * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectMatrices(client: DatanestClient, projectUuid: string): Promise<{ matrices: { matrix_id: number; matrix: EnviroMatrix; aliases: string[]; }[]; }>; /** * Get all Scenarios of a project * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectScenarios(client: DatanestClient, projectUuid: string): Promise<{ scenarios: ProjectScenario[]; }>; /** * Get all Guideline Standards of a project * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectScenarioStandards(client: DatanestClient, projectUuid: string, scenarioId: number, filters?: { page?: number; standard_id?: number; standard_ids?: number[]; }): Promise<PaginatedResponse<GuidelineStandard> & { guideline_scenario: GuidelineScenario; }>; /** * Get all Guidelines of a project * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectScenarioGuidelines(client: DatanestClient, projectUuid: string, scenarioId: number, filters?: { page?: number; standard_id?: number; standard_ids?: number[]; chemical_id?: number; chemical_ids?: number[]; }): Promise<PaginatedResponse<Guideline> & { guideline_scenario: GuidelineScenario; }>; /** * Get sample chemical results from a project * Note the date range filters applies to the sample locations, not when the results were created/updated. * @param filters.casno Optionally filter by one or more CAS numbers * @param filters.sample_ids Optionally filter by one or more Datanest sample ids * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectSampleChemicalResults(client: DatanestClient, projectUuid: string, filters?: { casno?: string[]; sample_ids?: number[]; } & DateRangeFilters): Promise<PaginatedResponse<SampleResult>>; /** * Get all sample locations of a project * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectSampleLocations(client: DatanestClient, projectUuid: string, filters?: { bbox?: BBox; include_geojson?: boolean; page?: number; /** Search for samples by title, lab title or original titles */ search?: string; } & DateRangeFilters): Promise<PaginatedResponse<Item>>; /** * Get all samples of a project * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectSamples(client: DatanestClient, projectUuid: string, filters?: { page?: number; /** Search for samples by title, lab title or original titles */ search?: string; } & DateRangeFilters): Promise<PaginatedResponse<Item>>; type enviro_CompanyChemicalProfile = CompanyChemicalProfile; type enviro_CriteriaSet = CriteriaSet; type enviro_EnviroChemical = EnviroChemical; type enviro_EnviroChemicalWithAliases = EnviroChemicalWithAliases; type enviro_EnviroMatrix = EnviroMatrix; type enviro_Guideline = Guideline; type enviro_GuidelineScenario = GuidelineScenario; type enviro_GuidelineStandard = GuidelineStandard; type enviro_ProjectAssessed = ProjectAssessed; type enviro_ProjectScenario = ProjectScenario; type enviro_SampleResult = SampleResult; declare const enviro_getAllEnviroChemicals: typeof getAllEnviroChemicals; declare const enviro_getAllEnviroMatrices: typeof getAllEnviroMatrices; declare const enviro_getCompanyChemicalProfiles: typeof getCompanyChemicalProfiles; declare const enviro_getProjectMatrices: typeof getProjectMatrices; declare const enviro_getProjectSampleChemicalResults: typeof getProjectSampleChemicalResults; declare const enviro_getProjectSampleLocations: typeof getProjectSampleLocations; declare const enviro_getProjectSamples: typeof getProjectSamples; declare const enviro_getProjectScenarioGuidelines: typeof getProjectScenarioGuidelines; declare const enviro_getProjectScenarioStandards: typeof getProjectScenarioStandards; declare const enviro_getProjectScenarios: typeof getProjectScenarios; declare namespace enviro { export { type enviro_CompanyChemicalProfile as CompanyChemicalProfile, type enviro_CriteriaSet as CriteriaSet, type enviro_EnviroChemical as EnviroChemical, type enviro_EnviroChemicalWithAliases as EnviroChemicalWithAliases, type enviro_EnviroMatrix as EnviroMatrix, type enviro_Guideline as Guideline, type enviro_GuidelineScenario as GuidelineScenario, type enviro_GuidelineStandard as GuidelineStandard, type enviro_ProjectAssessed as ProjectAssessed, type enviro_ProjectScenario as ProjectScenario, type enviro_SampleResult as SampleResult, enviro_getAllEnviroChemicals as getAllEnviroChemicals, enviro_getAllEnviroMatrices as getAllEnviroMatrices, enviro_getCompanyChemicalProfiles as getCompanyChemicalProfiles, enviro_getProjectMatrices as getProjectMatrices, enviro_getProjectSampleChemicalResults as getProjectSampleChemicalResults, enviro_getProjectSampleLocations as getProjectSampleLocations, enviro_getProjectSamples as getProjectSamples, enviro_getProjectScenarioGuidelines as getProjectScenarioGuidelines, enviro_getProjectScenarioStandards as getProjectScenarioStandards, enviro_getProjectScenarios as getProjectScenarios }; } declare enum IntegrationKey { BORE_DM = "boredm" } type IntegrationSetupData = { api_key?: string; access_token?: string; refresh_token?: string; /** * Some integrations allow you to override the API base URL * This is usually optional as the default production url can be inferred. */ service_url?: string; }; /** * Setup or override an integration with your Datanest company account * @param client * @param integrationKey * @param integrationSetupData * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function setupIntegration(client: DatanestClient, integrationKey: IntegrationKey, integrationSetupData: IntegrationSetupData): Promise<{ success: boolean; }>; /** * Remove an integration from your Datanest company account * @param client * @param integrationKey * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function removeIntegration(client: DatanestClient, integrationKey: IntegrationKey): Promise<boolean>; type integrations_IntegrationKey = IntegrationKey; declare const integrations_IntegrationKey: typeof IntegrationKey; type integrations_IntegrationSetupData = IntegrationSetupData; declare const integrations_removeIntegration: typeof removeIntegration; declare const integrations_setupIntegration: typeof setupIntegration; declare namespace integrations { export { integrations_IntegrationKey as IntegrationKey, type integrations_IntegrationSetupData as IntegrationSetupData, integrations_removeIntegration as removeIntegration, integrations_setupIntegration as setupIntegration }; } type TeamUser = User & { custom_role_id: number | null; }; /** * Get team members, external users and manager of a project * @param client Datanest REST API Client * @param projectUuid UUID of the project * @throws DatanestResponseError Request HTTP server or validation error * @returns */ declare function getProjectTeam(client: DatanestClient, projectUuid: UUID): Promise<{ project_manager: User; members: TeamUser[]; external_users: TeamUser[]; workflow_assignments: { workflow_id: number; workflow_title: string; workflow_apps: { workflow_app_id: number; workflow_group_id: number; group_title: string; users: { uuid: UUID; name: string; email: string; }[]; }[]; } | null; }>; declare function addProjectTeamMember(client: DatanestClient, projectUuid: UUID, userUuid: UUID, customRoleId?: number | null): Promise<TeamUser>; declare function removeProjectTeamMember(client: DatanestClient, projectUuid: UUID, userUuid: UUID): Promise<User>; declare function addExternalUserToProject(client: DatanestClient, projectUuid: UUID, userData: { email: string; name?: string | null; custom_role_id?: number | null; }): Promise<TeamUser>; declare function removeExternalUserToProject(client: DatanestClient, projectUuid: UUID, userUuidOrEmail: UUID | string): Promise<User>; declare function updateProjectMemberRole(client: DatanestClient, projectUuid: UUID, userUuid: UUID, customRoleId: number | null): Promise<TeamUser>; type teams_TeamUser = TeamUser; declare const teams_addExternalUserToProject: typeof addExternalUserToProject; declare const teams_addProjectTeamMember: typeof addProjectTeamMember; declare const teams_getProjectTeam: typeof getProjectTeam; declare const teams_removeExternalUserToProject: typeof removeExternalUserToProject; declare const teams_removeProjectTeamMember: typeof removeProjectTeamMember; declare const teams_updateProjectMemberRole: typeof updateProjectMemberRole; declare namespace teams { export { type teams_TeamUser as TeamUser, teams_addExternalUserToProject as addExternalUserToProject, teams_addProjectTeamMember as addProjectTeamMember, assignProjectWorkflowAppUser as assignProjectWorkflowUser, teams_getProjectTeam as getProjectTeam, teams_removeExternalUserToProject as removeExternalUserToProject, teams_removeProjectTeamMember as removeProjectTeamMember, unassignProjectWorkflowAppUser as unassignProjectWorkflowUser, teams_updateProjectMemberRole as updateProjectMemberRole }; } declare enum VirusStatus { /** * Pending scan */ PENDING = 0, /** * No virus detected */ PASSED = 1, /** * Virus detected */ FAILED = 2, /** * Unable to scan */ UNABLE = 3, /** * Scan skipped either by trusted internal process or file too large to scan. */ SKIP = 4 } declare enum ReviewStatus { WIP = 0, AWAITING_REVIEW = 1, REVIEW_PASSED = 2, REVIEW_FAILED = 3, AWAITING_FORMATTING = 4, FORMATTING_FAILED = 5, READY = 6, SENT = 7 } type File = { uuid: UUID; project_uuid: UUID; display_name: string; path: string; /** Link to the web interface */ link?: string; /** S3 file download link (expires after 10 minutes) */ temporary_url?: string; size_mb: null | number; version: number; is_final: boolean; /** The file record is awaiting an upload. The file will have an `expires_at` property if upload is not completed in time. */ is_pending: boolean; virus_status: VirusStatus; review_status: ReviewStatus; review_comments: string | null; formatter_comments: string | null; /** Used with `is_pending` */ expires_at: Timestamp | null; created_at: Timestamp; updated_at: Timestamp; deleted_at: Timestamp | null; }; type FileVersion = { id: number; file_uuid: UUID; version: number; size_mb: number; created_at: Timestamp; deleted_at: Timestamp | null; }; /** * Get project files * @param client Datanest REST API Client * @param projectUuid UUID of the project * @param page Page number * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectFiles(client: DatanestClient, projectUuid: UUID, page?: number, options?: { path?: string; latest?: boolean; } & DateRangeFilters): Promise<PaginatedResponse<File>>; /** * Get a project file * @param client Datanest REST API Client * @param projectUuid UUID of the project * @param fileUuid UUID of the file * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectFile(client: DatanestClient, projectUuid: UUID, fileUuid: UUID): Promise<File & { /** * Temporary URL to download the file * This maybe undefined if the VirusStatus is FAILED. */ temporary_url?: string; }>; /** * Get a project file with history * @param client Datanest REST API Client * @param projectUuid UUID of the project * @param fileUuid UUID of the file * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectFileHistory(client: DatanestClient, projectUuid: UUID, fileUuid: UUID): Promise<File & { /** * Temporary URL to download the file * This maybe undefined if the VirusStatus is FAILED. */ temporary_url?: string; previous_versions: FileVersion[]; }>; /** * Get project file version download url * @param client Datanest REST API Client * @param projectUuid UUID of the project * @param fileUuid UUID of the file * @param version Version number or id * @throws DatanestResponseError Request HTTP server or validation error */ declare function getProjectFileVersionUrl(client: DatanestClient, projectUuid: UUID, fileUuid: UUID, version: number): Promise<FileVersion & { /** * Temporary URL to download the file */ temporary_url: string; }>; declare function uploadFile(client: DatanestClient, projectUuid: UUID, path: string, name: string, file: File$1 | Blob | Buffer | string, options?: { create_notification?: boolean; }): Promise<File>; declare function createNewFileUploadUrl(client: DatanestClient, projectUuid: UUID, path: string, name: string, options?: { create_notification?: boolean; }): Promise<File & { uuid: string; /** * Temporary URL to upload the file * Make a PUT request with the `upload_headers` */ upload_put_url: string; upload_put_headers: Record<string, string>; accept_post_url: string; }>; /** * Accept an uploaded file */ declare function acceptFile(client: DatanestClient, projectUuid: UUID, fileUuid: UUID): Promise<File>; declare function deleteFile(client: DatanestClient, projectUuid: UUID, fileUuid: UUID): Promise<void>; /** * View recent notifications, which include file exports */ declare function getRecentNotifications(client: DatanestClient, projectUuid: UUID, page?: number, filters?: DateRangeFilters): Promise<PaginatedResponse<{ id: number; project_uuid: UUID; /** Typically available when status = completed */ file_uuid: UUID | null; type: "plan" | "parsing" | "xlsx" | "docx" | "zip" | "shapefile" | "photolog" | "image" | "custom-document" | "gather-table" | "proucl-table" | "other" | "ai-document-review" | "leaderboard"; status: "queued" | "in_progress" | "completed" | "failed" | "converting"; /** When `file_id` is not null, otherwise file is not defined. */ file?: File; created_at: Timestamp; updated_at: Timestamp; }>>; type files_File = File; type files_FileVersion = FileVersion; type files_ReviewStatus = ReviewStatus; declare const files_ReviewStatus: typeof ReviewStatus; type files_VirusStatus = VirusStatus; declare const files_VirusStatus: typeof VirusStatus; declare const files_acceptFile: typeof acceptFile; declare const files_createNewFileUploadUrl: typeof createNewFileUploadUrl; declare const files_deleteFile: typeof deleteFile; declare const files_getProjectFile: typeof getProjectFile; declare const files_getProjectFileHistory: typeof getProjectFileHistory; declare const files_getProjectFileVersionUrl: typeof getProjectFileVersionUrl; declare const files_getProjectFiles: typeof getProjectFiles; declare const files_getRecentNotifications: typeof getRecentNotifications; declare const files_uploadFile: typeof uploadFile; declare namespace files { export { type files_File as File, type files_FileVersion as FileVersion, files_ReviewStatus as ReviewStatus, files_VirusStatus as VirusStatus, files_acceptFile as acceptFile, files_createNewFileUploadUrl as createNewFileUploadUrl, files_deleteFile as deleteFile, files_getProjectFile as getProjectFile, files_getProjectFileHistory as getProjectFileHistory, files_getProjectFileVersionUrl as getProjectFileVersionUrl, files_getProjectFiles as getProjectFiles, files_getRecentNotifications as getRecentNotifications, files_uploadFile as uploadFile }; } type WebhookRequest = { event: WebhookEvent; trigger: WebhookTrigger; project: Project; artifacts: WebhookArtifact[]; log: WebhookLog[]; /** @deprecated */ file?: File; item?: Item; }; type WebhookEvent = { id: number; history_id: number; label: string; }; type WebhookTrigger = { id: number; type: number; reason: string; reason_long: string; payload: { item_id?: number; trigger_type?: number; trigger_id?: number; event_history_id?: number; document_id?: number; file_id?: string; }; }; type WebhookArtifact = { type: string; artifact_label?: string; artifact_type?: 'Webhook Sent' | 'Map Figure Generated' | 'Auto Doc Generated' | 'Insights Graphs Generated' | 'Set Gather Value' | 'Email Sent' | WebhookTrigger['reason_long']; action_id?: number; action_label?: string; app_uuid?: string; item_id?: number; field_id?: number; app_title?: string; field_label?: string; new_value?: string; trigger_id?: number; trigger_type?: string; recipients?: string[]; subject?: string; body?: string; attachments?: Attachment[]; webhook_url?: string; sent_at?: string; files?: File[]; graph_id?: number; }; type Attachment = { id: string; file: File; name: string; file_id: UUID; figure_id?: null | number; document_id?: null | number; type: "File" | "Figure" | "Document"; convert_to_pdf: boolean; auto_docs_options: Record<string, any>; }; /** * 0: Log Level; * 1: Timestamp; * 2: Message */ type WebhookLog = [string, string, string]; declare enum WebhookAuthorizationStatus { Success = 0, TimestampError = 1, SignatureError = 2, MissingTimestamp = 3, MissingSignature = 4, InvalidApiKey = 5, MissingApiKey = 6 } declare function formatAuthorizationStatus(status: WebhookAuthorizationStatus): string; /** * Verify the authenticity of a webhook request using the signature * @param request * @param secretKey * @param disableTimestampCheck for unit testing purposes * @returns WebhookAuthorizationStatus 0=Success */ declare function authenticateWebhook(request: Request, requestBody: string | null, apiKey: string, secretKey: string, disableTimestampCheck?: boolean): Promise<WebhookAuthorizationStatus>; type webhook_Attachment = Attachment; type webhook_WebhookArtifact = WebhookArtifact; type webhook_WebhookAuthorizationStatus = WebhookAuthorizationStatus; declare const webhook_WebhookAuthorizationStatus: typeof WebhookAuthorizationStatus; type webhook_WebhookEvent = WebhookEvent; type webhook_WebhookLog = WebhookLog; type webhook_WebhookRequest = WebhookRequest; type webhook_WebhookTrigger = WebhookTrigger; declare const webhook_authenticateWebhook: typeof authenticateWebhook; declare const webhook_formatAuthorizationStatus: typeof formatAuthorizationStatus; declare namespace webhook { export { type webhook_Attachment as Attachment, type webhook_WebhookArtifact as WebhookArtifact, webhook_WebhookAuthorizationStatus as WebhookAuthorizationStatus, type webhook_WebhookEvent as WebhookEvent, type webhook_WebhookLog as WebhookLog, type webhook_WebhookRequest as WebhookRequest, type webhook_WebhookTrigger as WebhookTrigger, webhook_authenticateWebhook as authenticateWebhook, webhook_formatAuthorizationStatus as formatAuthorizationStatus }; } /** * @deprecated Use `users` namespace instead */ declare const user: typeof users; declare class DatanestClient { private apiKey; private apiSecret; private baseUrl; private clientId; private logErrors; private logTrace; private static rateLimitMax; private static rateLimitIntervalMs; private static requestTimestamps; /** * Create a new Datanest API client * Note: You can use environment variables instead of using * the constructor params `apiKey` and `apiSecret` * ENV: * - `DATANEST_API_KEY` * - `DATANEST_API_SECRET` * - `DATANEST_API_BASE_URL` (optional) Default: https://app.datanest.earth/api */ constructor(apiKey?: string, apiSecret?: string); static disableRateLimit(): void; /** Datanest accepts up to 60 requests per minute, default limit is less for typical use */ static setRateLimit(maxRequests: number, intervalMs?: number): void; private static checkRateLimit; setLogErrors(logErrors: boolean): void; setLogTrace(logTrace: boolean): void; private signRequest; /** * Send a request to the Datanest API * @param method * @param path * @param params * @param fetchOptions * @throws DatanestResponseError Request HTTP server or validation error * @returns Fetch response with readable stream. */ private sendRequest; private traceRequest; /** * Send a GET request to the Datanest API * @param path e.g. `v1/projects` * @param params Query parameters * @param fetchOptions * @throws DatanestResponseError Request HTTP server or validation error * @returns Fetch response with readable stream. */ get(path: string, params?: Record<string, any>, fetchOptions?: DatanestRequestInit): Promise<Response>; /** * Send a POST request to the Datanest API * @param path e.g. `v1/projects` * @param params Will be converted to JSON in request body * @param fetchOptions * @throws DatanestResponseError Request HTTP server or validation error * @returns Fetch response with readable stream. */ post(path: string, params?: Record<string, any>, fetchOptions?: DatanestRequestInit): Promise<Response>; /** * Send a PATCH request to the Datanest API * @param path e.g. `v1/projects/{uuid}` * @param params Will be converted to JSON in request body * @param fetchOptions * @throws DatanestResponseError Request HTTP server or validation error * @returns Fetch response with readable stream. */ patch(path: string, params?: Record<string, any>, fetchOptions?: Datanest