@vertikalx/vtx-backend-client 3.0.1-dev-max.1 → 3.0.1-dev-max.3

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.
Files changed (73) hide show
  1. package/package.json +1 -1
  2. package/src/api/api-call-headers.js.map +1 -1
  3. package/src/api/backend-response.js.map +1 -1
  4. package/src/api/domains.js.map +1 -1
  5. package/src/api/response-builder.js.map +1 -1
  6. package/src/api/types.js.map +1 -1
  7. package/src/api/vtx-apikey-api.js.map +1 -1
  8. package/src/api/vtx-base-api.js.map +1 -1
  9. package/src/api/vtx-mobile-api.js.map +1 -1
  10. package/src/api/vtx-web-browser-api.js.map +1 -1
  11. package/src/api/vtx-web-server-api.js.map +1 -1
  12. package/src/client/index.js.map +1 -1
  13. package/src/client/runtime/batcher.js.map +1 -1
  14. package/src/client/runtime/createClient.js.map +1 -1
  15. package/src/client/runtime/error.js.map +1 -1
  16. package/src/client/runtime/fetcher.js.map +1 -1
  17. package/src/client/runtime/generateGraphqlOperation.js.map +1 -1
  18. package/src/client/runtime/index.js.map +1 -1
  19. package/src/client/runtime/linkTypeMap.js.map +1 -1
  20. package/src/client/runtime/typeSelection.js.map +1 -1
  21. package/src/client/runtime/types.js.map +1 -1
  22. package/src/client/schema.d.ts +0 -8
  23. package/src/client/schema.js.map +1 -1
  24. package/src/client/types.d.ts +0 -5
  25. package/src/client/types.js +0 -15
  26. package/src/client/types.js.map +1 -1
  27. package/src/generated/graphql.d.ts +0 -12
  28. package/src/generated/graphql.js +0 -7
  29. package/src/generated/graphql.js.map +1 -1
  30. package/src/index.js.map +1 -1
  31. package/src/api/api-call-headers.ts +0 -35
  32. package/src/api/backend-response.ts +0 -14
  33. package/src/api/domains.ts +0 -6
  34. package/src/api/response-builder.ts +0 -165
  35. package/src/api/types.ts +0 -9
  36. package/src/api/vtx-apikey-api.ts +0 -23
  37. package/src/api/vtx-base-api.ts +0 -2253
  38. package/src/api/vtx-mobile-api.ts +0 -43
  39. package/src/api/vtx-web-browser-api.ts +0 -46
  40. package/src/api/vtx-web-server-api.ts +0 -41
  41. package/src/client/index.ts +0 -65
  42. package/src/client/runtime/batcher.ts +0 -275
  43. package/src/client/runtime/createClient.ts +0 -68
  44. package/src/client/runtime/error.ts +0 -29
  45. package/src/client/runtime/fetcher.ts +0 -97
  46. package/src/client/runtime/generateGraphqlOperation.ts +0 -225
  47. package/src/client/runtime/index.ts +0 -13
  48. package/src/client/runtime/linkTypeMap.ts +0 -156
  49. package/src/client/runtime/typeSelection.ts +0 -95
  50. package/src/client/runtime/types.ts +0 -69
  51. package/src/client/schema.graphql +0 -4256
  52. package/src/client/schema.ts +0 -8329
  53. package/src/client/types.ts +0 -10578
  54. package/src/generated/graphql.ts +0 -12445
  55. package/src/index.ts +0 -16
  56. package/src/operations/admin.graphql +0 -19
  57. package/src/operations/ai-coach.graphql +0 -117
  58. package/src/operations/athlete.graphql +0 -1764
  59. package/src/operations/auth.graphql +0 -301
  60. package/src/operations/campaign.graphql +0 -775
  61. package/src/operations/email-campaign.graphql +0 -160
  62. package/src/operations/followers.graphql +0 -45
  63. package/src/operations/integrations.graphql +0 -216
  64. package/src/operations/leaderboard.graphql +0 -54
  65. package/src/operations/media.graphql +0 -179
  66. package/src/operations/notifications.graphql +0 -93
  67. package/src/operations/offers.graphql +0 -368
  68. package/src/operations/onboarding.graphql +0 -29
  69. package/src/operations/sponsor.graphql +0 -368
  70. package/src/operations/sport.graphql +0 -132
  71. package/src/operations/user.graphql +0 -446
  72. package/tsconfig.lib.json +0 -10
  73. package/tsconfig.lib.tsbuildinfo +0 -1
