@zohodesk/library-platform 1.2.0 → 1.2.2-exp.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.
Files changed (26) hide show
  1. package/es/cc/table-connected/SdkContract.js +28 -3
  2. package/es/cc/table-list/Properties.js +9 -8
  3. package/es/cc/table-list/row/Properties.js +19 -6
  4. package/es/index.js +6 -2
  5. package/es/library/custom-component/frameworks/json-schema-validator/Validator.js +57 -44
  6. package/es/library/custom-component/frameworks/json-schema-validator/__generated__/registry.d.js +1 -0
  7. package/es/library/custom-component/frameworks/json-schema-validator/__generated__/registry.js +92 -0
  8. package/es/library/custom-component/frameworks/json-schema-validator/__generated__/validators.js +1 -0
  9. package/es/library/custom-component/frameworks/json-schema-validator/__tests__/Validator.test.js +478 -0
  10. package/es/library/custom-component/frameworks/ui/DependencyFactory.js +16 -0
  11. package/es/platform/client-actions/behaviour/zclient-actions/adapters/presenters/FilterUtils.js +11 -0
  12. package/es/platform/client-actions/behaviour/zclient-actions/adapters/resources/ClientActionsFetchSDK.js +76 -0
  13. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/ClientActionsAPIGatewayParams.js +1 -0
  14. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/ClientActionsFetchSDKParams.js +10 -0
  15. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/IClientActionsFetchSDK.js +0 -0
  16. package/es/platform/client-actions/cc/action-event-mediator/Properties.js +18 -4
  17. package/es/platform/client-scripts/behaviour/zclient-scripts-fetch/adapters/resources/ClientScriptsFetchSDK.js +43 -0
  18. package/es/platform/client-scripts/behaviour/zclient-scripts-fetch/applications/interfaces/ClientScriptsAPIGatewayParams.js +1 -0
  19. package/es/platform/client-scripts/behaviour/zclient-scripts-fetch/applications/interfaces/ClientScriptsSDKFetchParams.js +1 -0
  20. package/es/platform/client-scripts/behaviour/zclient-scripts-fetch/applications/interfaces/IClientScriptsFetchSDK.js +0 -0
  21. package/es/platform/components/smart-action-band/adapters/presenters/ActionBandTranslator.js +7 -4
  22. package/es/platform/data-source/http-template/getPageClientActions.js +23 -0
  23. package/es/platform/zform/adapters/presenter/FormTranslator.js +18 -15
  24. package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +1 -1
  25. package/es/platform/zlist/adapters/presenters/TableTranslator.js +5 -4
  26. package/package.json +6 -4
