@outseta/react 0.5.7 → 0.5.8
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.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "React hooks and components for the Outseta API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@outseta/api-client": "0.4.
|
|
21
|
+
"@outseta/api-client": "0.4.8"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
} from '../../query';
|
|
15
15
|
|
|
16
16
|
import type {
|
|
17
|
+
AddDefinitionRequest,
|
|
17
18
|
Definition,
|
|
18
19
|
DefinitionGetAllDefinitions200,
|
|
19
20
|
DefinitionGetAllDefinitionsParams,
|
|
@@ -21,7 +22,9 @@ import type {
|
|
|
21
22
|
TagAddTagBody,
|
|
22
23
|
TagGetAllTags200,
|
|
23
24
|
TagGetAllTagsParams,
|
|
24
|
-
TagUpdateTagBody
|
|
25
|
+
TagUpdateTagBody,
|
|
26
|
+
UpdateDefinitionRequest,
|
|
27
|
+
ValidationError
|
|
25
28
|
} from '../outsetaAPI.schemas';
|
|
26
29
|
|
|
27
30
|
import { customFetch } from '../../mutator';
|
|
@@ -493,18 +496,106 @@ export function useDefinitionGetAllDefinitions<TData = Awaited<ReturnType<typeof
|
|
|
493
496
|
|
|
494
497
|
|
|
495
498
|
/**
|
|
496
|
-
*
|
|
497
|
-
|
|
499
|
+
* Adds the definition of a custom property: its label, its system name and the control
|
|
500
|
+
used to fill it in. Only Account, Person and Deal have custom properties; any other
|
|
501
|
+
entityType returns 404. Once added, the property's values are read and written under
|
|
502
|
+
its SystemName on the accounts, people or deals themselves.
|
|
503
|
+
|
|
504
|
+
- **Label** (required): the name shown in Outseta. It must be unique among the entity
|
|
505
|
+
type's custom properties and must not be the label of a standard property (for
|
|
506
|
+
example Email on a person).
|
|
507
|
+
- **SystemName**: the property's name in the API, webhooks and forms. It must start
|
|
508
|
+
with a letter, contain only letters, numbers and _, be unique for the entity type and
|
|
509
|
+
not be the name of a standard property. When left out it is derived from Label the way
|
|
510
|
+
the Outseta app does: Label "Favorite color" gives FavoriteColor.
|
|
511
|
+
- **ControlType**: one of Text, TextArea, Number, Date, Checkbox, Select, RadioList,
|
|
512
|
+
CheckboxList. Defaults to Text. Select is a dropdown with one choice, RadioList shows
|
|
513
|
+
the same choice as radio buttons, CheckboxList allows several choices, and Checkbox is
|
|
514
|
+
a single yes/no whose value is True or False.
|
|
515
|
+
- **ControlParams**: the control's settings as a JSON object serialized into a string,
|
|
516
|
+
not a nested object. Select, RadioList and CheckboxList need at least one option:
|
|
517
|
+
"{\"Options\":[\"Small\",\"Medium\",\"Large\"]}". Number may set a Step
|
|
518
|
+
("{\"Step\":0.01}"); Text may set HintText and a Pattern (a regular expression the value
|
|
519
|
+
must match). Other controls need no ControlParams.
|
|
520
|
+
|
|
521
|
+
EntityType comes from the URL; a Uid or EntityType in the request body is ignored.
|
|
522
|
+
* @summary Add a custom property to accounts, people or deals.
|
|
523
|
+
*/
|
|
524
|
+
export const definitionAddDefinition = (
|
|
525
|
+
entityType: string | null,
|
|
526
|
+
addDefinitionRequest: AddDefinitionRequest,
|
|
527
|
+
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
528
|
+
) => {
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
return customFetch<Definition>(
|
|
532
|
+
{url: `/api/v1/attributes/${entityType}/definitions`, method: 'POST',
|
|
533
|
+
headers: {'Content-Type': 'application/json', },
|
|
534
|
+
data: addDefinitionRequest, signal
|
|
535
|
+
},
|
|
536
|
+
options);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
export const getDefinitionAddDefinitionMutationOptions = <TError = ValidationError | void,
|
|
542
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof definitionAddDefinition>>, TError,{entityType: string | null;data: AddDefinitionRequest}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
543
|
+
): UseMutationOptions<Awaited<ReturnType<typeof definitionAddDefinition>>, TError,{entityType: string | null;data: AddDefinitionRequest}, TContext> => {
|
|
544
|
+
|
|
545
|
+
const mutationKey = ['definitionAddDefinition'];
|
|
546
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
547
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
548
|
+
options
|
|
549
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
550
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof definitionAddDefinition>>, {entityType: string | null;data: AddDefinitionRequest}> = (props) => {
|
|
556
|
+
const {entityType,data} = props ?? {};
|
|
557
|
+
|
|
558
|
+
return definitionAddDefinition(entityType,data,requestOptions)
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
return { mutationFn, ...mutationOptions }}
|
|
565
|
+
|
|
566
|
+
export type DefinitionAddDefinitionMutationResult = NonNullable<Awaited<ReturnType<typeof definitionAddDefinition>>>
|
|
567
|
+
export type DefinitionAddDefinitionMutationBody = AddDefinitionRequest
|
|
568
|
+
export type DefinitionAddDefinitionMutationError = ValidationError | void
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* @summary Add a custom property to accounts, people or deals.
|
|
572
|
+
*/
|
|
573
|
+
export const useDefinitionAddDefinition = <TError = ValidationError | void,
|
|
574
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof definitionAddDefinition>>, TError,{entityType: string | null;data: AddDefinitionRequest}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
575
|
+
): UseMutationResult<
|
|
576
|
+
Awaited<ReturnType<typeof definitionAddDefinition>>,
|
|
577
|
+
TError,
|
|
578
|
+
{entityType: string | null;data: AddDefinitionRequest},
|
|
579
|
+
TContext
|
|
580
|
+
> => {
|
|
581
|
+
|
|
582
|
+
const mutationOptions = getDefinitionAddDefinitionMutationOptions(options);
|
|
583
|
+
|
|
584
|
+
return useMutation(mutationOptions);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Use the entity type the definition belongs to (Account, Person or Deal) in the URL.
|
|
498
588
|
* @summary Retrieve a custom attribute definition.
|
|
499
589
|
*/
|
|
500
590
|
export const definitionGetDefinition = (
|
|
591
|
+
entityType: string | null,
|
|
501
592
|
definitionUid: string | null,
|
|
502
593
|
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
503
594
|
) => {
|
|
504
595
|
|
|
505
596
|
|
|
506
597
|
return customFetch<Definition>(
|
|
507
|
-
{url: `/api/v1/attributes/definitions/${definitionUid}`, method: 'GET', signal
|
|
598
|
+
{url: `/api/v1/attributes/${entityType}/definitions/${definitionUid}`, method: 'GET', signal
|
|
508
599
|
},
|
|
509
600
|
options);
|
|
510
601
|
}
|
|
@@ -512,29 +603,31 @@ export const definitionGetDefinition = (
|
|
|
512
603
|
|
|
513
604
|
|
|
514
605
|
|
|
515
|
-
export const getDefinitionGetDefinitionQueryKey = (
|
|
606
|
+
export const getDefinitionGetDefinitionQueryKey = (entityType?: string | null,
|
|
607
|
+
definitionUid?: string | null,) => {
|
|
516
608
|
return [
|
|
517
|
-
`/api/v1/attributes/definitions/${definitionUid}`
|
|
609
|
+
`/api/v1/attributes/${entityType}/definitions/${definitionUid}`
|
|
518
610
|
] as const;
|
|
519
611
|
}
|
|
520
612
|
|
|
521
613
|
|
|
522
|
-
export const getDefinitionGetDefinitionQueryOptions = <TData = Awaited<ReturnType<typeof definitionGetDefinition>>, TError = void>(
|
|
614
|
+
export const getDefinitionGetDefinitionQueryOptions = <TData = Awaited<ReturnType<typeof definitionGetDefinition>>, TError = void>(entityType: string | null,
|
|
615
|
+
definitionUid: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof definitionGetDefinition>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
|
523
616
|
) => {
|
|
524
617
|
|
|
525
618
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
526
619
|
|
|
527
|
-
const queryKey = queryOptions?.queryKey ?? getDefinitionGetDefinitionQueryKey(definitionUid);
|
|
620
|
+
const queryKey = queryOptions?.queryKey ?? getDefinitionGetDefinitionQueryKey(entityType,definitionUid);
|
|
528
621
|
|
|
529
622
|
|
|
530
623
|
|
|
531
|
-
const queryFn: QueryFunction<Awaited<ReturnType<typeof definitionGetDefinition>>> = ({ signal }) => definitionGetDefinition(definitionUid, requestOptions, signal);
|
|
624
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof definitionGetDefinition>>> = ({ signal }) => definitionGetDefinition(entityType,definitionUid, requestOptions, signal);
|
|
532
625
|
|
|
533
626
|
|
|
534
627
|
|
|
535
628
|
|
|
536
629
|
|
|
537
|
-
return { queryKey, queryFn, enabled: !!(definitionUid), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof definitionGetDefinition>>, TError, TData> & { queryKey: QueryKey }
|
|
630
|
+
return { queryKey, queryFn, enabled: !!(entityType && definitionUid), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof definitionGetDefinition>>, TError, TData> & { queryKey: QueryKey }
|
|
538
631
|
}
|
|
539
632
|
|
|
540
633
|
export type DefinitionGetDefinitionQueryResult = NonNullable<Awaited<ReturnType<typeof definitionGetDefinition>>>
|
|
@@ -546,11 +639,12 @@ export type DefinitionGetDefinitionQueryError = void
|
|
|
546
639
|
*/
|
|
547
640
|
|
|
548
641
|
export function useDefinitionGetDefinition<TData = Awaited<ReturnType<typeof definitionGetDefinition>>, TError = void>(
|
|
549
|
-
|
|
642
|
+
entityType: string | null,
|
|
643
|
+
definitionUid: string | null, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof definitionGetDefinition>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
|
550
644
|
|
|
551
645
|
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
|
552
646
|
|
|
553
|
-
const queryOptions = getDefinitionGetDefinitionQueryOptions(definitionUid,options)
|
|
647
|
+
const queryOptions = getDefinitionGetDefinitionQueryOptions(entityType,definitionUid,options)
|
|
554
648
|
|
|
555
649
|
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
556
650
|
|
|
@@ -562,3 +656,83 @@ export function useDefinitionGetDefinition<TData = Awaited<ReturnType<typeof def
|
|
|
562
656
|
|
|
563
657
|
|
|
564
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Send only the fields to change: fields left out keep their current values. The rules
|
|
661
|
+
for Label, SystemName, ControlType and ControlParams are those of adding a definition.
|
|
662
|
+
The Uid and EntityType in the request body are ignored; the definition must belong to
|
|
663
|
+
the entityType in the URL, otherwise 404.
|
|
664
|
+
|
|
665
|
+
ControlParams is replaced as a whole. To add an option to a Select, RadioList or
|
|
666
|
+
CheckboxList, read the definition, add the option to its Options and send the full
|
|
667
|
+
list: "{\"Options\":[\"Small\",\"Medium\",\"Large\",\"X-Large\"]}". Values already
|
|
668
|
+
stored on accounts, people or deals are not changed when an option is renamed or
|
|
669
|
+
removed.
|
|
670
|
+
|
|
671
|
+
Changing SystemName keeps the stored values, which are returned under the new name
|
|
672
|
+
from then on. Anything that uses the old name (API clients, sign-up and profile forms,
|
|
673
|
+
segments, Zapier or other integrations) has to be updated to the new name.
|
|
674
|
+
* @summary Update a custom property of accounts, people or deals.
|
|
675
|
+
*/
|
|
676
|
+
export const definitionUpdateDefinition = (
|
|
677
|
+
entityType: string | null,
|
|
678
|
+
definitionUid: string | null,
|
|
679
|
+
updateDefinitionRequest: UpdateDefinitionRequest,
|
|
680
|
+
options?: SecondParameter<typeof customFetch>,) => {
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
return customFetch<Definition>(
|
|
684
|
+
{url: `/api/v1/attributes/${entityType}/definitions/${definitionUid}`, method: 'PUT',
|
|
685
|
+
headers: {'Content-Type': 'application/json', },
|
|
686
|
+
data: updateDefinitionRequest
|
|
687
|
+
},
|
|
688
|
+
options);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
export const getDefinitionUpdateDefinitionMutationOptions = <TError = ValidationError | void,
|
|
694
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof definitionUpdateDefinition>>, TError,{entityType: string | null;definitionUid: string | null;data: UpdateDefinitionRequest}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
695
|
+
): UseMutationOptions<Awaited<ReturnType<typeof definitionUpdateDefinition>>, TError,{entityType: string | null;definitionUid: string | null;data: UpdateDefinitionRequest}, TContext> => {
|
|
696
|
+
|
|
697
|
+
const mutationKey = ['definitionUpdateDefinition'];
|
|
698
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
699
|
+
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
700
|
+
options
|
|
701
|
+
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
702
|
+
: {mutation: { mutationKey, }, request: undefined};
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof definitionUpdateDefinition>>, {entityType: string | null;definitionUid: string | null;data: UpdateDefinitionRequest}> = (props) => {
|
|
708
|
+
const {entityType,definitionUid,data} = props ?? {};
|
|
709
|
+
|
|
710
|
+
return definitionUpdateDefinition(entityType,definitionUid,data,requestOptions)
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
return { mutationFn, ...mutationOptions }}
|
|
717
|
+
|
|
718
|
+
export type DefinitionUpdateDefinitionMutationResult = NonNullable<Awaited<ReturnType<typeof definitionUpdateDefinition>>>
|
|
719
|
+
export type DefinitionUpdateDefinitionMutationBody = UpdateDefinitionRequest
|
|
720
|
+
export type DefinitionUpdateDefinitionMutationError = ValidationError | void
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* @summary Update a custom property of accounts, people or deals.
|
|
724
|
+
*/
|
|
725
|
+
export const useDefinitionUpdateDefinition = <TError = ValidationError | void,
|
|
726
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof definitionUpdateDefinition>>, TError,{entityType: string | null;definitionUid: string | null;data: UpdateDefinitionRequest}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
727
|
+
): UseMutationResult<
|
|
728
|
+
Awaited<ReturnType<typeof definitionUpdateDefinition>>,
|
|
729
|
+
TError,
|
|
730
|
+
{entityType: string | null;definitionUid: string | null;data: UpdateDefinitionRequest},
|
|
731
|
+
TContext
|
|
732
|
+
> => {
|
|
733
|
+
|
|
734
|
+
const mutationOptions = getDefinitionUpdateDefinitionMutationOptions(options);
|
|
735
|
+
|
|
736
|
+
return useMutation(mutationOptions);
|
|
737
|
+
}
|
|
738
|
+
|
|
@@ -144,6 +144,98 @@ export type DefinitionAllOf = {
|
|
|
144
144
|
|
|
145
145
|
export type Definition = AbstractQcountBean & DefinitionAllOf;
|
|
146
146
|
|
|
147
|
+
export interface ValidationError {
|
|
148
|
+
/** @nullable */
|
|
149
|
+
ErrorMessage?: string | null;
|
|
150
|
+
/** @nullable */
|
|
151
|
+
EntityValidationErrors?: EntityValidationError[] | null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @nullable
|
|
156
|
+
*/
|
|
157
|
+
export type EntityValidationErrorEntity = unknown | null;
|
|
158
|
+
|
|
159
|
+
export interface EntityValidationError {
|
|
160
|
+
/** @nullable */
|
|
161
|
+
Entity?: EntityValidationErrorEntity;
|
|
162
|
+
/** @nullable */
|
|
163
|
+
TypeName?: string | null;
|
|
164
|
+
/** @nullable */
|
|
165
|
+
ValidationErrors?: FieldValidationError[] | null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface FieldValidationError {
|
|
169
|
+
/** @nullable */
|
|
170
|
+
ErrorCode?: string | null;
|
|
171
|
+
/** @nullable */
|
|
172
|
+
ErrorMessage?: string | null;
|
|
173
|
+
/** @nullable */
|
|
174
|
+
PropertyName?: string | null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* A custom property to add to accounts, people or deals. Only Label is required.
|
|
179
|
+
*/
|
|
180
|
+
export interface AddDefinitionRequest {
|
|
181
|
+
/**
|
|
182
|
+
* The name of the property shown in Outseta, for example "T-shirt size". Unique among the
|
|
183
|
+
entity type's custom properties, and not the label of a standard property.
|
|
184
|
+
* @minLength 1
|
|
185
|
+
*/
|
|
186
|
+
Label: string;
|
|
187
|
+
/**
|
|
188
|
+
* The name of the property in the API, webhooks and forms, for example TShirtSize. Starts
|
|
189
|
+
with a letter and holds only letters, numbers and _. Unique for the entity type, and not
|
|
190
|
+
the name of a standard property. Derived from Label when left out.
|
|
191
|
+
* @nullable
|
|
192
|
+
* @pattern ^[A-Za-z][A-Za-z0-9_]*$
|
|
193
|
+
*/
|
|
194
|
+
SystemName?: string | null;
|
|
195
|
+
/**
|
|
196
|
+
* The control used to fill in the property: Text (the default), TextArea, Number, Date,
|
|
197
|
+
Checkbox (True or False), Select (a dropdown with one choice), RadioList (one choice) or
|
|
198
|
+
CheckboxList (several choices).
|
|
199
|
+
* @nullable
|
|
200
|
+
*/
|
|
201
|
+
ControlType?: string | null;
|
|
202
|
+
/**
|
|
203
|
+
* The control's settings: a JSON object serialized into a string, not a nested object.
|
|
204
|
+
Select, RadioList and CheckboxList need their options, for example
|
|
205
|
+
"{\"Options\":[\"Small\",\"Medium\",\"Large\"]}". Number may set a Step, for example
|
|
206
|
+
"{\"Step\":0.01}"; Text may set HintText and Pattern (a regular expression).
|
|
207
|
+
* @nullable
|
|
208
|
+
*/
|
|
209
|
+
ControlParams?: string | null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The fields of a custom property that an update may change. Every field is optional:
|
|
214
|
+
a field left out keeps its current value.
|
|
215
|
+
*/
|
|
216
|
+
export interface UpdateDefinitionRequest {
|
|
217
|
+
/** The name of the property shown in Outseta. Unique among the entity type's custom
|
|
218
|
+
properties, and not the label of a standard property. Cannot be null. */
|
|
219
|
+
Label?: string;
|
|
220
|
+
/**
|
|
221
|
+
* The name of the property in the API, webhooks and forms. Starts with a letter and holds
|
|
222
|
+
only letters, numbers and _. Changing it keeps the stored values under the new name;
|
|
223
|
+
anything that uses the old name has to be updated. Cannot be null.
|
|
224
|
+
* @pattern ^[A-Za-z][A-Za-z0-9_]*$
|
|
225
|
+
*/
|
|
226
|
+
SystemName?: string;
|
|
227
|
+
/** The control used to fill in the property: Text, TextArea, Number, Date, Checkbox, Select,
|
|
228
|
+
RadioList or CheckboxList. Cannot be null. */
|
|
229
|
+
ControlType?: string;
|
|
230
|
+
/**
|
|
231
|
+
* The control's settings: a JSON object serialized into a string, replaced as a whole.
|
|
232
|
+
To add an option, send the full list, for example
|
|
233
|
+
"{\"Options\":[\"Small\",\"Medium\",\"Large\",\"X-Large\"]}".
|
|
234
|
+
* @nullable
|
|
235
|
+
*/
|
|
236
|
+
ControlParams?: string | null;
|
|
237
|
+
}
|
|
238
|
+
|
|
147
239
|
export interface EmailSubscriptionsPayload {
|
|
148
240
|
/** @nullable */
|
|
149
241
|
ActiveSubscriptions?: EmailListPerson[] | null;
|