@trackunit/custom-field-api 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export * from "./fragment-masking";
2
+ export * from "./gql";
@@ -0,0 +1,8 @@
1
+ import { DeepPartialNullable } from "@trackunit/react-core-contexts-test";
2
+ import * as gql from "../graphql-api/graphql";
3
+ export declare const mockForGetCustomFieldsForAssetQuery: (variables: gql.GetCustomFieldsForAssetQueryVariables, data?: DeepPartialNullable<gql.GetCustomFieldsForAssetQuery>) => import("@apollo/client/testing").MockedResponse<gql.GetCustomFieldsForAssetQuery, Record<string, any>> & {
4
+ data: gql.GetCustomFieldsForAssetQuery;
5
+ };
6
+ export declare const mockForGetCustomFieldsForSiteQuery: (variables: gql.GetCustomFieldsForSiteQueryVariables, data?: DeepPartialNullable<gql.GetCustomFieldsForSiteQuery>) => import("@apollo/client/testing").MockedResponse<gql.GetCustomFieldsForSiteQuery, Record<string, any>> & {
7
+ data: gql.GetCustomFieldsForSiteQuery;
8
+ };
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./useCustomFieldsValueAndDefinition";
2
+ export { GetCustomFieldsForAssetDocument, type GetCustomFieldsForAssetQuery, type GetCustomFieldsForAssetQueryVariables, GetCustomFieldsForSiteDocument } from "./generated/graphql-api/graphql";
@@ -0,0 +1,33 @@
1
+ import { CustomFieldValueAndDefinitionFragment, CustomFieldValueAndDefinitionFragmentDoc, SystemOfMeasurement } from "./generated/graphql-api/graphql";
2
+ import { FragmentType } from "./generated/graphql-api/fragment-masking";
3
+ import { EntityType } from "@trackunit/iris-app-api";
4
+ export type CustomFieldValueAndDefinition = CustomFieldValueAndDefinitionFragment;
5
+ export type SupportedEntityTypes = Extract<EntityType, "ASSET" | "SITE">;
6
+ type CustomFieldValueAndDefinitionNode = FragmentType<typeof CustomFieldValueAndDefinitionFragmentDoc>;
7
+ /**
8
+ * A function used to get the CustomFieldValueAndDefinition from a node of CustomFieldValueAndDefinition.
9
+ *
10
+ * @param node - The node containing the CustomFieldValueAndDefinition, which may be null or undefined.
11
+ * @returns {CustomFieldValueAndDefinitionNode} The CustomFieldValueAndDefinition if it exists, or undefined otherwise.
12
+ */
13
+ export declare const getCustomFieldValueAndDefinitionFromRelevantNode: (node?: CustomFieldValueAndDefinitionNode | null) => CustomFieldValueAndDefinitionFragment | null | undefined;
14
+ export interface UseCustomFieldsValueAndDefinitionProps {
15
+ entityId?: string;
16
+ entityType?: SupportedEntityTypes;
17
+ systemOfMeasurement: SystemOfMeasurement;
18
+ }
19
+ export interface UseCustomFieldsValueAndDefinitionReturnValue {
20
+ loading: boolean;
21
+ fields: CustomFieldValueAndDefinition[];
22
+ }
23
+ /**
24
+ * Custom hook to fetch custom fields and definitions for a specified entity.
25
+ *
26
+ * @param {UseCustomFieldsValueAndDefinitionProps} props - The properties for the custom fields query.
27
+ * @param {string} [props.entityId] - The ID of the entity for which custom fields are fetched. Can be either an asset or a site.
28
+ * @param {SupportedEntityTypes} [props.entityType] - The type of the entity (e.g., 'ASSET' or 'SITE'). Determines which query to execute.
29
+ * @param {SystemOfMeasurement} props.systemOfMeasurement - The system of measurement to be used in the custom fields.
30
+ * @returns {UseCustomFieldsValueAndDefinitionReturnValue} An object containing a loading state and an array of custom fields and definitions.
31
+ */
32
+ export declare const useCustomFieldsValueAndDefinition: ({ entityId, entityType, systemOfMeasurement }: UseCustomFieldsValueAndDefinitionProps) => UseCustomFieldsValueAndDefinitionReturnValue;
33
+ export {};