@zimbra/api-client 98.0.0 → 100.0.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.
Files changed (36) hide show
  1. package/.babelrc.json +1 -2
  2. package/dist/schema.graphql +37 -3
  3. package/dist/src/apollo/local-batch-link.d.ts +0 -1
  4. package/dist/src/apollo/offline-queue-link/index.d.ts +1 -4
  5. package/dist/src/batch-client/index.d.ts +4 -1
  6. package/dist/src/batch-client/types.d.ts +2 -1
  7. package/dist/src/normalize/entities.d.ts +1 -0
  8. package/dist/src/normalize/index.d.ts +1 -1
  9. package/dist/src/request/types.d.ts +0 -1
  10. package/dist/src/schema/generated-schema-types.d.ts +38 -2
  11. package/dist/src/utils/map-values-deep.d.ts +1 -0
  12. package/dist/zm-api-js-client.esm.js +660 -355
  13. package/dist/zm-api-js-client.esm.js.map +1 -1
  14. package/dist/zm-api-js-client.js +8 -8
  15. package/dist/zm-api-js-client.js.map +1 -1
  16. package/dist/zm-api-js-client.umd.js +8 -8
  17. package/dist/zm-api-js-client.umd.js.map +1 -1
  18. package/package-lock.json +832 -1399
  19. package/package.json +6 -6
  20. package/rollup.config.js +1 -1
  21. package/src/apollo/offline-queue-link/util.ts +1 -2
  22. package/src/apollo/zimbra-error-link.ts +4 -3
  23. package/src/apollo/zimbra-in-memory-cache.ts +38 -8
  24. package/src/batch-client/index.ts +74 -44
  25. package/src/batch-client/types.ts +2 -1
  26. package/src/normalize/entities.ts +10 -3
  27. package/src/normalize/index.ts +42 -39
  28. package/src/request/index.ts +36 -48
  29. package/src/request/types.ts +0 -1
  30. package/src/schema/generated-schema-types.ts +41 -2
  31. package/src/schema/schema.graphql +37 -3
  32. package/src/schema/schema.ts +3 -2
  33. package/src/schema/session-handler.ts +1 -2
  34. package/src/utils/map-values-deep.ts +10 -2
  35. package/src/utils/normalize-attrs-custommetadata.ts +5 -6
  36. package/src/utils/normalize-otherAttribute-contact.ts +29 -19
@@ -1,6 +1,4 @@
1
- import concat from 'lodash/concat';
2
- import differenceBy from 'lodash/differenceBy';
3
- import forEach from 'lodash/forEach';
1
+ import { differenceBy } from 'es-toolkit';
4
2
  import { denormalize } from '../normalize';
5
3
  import { ContactInputRequest } from '../normalize/entities';
6
4
 
@@ -102,19 +100,29 @@ export function createContactBody(data: any, isDesktop: Boolean) {
102
100
  const { attributes, ...rest } = data;
103
101
  const contactAttrs = <Object[]>[];
104
102
 
105
- forEach(attributes, (val, key) =>
106
- key !== 'other'
107
- ? contactAttrs.push({
108
- name: key,
109
- [key === 'image' || (!isDesktop && key === 'userCertificate') ? 'aid' : 'content']: val
110
- })
111
- : forEach(val, otherValue =>
103
+ for (const [key, val] of Object.entries(attributes)) {
104
+ if (key !== 'other') {
105
+ contactAttrs.push({
106
+ name: key,
107
+ [key === 'image' || (!isDesktop && key === 'userCertificate') ? 'aid' : 'content']: val
108
+ });
109
+ } else if (Array.isArray(val)) {
110
+ for (const otherValue of val) {
111
+ if (
112
+ typeof otherValue === 'object' &&
113
+ otherValue !== null &&
114
+ 'key' in otherValue &&
115
+ 'value' in otherValue
116
+ ) {
117
+ const { key: otherKey, value: otherVal } = otherValue as { key: string; value: unknown };
112
118
  contactAttrs.push({
113
- name: otherValue.key,
114
- _content: otherValue.value
115
- })
116
- )
117
- );
119
+ name: otherKey,
120
+ _content: otherVal
121
+ });
122
+ }
123
+ }
124
+ }
125
+ }
118
126
  return {
119
127
  cn: denormalize(ContactInputRequest)({
120
128
  ...rest,
@@ -162,15 +170,17 @@ export function normalizeOtherAttr(data: any) {
162
170
  (a: any, b: any) => Number(a.key.match(/(\d+)/g)[0]) - Number(b.key.match(/(\d+)/g)[0])
163
171
  );
164
172
 
165
- const remainingOtherAttribute = differenceBy(other, otherAttributewithCustomKey, 'key').sort(
166
- (a: any, b: any) => a.key.localeCompare(b.key)
167
- );
173
+ const remainingOtherAttribute = differenceBy(
174
+ other || [],
175
+ otherAttributewithCustomKey || [],
176
+ (item: any) => item.key
177
+ ).sort((a: any, b: any) => a.key.localeCompare(b.key));
168
178
 
169
179
  return {
170
180
  ...contact,
171
181
  _attrs: {
172
182
  ...contact._attrs,
173
- other: concat(otherAttributewithCustomKey, remainingOtherAttribute)
183
+ other: (otherAttributewithCustomKey || []).concat(remainingOtherAttribute || [])
174
184
  }
175
185
  };
176
186
  });