@@ -0,0 +1,478 @@
1
+ import Validator from "../Validator"; // Schemas extracted from src/cc/table-connected/Properties.ts
2
+
3
+ const preferencesSchema = {
4
+ type: 'object',
5
+ properties: {
6
+ rowActions: {
7
+ type: 'object',
8
+ additionalProperties: {
9
+ width: {
10
+ type: 'string'
11
+ }
12
+ }
13
+ },
14
+ fields: {
15
+ type: 'object',
16
+ additionalProperties: {
17
+ type: 'object',
18
+ properties: {
19
+ initialWidth: {
20
+ type: 'number'
21
+ },
22
+ currencyLocale: {
23
+ type: 'string'
24
+ },
25
+ currencySymbol: {
26
+ type: 'string'
27
+ }
28
+ }
29
+ }
30
+ },
31
+ autoColumnSizing: {
32
+ type: 'boolean'
33
+ }
34
+ }
35
+ };
36
+ const moduleNameSchema = {
37
+ type: 'string'
38
+ };
39
+ const textOverflowConfigSchema = {
40
+ type: 'object',
41
+ properties: {
42
+ isEnabled: {
43
+ type: 'boolean'
44
+ },
45
+ mode: {
46
+ type: 'string',
47
+ enum: ['clip', 'wrap']
48
+ }
49
+ }
50
+ };
51
+ const nameFieldsConfigSchema = {
52
+ type: 'object'
53
+ };
54
+ const componentMappingSchema = {
55
+ type: 'object',
56
+ properties: {
57
+ fields: {
58
+ type: 'object'
59
+ },
60
+ rowActionsComponentName: {
61
+ type: 'string'
62
+ },
63
+ emptyState: {
64
+ type: 'string'
65
+ }
66
+ }
67
+ };
68
+ const selectionConfigSchema = {
69
+ type: 'object',
70
+ properties: {
71
+ isEnabled: {
72
+ type: 'boolean'
73
+ },
74
+ maxSelectionCount: {
75
+ type: 'number'
76
+ },
77
+ limitExceedAlertMessage: {
78
+ type: 'string'
79
+ },
80
+ isSelectAllEnabled: {
81
+ type: 'boolean'
82
+ }
83
+ }
84
+ };
85
+ describe('Validator', () => {
86
+ describe('validate() — direct schema (no schema.schema)', () => {
87
+ it('should return valid for a correct object value', () => {
88
+ const result = Validator.validate(preferencesSchema, {
89
+ fields: {},
90
+ autoColumnSizing: false
91
+ });
92
+ expect(result.isValid).toBe(true);
93
+ expect(result.errors).toEqual([]);
94
+ expect(result.warnings).toEqual([]);
95
+ });
96
+ it('should return invalid when a property has wrong type', () => {
97
+ const result = Validator.validate(preferencesSchema, {
98
+ fields: 'not-an-object',
99
+ autoColumnSizing: false
100
+ });
101
+ expect(result.isValid).toBe(false);
102
+ expect(result.errors.length).toBeGreaterThan(0);
103
+ });
104
+ it('should return valid for a correct string value', () => {
105
+ const result = Validator.validate(moduleNameSchema, 'deals');
106
+ expect(result.isValid).toBe(true);
107
+ expect(result.errors).toEqual([]);
108
+ });
109
+ it('should return invalid when string expected but number given', () => {
110
+ const result = Validator.validate(moduleNameSchema, 123);
111
+ expect(result.isValid).toBe(false);
112
+ expect(result.errors.length).toBeGreaterThan(0);
113
+ });
114
+ it('should return valid for a value matching an enum', () => {
115
+ const result = Validator.validate(textOverflowConfigSchema, {
116
+ isEnabled: true,
117
+ mode: 'clip'
118
+ });
119
+ expect(result.isValid).toBe(true);
120
+ expect(result.errors).toEqual([]);
121
+ });
122
+ it('should return invalid for a value not in enum', () => {
123
+ const result = Validator.validate(textOverflowConfigSchema, {
124
+ isEnabled: true,
125
+ mode: 'scroll'
126
+ });
127
+ expect(result.isValid).toBe(false);
128
+ expect(result.errors.length).toBeGreaterThan(0);
129
+ expect(result.errors.some(e => e.keyword === 'enum')).toBe(true);
130
+ });
131
+ it('should return valid for nested object with additionalProperties', () => {
132
+ const result = Validator.validate(preferencesSchema, {
133
+ fields: {
134
+ name: {
135
+ initialWidth: 200,
136
+ currencyLocale: 'en-US'
137
+ }
138
+ },
139
+ autoColumnSizing: true
140
+ });
141
+ expect(result.isValid).toBe(true);
142
+ });
143
+ it('should return invalid for nested additionalProperties with wrong type', () => {
144
+ const result = Validator.validate(preferencesSchema, {
145
+ fields: {
146
+ name: {
147
+ initialWidth: 'wide'
148
+ }
149
+ }
150
+ });
151
+ expect(result.isValid).toBe(false);
152
+ expect(result.errors.length).toBeGreaterThan(0);
153
+ });
154
+ it('should return valid for a loose object schema with any object', () => {
155
+ const result = Validator.validate(nameFieldsConfigSchema, {
156
+ isEnabled: true,
157
+ isPreventDefault: false,
158
+ constructUrl: null,
159
+ extraProp: 'anything'
160
+ });
161
+ expect(result.isValid).toBe(true);
162
+ });
163
+ it('should return valid for selectionConfig with correct values', () => {
164
+ const result = Validator.validate(selectionConfigSchema, {
165
+ isEnabled: true,
166
+ maxSelectionCount: 50,
167
+ limitExceedAlertMessage: 'Maximum records selected',
168
+ isSelectAllEnabled: false
169
+ });
170
+ expect(result.isValid).toBe(true);
171
+ expect(result.errors).toEqual([]);
172
+ });
173
+ it('should return invalid for selectionConfig with wrong types', () => {
174
+ const result = Validator.validate(selectionConfigSchema, {
175
+ isEnabled: 'yes',
176
+ maxSelectionCount: 'fifty'
177
+ });
178
+ expect(result.isValid).toBe(false);
179
+ expect(result.errors.length).toBeGreaterThan(0);
180
+ });
181
+ it('should return valid for componentMapping with partial properties', () => {
182
+ const result = Validator.validate(componentMappingSchema, {
183
+ fields: {},
184
+ emptyState: 'NoDataComponent'
185
+ });
186
+ expect(result.isValid).toBe(true);
187
+ });
188
+ it('should return valid for an empty object when no properties are required', () => {
189
+ const result = Validator.validate(preferencesSchema, {});
190
+ expect(result.isValid).toBe(true);
191
+ });
192
+ });
193
+ describe('checkFunctionsRecursively() — function type handling', () => {
194
+ it('should return valid when value is a function for function type schema', () => {
195
+ const schema = {
196
+ type: 'function'
197
+ };
198
+ const result = Validator.validate(schema, () => {});
199
+ expect(result.isValid).toBe(true);
200
+ expect(result.errors).toEqual([]);
201
+ });
202
+ it('should return error when value is not a function for function type schema', () => {
203
+ const schema = {
204
+ type: 'function'
205
+ };
206
+ const result = Validator.validate(schema, 'not a function');
207
+ expect(result.isValid).toBe(false);
208
+ expect(result.errors).toEqual(expect.arrayContaining([expect.objectContaining({
209
+ keyword: 'type',
210
+ params: {
211
+ type: 'function'
212
+ },
213
+ message: 'should be function'
214
+ })]));
215
+ });
216
+ it('should validate nested function property in object schema', () => {
217
+ const schema = {
218
+ type: 'object',
219
+ properties: {
220
+ onClick: {
221
+ type: 'function'
222
+ },
223
+ label: {
224
+ type: 'string'
225
+ }
226
+ }
227
+ };
228
+ const result = Validator.validate(schema, {
229
+ onClick: () => {},
230
+ label: 'Click me'
231
+ });
232
+ expect(result.isValid).toBe(true);
233
+ expect(result.errors).toEqual([]);
234
+ });
235
+ it('should return error with correct dataPath for nested function property', () => {
236
+ const schema = {
237
+ type: 'object',
238
+ properties: {
239
+ onClick: {
240
+ type: 'function'
241
+ },
242
+ label: {
243
+ type: 'string'
244
+ }
245
+ }
246
+ };
247
+ const result = Validator.validate(schema, {
248
+ onClick: 'not a function',
249
+ label: 'Click me'
250
+ });
251
+ expect(result.isValid).toBe(false);
252
+ expect(result.errors).toEqual(expect.arrayContaining([expect.objectContaining({
253
+ keyword: 'type',
254
+ dataPath: '.onClick',
255
+ schemaPath: '#/properties/onClick/type',
256
+ message: 'should be function'
257
+ })]));
258
+ });
259
+ it('should validate function items in array schema', () => {
260
+ const schema = {
261
+ type: 'array',
262
+ items: {
263
+ type: 'function'
264
+ }
265
+ };
266
+
267
+ const fn1 = () => {};
268
+
269
+ const fn2 = () => {};
270
+
271
+ const result = Validator.validate(schema, [fn1, fn2]);
272
+ expect(result.isValid).toBe(true);
273
+ expect(result.errors).toEqual([]);
274
+ });
275
+ it('should return error for non-function item in array of functions', () => {
276
+ const schema = {
277
+ type: 'array',
278
+ items: {
279
+ type: 'function'
280
+ }
281
+ };
282
+ const result = Validator.validate(schema, [() => {}, 'not a function']);
283
+ expect(result.isValid).toBe(false);
284
+ expect(result.errors).toEqual(expect.arrayContaining([expect.objectContaining({
285
+ keyword: 'type',
286
+ dataPath: '.[1]',
287
+ message: 'should be function'
288
+ })]));
289
+ });
290
+ it('should validate deeply nested function in object > object', () => {
291
+ const schema = {
292
+ type: 'object',
293
+ properties: {
294
+ handlers: {
295
+ type: 'object',
296
+ properties: {
297
+ onMount: {
298
+ type: 'function'
299
+ }
300
+ }
301
+ }
302
+ }
303
+ };
304
+ const result = Validator.validate(schema, {
305
+ handlers: {
306
+ onMount: 42
307
+ }
308
+ });
309
+ expect(result.isValid).toBe(false);
310
+ expect(result.errors).toEqual(expect.arrayContaining([expect.objectContaining({
311
+ dataPath: '.handlers.onMount',
312
+ schemaPath: '#/properties/handlers/properties/onMount/type'
313
+ })]));
314
+ });
315
+ });
316
+ describe('validatePropertySchema() — property schema path (schema.schema exists)', () => {
317
+ it('should return valid with key for required property provided with correct value', () => {
318
+ const propertySchema = {
319
+ required: true,
320
+ isValueProvided: true,
321
+ name: 'moduleName',
322
+ schema: moduleNameSchema
323
+ };
324
+ const result = Validator.validate(propertySchema, 'deals');
325
+ expect(result.isValid).toBe(true);
326
+ expect(result.key).toBe('moduleName');
327
+ expect(result.errors).toEqual([]);
328
+ expect(result.warnings).toEqual([]);
329
+ });
330
+ it('should return invalid for required property provided with wrong type', () => {
331
+ const propertySchema = {
332
+ required: true,
333
+ isValueProvided: true,
334
+ name: 'moduleName',
335
+ schema: moduleNameSchema
336
+ };
337
+ const result = Validator.validate(propertySchema, 123);
338
+ expect(result.isValid).toBe(false);
339
+ expect(result.key).toBe('moduleName');
340
+ expect(result.errors.length).toBeGreaterThan(0);
341
+ });
342
+ it('should return valid with warning when required property missing but has default', () => {
343
+ const propertySchema = {
344
+ required: true,
345
+ isValueProvided: false,
346
+ defaultValue: {
347
+ isEnabled: true
348
+ },
349
+ name: 'keyboardControlsConfig',
350
+ schema: {
351
+ type: 'object',
352
+ properties: {
353
+ isEnabled: {
354
+ type: 'boolean'
355
+ }
356
+ }
357
+ }
358
+ };
359
+ const result = Validator.validate(propertySchema, undefined);
360
+ expect(result.isValid).toBe(true);
361
+ expect(result.errors).toEqual([]);
362
+ expect(result.warnings.length).toBeGreaterThan(0);
363
+ expect(result.warnings[0].message).toContain('Default value will be used');
364
+ });
365
+ it('should return invalid when required property missing and no default', () => {
366
+ const propertySchema = {
367
+ required: true,
368
+ isValueProvided: false,
369
+ name: 'moduleName',
370
+ schema: moduleNameSchema
371
+ };
372
+ const result = Validator.validate(propertySchema, undefined);
373
+ expect(result.isValid).toBe(false);
374
+ expect(result.errors.length).toBeGreaterThan(0);
375
+ expect(result.errors[0].message).toContain('required but missing');
376
+ });
377
+ it('should return invalid when required property missing and default is undefined', () => {
378
+ const propertySchema = {
379
+ required: true,
380
+ isValueProvided: false,
381
+ defaultValue: undefined,
382
+ name: 'testProp',
383
+ schema: moduleNameSchema
384
+ };
385
+ const result = Validator.validate(propertySchema, undefined);
386
+ expect(result.isValid).toBe(false);
387
+ expect(result.errors[0].message).toContain('default value is undefined');
388
+ });
389
+ it('should return valid with no warnings for optional property not provided', () => {
390
+ const propertySchema = {
391
+ required: false,
392
+ isValueProvided: false,
393
+ name: 'preferences',
394
+ defaultValue: {
395
+ fields: {},
396
+ autoColumnSizing: false
397
+ },
398
+ schema: preferencesSchema
399
+ };
400
+ const result = Validator.validate(propertySchema, undefined);
401
+ expect(result.isValid).toBe(true);
402
+ expect(result.errors).toEqual([]);
403
+ expect(result.warnings).toEqual([]);
404
+ });
405
+ it('should return invalid for optional property provided with invalid value', () => {
406
+ const propertySchema = {
407
+ required: false,
408
+ isValueProvided: true,
409
+ name: 'textOverflowConfig',
410
+ schema: textOverflowConfigSchema
411
+ };
412
+ const result = Validator.validate(propertySchema, {
413
+ isEnabled: true,
414
+ mode: 'invalid'
415
+ });
416
+ expect(result.isValid).toBe(false);
417
+ expect(result.key).toBe('textOverflowConfig');
418
+ expect(result.errors.length).toBeGreaterThan(0);
419
+ });
420
+ it('should return valid for optional property provided with valid value', () => {
421
+ const propertySchema = {
422
+ required: false,
423
+ isValueProvided: true,
424
+ name: 'textOverflowConfig',
425
+ schema: textOverflowConfigSchema
426
+ };
427
+ const result = Validator.validate(propertySchema, {
428
+ isEnabled: true,
429
+ mode: 'wrap'
430
+ });
431
+ expect(result.isValid).toBe(true);
432
+ expect(result.key).toBe('textOverflowConfig');
433
+ });
434
+ it('should validate componentMapping property schema with valid data', () => {
435
+ const propertySchema = {
436
+ required: false,
437
+ isValueProvided: true,
438
+ name: 'componentMapping',
439
+ defaultValue: {
440
+ fields: {},
441
+ emptyState: ''
442
+ },
443
+ schema: componentMappingSchema
444
+ };
445
+ const result = Validator.validate(propertySchema, {
446
+ fields: {
447
+ name: 'TextField'
448
+ },
449
+ rowActionsComponentName: 'RowActions',
450
+ emptyState: 'EmptyState'
451
+ });
452
+ expect(result.isValid).toBe(true);
453
+ expect(result.key).toBe('componentMapping');
454
+ });
455
+ });
456
+ describe('AJV useDefaults behavior', () => {
457
+ it('should fill in default values defined in schema', () => {
458
+ const schema = {
459
+ type: 'object',
460
+ properties: {
461
+ isEnabled: {
462
+ type: 'boolean',
463
+ default: true
464
+ },
465
+ mode: {
466
+ type: 'string',
467
+ default: 'clip'
468
+ }
469
+ }
470
+ };
471
+ const value = {};
472
+ const result = Validator.validate(schema, value);
473
+ expect(result.isValid).toBe(true);
474
+ expect(value.isEnabled).toBe(true);
475
+ expect(value.mode).toBe('clip');
476
+ });
477
+ });
478
+ });
@@ -4,12 +4,28 @@ import Controller from "../../adapters/controllers/Controller";
4
4
  import Repository from "../../adapters/gateways/repository/Repository";
