@outseta/react 0.2.3 → 0.2.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outseta/react",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "React hooks and components for the Outseta API",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,14 +17,9 @@
17
17
  "import": "./dist/index.js"
18
18
  }
19
19
  },
20
- "scripts": {
21
- "build": "rimraf dist && bun build src/index.ts --outdir dist --target browser --format esm --packages external",
22
- "typecheck": "tsc --noEmit",
23
- "lint": "eslint src --ignore-pattern generated"
24
- },
25
20
  "dependencies": {
26
- "@outseta/api-client": "*",
27
- "@tanstack/react-query": "^5.0.0"
21
+ "@tanstack/react-query": "^5.0.0",
22
+ "@outseta/api-client": "0.2.5"
28
23
  },
29
24
  "peerDependencies": {
30
25
  "react": "^18.0.0 || ^19.0.0"
@@ -41,5 +36,10 @@
41
36
  "publishConfig": {
42
37
  "access": "public",
43
38
  "provenance": true
39
+ },
40
+ "scripts": {
41
+ "build": "rimraf dist && bun build src/index.ts --outdir dist --target browser --format esm --packages external",
42
+ "typecheck": "tsc --noEmit",
43
+ "lint": "eslint src --ignore-pattern generated"
44
44
  }
45
- }
45
+ }
@@ -27,10 +27,12 @@ type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
27
27
 
28
28
 
29
29
  /**
30
- * @summary Retrieves all the activities. One or multiple parameters can be defined to filter the results.
31
- ActivityType=[100,101] where ActivityUpdated = 100 and AcccountUpdated = 101
30
+ * One or multiple parameters can be defined to filter the results.
31
+ ActivityType=[100,101] where ActivityUpdated = 100 and AcccountUpdated = 101.
32
32
  Results will be limited to the last year unless ActivityDateTime is specified,
33
- possibly with ActivityDateTime__gt/ActivityDateTime__gte and ActivityDateTime__lt/ActivityDateTime__lte
33
+ possibly with ActivityDateTime__gt/ActivityDateTime__gte and
34
+ ActivityDateTime__lt/ActivityDateTime__lte.
35
+ * @summary Retrieve all activities, optionally filtered.
34
36
  */
