@pexip-engage-public/graphql 1.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.
- package/CHANGELOG.md +19 -0
- package/README.md +5 -0
- package/dist/get-api-client.d.ts +9 -0
- package/dist/get-api-client.d.ts.map +1 -0
- package/dist/get-api-client.js +28 -0
- package/dist/graphql-error-codes.d.ts +94 -0
- package/dist/graphql-error-codes.d.ts.map +1 -0
- package/dist/graphql-error-codes.js +94 -0
- package/dist/graphql-error-handler.d.ts +77 -0
- package/dist/graphql-error-handler.d.ts.map +1 -0
- package/dist/graphql-error-handler.js +98 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/schema.d.ts +4280 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +1 -0
- package/package.json +65 -0
- package/scalars.d.ts +18 -0
- package/src/get-api-client.ts +44 -0
- package/src/graphql-error-codes.ts +93 -0
- package/src/graphql-error-handler.ts +102 -0
- package/src/index.ts +4 -0
- package/src/schema.ts +5111 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @pexip-engage-public/graphql
|
|
2
|
+
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5a13e9410: chore: release graphql types as public pkg
|
|
8
|
+
|
|
9
|
+
## 1.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- 7412230be: feat: This package is ESM only starting from this release.
|
|
14
|
+
|
|
15
|
+
## 0.1.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 93c2a834b: (minor) prepare for legacy switch
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphQLClient } from "graphql-request";
|
|
2
|
+
export declare function getApiClient(url: string): GraphQLClient;
|
|
3
|
+
export declare function getGQLOperationName(input: string): string;
|
|
4
|
+
export declare function createStudioSearchParam({ document, headers, variables, }: {
|
|
5
|
+
document: string;
|
|
6
|
+
variables?: unknown;
|
|
7
|
+
headers: Record<string, string>;
|
|
8
|
+
}): string;
|
|
9
|
+
//# sourceMappingURL=get-api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-api-client.d.ts","sourceRoot":"","sources":["../src/get-api-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,iBAKvC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,UAchD;AAED,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,UAQA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Kind, parse } from "graphql";
|
|
2
|
+
import { GraphQLClient } from "graphql-request";
|
|
3
|
+
import lzString from "lz-string";
|
|
4
|
+
export function getApiClient(url) {
|
|
5
|
+
return new GraphQLClient(url, {
|
|
6
|
+
fetch: fetch,
|
|
7
|
+
headers: { Connection: "keep-alive" },
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export function getGQLOperationName(input) {
|
|
11
|
+
try {
|
|
12
|
+
const document = parse(input);
|
|
13
|
+
const operationDefinition = document.definitions.find((definition) => definition.kind === Kind.OPERATION_DEFINITION);
|
|
14
|
+
if (!operationDefinition)
|
|
15
|
+
return "gql";
|
|
16
|
+
return `gql:${operationDefinition.name?.value ?? ""}`;
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
return "gql";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function createStudioSearchParam({ document, headers, variables, }) {
|
|
23
|
+
return `?explorerURLState=${lzString.compressToEncodedURIComponent(JSON.stringify({
|
|
24
|
+
document: document.toString().trim(),
|
|
25
|
+
variables: variables ? JSON.stringify(variables, null, 2) : undefined,
|
|
26
|
+
headers: JSON.stringify(headers),
|
|
27
|
+
}))}`;
|
|
28
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** https://developer.pexipengage.com/topic/topic-error-codes */
|
|
2
|
+
export declare enum GraphQLErrorCode {
|
|
3
|
+
/**Cannot provide selected answer options for a question that is not of input type SELECT or MULTI_SELECT. */
|
|
4
|
+
ANSWER_SELECTED_OPTIONS_FOR_NON_SELECTION_TYPE = "ANSWER_SELECTED_OPTIONS_FOR_NON_SELECTION_TYPE",
|
|
5
|
+
/**Cannot provide single answer value for a question with input type SELECT or MULTI_SELECT. */
|
|
6
|
+
ANSWER_VALUE_FOR_SELECTION_TYPE = "ANSWER_VALUE_FOR_SELECTION_TYPE",
|
|
7
|
+
/**The default availability template cannot be applied. */
|
|
8
|
+
APPLIED_TEMPLATE_DEFAULT_TEMPLATE = "APPLIED_TEMPLATE_DEFAULT_TEMPLATE",
|
|
9
|
+
/** The applied template overlaps with an existing applied template. */
|
|
10
|
+
APPLIED_TEMPLATE_OVERLAP = "APPLIED_TEMPLATE_OVERLAP",
|
|
11
|
+
/** The endDate must be greater than or equal to the startDate of an applied template. */
|
|
12
|
+
APPLIED_TEMPLATE_START_AFTER_END = "APPLIED_TEMPLATE_START_AFTER_END",
|
|
13
|
+
/** Appointments cannot be completed earlier than a specific number of days before their start time. This number is configured in the enterprise settings. */
|
|
14
|
+
APPOINTMENT_COMPLETION_TOO_EARLY = "APPOINTMENT_COMPLETION_TOO_EARLY",
|
|
15
|
+
/** An appointment needs at least one PRIMARY CUSTOMER participant. */
|
|
16
|
+
APPOINTMENT_PRIMARY_CUSTOMER_MISSING = "APPOINTMENT_PRIMARY_CUSTOMER_MISSING",
|
|
17
|
+
/** An appointment needs at least one PRIMARY EMPLOYEE participant. */
|
|
18
|
+
APPOINTMENT_PRIMARY_EMPLOYEE_MISSING = "APPOINTMENT_PRIMARY_EMPLOYEE_MISSING",
|
|
19
|
+
/** PRIMARY appointment participants cannot be added or removed. */
|
|
20
|
+
APPOINTMENT_PRIMARY_PARTICIPANT_ADDED_OR_REMOVED = "APPOINTMENT_PRIMARY_PARTICIPANT_ADDED_OR_REMOVED",
|
|
21
|
+
/** An on-location appointment must have a location. */
|
|
22
|
+
APPOINTMENT_LOCATION_REQUIRED = "APPOINTMENT_LOCATION_REQUIRED",
|
|
23
|
+
/** No employees available on the chosen time slot. */
|
|
24
|
+
APPOINTMENT_NO_AVAILABILITY = "APPOINTMENT_NO_AVAILABILITY",
|
|
25
|
+
/** The end must be strictly greater than the start of an appointment. */
|
|
26
|
+
APPOINTMENT_START_AFTER_END = "APPOINTMENT_START_AFTER_END",
|
|
27
|
+
/** The operation cannot be performed on the appointment because the appointment status does not allow it. */
|
|
28
|
+
APPOINTMENT_STATUS_INVALID = "APPOINTMENT_STATUS_INVALID",
|
|
29
|
+
/** The default availability template cannot be modified. */
|
|
30
|
+
AVAILABILITY_TEMPLATE_DEFAULT_TEMPLATE_MODIFICATION_NOT_ALLOWED = "AVAILABILITY_TEMPLATE_DEFAULT_TEMPLATE_MODIFICATION_NOT_ALLOWED",
|
|
31
|
+
/** The day of the week cannot be set on availability time ranges for DAY availability templates. */
|
|
32
|
+
AVAILABILITY_TIME_RANGE_DAY_TEMPLATE_WITH_DAY_OF_WEEK = "AVAILABILITY_TIME_RANGE_DAY_TEMPLATE_WITH_DAY_OF_WEEK",
|
|
33
|
+
/** Availability time ranges cannot overlap. */
|
|
34
|
+
AVAILABILITY_TIME_RANGE_OVERLAP = "AVAILABILITY_TIME_RANGE_OVERLAP",
|
|
35
|
+
/** The end must be strictly greater than or equal to the start of an availability time range. */
|
|
36
|
+
AVAILABILITY_TIME_RANGE_START_AFTER_END = "AVAILABILITY_TIME_RANGE_START_AFTER_END",
|
|
37
|
+
/** The day of the week must be set on availability time ranges for WEEK availability templates. */
|
|
38
|
+
AVAILABILITY_TIME_RANGE_WEEK_TEMPLATE_WITHOUT_DAY_OF_WEEK = "AVAILABILITY_TIME_RANGE_WEEK_TEMPLATE_WITHOUT_DAY_OF_WEEK",
|
|
39
|
+
/** A customer must have at least one of the following fields: externalId, customerNumber, email, lastName, company, phoneNumber. */
|
|
40
|
+
CUSTOMER_NOT_IDENTIFIABLE = "CUSTOMER_NOT_IDENTIFIABLE",
|
|
41
|
+
/** An ACTIVE employee must have a first and last name. */
|
|
42
|
+
EMPLOYEE_ACTIVE_WITHOUT_FIRST_LAST_NAME = "EMPLOYEE_ACTIVE_WITHOUT_FIRST_LAST_NAME",
|
|
43
|
+
/** The employee cannot be activated because it is already active. */
|
|
44
|
+
EMPLOYEE_ALREADY_ACTIVE = "EMPLOYEE_ALREADY_ACTIVE",
|
|
45
|
+
/** The provided email address for the employee is already in use for another employee. */
|
|
46
|
+
EMPLOYEE_EMAIL_ALREADY_IN_USE = "EMPLOYEE_EMAIL_ALREADY_IN_USE",
|
|
47
|
+
/** The office relation roles should match the available employee roles. */
|
|
48
|
+
EMPLOYEE_OFFICE_RELATION_ROLE_MISMATCH = "EMPLOYEE_OFFICE_RELATION_ROLE_MISMATCH",
|
|
49
|
+
/** Online planning can only be enabled for ACTIVE employees with the AGENT role. */
|
|
50
|
+
EMPLOYEE_ONLINE_PLANNING_NON_AGENT = "EMPLOYEE_ONLINE_PLANNING_NON_AGENT",
|
|
51
|
+
/** The operation cannot be performed on the employe because the employee is SUSPENDED. */
|
|
52
|
+
EMPLOYEE_SUSPENDED = "EMPLOYEE_SUSPENDED",
|
|
53
|
+
/** Cannot set employee status to PENDING. */
|
|
54
|
+
EMPLOYEE_UPDATE_STATUS_PENDING = "EMPLOYEE_UPDATE_STATUS_PENDING",
|
|
55
|
+
/** A fetch configuration can only be deleted if it is not linked to a question. */
|
|
56
|
+
FETCH_CONFIGURATION_LINKED_TO_QUESTION_ON_DELETE = "FETCH_CONFIGURATION_LINKED_TO_QUESTION_ON_DELETE",
|
|
57
|
+
/** The provided URL for an uploaded file is invalid. */
|
|
58
|
+
FILE_URL_INVALID = "FILE_URL_INVALID",
|
|
59
|
+
/** The provided code for the lead segment is already in use for another lead segment. */
|
|
60
|
+
LEAD_SEGMENT_CODE_ALREADY_IN_USE = "LEAD_SEGMENT_CODE_ALREADY_IN_USE",
|
|
61
|
+
/** The latestCallbackHours must be greater than or equal to earliestCallbackHours. */
|
|
62
|
+
LEAD_SEGMENT_EARLIEST_CALLBACK_HOURS_GREATHER_THAN_LATEST_CALLBACK_HOURS = "LEAD_SEGMENT_EARLIEST_CALLBACK_HOURS_GREATHER_THAN_LATEST_CALLBACK_HOURS",
|
|
63
|
+
/** Employees assigned to a listing time slot must be linked to the parent listing. */
|
|
64
|
+
LISTING_TIME_SLOT_EMPLOYEE_NOT_LINKED = "LISTING_TIME_SLOT_EMPLOYEE_NOT_LINKED",
|
|
65
|
+
/** Listing time slots cannot overlap. */
|
|
66
|
+
LISTING_TIME_SLOT_OVERLAP = "LISTING_TIME_SLOT_OVERLAP",
|
|
67
|
+
/** The geolocation could not be determined for the provided location. */
|
|
68
|
+
LOCATION_GEOCODING_FAILED = "LOCATION_GEOCODING_FAILED",
|
|
69
|
+
/** An error occurred while determining the time zone for the given location. */
|
|
70
|
+
LOCATION_TIME_ZONE_RESOLUTION_FAILED = "LOCATION_TIME_ZONE_RESOLUTION_FAILED",
|
|
71
|
+
/** A question with input type FETCH should have a fetch configuration ID. */
|
|
72
|
+
QUESTION_FETCH_TYPE_WITHOUT_FETCH_CONFIGURATION = "QUESTION_FETCH_TYPE_WITHOUT_FETCH_CONFIGURATION",
|
|
73
|
+
/** Only a question with input type FETCH can have a fetch configuration ID. */
|
|
74
|
+
QUESTION_NON_FETCH_TYPE_WITH_FETCH_CONFIGURATION = "QUESTION_NON_FETCH_TYPE_WITH_FETCH_CONFIGURATION",
|
|
75
|
+
/** Answer options cannot be configured for a question that is not of type SELECT or MULTI_SELECT. */
|
|
76
|
+
QUESTION_NON_SELECTION_TYPE_WITH_ANSWER_OPTIONS = "QUESTION_NON_SELECTION_TYPE_WITH_ANSWER_OPTIONS",
|
|
77
|
+
/** A question with input type SELECT or MULTI_SELECT should have at least one answer option. */
|
|
78
|
+
QUESTION_SELECTION_TYPE_WITHOUT_ANSWER_OPTIONS = "QUESTION_SELECTION_TYPE_WITHOUT_ANSWER_OPTIONS",
|
|
79
|
+
/** The appointmentLatestPossible enterprise setting must be greater than or equal to appointmentEarliestPossible. */
|
|
80
|
+
SETTING_APPOINTMENT_EARLIEST_LATEST_POSSIBLE_INVALID = "SETTING_APPOINTMENT_EARLIEST_LATEST_POSSIBLE_INVALID",
|
|
81
|
+
/** Cannot update a manageable enterprise setting to a non-manageable enterprise setting. */
|
|
82
|
+
SETTING_MANAGEABILITY_MODIFICATION_NOT_ALLOWED = "SETTING_MANAGEABILITY_MODIFICATION_NOT_ALLOWED",
|
|
83
|
+
/** Cannot update a non-manageable enterprise setting. */
|
|
84
|
+
SETTING_NON_MANAGEABLE = "SETTING_NON_MANAGEABLE",
|
|
85
|
+
/** The value of the enterprise setting is invalid. */
|
|
86
|
+
SETTING_VALUE_INVALID = "SETTING_VALUE_INVALID",
|
|
87
|
+
/** A subject group can only be deleted if it has no subjects. */
|
|
88
|
+
SUBJECT_GROUP_NOT_EMPTY_ON_DELETE = "SUBJECT_GROUP_NOT_EMPTY_ON_DELETE",
|
|
89
|
+
/** The requested combination is not schedulable. */
|
|
90
|
+
TIMETABLE_NOT_SCHEDULABLE = "TIMETABLE_NOT_SCHEDULABLE",
|
|
91
|
+
/** The user-defined unavailability overlaps with another existing user-defined unavailability. */
|
|
92
|
+
UNAVAILABILITY_OVERLAP = "UNAVAILABILITY_OVERLAP"
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=graphql-error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-error-codes.d.ts","sourceRoot":"","sources":["../src/graphql-error-codes.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,oBAAY,gBAAgB;IAC1B,6GAA6G;IAC7G,8CAA8C,mDAAmD;IACjG,+FAA+F;IAC/F,+BAA+B,oCAAoC;IACnE,0DAA0D;IAC1D,iCAAiC,sCAAsC;IACvE,uEAAuE;IACvE,wBAAwB,6BAA6B;IACrD,yFAAyF;IACzF,gCAAgC,qCAAqC;IACrE,6JAA6J;IAC7J,gCAAgC,qCAAqC;IACrE,sEAAsE;IACtE,oCAAoC,yCAAyC;IAC7E,sEAAsE;IACtE,oCAAoC,yCAAyC;IAC7E,mEAAmE;IACnE,gDAAgD,qDAAqD;IACrG,uDAAuD;IACvD,6BAA6B,kCAAkC;IAC/D,uDAAuD;IACvD,2BAA2B,gCAAgC;IAC3D,0EAA0E;IAC1E,2BAA2B,gCAAgC;IAC3D,6GAA6G;IAC7G,0BAA0B,+BAA+B;IACzD,4DAA4D;IAC5D,+DAA+D,oEAAoE;IACnI,oGAAoG;IACpG,qDAAqD,0DAA0D;IAC/G,iDAAiD;IACjD,+BAA+B,oCAAoC;IACnE,iGAAiG;IACjG,uCAAuC,4CAA4C;IACnF,mGAAmG;IACnG,yDAAyD,8DAA8D;IACvH,qIAAqI;IACrI,yBAAyB,8BAA8B;IACvD,2DAA2D;IAC3D,uCAAuC,4CAA4C;IACnF,qEAAqE;IACrE,uBAAuB,4BAA4B;IACnD,0FAA0F;IAC1F,6BAA6B,kCAAkC;IAC/D,2EAA2E;IAC3E,sCAAsC,2CAA2C;IACjF,qFAAqF;IACrF,kCAAkC,uCAAuC;IACzE,0FAA0F;IAC1F,kBAAkB,uBAAuB;IACzC,6CAA6C;IAC7C,8BAA8B,mCAAmC;IACjE,oFAAoF;IACpF,gDAAgD,qDAAqD;IACrG,wDAAwD;IACxD,gBAAgB,qBAAqB;IACrC,yFAAyF;IACzF,gCAAgC,qCAAqC;IACrE,sFAAsF;IACtF,wEAAwE,6EAA6E;IACrJ,sFAAsF;IACtF,qCAAqC,0CAA0C;IAC/E,yCAAyC;IACzC,yBAAyB,8BAA8B;IACvD,yEAAyE;IACzE,yBAAyB,8BAA8B;IACvD,iFAAiF;IACjF,oCAAoC,yCAAyC;IAC7E,6EAA6E;IAC7E,+CAA+C,oDAAoD;IACnG,+EAA+E;IAC/E,gDAAgD,qDAAqD;IACrG,qGAAqG;IACrG,+CAA+C,oDAAoD;IACnG,gGAAgG;IAChG,8CAA8C,mDAAmD;IACjG,sHAAsH;IACtH,oDAAoD,yDAAyD;IAC7G,6FAA6F;IAC7F,8CAA8C,mDAAmD;IACjG,yDAAyD;IACzD,sBAAsB,2BAA2B;IACjD,uDAAuD;IACvD,qBAAqB,0BAA0B;IAC/C,iEAAiE;IACjE,iCAAiC,sCAAsC;IACvE,qDAAqD;IACrD,yBAAyB,8BAA8B;IACvD,kGAAkG;IAClG,sBAAsB,2BAA2B;CAClD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** https://developer.pexipengage.com/topic/topic-error-codes */
|
|
2
|
+
export var GraphQLErrorCode;
|
|
3
|
+
(function (GraphQLErrorCode) {
|
|
4
|
+
/**Cannot provide selected answer options for a question that is not of input type SELECT or MULTI_SELECT. */
|
|
5
|
+
GraphQLErrorCode["ANSWER_SELECTED_OPTIONS_FOR_NON_SELECTION_TYPE"] = "ANSWER_SELECTED_OPTIONS_FOR_NON_SELECTION_TYPE";
|
|
6
|
+
/**Cannot provide single answer value for a question with input type SELECT or MULTI_SELECT. */
|
|
7
|
+
GraphQLErrorCode["ANSWER_VALUE_FOR_SELECTION_TYPE"] = "ANSWER_VALUE_FOR_SELECTION_TYPE";
|
|
8
|
+
/**The default availability template cannot be applied. */
|
|
9
|
+
GraphQLErrorCode["APPLIED_TEMPLATE_DEFAULT_TEMPLATE"] = "APPLIED_TEMPLATE_DEFAULT_TEMPLATE";
|
|
10
|
+
/** The applied template overlaps with an existing applied template. */
|
|
11
|
+
GraphQLErrorCode["APPLIED_TEMPLATE_OVERLAP"] = "APPLIED_TEMPLATE_OVERLAP";
|
|
12
|
+
/** The endDate must be greater than or equal to the startDate of an applied template. */
|
|
13
|
+
GraphQLErrorCode["APPLIED_TEMPLATE_START_AFTER_END"] = "APPLIED_TEMPLATE_START_AFTER_END";
|
|
14
|
+
/** Appointments cannot be completed earlier than a specific number of days before their start time. This number is configured in the enterprise settings. */
|
|
15
|
+
GraphQLErrorCode["APPOINTMENT_COMPLETION_TOO_EARLY"] = "APPOINTMENT_COMPLETION_TOO_EARLY";
|
|
16
|
+
/** An appointment needs at least one PRIMARY CUSTOMER participant. */
|
|
17
|
+
GraphQLErrorCode["APPOINTMENT_PRIMARY_CUSTOMER_MISSING"] = "APPOINTMENT_PRIMARY_CUSTOMER_MISSING";
|
|
18
|
+
/** An appointment needs at least one PRIMARY EMPLOYEE participant. */
|
|
19
|
+
GraphQLErrorCode["APPOINTMENT_PRIMARY_EMPLOYEE_MISSING"] = "APPOINTMENT_PRIMARY_EMPLOYEE_MISSING";
|
|
20
|
+
/** PRIMARY appointment participants cannot be added or removed. */
|
|
21
|
+
GraphQLErrorCode["APPOINTMENT_PRIMARY_PARTICIPANT_ADDED_OR_REMOVED"] = "APPOINTMENT_PRIMARY_PARTICIPANT_ADDED_OR_REMOVED";
|
|
22
|
+
/** An on-location appointment must have a location. */
|
|
23
|
+
GraphQLErrorCode["APPOINTMENT_LOCATION_REQUIRED"] = "APPOINTMENT_LOCATION_REQUIRED";
|
|
24
|
+
/** No employees available on the chosen time slot. */
|
|
25
|
+
GraphQLErrorCode["APPOINTMENT_NO_AVAILABILITY"] = "APPOINTMENT_NO_AVAILABILITY";
|
|
26
|
+
/** The end must be strictly greater than the start of an appointment. */
|
|
27
|
+
GraphQLErrorCode["APPOINTMENT_START_AFTER_END"] = "APPOINTMENT_START_AFTER_END";
|
|
28
|
+
/** The operation cannot be performed on the appointment because the appointment status does not allow it. */
|
|
29
|
+
GraphQLErrorCode["APPOINTMENT_STATUS_INVALID"] = "APPOINTMENT_STATUS_INVALID";
|
|
30
|
+
/** The default availability template cannot be modified. */
|
|
31
|
+
GraphQLErrorCode["AVAILABILITY_TEMPLATE_DEFAULT_TEMPLATE_MODIFICATION_NOT_ALLOWED"] = "AVAILABILITY_TEMPLATE_DEFAULT_TEMPLATE_MODIFICATION_NOT_ALLOWED";
|
|
32
|
+
/** The day of the week cannot be set on availability time ranges for DAY availability templates. */
|
|
33
|
+
GraphQLErrorCode["AVAILABILITY_TIME_RANGE_DAY_TEMPLATE_WITH_DAY_OF_WEEK"] = "AVAILABILITY_TIME_RANGE_DAY_TEMPLATE_WITH_DAY_OF_WEEK";
|
|
34
|
+
/** Availability time ranges cannot overlap. */
|
|
35
|
+
GraphQLErrorCode["AVAILABILITY_TIME_RANGE_OVERLAP"] = "AVAILABILITY_TIME_RANGE_OVERLAP";
|
|
36
|
+
/** The end must be strictly greater than or equal to the start of an availability time range. */
|
|
37
|
+
GraphQLErrorCode["AVAILABILITY_TIME_RANGE_START_AFTER_END"] = "AVAILABILITY_TIME_RANGE_START_AFTER_END";
|
|
38
|
+
/** The day of the week must be set on availability time ranges for WEEK availability templates. */
|
|
39
|
+
GraphQLErrorCode["AVAILABILITY_TIME_RANGE_WEEK_TEMPLATE_WITHOUT_DAY_OF_WEEK"] = "AVAILABILITY_TIME_RANGE_WEEK_TEMPLATE_WITHOUT_DAY_OF_WEEK";
|
|
40
|
+
/** A customer must have at least one of the following fields: externalId, customerNumber, email, lastName, company, phoneNumber. */
|
|
41
|
+
GraphQLErrorCode["CUSTOMER_NOT_IDENTIFIABLE"] = "CUSTOMER_NOT_IDENTIFIABLE";
|
|
42
|
+
/** An ACTIVE employee must have a first and last name. */
|
|
43
|
+
GraphQLErrorCode["EMPLOYEE_ACTIVE_WITHOUT_FIRST_LAST_NAME"] = "EMPLOYEE_ACTIVE_WITHOUT_FIRST_LAST_NAME";
|
|
44
|
+
/** The employee cannot be activated because it is already active. */
|
|
45
|
+
GraphQLErrorCode["EMPLOYEE_ALREADY_ACTIVE"] = "EMPLOYEE_ALREADY_ACTIVE";
|
|
46
|
+
/** The provided email address for the employee is already in use for another employee. */
|
|
47
|
+
GraphQLErrorCode["EMPLOYEE_EMAIL_ALREADY_IN_USE"] = "EMPLOYEE_EMAIL_ALREADY_IN_USE";
|
|
48
|
+
/** The office relation roles should match the available employee roles. */
|
|
49
|
+
GraphQLErrorCode["EMPLOYEE_OFFICE_RELATION_ROLE_MISMATCH"] = "EMPLOYEE_OFFICE_RELATION_ROLE_MISMATCH";
|
|
50
|
+
/** Online planning can only be enabled for ACTIVE employees with the AGENT role. */
|
|
51
|
+
GraphQLErrorCode["EMPLOYEE_ONLINE_PLANNING_NON_AGENT"] = "EMPLOYEE_ONLINE_PLANNING_NON_AGENT";
|
|
52
|
+
/** The operation cannot be performed on the employe because the employee is SUSPENDED. */
|
|
53
|
+
GraphQLErrorCode["EMPLOYEE_SUSPENDED"] = "EMPLOYEE_SUSPENDED";
|
|
54
|
+
/** Cannot set employee status to PENDING. */
|
|
55
|
+
GraphQLErrorCode["EMPLOYEE_UPDATE_STATUS_PENDING"] = "EMPLOYEE_UPDATE_STATUS_PENDING";
|
|
56
|
+
/** A fetch configuration can only be deleted if it is not linked to a question. */
|
|
57
|
+
GraphQLErrorCode["FETCH_CONFIGURATION_LINKED_TO_QUESTION_ON_DELETE"] = "FETCH_CONFIGURATION_LINKED_TO_QUESTION_ON_DELETE";
|
|
58
|
+
/** The provided URL for an uploaded file is invalid. */
|
|
59
|
+
GraphQLErrorCode["FILE_URL_INVALID"] = "FILE_URL_INVALID";
|
|
60
|
+
/** The provided code for the lead segment is already in use for another lead segment. */
|
|
61
|
+
GraphQLErrorCode["LEAD_SEGMENT_CODE_ALREADY_IN_USE"] = "LEAD_SEGMENT_CODE_ALREADY_IN_USE";
|
|
62
|
+
/** The latestCallbackHours must be greater than or equal to earliestCallbackHours. */
|
|
63
|
+
GraphQLErrorCode["LEAD_SEGMENT_EARLIEST_CALLBACK_HOURS_GREATHER_THAN_LATEST_CALLBACK_HOURS"] = "LEAD_SEGMENT_EARLIEST_CALLBACK_HOURS_GREATHER_THAN_LATEST_CALLBACK_HOURS";
|
|
64
|
+
/** Employees assigned to a listing time slot must be linked to the parent listing. */
|
|
65
|
+
GraphQLErrorCode["LISTING_TIME_SLOT_EMPLOYEE_NOT_LINKED"] = "LISTING_TIME_SLOT_EMPLOYEE_NOT_LINKED";
|
|
66
|
+
/** Listing time slots cannot overlap. */
|
|
67
|
+
GraphQLErrorCode["LISTING_TIME_SLOT_OVERLAP"] = "LISTING_TIME_SLOT_OVERLAP";
|
|
68
|
+
/** The geolocation could not be determined for the provided location. */
|
|
69
|
+
GraphQLErrorCode["LOCATION_GEOCODING_FAILED"] = "LOCATION_GEOCODING_FAILED";
|
|
70
|
+
/** An error occurred while determining the time zone for the given location. */
|
|
71
|
+
GraphQLErrorCode["LOCATION_TIME_ZONE_RESOLUTION_FAILED"] = "LOCATION_TIME_ZONE_RESOLUTION_FAILED";
|
|
72
|
+
/** A question with input type FETCH should have a fetch configuration ID. */
|
|
73
|
+
GraphQLErrorCode["QUESTION_FETCH_TYPE_WITHOUT_FETCH_CONFIGURATION"] = "QUESTION_FETCH_TYPE_WITHOUT_FETCH_CONFIGURATION";
|
|
74
|
+
/** Only a question with input type FETCH can have a fetch configuration ID. */
|
|
75
|
+
GraphQLErrorCode["QUESTION_NON_FETCH_TYPE_WITH_FETCH_CONFIGURATION"] = "QUESTION_NON_FETCH_TYPE_WITH_FETCH_CONFIGURATION";
|
|
76
|
+
/** Answer options cannot be configured for a question that is not of type SELECT or MULTI_SELECT. */
|
|
77
|
+
GraphQLErrorCode["QUESTION_NON_SELECTION_TYPE_WITH_ANSWER_OPTIONS"] = "QUESTION_NON_SELECTION_TYPE_WITH_ANSWER_OPTIONS";
|
|
78
|
+
/** A question with input type SELECT or MULTI_SELECT should have at least one answer option. */
|
|
79
|
+
GraphQLErrorCode["QUESTION_SELECTION_TYPE_WITHOUT_ANSWER_OPTIONS"] = "QUESTION_SELECTION_TYPE_WITHOUT_ANSWER_OPTIONS";
|
|
80
|
+
/** The appointmentLatestPossible enterprise setting must be greater than or equal to appointmentEarliestPossible. */
|
|
81
|
+
GraphQLErrorCode["SETTING_APPOINTMENT_EARLIEST_LATEST_POSSIBLE_INVALID"] = "SETTING_APPOINTMENT_EARLIEST_LATEST_POSSIBLE_INVALID";
|
|
82
|
+
/** Cannot update a manageable enterprise setting to a non-manageable enterprise setting. */
|
|
83
|
+
GraphQLErrorCode["SETTING_MANAGEABILITY_MODIFICATION_NOT_ALLOWED"] = "SETTING_MANAGEABILITY_MODIFICATION_NOT_ALLOWED";
|
|
84
|
+
/** Cannot update a non-manageable enterprise setting. */
|
|
85
|
+
GraphQLErrorCode["SETTING_NON_MANAGEABLE"] = "SETTING_NON_MANAGEABLE";
|
|
86
|
+
/** The value of the enterprise setting is invalid. */
|
|
87
|
+
GraphQLErrorCode["SETTING_VALUE_INVALID"] = "SETTING_VALUE_INVALID";
|
|
88
|
+
/** A subject group can only be deleted if it has no subjects. */
|
|
89
|
+
GraphQLErrorCode["SUBJECT_GROUP_NOT_EMPTY_ON_DELETE"] = "SUBJECT_GROUP_NOT_EMPTY_ON_DELETE";
|
|
90
|
+
/** The requested combination is not schedulable. */
|
|
91
|
+
GraphQLErrorCode["TIMETABLE_NOT_SCHEDULABLE"] = "TIMETABLE_NOT_SCHEDULABLE";
|
|
92
|
+
/** The user-defined unavailability overlaps with another existing user-defined unavailability. */
|
|
93
|
+
GraphQLErrorCode["UNAVAILABILITY_OVERLAP"] = "UNAVAILABILITY_OVERLAP";
|
|
94
|
+
})(GraphQLErrorCode || (GraphQLErrorCode = {}));
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ClientError } from "graphql-request";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { GraphQLErrorCode } from "./graphql-error-codes.js";
|
|
4
|
+
export declare function handleGQLError(error: unknown): {
|
|
5
|
+
readonly type: "GQL";
|
|
6
|
+
readonly error: ClientError;
|
|
7
|
+
readonly errors: {
|
|
8
|
+
extensions: {
|
|
9
|
+
http: 400;
|
|
10
|
+
exception: {
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
14
|
+
http: 401;
|
|
15
|
+
exception: {
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
http: 403;
|
|
20
|
+
exception: {
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
http: 404;
|
|
25
|
+
exception: {
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
http: 405;
|
|
30
|
+
exception: {
|
|
31
|
+
message: string;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
http: 409;
|
|
35
|
+
exception: {
|
|
36
|
+
message: string;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
code: GraphQLErrorCode;
|
|
40
|
+
type: "UnprocessableEntity";
|
|
41
|
+
http: 422;
|
|
42
|
+
exception: {
|
|
43
|
+
message: string;
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
http: 429;
|
|
47
|
+
exception: {
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
} | z.objectOutputType<{}, z.ZodTypeAny, "passthrough">;
|
|
51
|
+
locations: readonly import("graphql").SourceLocation[] | undefined;
|
|
52
|
+
path: readonly (string | number)[] | undefined;
|
|
53
|
+
nodes: readonly import("graphql").ASTNode[] | undefined;
|
|
54
|
+
source: import("graphql").Source | undefined;
|
|
55
|
+
positions: readonly number[] | undefined;
|
|
56
|
+
originalError: Error | undefined;
|
|
57
|
+
name: string;
|
|
58
|
+
message: string;
|
|
59
|
+
stack?: string | undefined;
|
|
60
|
+
cause?: unknown;
|
|
61
|
+
}[] | undefined;
|
|
62
|
+
readonly subtype?: undefined;
|
|
63
|
+
readonly err?: undefined;
|
|
64
|
+
} | {
|
|
65
|
+
readonly type: "GQL";
|
|
66
|
+
readonly subtype: "ZOD_VALIDATION_FAILED";
|
|
67
|
+
readonly error: ClientError;
|
|
68
|
+
readonly err: unknown;
|
|
69
|
+
readonly errors?: undefined;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "UNKNOWN";
|
|
72
|
+
readonly error: unknown;
|
|
73
|
+
readonly errors?: undefined;
|
|
74
|
+
readonly subtype?: undefined;
|
|
75
|
+
readonly err?: undefined;
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=graphql-error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-error-handler.d.ts","sourceRoot":"","sources":["../src/graphql-error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAkF5D,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgB5C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ClientError } from "graphql-request";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { GraphQLErrorCode } from "./graphql-error-codes.js";
|
|
4
|
+
const ExtensionSchema = z.union([
|
|
5
|
+
z.object({
|
|
6
|
+
/**
|
|
7
|
+
* A `400` response code indicates a malformed request.
|
|
8
|
+
*
|
|
9
|
+
* The request should not be retried without changes.
|
|
10
|
+
*/
|
|
11
|
+
http: z.literal(400),
|
|
12
|
+
exception: z.object({ message: z.string() }),
|
|
13
|
+
}),
|
|
14
|
+
z.object({
|
|
15
|
+
/**
|
|
16
|
+
* A `401` response code indicates an unauthorized request.
|
|
17
|
+
*
|
|
18
|
+
* This response can be expected when the `Authorization` header value is invalid, expired or missing.
|
|
19
|
+
*
|
|
20
|
+
* The request should not be retried with the same `Authorization` header value.
|
|
21
|
+
*/
|
|
22
|
+
http: z.literal(401),
|
|
23
|
+
exception: z.object({ message: z.string() }),
|
|
24
|
+
}),
|
|
25
|
+
z.object({
|
|
26
|
+
/**
|
|
27
|
+
* A `403` response code indicates a forbidden request.
|
|
28
|
+
*
|
|
29
|
+
* The provided `Authorization` header value is valid but the request is prohibited due to other permission restrictions (e.g., missing scopes or organizational settings).
|
|
30
|
+
*/
|
|
31
|
+
http: z.literal(403),
|
|
32
|
+
exception: z.object({ message: z.string() }),
|
|
33
|
+
}),
|
|
34
|
+
z.object({
|
|
35
|
+
/**
|
|
36
|
+
* A `404` response code indicates a resource that cannot be found.
|
|
37
|
+
*
|
|
38
|
+
* This response code will be returned in case of a non-existent URL being used or a non-existent resource ID being used in a valid URL structure.
|
|
39
|
+
*/
|
|
40
|
+
http: z.literal(404),
|
|
41
|
+
exception: z.object({ message: z.string() }),
|
|
42
|
+
}),
|
|
43
|
+
z.object({
|
|
44
|
+
/**
|
|
45
|
+
* A `405` response code indicates that the HTTP method being used is not supported for the target URL.
|
|
46
|
+
*
|
|
47
|
+
* The request should not be retried without changes.
|
|
48
|
+
*/
|
|
49
|
+
http: z.literal(405),
|
|
50
|
+
exception: z.object({ message: z.string() }),
|
|
51
|
+
}),
|
|
52
|
+
z.object({
|
|
53
|
+
/**
|
|
54
|
+
* A `409` response code indicates a conflict, caused by concurrent operations, that resulted in a situation where the requested operation could not be performed simultaneously with another operation.
|
|
55
|
+
*
|
|
56
|
+
* The request can be retried without changes but will most likely result in another error response code.
|
|
57
|
+
*/
|
|
58
|
+
http: z.literal(409),
|
|
59
|
+
exception: z.object({ message: z.string() }),
|
|
60
|
+
}),
|
|
61
|
+
z.object({
|
|
62
|
+
/**
|
|
63
|
+
* A `422` response code indicates a failed business validation.
|
|
64
|
+
*
|
|
65
|
+
* More information on the business validation concerned can be found in [Error codes](https://developer.pexipengage.com/topic/topic-error-codes) by looking up the specific error code mentioned in the `errors` array in the response body.
|
|
66
|
+
*/
|
|
67
|
+
http: z.literal(422),
|
|
68
|
+
code: z.nativeEnum(GraphQLErrorCode),
|
|
69
|
+
type: z.literal("UnprocessableEntity"),
|
|
70
|
+
exception: z.object({ message: z.string() }),
|
|
71
|
+
// type: "UnprocessableEntity",
|
|
72
|
+
// exception: {
|
|
73
|
+
// message: "No employees available on the chosen time slot.",
|
|
74
|
+
// },
|
|
75
|
+
}),
|
|
76
|
+
z.object({
|
|
77
|
+
/** A `429` response code indicates that too many requests were sent in a given amount of time. See [Rate limiting](https://developer.pexipengage.com/topic/topic-rate-limiting). */
|
|
78
|
+
http: z.literal(429),
|
|
79
|
+
exception: z.object({ message: z.string() }),
|
|
80
|
+
}),
|
|
81
|
+
z.object({}).passthrough(),
|
|
82
|
+
]);
|
|
83
|
+
export function handleGQLError(error) {
|
|
84
|
+
if (error instanceof ClientError) {
|
|
85
|
+
// TODO fix this mess..
|
|
86
|
+
try {
|
|
87
|
+
const errors = error.response.errors?.map((err) => ({
|
|
88
|
+
...err,
|
|
89
|
+
extensions: ExtensionSchema.parse(err.extensions),
|
|
90
|
+
}));
|
|
91
|
+
return { type: "GQL", error, errors };
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
return { type: "GQL", subtype: "ZOD_VALIDATION_FAILED", error, err };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { type: "UNKNOWN", error };
|
|
98
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createStudioSearchParam, getApiClient, getGQLOperationName } from "./get-api-client.js";
|
|
2
|
+
export { GraphQLErrorCode } from "./graphql-error-codes.js";
|
|
3
|
+
export { handleGQLError } from "./graphql-error-handler.js";
|
|
4
|
+
export * from "./schema.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED