n8n-nodes-netsapiens 0.2.5 → 0.2.6

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 David Szpunar
3
+ Copyright (c) 2023 David Szpunar
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -172,6 +172,10 @@ const validateUserCredsClientSecretParam = `${validateUserCredsOperationId}__cli
172
172
  const templatedUserResource = 'Users';
173
173
  const createUserRequiredFields = ['user', 'name-first-name', 'name-last-name', 'email-address', 'user-scope'];
174
174
  const updateUserRequiredFields = ['name-first-name', 'name-last-name', 'email-address', 'user-scope'];
175
+ const clearableUpdateFields = new Set(['name-first-name', 'name-last-name', 'email-address']);
176
+ function clearFieldToggleKey(operationId, fieldName) {
177
+ return operationKey(operationId, `clear__${fieldName}`);
178
+ }
175
179
  const mediaTtsOperationIds = new Set([
176
180
  'CreateMohDomainTTS', 'UpdateMohDomainTTS',
177
181
  'CreateMohUserTTS', 'UpdateMohUserTTS',
@@ -560,7 +564,7 @@ const userCommonFields = [
560
564
  {
561
565
  displayName: 'Caller ID Number',
562
566
  name: 'caller-id-number',
563
- type: 'number',
567
+ type: 'string',
564
568
  default: '',
565
569
  },
566
570
  {
@@ -657,7 +661,6 @@ const userCommonFields = [
657
661
  ];
658
662
  const numericUserFields = new Set([
659
663
  'area-code',
660
- 'caller-id-number',
661
664
  'caller-id-number-emergency',
662
665
  'directory-name-number-dtmf-mapping',
663
666
  'directory-override-order-duplicate-dtmf-mapping',
@@ -930,7 +933,7 @@ function buildTemplatedUserFields() {
930
933
  : field.options;
931
934
  const updateDefault = isOptionsField ? '__USE_CURRENT__' : field.default;
932
935
  const updateDescription = isRequired
933
- ? `${field.description ? `${field.description} ` : ''}Required. Leave empty to keep the current value`
936
+ ? `${field.description ? `${field.description} ` : ''}Leave empty to keep the current value`
934
937
  : field.description;
935
938
  if (field.name === 'site') {
936
939
  fields.push({
@@ -1025,17 +1028,41 @@ function buildTemplatedUserFields() {
1025
1028
  });
1026
1029
  continue;
1027
1030
  }
1028
- fields.push({
1029
- displayName: field.displayName,
1030
- name: operationBodyFieldKey(templatedUserUpdateId, field.name),
1031
- type: field.type,
1032
- default: updateDefault,
1033
- required: isRequired,
1034
- displayOptions: { show: shouldShow },
1035
- description: updateDescription,
1036
- options: updateOptions,
1037
- typeOptions: field.typeOptions,
1038
- });
1031
+ const isClearable = clearableUpdateFields.has(field.name);
1032
+ if (isClearable) {
1033
+ const clearToggleName = clearFieldToggleKey(templatedUserUpdateId, field.name);
1034
+ fields.push({
1035
+ displayName: `Clear ${field.displayName}`,
1036
+ name: clearToggleName,
1037
+ type: 'boolean',
1038
+ default: false,
1039
+ displayOptions: { show: shouldShow },
1040
+ description: `Whether to clear the ${field.displayName.toLowerCase()} field (send empty value to the API)`,
1041
+ });
1042
+ fields.push({
1043
+ displayName: field.displayName,
1044
+ name: operationBodyFieldKey(templatedUserUpdateId, field.name),
1045
+ type: field.type,
1046
+ default: updateDefault,
1047
+ displayOptions: { show: { ...shouldShow, [clearToggleName]: [false] } },
1048
+ description: updateDescription,
1049
+ options: updateOptions,
1050
+ typeOptions: field.typeOptions,
1051
+ });
1052
+ }
1053
+ else {
1054
+ fields.push({
1055
+ displayName: field.displayName,
1056
+ name: operationBodyFieldKey(templatedUserUpdateId, field.name),
1057
+ type: field.type,
1058
+ default: updateDefault,
1059
+ required: isRequired,
1060
+ displayOptions: { show: shouldShow },
1061
+ description: updateDescription,
1062
+ options: updateOptions,
1063
+ typeOptions: field.typeOptions,
1064
+ });
1065
+ }
1039
1066
  }
1040
1067
  fields.push({
1041
1068
  displayName: 'Domain',
@@ -1373,6 +1400,13 @@ function buildTemplatedBody(context, itemIndex, operationId, requiredFields, opt
1373
1400
  if ((_a = options.readOnlyFields) === null || _a === void 0 ? void 0 : _a.has(fieldName)) {
1374
1401
  continue;
1375
1402
  }
1403
+ if (clearableUpdateFields.has(fieldName)) {
1404
+ const clearToggle = context.getNodeParameter(clearFieldToggleKey(operationId, fieldName), itemIndex, false);
1405
+ if (clearToggle) {
1406
+ body[fieldName] = '';
1407
+ continue;
1408
+ }
1409
+ }
1376
1410
  const raw = context.getNodeParameter(operationBodyFieldKey(operationId, fieldName), itemIndex, '');
1377
1411
  const normalizedRaw = raw && typeof raw === 'object' && 'value' in raw
1378
1412
  ? extractLocatorValue(raw)
@@ -1396,9 +1430,11 @@ function buildTemplatedBody(context, itemIndex, operationId, requiredFields, opt
1396
1430
  }
1397
1431
  body[fieldName] = value;
1398
1432
  }
1399
- for (const requiredField of requiredFields) {
1400
- if (body[requiredField] === undefined) {
1401
- throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Missing required field: ${requiredField}`, { itemIndex });
1433
+ if (options.strictRequired !== false) {
1434
+ for (const requiredField of requiredFields) {
1435
+ if (body[requiredField] === undefined) {
1436
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Missing required field: ${requiredField}`, { itemIndex });
1437
+ }
1402
1438
  }
1403
1439
  }
1404
1440
  if (options.includeSynchronous) {
@@ -4285,6 +4321,7 @@ class NetSapiens {
4285
4321
  body = buildTemplatedBody(this, itemIndex, templatedUserUpdateId, updateUserRequiredFields, {
4286
4322
  includeSynchronous: false,
4287
4323
  readOnlyFields: userUpdateReadOnlyFields,
4324
+ strictRequired: false,
4288
4325
  });
4289
4326
  }
4290
4327
  const requestOptions = {