@verdocs/js-sdk 4.2.148 → 5.0.2
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/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -23
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +2 -2
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2951,31 +2951,34 @@ const getTemplates = (endpoint, params) => endpoint.api //
|
|
|
2951
2951
|
* const template = await getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
|
|
2952
2952
|
* ```
|
|
2953
2953
|
*/
|
|
2954
|
-
const getTemplate = (endpoint, templateId) =>
|
|
2955
|
-
|
|
2956
|
-
.
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
template
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
if (!document.order) {
|
|
2965
|
-
document.order = 0;
|
|
2966
|
-
}
|
|
2967
|
-
if (document.page_numbers) {
|
|
2968
|
-
document.pages = document.page_numbers;
|
|
2969
|
-
}
|
|
2970
|
-
});
|
|
2971
|
-
// Temporary upgrade from legacy app
|
|
2972
|
-
template.fields?.forEach((field) => {
|
|
2973
|
-
if (field.setting) {
|
|
2974
|
-
field.settings = field.setting;
|
|
2954
|
+
const getTemplate = (endpoint, templateId) => {
|
|
2955
|
+
window?.console?.log('[JS_SDK] Loading template', templateId);
|
|
2956
|
+
return endpoint.api //
|
|
2957
|
+
.get(`/v2/templates/${templateId}`)
|
|
2958
|
+
.then((r) => {
|
|
2959
|
+
const template = r.data;
|
|
2960
|
+
window?.console?.log('[JS_SDK] Post-processing template', template);
|
|
2961
|
+
// Post-process the template to upgrade to new data fields
|
|
2962
|
+
if (!template.documents && template.template_documents) {
|
|
2963
|
+
template.documents = template.template_documents;
|
|
2975
2964
|
}
|
|
2965
|
+
template.documents?.forEach((document) => {
|
|
2966
|
+
if (!document.order) {
|
|
2967
|
+
document.order = 0;
|
|
2968
|
+
}
|
|
2969
|
+
if (document.page_numbers) {
|
|
2970
|
+
document.pages = document.page_numbers;
|
|
2971
|
+
}
|
|
2972
|
+
});
|
|
2973
|
+
// Temporary upgrade from legacy app
|
|
2974
|
+
template.fields?.forEach((field) => {
|
|
2975
|
+
if (field.setting) {
|
|
2976
|
+
field.settings = field.setting;
|
|
2977
|
+
}
|
|
2978
|
+
});
|
|
2979
|
+
return template;
|
|
2976
2980
|
});
|
|
2977
|
-
|
|
2978
|
-
});
|
|
2981
|
+
};
|
|
2979
2982
|
const ALLOWED_CREATE_FIELDS = [
|
|
2980
2983
|
'name',
|
|
2981
2984
|
'is_personal',
|