@datanest-earth/nodejs-client
Version:
Datanest API Client to easily create signed requests
1,303 lines (1,287 loc) • 68.1 kB
text/typescript
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 ID of the original revision 0 workflow */
original_workflow_id: number;
workflow_title: string;
/** Starting at 0, incremented when the workflow is updated */
revision: number;
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;
}[];
published_at: string | null;
updated_at: string;
created_at: string;
};
type CompanyCustomRole = {
custom_role_id: number;
custom_role_title: string;
};
type WorkflowFilters = {
/** Include draft workflows where published_at is null */
include_drafts?: boolean;
/**
* Include revisions of the workflow that have previous `revision` values.
* These cannot be used to create or assign to new projects.
*/
include_revisions?: boolean;
page?: number;
};
/**
* Get Company Workflow templates.
* You can use this to help setup projects with workflows.
* By default, only published workflows are returned. See WorkflowFilters
* @param client
* @returns
*/
declare function getCompanyWorkflows(client: DatanestClient, filters?: WorkflowFilters & DateRangeFilters): Promise<PaginatedResponse<CompanyWorkflow>>;
/**
* Get Company Workflow workflow with the latest revision.
* You can use this to help setup projects with workflows.
* @param client
* @returns
*/
declare function getCompanyWorkflow(client: DatanestClient, workflowId: number): Promise<{
original_workflow_id: number;
/** Starting at 0, incremented when the workflow is updated */
revision: number;
/** Starting at 0, incremented when the workflow is updated. Includes draft */
latest_revision: number;
/** Starting at 0, incremented when the workflow is updated. Includes draft */
latest_revision_id: number;
/** Starting at 0, incremented when the workflow is updated. Includes draft */
latest_published_revision: number | null;
/** Workflow ID of the latest published revision */
latest_published_id: number | null;
/** Is the workflow the latest published revision? */
is_latest: boolean;
/** Workflow for the workflowId requested, which may be a draft or revision or latest published */
workflow: CompanyWorkflow;
/** This will always have a published_at set but there may be no published workflow yet. */
latest_published_workflow: CompanyWorkflow | null;
/** This may be a draft with published_at set to null */
latest_workflow: 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, shareGroupOrWorkflowAppId: string | 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>;
declare function getLatestWorkflowFromList(workflows: CompanyWorkflow[]): CompanyWorkflow;
declare function getLatestDraftWorkflowFromList(workflows: CompanyWorkflow[]): CompanyWorkflow;
declare function getLatestPublishedWorkflowFromList(workflows: CompanyWorkflow[]): CompanyWorkflow;
declare function isDraftWorkflow(workflow: CompanyWorkflow): boolean;
/** This does not mean that it is the latest published workflow. Just that it was published at some point. */
declare function isPublishedWorkflow(workflow: CompanyWorkflow): boolean;
type workflows_CompanyCustomRole = CompanyCustomRole;
type workflows_CompanyWorkflow = CompanyWorkflow;
type workflows_WorkflowFilters = WorkflowFilters;
declare const workflows_assignProjectWorkflowAppUser: typeof assignProjectWorkflowAppUser;
declare const workflows_getCompanyCustomRoles: typeof getCompanyCustomRoles;
declare const workflows_getCompanyWorkflow: typeof getCompanyWorkflow;
declare const workflows_getCompanyWorkflows: typeof getCompanyWorkflows;
declare const workflows_getLatestDraftWorkflowFromList: typeof getLatestDraftWorkflowFromList;
declare const workflows_getLatestPublishedWorkflowFromList: typeof getLatestPublishedWorkflowFromList;
declare const workflows_getLatestWorkflowFromList: typeof getLatestWorkflowFromList;
declare const workflows_isDraftWorkflow: typeof isDraftWorkflow;
declare const workflows_isPublishedWorkflow: typeof isPublishedWorkflow;
declare const workflows_unassignProjectWorkflowAppUser: typeof unassignProjectWorkflowAppUser;
declare namespace workflows {
export { type workflows_CompanyCustomRole as CompanyCustomRole, type workflows_CompanyWorkflow as CompanyWorkflow, type workflows_WorkflowFilters as WorkflowFilters, workflows_assignProjectWorkflowAppUser as assignProjectWorkflowAppUser, workflows_getCompanyCustomRoles as getCompanyCustomRoles, workflows_getCompanyWorkflow as getCompanyWorkflow, workflows_getCompanyWorkflows as getCompanyWorkflows, workflows_getLatestDraftWorkflowFromList as getLatestDraftWorkflowFromList, workflows_getLatestPublishedWorkflowFromList as getLatestPublishedWorkflowFromList, workflows_getLatestWorkflowFromList as getLatestWorkflowFromList, workflows_isDraftWorkflow as isDraftWorkflow, workflows_isPublishedWorkflow as isPublishedWorkflow, 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 | null>;
/**
* Supported ISO 3166-1 alpha-2 country codes
*/
address_country: Country2CharCode;
address_postcode: null | string;
measurement_type: MeasurementType | null;
/** IANA Timezone identifier e.g. Australia/Sydney or Pacific/Auckland */
timezone: null | 'UTC' | TimezoneIdentifier;
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;
/** UUID of the project manager */
project_manager_uuid?: UUID;
/** Email of the project manager */
project_manager?: Email;
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>;
};
type WorkflowAppIdentifier = {
/**
* Recommended workflow app selector.
* The recommended convention is `share.company.app-identifier-version`
* To handle version control, only provide the prefix and the project's version will be automatically resolved.
* E.g. use "share.my-company.app-identifier" and the corresponding "share.my-company.app-identifier.v3" will be automatically resolved.
*/
share_group: string;
} | {
/**
* Caution: Publishing new revisions will change the ID of the workflow_app_id
* this can be inconvenient as republishing a workflow will cause breaking changes to API calls.
* @deprecated Please use share_group instead
*/
workflow_app_id: number;
};
type WorkflowAppUserAssignment = WorkflowAppIdentifier & ({
/**
* Set currently assigned users to the project's app group by UUID
* Omitted users will be removed from the project's app group
*/
user_uuids: UUID[];
} | {
/**
* Set currently assigned users to the project's app group by email
* Omitted users will be removed from the project's app group
*/
users: Email[];
});
/**
* 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?: WorkflowAppUserAssignment[];
};
/**
* 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;
latest?: boolean;
} & 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> & Partial<Project>): 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;
type projects_WorkflowAppUserAssignment = WorkflowAppUserAssignment;
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, type projects_WorkflowAppUserAssignment as WorkflowAppUserAssignment, 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;
/** @internal used internally by datanest, use of UUID for Public API is recommended. */
id?: number;
};
type AppSchema = App & {
sections: SectionWithFields[];
};
type Section = {
id: number;
template_tab_id: number;
system_reference: string | null;
cloned_from_id: number | null;
label: string;
is_public_form: boolean;
is_shown_on_new_page: boolean;
is_repeatable: boolean;
is_permanent: boolean;
order: number;
is_lab_sample: boolean;
is_health_safety: boolean;
is_soil_log: boolean;
is_site_visit: boolean;
is_photolog: boolean;
is_gps_point_metadata: boolean;
is_number_used_as_title: boolean;
created_at: Timestamp;
updated_at: Timestamp;
deleted_at: Timestamp | null;
primary_field_id: number | null;
secondary_field_id: number | null;
};
type SectionWithFields = Section & {
template_fields: Field[];
};
declare const FieldTypes: {
readonly TEXT: 1;
readonly NUMBER: 2;
readonly DATE: 3;
readonly DROPDOWN: 4;
readonly CHECKBOX: 5;
readonly MEDIA: 6;
readonly DEPTH: 7;
readonly REFERENCE: 8;
readonly SIGNATURE: 9;
readonly CAPTION: 10;
readonly EXPRESSION: 11;
readonly DOCUMENT: 12;
readonly DUPLICATE: 13;
readonly TRIPLICATE: 14;
readonly DRAWING: 15;
readonly LITHOLOGY: 16;
readonly ADDRESS: 17;
readonly USER: 18;
readonly LAB_ID: 19;
readonly COPY_DATA_LINK: 20;
readonly AI_PROMPT: 21;
readonly FIELD_SPLITTER: 22;
};
type FieldTypeId = typeof FieldTypes[keyof typeof FieldTypes];
declare const FieldTypeNames: Record<FieldTypeId, string>;
/**
* Not all options are supported by certain field types.
* It is recommended to build the options via the App Editor UI and ask for a JSON export.
*/
type FieldOptions = {
default?: string;
defaults?: any[];
conditions?: any[];
[key: string]: any;
};
type Field = {
id: number;
template_section_id: number;
field_type_id: FieldTypeId;
system_reference: string | null;
cloned_from_id: number | null;
label: string;
is_required: boolean;
is_permanent: number;
options: FieldOptions | null;
order: number;
width: number;
c_template_field_id: number | null;
c_input_value: any;
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_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<AppSchema>;
declare function deleteApp(client: DatanestClient, projectUuid: UUID, appUuid: UUID): Promise<void>;
type AppSchemaExportJson = {
_datanest_type: 'gather_schema_v1' | string;
_datanest_version: string;
_datanest_env: string;
project: Project;
workflow: CompanyWorkflow | null;
project_link: string;
collection_link: string;
apps: AppSchema[];
exported_at: Timestamp;
};
/**
* @internal EXPERIMENTAL ENDPOINT: Some field options including Auto Assigns & Expressions may not be supported.
* Import multiple apps from a previous JSON export. Within the same project or across projects
* If uploading to the same project, it will match existing IDs and avoid duplicates.
* Tip: Remove any apps.*.id & apps.*.uuid to create duplicate apps
* @param client asDuplicates
* @param projectUuid
* @param appsJson
* @returns
*/
declare function importAppSchemaFromJson(client: DatanestClient, projectUuid: UUID, appsJson: string | {
apps: AppSchema[];
} & Partial<AppSchemaExportJson>, options?: {
asDuplicates?: boolean;
}): Promise<AppSchemaExportJson>;
type ShareGroupFilter = 'all' | 'company' | 'global';
type ShareGroupSearchFilters = {
/**
* Search for share groups by title or share_group prefix
*/
search?: string;
/**
* Filter by share group or share group prefix
*/
share_group?: string;
};
type ShareGroup = {
/**
* 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[];
};
/**
* 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?: ShareGroupSearchFilters & DateRangeFilters): Promise<PaginatedResponse<ShareGroup>>;
/**
* 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[];
}>;
declare function shareAppsFromProject(client: DatanestClient, projectUuid: UUID, shareGroupDetails: {
app_uuids: UUID[];
group_title: string;
group_description?: string | null;
share_group?: string | null;
}): Promise<{
share_group: ShareGroup;
}>;
/** This will REPLACE the shared apps, documents & data events with any specified */
declare function updateShareGroup(client: DatanestClient, projectUuid: UUID, shareGroup: string, shareGroupDetails: {
app_uuids: UUID[];
group_title: string;
group_description?: string | null;
share_group?: string | null;
}): Promise<{
share_group: ShareGroup;
}>;
declare function unshareAppGroup(client: DatanestClient, projectUuid: UUID, shareGroup: string): Promise<void>;
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_AppSchema = AppSchema;
type gather_AppSchemaExportJson = AppSchemaExportJson;
type gather_DataEvent = DataEvent;
type gather_Document = Document;
type gather_Field = Field;
type gather_FieldOptions = FieldOptions;
type gather_FieldTypeId = FieldTypeId;
declare const gather_FieldTypeNames: typeof FieldTypeNames;
declare const gather_FieldTypes: typeof FieldTypes;
type gather_Item = Item;
type gather_ItemUpdatableData = ItemUpdatableData;
type gather_ItemUpdateMeta = ItemUpdateMeta;
type gather_ItemWithDetails = ItemWithDetails;
type gather_Section = Section;
type gather_SectionWithFields = SectionWithFields;
type gather_ShareGroup = ShareGroup;
type gather_ShareGroupFilter = ShareGroupFilter;
type gather_ShareGroupSearchFilters = ShareGroupSearchFilters;
declare const gather_createGatherItem: typeof createGatherItem;
declare const gather_deleteApp: typeof deleteApp;
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_importAppSchemaFromJson: typeof importAppSchemaFromJson;
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_shareAppsFromProject: typeof shareAppsFromProject;
declare const gather_unshareAppGroup: typeof unshareAppGroup;
declare const gather_updateGatherItem: typeof updateGatherItem;
declare const gather_updateShareGroup: typeof updateShareGroup;
declare namespace gather {
export { type gather_App as App, type gather_AppSchema as AppSchema, type gather_AppSchemaExportJson as AppSchemaExportJson, type gather_DataEvent as DataEvent, type gather_Document as Document, type gather_Field as Field, type gather_FieldOptions as FieldOptions, type gather_FieldTypeId as FieldTypeId, gather_FieldTypeNames as FieldTypeNames, gather_FieldTypes as FieldTypes, type gather_Item as Item, type gather_ItemUpdatableData as ItemUpdatableData, type gather_ItemUpdateMeta as ItemUpdateMeta, type gather_ItemWithDetails as ItemWithDetails, type gather_Section as Section, type gather_SectionWithFields as SectionWithFields, type gather_ShareGroup as ShareGroup, type gather_ShareGroupFilter as ShareGroupFilter, type gather_ShareGroupSearchFilters as ShareGroupSearchFilters, gather_createGatherItem as createGatherItem, gather_deleteApp as deleteApp, gather_deleteItem as deleteItem, gather_getAppSchema as getAppSchema, gather_getProjectItemDetails as getProjectItemDetails, gather_importAppGroup as importAppGroup, gather_importAppSchemaFromJson as importAppSchemaFromJson, gather_listProjectAppItems as listProjectAppItems, gather_listProjectApps as listProjectApps, gather_listProjectItems as listProjectItems, gather_listSharedAppGroups as listSharedAppGroups, gather_shareAppsFromProject as shareAppsFromProject, gather_unshareAppGroup as unshareAppGroup, gather_updateGatherItem as updateGatherItem, gather_updateShareGroup as updateShareGroup };
}
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_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;
total_or_filtered: 'T' | 'F';
is_surrogate: boolean;
is_internal_standard: boolean;
ucl: number | null;
lcl: number | null;
extraction_method: string | null;
result: number | null;
lod_result: number | null;
prefix: string | null;
display_result: number | null;
changed_result_value: number | null;
changed_result_reason: string | null;
eql: number | null;
detection_limit_units: string | null;
result_type: string | null;
extraction_date: string | null;
analyzed_date: string | null;
lab_analysis_id: number | null;
lab_preperation_batch_id: number | null;
lab_analysis_batch_id: number | null;
rdl: number | null;
mdl: number | null;
odl: number | null;
lab_comments: string | null;
lab_qualifier: string | null;
dilution_factor: number | null;
spike_concentration: number | null;
spike_measurement: number | null;
spike_units: 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;
share_group: 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 tim