35
37
  export const activityGetAll = (
36
38
  params?: ActivityGetAllParams,
@@ -78,10 +80,7 @@ export type ActivityGetAllQueryError = void
78
80
 
79
81
 
80
82
  /**
81
- * @summary Retrieves all the activities. One or multiple parameters can be defined to filter the results.
82
- ActivityType=[100,101] where ActivityUpdated = 100 and AcccountUpdated = 101
83
- Results will be limited to the last year unless ActivityDateTime is specified,
84
- possibly with ActivityDateTime__gt/ActivityDateTime__gte and ActivityDateTime__lt/ActivityDateTime__lte
83
+ * @summary Retrieve all activities, optionally filtered.
85
84
  */
86
85
 
87
86
  export function useActivityGetAll<TData = Awaited<ReturnType<typeof activityGetAll>>, TError = void>(
@@ -102,10 +101,11 @@ export function useActivityGetAll<TData = Awaited<ReturnType<typeof activityGetA
102
101
 
103
102
 
104
103
  /**
105
- * @summary Record custom events associated to an account, person or deal. These activities show up
106
- on the activity feed of the corresponding entity and can be leveraged to trigger drip
107
- campaigns and other automation. For integration with drip campaigns make sure that what
108
- you pass in the Title property matches the start / stop value specified for the campaign.
104
+ * These activities show up on the activity feed of the corresponding entity and can be
105
+ leveraged to trigger drip campaigns and other automation. For integration with drip
106
+ campaigns make sure that what you pass in the Title property matches the start / stop
107
+ value specified for the campaign.
108
+ * @summary Record a custom event associated to an account, person or deal.
109
109
  */
110
110
  export const activityAddCustomActivity = (
111
111
  activityAddCustomActivityBody: ActivityAddCustomActivityBody,
@@ -154,10 +154,7 @@ const {mutation: mutationOptions, request: requestOptions} = options ?
154
154
  export type ActivityAddCustomActivityMutationError = void
155
155
 
156
156
  /**
157
- * @summary Record custom events associated to an account, person or deal. These activities show up
158
- on the activity feed of the corresponding entity and can be leveraged to trigger drip
159
- campaigns and other automation. For integration with drip campaigns make sure that what
160
- you pass in the Title property matches the start / stop value specified for the campaign.
157
+ * @summary Record a custom event associated to an account, person or deal.
161
158
  */
162
159
  export const useActivityAddCustomActivity = <TError = void,
163
160
  TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof activityAddCustomActivity>>, TError,{data: ActivityAddCustomActivityBody}, TContext>, request?: SecondParameter<typeof customFetch>}
@@ -0,0 +1,163 @@
1
+ // @ts-nocheck
2
+ import {
3
+ useQuery
4
+ } from '@tanstack/react-query';
5
+ import type {
6
+ QueryFunction,
7
+ QueryKey,
8
+ UseQueryOptions,
9
+ UseQueryResult
10
+ } from '@tanstack/react-query';
11
+
12
+ import type {
13
+ Definition
14
+ } from '../outsetaAPI.schemas';
15
+
16
+ import { customFetch } from '../../mutator';
17
+
18
+
19
+ type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
20
+
21
+
22
+
23
+ /**
24
+ * entityType is the name of an EntityType enum value, for example: Account, Person,
25
+ Deal. Definitions describe the labels, system names, and control types of
26
+ the custom attributes that have been added to that entity.
27
+ * @summary Returns all custom attribute definitions for the given entity type.
28
+ */
29
+ export const definitionGetAllDefinitions = (
30
+ entityType: string | null,
31
+ options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
32
+ ) => {
33
+
34
+
35
+ return customFetch<Definition[]>(
36
+ {url: `/api/v1/attributes/${entityType}/definitions`, method: 'GET', signal
37
+ },
38
+ options);
39
+ }
40
+
41
+
42
+
43
+
44
+ export const getDefinitionGetAllDefinitionsQueryKey = (entityType?: string | null,) => {
45
+ return [
46
+ `/api/v1/attributes/${entityType}/definitions`
47
+ ] as const;
48
+ }
49
+
50
+
51
+ export const getDefinitionGetAllDefinitionsQueryOptions = <TData = Awaited<ReturnType<typeof definitionGetAllDefinitions>>, TError = unknown>(entityType: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof definitionGetAllDefinitions>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
52
+ ) => {
53
+
54
+ const {query: queryOptions, request: requestOptions} = options ?? {};
55
+
56
+ const queryKey = queryOptions?.queryKey ?? getDefinitionGetAllDefinitionsQueryKey(entityType);
57
+
58
+
59
+
60
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof definitionGetAllDefinitions>>> = ({ signal }) => definitionGetAllDefinitions(entityType, requestOptions, signal);
61
+
62
+
63
+
64
+
65
+
66
+ return { queryKey, queryFn, enabled: !!(entityType), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof definitionGetAllDefinitions>>, TError, TData> & { queryKey: QueryKey }
67
+ }
68
+
69
+ export type DefinitionGetAllDefinitionsQueryResult = NonNullable<Awaited<ReturnType<typeof definitionGetAllDefinitions>>>
70
+ export type DefinitionGetAllDefinitionsQueryError = unknown
71
+
72
+
73
+ /**
74
+ * @summary Returns all custom attribute definitions for the given entity type.
75
+ */
76
+
77
+ export function useDefinitionGetAllDefinitions<TData = Awaited<ReturnType<typeof definitionGetAllDefinitions>>, TError = unknown>(
78
+ entityType: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof definitionGetAllDefinitions>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
79
+
80
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
81
+
82
+ const queryOptions = getDefinitionGetAllDefinitionsQueryOptions(entityType,options)
83
+
84
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
85
+
86
+ query.queryKey = queryOptions.queryKey ;
87
+
88
+ return query;
89
+ }
90
+
91
+
92
+
93
+
94
+ /**
95
+ * The entityType segment of the URL must match the type the definition belongs to
96
+ (e.g. Account, Person, Deal).
97
+ * @summary Returns a single custom attribute definition by UID.
98
+ */
99
+ export const definitionGetDefinition = (
100
+ definitionUid: string | null,
101
+ options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
102
+ ) => {
103
+
104
+
105
+ return customFetch<Definition>(
106
+ {url: `/api/v1/attributes/definitions/${definitionUid}`, method: 'GET', signal
107
+ },
108
+ options);
109
+ }
110
+
111
+
112
+
113
+
114
+ export const getDefinitionGetDefinitionQueryKey = (definitionUid?: string | null,) => {
115
+ return [
116
+ `/api/v1/attributes/definitions/${definitionUid}`
117
+ ] as const;
118
+ }
119
+
120
+
121
+ export const getDefinitionGetDefinitionQueryOptions = <TData = Awaited<ReturnType<typeof definitionGetDefinition>>, TError = void>(definitionUid: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof definitionGetDefinition>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
122
+ ) => {
123
+
124
+ const {query: queryOptions, request: requestOptions} = options ?? {};
125
+
126
+ const queryKey = queryOptions?.queryKey ?? getDefinitionGetDefinitionQueryKey(definitionUid);
127
+
128
+
129
+
130
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof definitionGetDefinition>>> = ({ signal }) => definitionGetDefinition(definitionUid, requestOptions, signal);
131
+
132
+
133
+
134
+
135
+
136
+ return { queryKey, queryFn, enabled: !!(definitionUid), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof definitionGetDefinition>>, TError, TData> & { queryKey: QueryKey }
137
+ }
138
+
139
+ export type DefinitionGetDefinitionQueryResult = NonNullable<Awaited<ReturnType<typeof definitionGetDefinition>>>
140
+ export type DefinitionGetDefinitionQueryError = void
141
+
142
+
143
+ /**
144
+ * @summary Returns a single custom attribute definition by UID.
145
+ */
146
+
147
+ export function useDefinitionGetDefinition<TData = Awaited<ReturnType<typeof definitionGetDefinition>>, TError = void>(
148
+ definitionUid: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof definitionGetDefinition>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
149
+
150
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
151
+
152
+ const queryOptions = getDefinitionGetDefinitionQueryOptions(definitionUid,options)
153
+
154
+ const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
155
+
156
+ query.queryKey = queryOptions.queryKey ;
157
+
158
+ return query;
159
+ }
160
+
161
+
162
+
163
+