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