@o2s/modules.surveyjs 0.1.0
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/api-harmonization/api-harmonization/index.d.ts +6 -0
- package/dist/api-harmonization/api-harmonization/index.d.ts.map +1 -0
- package/dist/api-harmonization/api-harmonization/index.js +44 -0
- package/dist/api-harmonization/api-harmonization/index.js.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.client.d.ts +4 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.client.d.ts.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.client.js +40 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.client.js.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.controller.d.ts +12 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.controller.d.ts.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.controller.js +54 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.controller.js.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.mapper.d.ts +4 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.mapper.d.ts.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.mapper.js +63 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.mapper.js.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.model.d.ts +1645 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.model.d.ts.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.model.js +91 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.model.js.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.module.d.ts +6 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.module.d.ts.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.module.js +39 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.module.js.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.request.d.ts +9 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.request.d.ts.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.request.js +13 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.request.js.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.service.d.ts +21 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.service.d.ts.map +1 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.service.js +127 -0
- package/dist/api-harmonization/api-harmonization/surveyjs.service.js.map +1 -0
- package/dist/frontend/api-harmonization/surveyjs.client.d.ts +4 -0
- package/dist/frontend/api-harmonization/surveyjs.client.d.ts.map +1 -0
- package/dist/frontend/api-harmonization/surveyjs.client.js +3 -0
- package/dist/frontend/api-harmonization/surveyjs.model.d.ts +1645 -0
- package/dist/frontend/api-harmonization/surveyjs.model.d.ts.map +1 -0
- package/dist/frontend/api-harmonization/surveyjs.model.js +83 -0
- package/dist/frontend/api-harmonization/surveyjs.request.d.ts +9 -0
- package/dist/frontend/api-harmonization/surveyjs.request.d.ts.map +1 -0
- package/dist/frontend/api-harmonization/surveyjs.request.js +7 -0
- package/dist/frontend/frontend/Components/Fieldset/Fieldset.d.ts +4 -0
- package/dist/frontend/frontend/Components/Fieldset/Fieldset.d.ts.map +1 -0
- package/dist/frontend/frontend/Components/Fieldset/Fieldset.jsx +11 -0
- package/dist/frontend/frontend/Components/Fieldset/Fieldset.types.d.ts +9 -0
- package/dist/frontend/frontend/Components/Fieldset/Fieldset.types.d.ts.map +1 -0
- package/dist/frontend/frontend/Components/Fieldset/Fieldset.types.js +1 -0
- package/dist/frontend/frontend/Elements/CustomSurveyNavigationButton.d.ts +2 -0
- package/dist/frontend/frontend/Elements/CustomSurveyNavigationButton.d.ts.map +1 -0
- package/dist/frontend/frontend/Elements/CustomSurveyNavigationButton.jsx +13 -0
- package/dist/frontend/frontend/Elements/CustomSurveyPanel.d.ts +2 -0
- package/dist/frontend/frontend/Elements/CustomSurveyPanel.d.ts.map +1 -0
- package/dist/frontend/frontend/Elements/CustomSurveyPanel.jsx +56 -0
- package/dist/frontend/frontend/Elements/CustomSurveyQuestion.d.ts +2 -0
- package/dist/frontend/frontend/Elements/CustomSurveyQuestion.d.ts.map +1 -0
- package/dist/frontend/frontend/Elements/CustomSurveyQuestion.jsx +48 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionBoolean.d.ts +2 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionBoolean.d.ts.map +1 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionBoolean.jsx +23 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionCheckbox.d.ts +2 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionCheckbox.d.ts.map +1 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionCheckbox.jsx +27 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionComment.d.ts +2 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionComment.d.ts.map +1 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionComment.jsx +16 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionDropdown.d.ts +2 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionDropdown.d.ts.map +1 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionDropdown.jsx +27 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionRadioGroup.d.ts +2 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionRadioGroup.d.ts.map +1 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionRadioGroup.jsx +28 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionText.d.ts +2 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionText.d.ts.map +1 -0
- package/dist/frontend/frontend/Questions/CustomSurveyQuestionText.jsx +63 -0
- package/dist/frontend/frontend/Survey.d.ts +13 -0
- package/dist/frontend/frontend/Survey.d.ts.map +1 -0
- package/dist/frontend/frontend/Survey.jsx +123 -0
- package/dist/frontend/frontend/Survey.types.d.ts +31 -0
- package/dist/frontend/frontend/Survey.types.d.ts.map +1 -0
- package/dist/frontend/frontend/Survey.types.js +1 -0
- package/dist/frontend/frontend/index.d.ts +3 -0
- package/dist/frontend/frontend/index.d.ts.map +1 -0
- package/dist/frontend/frontend/index.js +1 -0
- package/dist/frontend/sdk/index.d.ts +8 -0
- package/dist/frontend/sdk/index.d.ts.map +1 -0
- package/dist/frontend/sdk/index.js +20 -0
- package/dist/frontend/sdk/surveyjs.d.ts +10 -0
- package/dist/frontend/sdk/surveyjs.d.ts.map +1 -0
- package/dist/frontend/sdk/surveyjs.js +35 -0
- package/dist/sdk/api-harmonization/surveyjs.client.d.ts +4 -0
- package/dist/sdk/api-harmonization/surveyjs.client.d.ts.map +1 -0
- package/dist/sdk/api-harmonization/surveyjs.client.js +40 -0
- package/dist/sdk/api-harmonization/surveyjs.client.js.map +1 -0
- package/dist/sdk/api-harmonization/surveyjs.model.d.ts +1645 -0
- package/dist/sdk/api-harmonization/surveyjs.model.d.ts.map +1 -0
- package/dist/sdk/api-harmonization/surveyjs.model.js +91 -0
- package/dist/sdk/api-harmonization/surveyjs.model.js.map +1 -0
- package/dist/sdk/api-harmonization/surveyjs.request.d.ts +9 -0
- package/dist/sdk/api-harmonization/surveyjs.request.d.ts.map +1 -0
- package/dist/sdk/api-harmonization/surveyjs.request.js +13 -0
- package/dist/sdk/api-harmonization/surveyjs.request.js.map +1 -0
- package/dist/sdk/sdk/index.d.ts +8 -0
- package/dist/sdk/sdk/index.d.ts.map +1 -0
- package/dist/sdk/sdk/index.js +22 -0
- package/dist/sdk/sdk/index.js.map +1 -0
- package/dist/sdk/sdk/surveyjs.d.ts +10 -0
- package/dist/sdk/sdk/surveyjs.d.ts.map +1 -0
- package/dist/sdk/sdk/surveyjs.js +40 -0
- package/dist/sdk/sdk/surveyjs.js.map +1 -0
- package/dist/tsconfig.api.tsbuildinfo +1 -0
- package/dist/tsconfig.frontend.tsbuildinfo +1 -0
- package/dist/tsconfig.sdk.tsbuildinfo +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './Elements/CustomSurveyNavigationButton';
|
|
3
|
+
import './Elements/CustomSurveyPanel';
|
|
4
|
+
import './Elements/CustomSurveyQuestion';
|
|
5
|
+
import './Questions/CustomSurveyQuestionBoolean';
|
|
6
|
+
import './Questions/CustomSurveyQuestionCheckbox';
|
|
7
|
+
import './Questions/CustomSurveyQuestionComment';
|
|
8
|
+
import './Questions/CustomSurveyQuestionDropdown';
|
|
9
|
+
import './Questions/CustomSurveyQuestionRadioGroup';
|
|
10
|
+
import './Questions/CustomSurveyQuestionText';
|
|
11
|
+
import { SurveyProps } from './Survey.types';
|
|
12
|
+
export declare const Survey: React.FC<SurveyProps>;
|
|
13
|
+
//# sourceMappingURL=Survey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Survey.d.ts","sourceRoot":"","sources":["../../../src/frontend/Survey.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAe1E,OAAO,yCAAyC,CAAC;AACjD,OAAO,8BAA8B,CAAC;AACtC,OAAO,iCAAiC,CAAC;AACzC,OAAO,yCAAyC,CAAC;AACjD,OAAO,0CAA0C,CAAC;AAClD,OAAO,yCAAyC,CAAC;AACjD,OAAO,0CAA0C,CAAC;AAClD,OAAO,4CAA4C,CAAC;AACpD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAwB,WAAW,EAAe,MAAM,gBAAgB,CAAC;AA2EhF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAkExC,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { startTransition, useActionState, useEffect } from 'react';
|
|
3
|
+
import { Model as SurveyJsModel } from 'survey-core';
|
|
4
|
+
import { Survey as SurveySDK } from 'survey-react-ui';
|
|
5
|
+
import { cn } from '@o2s/ui/lib/utils';
|
|
6
|
+
import { toast } from '@o2s/ui/hooks/use-toast';
|
|
7
|
+
import { Loading } from '@o2s/ui/components/Loading';
|
|
8
|
+
import { LoadingOverlay } from '@o2s/ui/elements/loading-overlay';
|
|
9
|
+
import { sdk } from '../sdk';
|
|
10
|
+
import './Elements/CustomSurveyNavigationButton';
|
|
11
|
+
import './Elements/CustomSurveyPanel';
|
|
12
|
+
import './Elements/CustomSurveyQuestion';
|
|
13
|
+
import './Questions/CustomSurveyQuestionBoolean';
|
|
14
|
+
import './Questions/CustomSurveyQuestionCheckbox';
|
|
15
|
+
import './Questions/CustomSurveyQuestionComment';
|
|
16
|
+
import './Questions/CustomSurveyQuestionDropdown';
|
|
17
|
+
import './Questions/CustomSurveyQuestionRadioGroup';
|
|
18
|
+
import './Questions/CustomSurveyQuestionText';
|
|
19
|
+
const initialState = {
|
|
20
|
+
isLoading: true,
|
|
21
|
+
error: null,
|
|
22
|
+
model: null,
|
|
23
|
+
};
|
|
24
|
+
const createSurveyModel = (schema, locale, onComplete) => {
|
|
25
|
+
const survey = new SurveyJsModel(schema);
|
|
26
|
+
survey.loadingHtml = '';
|
|
27
|
+
survey.locale = locale;
|
|
28
|
+
survey.css = {
|
|
29
|
+
root: 'bg-transparent text-sm md:text-base [&>*]:[&>*:last-child]:hidden',
|
|
30
|
+
body: '!m-0 box-border',
|
|
31
|
+
header: 'pb-8',
|
|
32
|
+
title: 'scroll-m-20 text-lg md:text-2xl font-semibold tracking-tight first:mt-0',
|
|
33
|
+
description: 'text-base text-muted-foreground font-inherit',
|
|
34
|
+
footer: 'flex flex-wrap gap-8 justify-end mt-6 !p-0 [&_.sv-action--hidden]:hidden',
|
|
35
|
+
page: {
|
|
36
|
+
root: '',
|
|
37
|
+
title: 'scroll-m-20 text-base md:text-xl font-semibold tracking-tight',
|
|
38
|
+
description: 'text-base text-muted-foreground font-inherit',
|
|
39
|
+
},
|
|
40
|
+
row: '!w-full mt-4 first:mt-0 flex flex-row flex-wrap md:!flex-nowrap [.sd-row--multiple]:!gap-4 !ml-0 [&>*]:!p-0',
|
|
41
|
+
pageRow: 'mt-4',
|
|
42
|
+
dropdown: {
|
|
43
|
+
root: 'text-sm',
|
|
44
|
+
control: 'pl-3 pr-12 h-10 m-0 border border-input rounded-md shadow-none flex space-between text-sm bg-background',
|
|
45
|
+
controlValue: cn(survey.css.dropdown.controlValue, '!text-sm w-full truncate flex items-center !font-[Inter] font-sans font-normal'),
|
|
46
|
+
filterStringInput: cn(survey.css.dropdown.filterStringInput, '!text-sm !text-foreground !font-[Inter] font-sans font-normal'),
|
|
47
|
+
},
|
|
48
|
+
list: {
|
|
49
|
+
itemBody: 'p-2 hover:bg-accent rounded-md text-base',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
survey.onGetTitleTagName.add((_model, options) => {
|
|
53
|
+
switch (options.element.getType()) {
|
|
54
|
+
case 'survey':
|
|
55
|
+
options.tagName = 'h2';
|
|
56
|
+
break;
|
|
57
|
+
case 'page':
|
|
58
|
+
options.tagName = 'h3';
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
survey.onComplete.add((model) => onComplete(model.data));
|
|
63
|
+
return survey;
|
|
64
|
+
};
|
|
65
|
+
const handleError = (error, labels) => {
|
|
66
|
+
toast({
|
|
67
|
+
variant: 'destructive',
|
|
68
|
+
title: labels.errors.requestError.title,
|
|
69
|
+
description: labels.errors.requestError.content,
|
|
70
|
+
});
|
|
71
|
+
return error instanceof Error ? error.message : 'Unknown error';
|
|
72
|
+
};
|
|
73
|
+
export const Survey = ({ code, labels, locale, accessToken }) => {
|
|
74
|
+
const [state, dispatch] = useActionState((prevState, action) => {
|
|
75
|
+
switch (action.type) {
|
|
76
|
+
case 'LOAD':
|
|
77
|
+
return { ...prevState, isLoading: true, error: null };
|
|
78
|
+
case 'ERROR':
|
|
79
|
+
return { ...prevState, isLoading: false, error: action.payload };
|
|
80
|
+
case 'SET_MODEL':
|
|
81
|
+
return { ...prevState, isLoading: false, model: action.payload };
|
|
82
|
+
default:
|
|
83
|
+
return prevState;
|
|
84
|
+
}
|
|
85
|
+
}, initialState);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const handleSubmit = async (data) => {
|
|
88
|
+
startTransition(async () => {
|
|
89
|
+
try {
|
|
90
|
+
await sdk.modules.submitSurvey({
|
|
91
|
+
code,
|
|
92
|
+
surveyPayload: data,
|
|
93
|
+
}, { 'x-locale': locale }, accessToken);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
handleError(error, labels);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const loadSurvey = async () => {
|
|
101
|
+
startTransition(async () => {
|
|
102
|
+
try {
|
|
103
|
+
dispatch({ type: 'LOAD' });
|
|
104
|
+
const { schema } = await sdk.modules.getSurvey({
|
|
105
|
+
code,
|
|
106
|
+
}, { 'x-locale': locale }, accessToken);
|
|
107
|
+
if (!schema) {
|
|
108
|
+
throw new Error(`No survey with code '${code}' found`);
|
|
109
|
+
}
|
|
110
|
+
const model = createSurveyModel(schema, locale, handleSubmit);
|
|
111
|
+
dispatch({ type: 'SET_MODEL', payload: model });
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
dispatch({ type: 'ERROR', payload: handleError(error, labels) });
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
loadSurvey();
|
|
119
|
+
}, [dispatch, code, locale, accessToken, labels]);
|
|
120
|
+
return (<LoadingOverlay isActive={state.isLoading} fallback={<Loading bars={12}/>}>
|
|
121
|
+
<div className={'min-h-[400px]'}>{state.model && <SurveySDK model={state.model}/>}</div>
|
|
122
|
+
</LoadingOverlay>);
|
|
123
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Model } from 'survey-core';
|
|
2
|
+
export interface SurveyProps {
|
|
3
|
+
code: string;
|
|
4
|
+
locale: string;
|
|
5
|
+
accessToken?: string;
|
|
6
|
+
labels: Labels;
|
|
7
|
+
}
|
|
8
|
+
export type SurveyState = {
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
error: string | null;
|
|
11
|
+
model: Model | null;
|
|
12
|
+
};
|
|
13
|
+
export type SurveyAction = {
|
|
14
|
+
type: 'LOAD';
|
|
15
|
+
} | {
|
|
16
|
+
type: 'ERROR';
|
|
17
|
+
payload: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'SET_MODEL';
|
|
20
|
+
payload: Model;
|
|
21
|
+
};
|
|
22
|
+
export interface ErrorLabels {
|
|
23
|
+
title: string;
|
|
24
|
+
content?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface Labels {
|
|
27
|
+
errors: {
|
|
28
|
+
requestError: ErrorLabels;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=Survey.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Survey.types.d.ts","sourceRoot":"","sources":["../../../src/frontend/Survey.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,WAAW,GAAG;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAClB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAE5C,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACnB,MAAM,EAAE;QACJ,YAAY,EAAE,WAAW,CAAC;KAC7B,CAAC;CACL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frontend/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Survey } from './Survey';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Models } from '@o2s/utils.api-harmonization';
|
|
2
|
+
export declare const sdk: import("@o2s/framework/sdk").Sdk & {
|
|
3
|
+
modules: {
|
|
4
|
+
getSurvey: (params: import("../api-harmonization/surveyjs.request").SurveyJsQuery, headers: Models.Headers.AppHeaders, authorization?: string) => Promise<import("../api-harmonization/surveyjs.model").SurveyJs>;
|
|
5
|
+
submitSurvey: (params: import("../api-harmonization/surveyjs.request").SurveyJsSubmitPayload, headers: Models.Headers.AppHeaders, authorization?: string) => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAqBtD,eAAO,MAAM,GAAG;;;;;CAKd,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { extendSdk, getSdk } from '@o2s/framework/sdk';
|
|
2
|
+
import { surveyjs } from './surveyjs';
|
|
3
|
+
const API_URL = (typeof window === 'undefined' ? process.env.NEXT_PUBLIC_API_URL_INTERNAL : process.env.NEXT_PUBLIC_API_URL) ||
|
|
4
|
+
process.env.NEXT_PUBLIC_API_URL;
|
|
5
|
+
const internalSdk = getSdk({
|
|
6
|
+
apiUrl: API_URL,
|
|
7
|
+
logger: {
|
|
8
|
+
// @ts-expect-error missing types
|
|
9
|
+
level: process.env.NEXT_PUBLIC_LOG_LEVEL,
|
|
10
|
+
// @ts-expect-error missing types
|
|
11
|
+
format: process.env.NEXT_PUBLIC_LOG_FORMAT,
|
|
12
|
+
colorsEnabled: process.env.NEXT_PUBLIC_LOG_COLORS_ENABLED === 'true',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
export const sdk = extendSdk(internalSdk, {
|
|
16
|
+
modules: {
|
|
17
|
+
getSurvey: surveyjs(internalSdk).modules.getSurvey,
|
|
18
|
+
submitSurvey: surveyjs(internalSdk).modules.submitSurvey,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Models as ApiModels } from '@o2s/utils.api-harmonization';
|
|
2
|
+
import { Sdk } from '@o2s/framework/sdk';
|
|
3
|
+
import { Model, Request } from '../api-harmonization/surveyjs.client';
|
|
4
|
+
export declare const surveyjs: (sdk: Sdk) => {
|
|
5
|
+
modules: {
|
|
6
|
+
getSurvey: (params: Request.SurveyJsQuery, headers: ApiModels.Headers.AppHeaders, authorization?: string) => Promise<Model.SurveyJs>;
|
|
7
|
+
submitSurvey: (params: Request.SurveyJsSubmitPayload, headers: ApiModels.Headers.AppHeaders, authorization?: string) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=surveyjs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surveyjs.d.ts","sourceRoot":"","sources":["../../../src/sdk/surveyjs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAO,MAAM,sCAAsC,CAAC;AAI3E,eAAO,MAAM,QAAQ,GAAI,KAAK,GAAG;;4BAGb,OAAO,CAAC,aAAa,WACpB,SAAS,CAAC,OAAO,CAAC,UAAU,kBACrB,MAAM,KACvB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;+BAiBd,OAAO,CAAC,qBAAqB,WAC5B,SAAS,CAAC,OAAO,CAAC,UAAU,kBACrB,MAAM,KACvB,OAAO,CAAC,IAAI,CAAC;;CAgBtB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Utils } from '@o2s/utils.frontend';
|
|
2
|
+
import { URL } from '../api-harmonization/surveyjs.client';
|
|
3
|
+
const API_URL = URL;
|
|
4
|
+
export const surveyjs = (sdk) => ({
|
|
5
|
+
modules: {
|
|
6
|
+
getSurvey: (params, headers, authorization) => sdk.makeRequest({
|
|
7
|
+
method: 'get',
|
|
8
|
+
url: API_URL,
|
|
9
|
+
headers: {
|
|
10
|
+
...Utils.Headers.getApiHeaders(),
|
|
11
|
+
...headers,
|
|
12
|
+
...(authorization
|
|
13
|
+
? {
|
|
14
|
+
Authorization: `Bearer ${authorization}`,
|
|
15
|
+
}
|
|
16
|
+
: {}),
|
|
17
|
+
},
|
|
18
|
+
params: params,
|
|
19
|
+
}),
|
|
20
|
+
submitSurvey: (params, headers, authorization) => sdk.makeRequest({
|
|
21
|
+
method: 'post',
|
|
22
|
+
url: API_URL,
|
|
23
|
+
headers: {
|
|
24
|
+
...Utils.Headers.getApiHeaders(),
|
|
25
|
+
...headers,
|
|
26
|
+
...(authorization
|
|
27
|
+
? {
|
|
28
|
+
Authorization: `Bearer ${authorization}`,
|
|
29
|
+
}
|
|
30
|
+
: {}),
|
|
31
|
+
},
|
|
32
|
+
data: params,
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surveyjs.client.d.ts","sourceRoot":"","sources":["../../../src/api-harmonization/surveyjs.client.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG,cAAc,CAAC;AAE/B,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Model = exports.Request = exports.URL = void 0;
|
|
37
|
+
exports.URL = '/surveyjs';
|
|
38
|
+
exports.Request = __importStar(require("./surveyjs.request"));
|
|
39
|
+
exports.Model = __importStar(require("./surveyjs.model"));
|
|
40
|
+
//# sourceMappingURL=surveyjs.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surveyjs.client.js","sourceRoot":"","sources":["../../../src/api-harmonization/surveyjs.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAa,QAAA,GAAG,GAAG,WAAW,CAAC;AAE/B,8DAA8C;AAC9C,0DAA0C"}
|