@timum/timum_pdk 2.0.8 → 2.0.9
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/dist/TimumPDK - Verkn/303/274pfung.lnk +0 -0
- package/dist/main.js +86 -2
- package/dist/main.js.map +1 -0
- package/package.json +17 -8
- package/rollup.config.js +43 -0
- package/src/index.js +1 -337
- package/src/timumPdk.js +348 -0
- package/src/util/failSafeLocalStorage.js +50 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timum/timum_pdk",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"next_version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
|
+
"next_version": "2.0.9",
|
|
5
5
|
"current_major_version": "2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Contains timum public and general api endpoints",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"lint:fix": "eslint --fix .",
|
|
22
22
|
"s3:deleteCurrentVersionStage": "aws s3 rm \"s3://staging-cdn.timum/timum_pdk/%npm_package_current_major_version%/%npm_package_next_version%\" --recursive",
|
|
23
23
|
"s3:deleteLatestStage": "aws s3 rm \"s3://staging-cdn.timum/timum_pdk/%npm_package_current_major_version%/\" --exclude \"*\" --include \"*.*\" --exclude \"*/*\" --recursive",
|
|
24
|
-
"s3:publishToStage": "yarn
|
|
24
|
+
"s3:publishToStage": "yarn buildProd && yarn s3:deleteCurrentVersionStage && aws s3 sync ./dist/ \"s3://staging-cdn.timum/timum_pdk/%npm_package_current_major_version%/%npm_package_next_version%/\" && yarn s3:deleteLatestStage && aws s3 sync ./dist/ \"s3://staging-cdn.timum/timum_pdk/%npm_package_current_major_version%/\"",
|
|
25
25
|
"s3:deleteLatestProd": "aws s3 rm \"s3://cdn.timum/timum_pdk/%npm_package_current_major_version%\" --exclude \"*\" --include \"*.*\" --exclude \"*/*\" --recursive",
|
|
26
|
-
"s3:publishToProd": "yarn
|
|
27
|
-
"build": "
|
|
28
|
-
"
|
|
26
|
+
"s3:publishToProd": "yarn buildProd && np --no-yarn --no-cleanup && aws s3 sync ./dist/ \"s3://cdn.timum/timum_pdk/%npm_package_current_major_version%/%npm_package_version%/\" && yarn s3:deleteLatestProd && aws s3 sync ./dist/ \"s3://cdn.timum/timum_pdk/%npm_package_current_major_version%/\"",
|
|
27
|
+
"build": "rollup --config && moveBundle.bat",
|
|
28
|
+
"buildProd": "rollup --config",
|
|
29
29
|
"test": "echo \"No tests yet\""
|
|
30
30
|
},
|
|
31
31
|
"browserslist": {
|
|
@@ -45,7 +45,16 @@
|
|
|
45
45
|
"eslint-config-prettier": "^8.5.0",
|
|
46
46
|
"eslint-plugin-prettier": "^4.0.0",
|
|
47
47
|
"eslint-plugin-react": "^7.30.0",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"eslint-plugin-storybook": "^0.5.12",
|
|
49
|
+
"@babel/core": "^7.20.5",
|
|
50
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
51
|
+
"@babel/preset-env": "^7.20.2",
|
|
52
|
+
"@reduxjs/toolkit": "^1.9.1",
|
|
53
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
54
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
55
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
56
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
57
|
+
"rollup": "^3.7.5",
|
|
58
|
+
"rollup-plugin-peer-deps-external": "^2.2.4"
|
|
50
59
|
}
|
|
51
60
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
const resolve = require('@rollup/plugin-node-resolve');
|
|
3
|
+
|
|
4
|
+
//converts commonjs modules to ES6 so that they can be included in a rollup bundle
|
|
5
|
+
const commonjs = require('@rollup/plugin-commonjs');
|
|
6
|
+
|
|
7
|
+
// minifies the resulting code to further reduce package size
|
|
8
|
+
const terser = require('@rollup/plugin-terser');
|
|
9
|
+
|
|
10
|
+
// makes it so that deps marked as peer deps in package.json aren't included in the resulting bundle.
|
|
11
|
+
const peerDepsExternal = require('rollup-plugin-peer-deps-external');
|
|
12
|
+
|
|
13
|
+
// transpiles the code so older browser can interpret this
|
|
14
|
+
// if there is jsx in the repo this transforms it into plain javascript (at least if it's configured that way in your .babelrc)
|
|
15
|
+
const babel = require('@rollup/plugin-babel');
|
|
16
|
+
|
|
17
|
+
const packageJson = require('./package.json');
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
input: 'src/index.js',
|
|
21
|
+
external: [/@babel\/runtime/],
|
|
22
|
+
output: [
|
|
23
|
+
{
|
|
24
|
+
file: packageJson.main,
|
|
25
|
+
format: 'es',
|
|
26
|
+
sourcemap: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
plugins: [
|
|
30
|
+
peerDepsExternal(),
|
|
31
|
+
resolve(),
|
|
32
|
+
babel({
|
|
33
|
+
exclude: 'node_modules/**',
|
|
34
|
+
babelHelpers: 'runtime',
|
|
35
|
+
}),
|
|
36
|
+
commonjs({
|
|
37
|
+
strictRequires: true,
|
|
38
|
+
}),
|
|
39
|
+
terser({
|
|
40
|
+
sourceMap: true, // doesn't work for some reason
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,337 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { reactLocalStorage } from "reactjs-localstorage";
|
|
4
|
-
|
|
5
|
-
let host = undefined;
|
|
6
|
-
export const setTimumApiHost = (url) => {
|
|
7
|
-
host = url;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const getTimumApiHost = () => {
|
|
11
|
-
if (host) {
|
|
12
|
-
return host;
|
|
13
|
-
} else {
|
|
14
|
-
return reactLocalStorage.get("timumApiHost", "https://www.timum.de");
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// we do it this way so that the base url can be determined dynamically
|
|
19
|
-
export const getBaseUrl = () => {
|
|
20
|
-
return getTimumApiHost() + "/rest/1";
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const constructUrl = (url, props, plain) => {
|
|
24
|
-
if (props.params) {
|
|
25
|
-
for (const [paramName, paramValue] of Object.entries(props.params)) {
|
|
26
|
-
if (!url.includes("?")) {
|
|
27
|
-
url = `${url}?${paramName}=${paramValue}`;
|
|
28
|
-
} else {
|
|
29
|
-
url = `${url}&${paramName}=${paramValue}`;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!url.includes("?")) {
|
|
35
|
-
url = `${url}?X-DISABLE-COOKIES=true`;
|
|
36
|
-
} else {
|
|
37
|
-
url = `${url}&X-DISABLE-COOKIES=true`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (plain) {
|
|
41
|
-
return `${getTimumApiHost()}${url}`;
|
|
42
|
-
} else {
|
|
43
|
-
return `${getBaseUrl()}${url}`;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const timumApiSlice = createApi({
|
|
48
|
-
reducerPath: "timumApi",
|
|
49
|
-
baseQuery: fetchBaseQuery({
|
|
50
|
-
baseUrl: undefined,
|
|
51
|
-
credentials: "include",
|
|
52
|
-
}),
|
|
53
|
-
tagTypes: [
|
|
54
|
-
"Timeslot",
|
|
55
|
-
"Product",
|
|
56
|
-
"Account",
|
|
57
|
-
"Provider",
|
|
58
|
-
"User",
|
|
59
|
-
"IdentifiedCustomer",
|
|
60
|
-
],
|
|
61
|
-
endpoints: (builder) => ({
|
|
62
|
-
// ##########################################
|
|
63
|
-
// # ConsumerAPI v2
|
|
64
|
-
// ##########################################
|
|
65
|
-
|
|
66
|
-
upcomingBookables: builder.query({
|
|
67
|
-
query: (props) => ({
|
|
68
|
-
url: constructUrl(
|
|
69
|
-
`/resources/${props.channelOrResourceId}/upcoming_bookables`,
|
|
70
|
-
props
|
|
71
|
-
),
|
|
72
|
-
headers: props.headers,
|
|
73
|
-
}),
|
|
74
|
-
providesTags: (/* result = [], error, arg */) => ["Timeslot"],
|
|
75
|
-
}),
|
|
76
|
-
|
|
77
|
-
activeProducts: builder.query({
|
|
78
|
-
query: (props) => ({
|
|
79
|
-
url: constructUrl(
|
|
80
|
-
`/resources/${props.channelOrResourceId}/active_products`,
|
|
81
|
-
props
|
|
82
|
-
),
|
|
83
|
-
headers: props.headers,
|
|
84
|
-
}),
|
|
85
|
-
providesTags: (/* result = [], error, arg */) => ["Product"],
|
|
86
|
-
}),
|
|
87
|
-
|
|
88
|
-
createAppointmentWithConsumer: builder.mutation({
|
|
89
|
-
query: (props) => ({
|
|
90
|
-
url: constructUrl(
|
|
91
|
-
`/resources/${props.channelOrResourceId}/create_appointment_with_consumer`,
|
|
92
|
-
props
|
|
93
|
-
),
|
|
94
|
-
method: "post",
|
|
95
|
-
body: props.body,
|
|
96
|
-
headers: props.headers,
|
|
97
|
-
}),
|
|
98
|
-
invalidatesTags: (result, error, arg) => {
|
|
99
|
-
const invalidatedTags = [{ type: "Timeslot" }];
|
|
100
|
-
|
|
101
|
-
if (arg.shouldInvalidateCustomerIdentification) {
|
|
102
|
-
invalidatedTags.push({ type: "IdentifiedCustomer" });
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return invalidatedTags;
|
|
106
|
-
},
|
|
107
|
-
}),
|
|
108
|
-
|
|
109
|
-
removeCustomerFromAppointment: builder.mutation({
|
|
110
|
-
query: (props) => ({
|
|
111
|
-
url: constructUrl(
|
|
112
|
-
`/customers/${props.customersId}/appointments/${props.appointmentId}`,
|
|
113
|
-
props
|
|
114
|
-
),
|
|
115
|
-
method: "delete",
|
|
116
|
-
headers: props.headers,
|
|
117
|
-
}),
|
|
118
|
-
invalidatesTags: (/* result, error, arg */) => [{ type: "Timeslot" }],
|
|
119
|
-
}),
|
|
120
|
-
|
|
121
|
-
authenticate: builder.query({
|
|
122
|
-
query: (props) => {
|
|
123
|
-
return {
|
|
124
|
-
url: constructUrl(`/auth/cookieless/login`, props, true),
|
|
125
|
-
headers: props.headers,
|
|
126
|
-
method: "post",
|
|
127
|
-
body: props.body,
|
|
128
|
-
};
|
|
129
|
-
},
|
|
130
|
-
}),
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Returns an object with the following makeup:
|
|
134
|
-
* {
|
|
135
|
-
* contact: {
|
|
136
|
-
* name,
|
|
137
|
-
* email,
|
|
138
|
-
* mobile,
|
|
139
|
-
* phone
|
|
140
|
-
* },
|
|
141
|
-
* resource: {
|
|
142
|
-
* name,
|
|
143
|
-
* description,
|
|
144
|
-
* msgHelpText
|
|
145
|
-
* },
|
|
146
|
-
* provider: {
|
|
147
|
-
* name
|
|
148
|
-
* }
|
|
149
|
-
* }
|
|
150
|
-
*/
|
|
151
|
-
publicData: builder.query({
|
|
152
|
-
query: (props) => ({
|
|
153
|
-
url: constructUrl(
|
|
154
|
-
`/resources/${props.channelOrResourceId}/public_data`,
|
|
155
|
-
props
|
|
156
|
-
),
|
|
157
|
-
headers: props.headers,
|
|
158
|
-
}),
|
|
159
|
-
}),
|
|
160
|
-
|
|
161
|
-
identifyCustomer: builder.query({
|
|
162
|
-
query: (props) => ({
|
|
163
|
-
url: constructUrl(
|
|
164
|
-
`/crms/${props.crmSlug}/resources/${props.channelOrResourceId}/customers/${props.personId}/identify`,
|
|
165
|
-
props
|
|
166
|
-
),
|
|
167
|
-
headers: props.headers,
|
|
168
|
-
}),
|
|
169
|
-
providesTags: "IdentifiedCustomer", //
|
|
170
|
-
keepUnusedDataFor: 9999999, // once identified it's not going to change
|
|
171
|
-
}),
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* body contain:
|
|
175
|
-
* resource_id*,
|
|
176
|
-
* product_id*,
|
|
177
|
-
* provider_id,
|
|
178
|
-
* timeslotUuid (if available)
|
|
179
|
-
* from* (ISO format),
|
|
180
|
-
* to* (ISO format)
|
|
181
|
-
* -> * marks those which are required.
|
|
182
|
-
*/
|
|
183
|
-
reserveAppoinment: builder.mutation({
|
|
184
|
-
query: (props) => ({
|
|
185
|
-
url: constructUrl(
|
|
186
|
-
`/resources/${props.channelOrResourceId}/reserve_appointment`,
|
|
187
|
-
props
|
|
188
|
-
),
|
|
189
|
-
method: "post",
|
|
190
|
-
body: props.body,
|
|
191
|
-
headers: props.headers,
|
|
192
|
-
}),
|
|
193
|
-
}),
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* body must contain:
|
|
197
|
-
* placeholder_id (id created for ephemeral customer during call to),
|
|
198
|
-
* appointment_id
|
|
199
|
-
*/
|
|
200
|
-
revokeAppointmentReservation: builder.mutation({
|
|
201
|
-
query: (props) => ({
|
|
202
|
-
url: constructUrl(
|
|
203
|
-
`/resources/${props.channelOrResourceId}/revoke_reservation`,
|
|
204
|
-
props
|
|
205
|
-
),
|
|
206
|
-
method: "post",
|
|
207
|
-
body: props.body,
|
|
208
|
-
headers: props.headers,
|
|
209
|
-
}),
|
|
210
|
-
}),
|
|
211
|
-
|
|
212
|
-
// ##########################################
|
|
213
|
-
// # CRM API requests (general api)
|
|
214
|
-
// ##########################################
|
|
215
|
-
|
|
216
|
-
getAccount: builder.query({
|
|
217
|
-
query: (props) => ({
|
|
218
|
-
url: constructUrl(
|
|
219
|
-
`/crms/${props.platform}/account/${props.accountReference}`,
|
|
220
|
-
props
|
|
221
|
-
),
|
|
222
|
-
}),
|
|
223
|
-
providesTags: (/* result = [], error, arg */) => ["Account"],
|
|
224
|
-
}),
|
|
225
|
-
|
|
226
|
-
createAccount: builder.mutation({
|
|
227
|
-
query: (props) => {
|
|
228
|
-
return {
|
|
229
|
-
url: constructUrl(`/crms/${props.platform}/account`, props),
|
|
230
|
-
method: "post",
|
|
231
|
-
body: JSON.stringify(props.accountData),
|
|
232
|
-
};
|
|
233
|
-
},
|
|
234
|
-
invalidatesTags: (/* result, error, arg */) => [{ type: "Account" }],
|
|
235
|
-
}),
|
|
236
|
-
|
|
237
|
-
getProviders: builder.query({
|
|
238
|
-
query: (props) => ({
|
|
239
|
-
url: constructUrl(
|
|
240
|
-
`/crms/${props.platform}/account/${props.accountReference}/providers`,
|
|
241
|
-
props
|
|
242
|
-
),
|
|
243
|
-
}),
|
|
244
|
-
providesTags: (/* result = [], error, arg */) => ["Product"],
|
|
245
|
-
}),
|
|
246
|
-
|
|
247
|
-
getProvider: builder.query({
|
|
248
|
-
query: (props) => ({
|
|
249
|
-
url: constructUrl(
|
|
250
|
-
`/crms/${props.platform}/provider/${props.providerReference}`,
|
|
251
|
-
props
|
|
252
|
-
),
|
|
253
|
-
}),
|
|
254
|
-
}),
|
|
255
|
-
|
|
256
|
-
createProvider: builder.mutation({
|
|
257
|
-
query: (props) => ({
|
|
258
|
-
url: constructUrl(`/crms/${props.platform}/provider`, props),
|
|
259
|
-
method: "post",
|
|
260
|
-
body: JSON.stringify(
|
|
261
|
-
(() => ({
|
|
262
|
-
user: props.userData ?? {},
|
|
263
|
-
provider: props.providerData ?? {},
|
|
264
|
-
address: props.addressData ?? null,
|
|
265
|
-
account: props.account ?? null,
|
|
266
|
-
sendEmail: props.sendEmail ?? false,
|
|
267
|
-
}))()
|
|
268
|
-
),
|
|
269
|
-
}),
|
|
270
|
-
invalidatesTags: (/* result, error, arg */) => [{ type: "Provider" }],
|
|
271
|
-
}),
|
|
272
|
-
|
|
273
|
-
// loginUserViaApi: builder.query({
|
|
274
|
-
// query: (props) => ({
|
|
275
|
-
// url: constructUrl(`/crms/${props.platform}/user/loginWithJwt`),
|
|
276
|
-
// }),
|
|
277
|
-
// async onQueryStarted(props, { dispatch, queryFulfilled }) {
|
|
278
|
-
// const { data /* , meta */ } = await queryFulfilled;
|
|
279
|
-
// if (data) {
|
|
280
|
-
// dispatch(timumClientAuthorised({ auth2: data.auth2 }));
|
|
281
|
-
// }
|
|
282
|
-
// },
|
|
283
|
-
// }),
|
|
284
|
-
getUser: builder.query({
|
|
285
|
-
query: (props) => ({
|
|
286
|
-
url: constructUrl(
|
|
287
|
-
`/crms/${props.platform}/user/${props.userReference}`,
|
|
288
|
-
props
|
|
289
|
-
),
|
|
290
|
-
}),
|
|
291
|
-
}),
|
|
292
|
-
|
|
293
|
-
createUser: builder.mutation({
|
|
294
|
-
query: (props) => ({
|
|
295
|
-
url: constructUrl(`/crms/${props.platform}/user`, props),
|
|
296
|
-
method: "post",
|
|
297
|
-
body: JSON.stringify(props.userData),
|
|
298
|
-
}),
|
|
299
|
-
invalidatesTags: (/* result, error, arg */) => [{ type: "User" }],
|
|
300
|
-
}),
|
|
301
|
-
}),
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
export const {
|
|
305
|
-
// ##########################################
|
|
306
|
-
// # ConsumerAPI v2
|
|
307
|
-
// ##########################################
|
|
308
|
-
|
|
309
|
-
useUpcomingBookablesQuery,
|
|
310
|
-
useLazyUpcomingBookablesQuery,
|
|
311
|
-
useActiveProductsQuery,
|
|
312
|
-
useLazyActiveProductsQuery,
|
|
313
|
-
useCreateAppointmentWithConsumerMutation,
|
|
314
|
-
useIdentifyCustomerQuery,
|
|
315
|
-
useLazyIdentifyCustomerQuery,
|
|
316
|
-
usePublicDataQuery,
|
|
317
|
-
useLazyPublicDataQuery,
|
|
318
|
-
useReserveAppoinmentMutation,
|
|
319
|
-
useRevokeAppointmentReservationMutation,
|
|
320
|
-
useRemoveCustomerFromAppointmentMutation,
|
|
321
|
-
useAuthenticateQuery,
|
|
322
|
-
useLazyAuthenticateQuery,
|
|
323
|
-
|
|
324
|
-
// ##########################################
|
|
325
|
-
// # CRM API requests (general api)
|
|
326
|
-
// ##########################################
|
|
327
|
-
useCreateAccountMutation,
|
|
328
|
-
useGetAccountQuery,
|
|
329
|
-
useLazyGetAccountQuery,
|
|
330
|
-
useGetProvidersQuery,
|
|
331
|
-
useLazyGetProvidersQuery,
|
|
332
|
-
useCreateProviderMutation,
|
|
333
|
-
// useLoginUserViaApiQuery,
|
|
334
|
-
useCreateUserMutation,
|
|
335
|
-
useGetUserQuery,
|
|
336
|
-
useLazyGetUserQuery,
|
|
337
|
-
} = timumApiSlice;
|
|
1
|
+
export * from "./timumPdk";
|