5
5
  import Validator from "../json-schema-validator/Validator";
6
6
  import EventManager from "../../adapters/gateways/event-manager/EventManager";
7
+ // One-time registration of precompiled validators
8
+ let precompiledRegistered = false;
9
+
10
+ function ensurePrecompiledRegistered() {
11
+ if (precompiledRegistered) return;
12
+ precompiledRegistered = true;
13
+
14
+ try {
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ const registry = require("../json-schema-validator/__generated__/registry");
17
+
18
+ Validator.registerPrecompiled(registry.default || registry);
19
+ } catch (e) {// __generated__ not available (e.g., first build) — runtime fallback
20
+ }
21
+ }
7
22
 
8
23
  class DependencyFactory {
9
24
  static create(_ref, input) {
10
25
  let {
11
26
  updateState
12
27
  } = _ref;
28
+ ensurePrecompiledRegistered();
13
29
  const repository = new Repository();
14
30
  const presenter = new Presenter({
15
31
  updateState
@@ -0,0 +1,11 @@
1
+ function validateClientActionLocation(actualLocation, expectedLocation) {
2
+ return actualLocation === expectedLocation || actualLocation.endsWith(`.${expectedLocation}`);
3
+ }
4
+
5
+ function validateClientAction(clientAction, location) {
6
+ return clientAction.location && validateClientActionLocation(clientAction.location, location);
7
+ }
8
+
9
+ export function filterClientActionsByLocation(clientActions, location) {
10
+ return clientActions.filter(clientAction => clientAction && validateClientAction(clientAction, location));
11
+ }
@@ -0,0 +1,76 @@
1
+ import FetchGateWay from "../../../../../zhttp/adapters/gateway/FetchGateWay";
2
+ import APITemplate from "../../../../../zdata-source/domain/entities/APITemplate";
3
+ import getClientActions from "../../../../../data-source/http-template/getPageClientActions";
4
+ import TemplateHelpers from "../../../../../zdata-source/adapters/gateways/TemplateHelpers";
5
+
6
+ //TODO: Remove this SDK when smart page is ready for production
7
+ // Use this SDK only for fetching client actions at page level in desk_client_app until smart page is ready
8
+ class ClientActionsFetchSDK {
9
+ getClientActionsAPIDetails(args) {
10
+ const apiTemplate = new APITemplate(getClientActions, new TemplateHelpers());
11
+ const apiArgs = { ...args,
12
+ servicePrefix: 'supportapi/zd',
13
+ // @ts-ignore - custom property
14
+ orgName: window.currentOrg.portalName
15
+ };
16
+ const apiDetailsModel = apiTemplate.getApiDetails(apiArgs);
17
+ return { ...apiDetailsModel,
18
+ options: {
19
+ headers: {
20
+ // @ts-ignore - custom property
21
+ orgId: window.currentOrg.id
22
+ },
23
+ method: apiDetailsModel.method
24
+ }
25
+ };
26
+ }
27
+
28
+ mapClientActionsByInstanceLocation(clientActions) {
29
+ const filteredClientActionsMap = new Map();
30
+
31
+ for (const clientAction of clientActions) {
32
+ const {
33
+ location,
34
+ component
35
+ } = clientAction;
36
+ const locationPathArr = location.split('.');
37
+ const instanceName = locationPathArr[1] || component;
38
+ const locationName = locationPathArr[2] || location;
39
+
40
+ if (!instanceName || !locationName) {
41
+ continue;
42
+ }
43
+
44
+ if (!filteredClientActionsMap.has(instanceName)) {
45
+ filteredClientActionsMap.set(instanceName, {});
46
+ }
47
+
48
+ const instanceActions = filteredClientActionsMap.get(instanceName);
49
+
50
+ if (!instanceActions[locationName]) {
51
+ instanceActions[locationName] = [];
52
+ }
53
+
54
+ instanceActions[locationName].push(clientAction);
55
+ }
56
+
57
+ return filteredClientActionsMap;
58
+ }
59
+
60
+ async fetchClientActions(params) {
61
+ const apiDetails = this.getClientActionsAPIDetails(params);
62
+ const fetchGateway = new FetchGateWay(window.fetch.bind(window));
63
+ return new Promise((resolve, reject) => {
64
+ fetchGateway.fetch(apiDetails.url, apiDetails.options).then(response => response.json()).then(clientActions => {
65
+ this.clientActions = clientActions;
66
+ const filteredClientActionsMap = this.mapClientActionsByInstanceLocation(this.clientActions);
67
+ return resolve(filteredClientActionsMap);
68
+ }).catch(err => {
69
+ reject(err);
70
+ });
71
+ });
72
+ }
73
+
74
+ }
75
+
76
+ export default ClientActionsFetchSDK;
@@ -0,0 +1,10 @@
1
+ var ClientActionPage = /*#__PURE__*/function (ClientActionPage) {
2
+ ClientActionPage["LIST"] = "list";
3
+ ClientActionPage["DETAILS"] = "details";
4
+ ClientActionPage["CREATE_PAGE"] = "createPage";
5
+ ClientActionPage["EDIT_PAGE"] = "editPage";
6
+ ClientActionPage["ALL_PAGES"] = "allPages";
7
+ return ClientActionPage;
8
+ }(ClientActionPage || {});
9
+
10
+ export {};
@@ -1,5 +1,19 @@
1
- import { ActionViewGap } from "../../components/interfaces/ActionViewModel";
2
- import { clientScriptsSchema } from "../../../client-scripts/cc/zclient-scripts-execution/clientScriptsSchema";
1
+ // OPTIMIZE: Duplicated clientScriptsSchema in cc/table-list/row/Properties.ts
2
+ const clientScriptsSchema = {
3
+ type: 'array',
4
+ minItems: 0,
5
+ items: {
6
+ type: 'object',
7
+ properties: {
8
+ targetEventName: {
9
+ type: 'string'
10
+ },
11
+ clientScript: {
12
+ type: 'string'
13
+ }
14
+ }
15
+ }
16
+ };
3
17
  export const actionSchema = {
4
18
  type: 'object',
5
19
  properties: {
@@ -104,11 +118,11 @@ export default {
104
118
  },
105
119
  gap: {
106
120
  required: false,
107
- defaultValue: ActionViewGap.NONE,
121
+ defaultValue: 'none',
108
122
  typeMetadata: {
109
123
  schema: {
110
124
  type: 'string',
111
- enum: Object.values(ActionViewGap)
125
+ enum: ['none', 'small', 'xmedium', 'medium', 'large', 'xlarge']
112
126
  }
113
127
  }
114
128
  }
@@ -0,0 +1,43 @@
1
+ import APITemplate from "../../../../../zdata-source/domain/entities/APITemplate";
2
+ import TemplateHelpers from "../../../../../zdata-source/adapters/gateways/TemplateHelpers";
3
+ import FetchGateWay from "../../../../../zhttp/adapters/gateway/FetchGateWay";
4
+ import getClientScripts from "../../../../../data-source/http-template/getClientScripts";
5
+
6
+ //TODO: Remove this SDK when smart page is ready for production
7
+ // Use this SDK only for fetching client actions at page level in desk_client_app until smart page is ready
8
+ class ClientScriptsFetchSDK {
9
+ getClientScriptsAPIDetails(args) {
10
+ const apiTemplate = new APITemplate(getClientScripts, new TemplateHelpers());
11
+ const apiArgs = { ...args,
12
+ servicePrefix: 'supportapi/zd',
13
+ // @ts-ignore - custom property
14
+ orgName: window.currentOrg.portalName
15
+ };
16
+ const apiDetailsModel = apiTemplate.getApiDetails(apiArgs);
17
+ return { ...apiDetailsModel,
18
+ options: {
19
+ headers: {
20
+ // @ts-ignore - custom property
21
+ orgId: window.currentOrg.id
22
+ },
23
+ method: apiDetailsModel.method
24
+ }
25
+ };
26
+ }
27
+
28
+ async fetchClientScripts(params) {
29
+ const apiDetails = this.getClientScriptsAPIDetails(params);
30
+ const fetchGateway = new FetchGateWay(window.fetch.bind(window));
31
+ return new Promise((resolve, reject) => {
32
+ fetchGateway.fetch(apiDetails.url, apiDetails.options).then(response => response.json()).then(clientScripts => {
33
+ this.clientScripts = clientScripts;
34
+ return resolve(clientScripts);
35
+ }).catch(err => {
36
+ reject(err);
37
+ });
38
+ });
39
+ }
40
+
41
+ }
42
+
43
+ export default ClientScriptsFetchSDK;