@@ -1,165 +0,0 @@
1
- import { AnyARecord } from "dns";
2
- import { BackendError, ITypedBackendResponse } from "./backend-response";
3
- import { VTX_ERRORS } from "@vertikalx/vtx-core-common";
4
-
5
-
6
- export type checkerFn = (response:any)=>boolean;
7
-
8
- const Logger = {
9
- log:(msg:string)=>{
10
- //console.log(msg)
11
- }
12
- };
13
-
14
- export function buildResponse<T>(response:any, rootProperty:string, checker: checkerFn):ITypedBackendResponse<T>{
15
- const retValue:ITypedBackendResponse<T> = {}
16
-
17
- //console.log("=========== BEGIN buildResponse =============");
18
- //console.log(JSON.stringify(response, null, 2));
19
-
20
- //console.log("=========== END buildResponse =============");
21
-
22
- if (checker(response)){
23
-
24
- //Logger.log('checker 1');
25
- try {
26
- retValue.data = response[rootProperty] as T;
27
- } catch (casterr) {
28
- Logger.log('Error trying to cast to return type');
29
- retValue.error = {
30
- httpStatus:500,
31
- code:VTX_ERRORS.VTX_SERVER_ERROR.code,
32
- message:"Error: Obtained incorrect data from Backend"
33
- };
34
- retValue.rawErrors = [
35
- {
36
- data:response,
37
- error:casterr
38
- }
39
- ];
40
- }
41
-
42
- } else if (response?.errors) {
43
-
44
- //Logger.log('checker 2');
45
- if (Array.isArray(response.errors)) {
46
- retValue.rawErrors = response.errors;
47
- } else {
48
- retValue.rawErrors = [response.errors];
49
- }
50
-
51
- } else if (response?.error) {
52
- //Logger.log('checker 3');
53
-
54
- if (Array.isArray(response.error)) {
55
- retValue.rawErrors = response.error;
56
- } else {
57
- retValue.rawErrors = [response.error];
58
- }
59
-
60
- } else if (checker(response?.data)) {
61
- //Logger.log('checker 4');
62
-
63
- try {
64
- retValue.data = response.data[rootProperty] as T;
65
- } catch (casterr) {
66
- Logger.log('Error trying to cast to return type');
67
-
68
- retValue.error = {
69
- httpStatus:500,
70
- code:VTX_ERRORS.VTX_SERVER_ERROR.code,
71
- message:"Error: Obtained incorrect data from Backend"
72
- };
73
- retValue.rawErrors = [
74
- {
75
- data:response.data,
76
- error:casterr
77
- }
78
- ];
79
-
80
- }
81
- } else {
82
- //Logger.log('checker 5');
83
- retValue.error = {
84
- httpStatus:500,
85
- code:VTX_ERRORS.VTX_SERVER_ERROR.code,
86
- message:"Error: Obtained incorrect data from Backend"
87
- };
88
- retValue.rawErrors = ['Error: Obtained incorrect data from Backend'];
89
- }
90
-
91
-
92
- Logger.log('buildResponse retValue:');
93
- Logger.log(JSON.stringify(retValue,null,2));
94
-
95
- return retValue;
96
- }
97
- export function buildErrorResponse<T>(error:any):ITypedBackendResponse<T>{
98
-
99
- //Logger.log("=========== BEGIN buildErrorResponse received =============");
100
- //Logger.log(JSON.stringify(error, null, 2));
101
-
102
- //Logger.log("=========== END buildErrorResponse received =============");
103
-
104
- const retValue:ITypedBackendResponse<T> = {}
105
- if (error.errors){
106
-
107
- if (Array.isArray(error.errors)){
108
- retValue.rawErrors = error.errors;
109
-
110
- }else{
111
- retValue.rawErrors = [error.errors];
112
-
113
- }
114
-
115
- }else{
116
- if (Array.isArray(error)){
117
- retValue.rawErrors = error;
118
- }else{
119
- retValue.rawErrors = [error];
120
- }
121
- }
122
-
123
- retValue.error = extractError(retValue.rawErrors );
124
-
125
- //Logger.log("=========== BEGIN buildErrorResponse returned =============");
126
- //Logger.log(JSON.stringify(retValue, null, 2));
127
-
128
- //Logger.log("=========== END buildErrorResponse returned =============");
129
-
130
-
131
- return retValue;
132
- }
133
- function extractError(rawErrors: any[]|undefined): BackendError {
134
-
135
- let retValue:BackendError = {
136
- httpStatus:500,
137
- code:VTX_ERRORS.VTX_SERVER_ERROR.code,
138
- message:VTX_ERRORS.VTX_SERVER_ERROR.description
139
- };
140
-
141
- if (! rawErrors || rawErrors.length <= 0){
142
- return retValue;
143
- }
144
-
145
- let theError:any = rawErrors.find( e => {
146
-
147
- if (e.extensions && e.extensions.type === "VtxError"){
148
- return true;
149
- }
150
- return false;
151
- });
152
-
153
- if (theError){
154
- retValue = {
155
- httpStatus:theError?.extensions?.httpStatus ?? 500,
156
- code: theError?.extensions?.vtxError?.code ?? VTX_ERRORS.VTX_SERVER_ERROR.code,
157
- message: theError?.extensions?.vtxError?.description ?? VTX_ERRORS.VTX_SERVER_ERROR.description
158
- }
159
- }
160
-
161
- return retValue;
162
-
163
-
164
- }
165
-
package/src/api/types.ts DELETED
@@ -1,9 +0,0 @@
1
- import { QualificationDto,
2
- AgeQualificationDto, GenderQualificationDto ,
3
- ScoreQualificationDto, LocationQualificationDto,
4
- NationalityQualificationDto, DistanceQualificationDto,
5
- SportsQualificationDto, SportsLevelQualificationDto
6
- } from "../client";
7
-
8
-
9
- export type QualificationDtoUnion = QualificationDto | AgeQualificationDto | GenderQualificationDto | ScoreQualificationDto | LocationQualificationDto | NationalityQualificationDto | DistanceQualificationDto | SportsQualificationDto | SportsLevelQualificationDto;
@@ -1,23 +0,0 @@
1
-
2
- import pjson from "../../package.json";
3
- import { APICallHeaders, DEFAULT_API_KEY_ID_HEADER, DEFAULT_API_KEY_VALUE_HEADER, DEFAULT_APP_KEY_HEADER, DEFAULT_HEADERS } from "./api-call-headers";
4
- import { VTXBaseAPI } from "./vtx-base-api";
5
-
6
-
7
-
8
-
9
-
10
- export class VTXAPIKeyAPI extends VTXBaseAPI{
11
-
12
- constructor(backendUrl:string, apiKeyId:string, apiKeyValue:string ){
13
- super(backendUrl, VTXAPIKeyAPI.getDefaultHeaders(apiKeyId, apiKeyValue));
14
- }
15
-
16
- public static getDefaultHeaders(apiKeyId:string, apiKeyValue:string):APICallHeaders{
17
- return {
18
- [DEFAULT_API_KEY_ID_HEADER]: apiKeyId,
19
- [DEFAULT_API_KEY_VALUE_HEADER]: apiKeyValue,
20
- ...DEFAULT_HEADERS
21
- }
22
- }
23
- }