@verdocs/js-sdk 4.1.0 → 4.1.1

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.mjs CHANGED
@@ -1217,7 +1217,19 @@ const getEnvelopeRecipients = async (endpoint, envelopeId) => endpoint.api //
1217
1217
  */
1218
1218
  const getEnvelope = async (endpoint, envelopeId) => endpoint.api //
1219
1219
  .get(`/envelopes/${envelopeId}`)
1220
- .then((r) => r.data);
1220
+ .then((r) => {
1221
+ const envelope = r.data;
1222
+ // Post-process the envelope to upgrade to new data fields
1223
+ envelope.documents?.forEach((document) => {
1224
+ if (!document.order) {
1225
+ document.order = 0;
1226
+ }
1227
+ if (document.page_numbers) {
1228
+ document.pages = document.page_numbers;
1229
+ }
1230
+ });
1231
+ return envelope;
1232
+ });
1221
1233
  /**
1222
1234
  * Get an Envelope Document
1223
1235
  */
@@ -2140,7 +2152,27 @@ const getTemplates = (endpoint, params) => endpoint.api //
2140
2152
  */
2141
2153
  const getTemplate = (endpoint, templateId) => endpoint.api //
2142
2154
  .get(`/templates/${templateId}`)
2143
- .then((r) => r.data);
2155
+ .then((r) => {
2156
+ const template = r.data;
2157
+ // Post-process the template to upgrade to new data fields
2158
+ if (!template.documents && template.template_documents) {
2159
+ template.documents = template.template_documents;
2160
+ }
2161
+ template.documents?.forEach((document) => {
2162
+ if (!document.order) {
2163
+ document.order = 0;
2164
+ }
2165
+ if (document.page_numbers) {
2166
+ document.pages = document.page_numbers;
2167
+ }
2168
+ });
2169
+ template.fields?.forEach((field) => {
2170
+ if (field.setting) {
2171
+ field.settings = field.setting;
2172
+ }
2173
+ });
2174
+ return template;
2175
+ });
2144
2176
  /**
2145
2177
  * Get owner information for a template.
2146
2178
  *