@ruiapp/rapid-configure-tools 0.4.1 → 0.4.3

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/mod.js CHANGED
@@ -280,6 +280,8 @@ function convertSdRpdFieldTypeToTypeScriptType(field, entities) {
280
280
  switch (type) {
281
281
  case "text":
282
282
  return "string";
283
+ case "richText":
284
+ return "string";
283
285
  case "boolean":
284
286
  return "boolean";
285
287
  case "integer":
@@ -290,6 +292,8 @@ function convertSdRpdFieldTypeToTypeScriptType(field, entities) {
290
292
  return "number";
291
293
  case "double":
292
294
  return "number";
295
+ case "decimal":
296
+ return "number";
293
297
  case "date":
294
298
  case "time":
295
299
  case "datetime":
@@ -298,9 +302,18 @@ function convertSdRpdFieldTypeToTypeScriptType(field, entities) {
298
302
  return "Record<string, any>";
299
303
  case "option":
300
304
  return dataDictionary;
305
+ case "option[]":
306
+ return `${dataDictionary}[]`;
301
307
  case "relation":
308
+ case "relation[]":
302
309
  const targetCode = lodash.find(entities, { singularCode: targetSingularCode })?.code;
303
310
  return relation === "one" ? `Partial<${targetCode}>` : `Partial<${targetCode}>[]`;
311
+ case "file":
312
+ case "image":
313
+ return "FileOrImageFieldType";
314
+ case "file[]":
315
+ case "image[]":
316
+ return "FileOrImageFieldType[]";
304
317
  }
305
318
  return "any";
306
319
  }
@@ -344,6 +357,9 @@ function generateEntityTypes(metaDir) {
344
357
  codes.push(` ${dictionaryCode},`);
345
358
  }
346
359
  codes.push(`} from "./data-dictionary-types";`);
360
+ codes.push();
361
+ codes.push(`export type FileOrImageFieldType = { key: string; name: string; size: number; type: string };`);
362
+ codes.push();
347
363
  // types of entities.
348
364
  for (const entity of entities) {
349
365
  codes.push(`/**`);
@@ -401,10 +417,14 @@ function generateDictionaryLocales(metaDir) {
401
417
  const dictionaryLocale = dictionary.locales?.[lingual];
402
418
  codes.push(` "${dictionary.code}": {`);
403
419
  if (dictionaryLocale) {
404
- codes.push(` name: "${dictionaryLocale.name}",`);
405
- codes.push(` description: "${dictionaryLocale.description}",`);
420
+ if (dictionaryLocale.name) {
421
+ codes.push(` name: "${dictionaryLocale.name}",`);
422
+ }
423
+ if (dictionaryLocale.description) {
424
+ codes.push(` description: "${dictionaryLocale.description}",`);
425
+ }
406
426
  }
407
- codes.push(` entries: {`);
427
+ codes.push(` entries: {`);
408
428
  for (const entry of dictionary.entries) {
409
429
  let entryLocaleName;
410
430
  let entryLocaleDescription;
@@ -414,18 +434,18 @@ function generateDictionaryLocales(metaDir) {
414
434
  entryLocaleDescription = entryLocale.description || dictionaryLocale?.entries?.[entry.value]?.description;
415
435
  }
416
436
  if (entryLocaleName || entryLocaleDescription) {
417
- codes.push(` "${entry.value}": {`);
437
+ codes.push(` "${entry.value}": {`);
418
438
  if (entryLocaleName) {
419
- codes.push(` name: "${entryLocaleName}",`);
439
+ codes.push(` name: "${entryLocaleName}",`);
420
440
  }
421
441
  if (entryLocaleDescription) {
422
- codes.push(` description: "${entryLocaleDescription}",`);
442
+ codes.push(` description: "${entryLocaleDescription}",`);
423
443
  }
424
- codes.push(` },`);
444
+ codes.push(` },`);
425
445
  }
426
446
  }
447
+ codes.push(` },`);
427
448
  codes.push(` },`);
428
- codes.push(` },`);
429
449
  }
430
450
  codes.push(` },`);
431
451
  codes.push(` },`);
@@ -463,8 +483,12 @@ function generateEntityLocales(metaDir) {
463
483
  const entityLocale = entity.locales?.[lingual];
464
484
  codes.push(` "${entity.code}": {`);
465
485
  if (entityLocale) {
466
- codes.push(` name: "${entityLocale.name}",`);
467
- codes.push(` description: "${entityLocale.description}",`);
486
+ if (entityLocale.name) {
487
+ codes.push(` name: "${entityLocale.name}",`);
488
+ }
489
+ if (entityLocale.description) {
490
+ codes.push(` description: "${entityLocale.description}",`);
491
+ }
468
492
  }
469
493
  codes.push(` fields: {`);
470
494
  for (const field of entity.fields) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-configure-tools",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "",
5
5
  "main": "dist/mod.js",
6
6
  "keywords": [],
@@ -20,7 +20,7 @@
20
20
  "axios-cookiejar-support": "^4.0.7",
21
21
  "lodash": "^4.17.21",
22
22
  "tough-cookie": "^4.1.3",
23
- "@ruiapp/rapid-extension": "^0.4.2"
23
+ "@ruiapp/rapid-extension": "^0.4.5"
24
24
  },
25
25
  "dependencies": {},
26
26
  "scripts": {
@@ -33,11 +33,15 @@ function generateDictionaryLocales(metaDir: string) {
33
33
  const dictionaryLocale = dictionary.locales?.[lingual];
34
34
  codes.push(` "${dictionary.code}": {`);
35
35
  if (dictionaryLocale) {
36
- codes.push(` name: "${dictionaryLocale.name}",`);
37
- codes.push(` description: "${dictionaryLocale.description}",`);
36
+ if (dictionaryLocale.name) {
37
+ codes.push(` name: "${dictionaryLocale.name}",`);
38
+ }
39
+ if (dictionaryLocale.description) {
40
+ codes.push(` description: "${dictionaryLocale.description}",`);
41
+ }
38
42
  }
39
43
 
40
- codes.push(` entries: {`);
44
+ codes.push(` entries: {`);
41
45
  for (const entry of dictionary.entries) {
42
46
  let entryLocaleName;
43
47
  let entryLocaleDescription;
@@ -48,18 +52,18 @@ function generateDictionaryLocales(metaDir: string) {
48
52
  }
49
53
 
50
54
  if (entryLocaleName || entryLocaleDescription) {
51
- codes.push(` "${entry.value}": {`);
55
+ codes.push(` "${entry.value}": {`);
52
56
  if (entryLocaleName) {
53
- codes.push(` name: "${entryLocaleName}",`);
57
+ codes.push(` name: "${entryLocaleName}",`);
54
58
  }
55
59
  if (entryLocaleDescription) {
56
- codes.push(` description: "${entryLocaleDescription}",`);
60
+ codes.push(` description: "${entryLocaleDescription}",`);
57
61
  }
58
- codes.push(` },`);
62
+ codes.push(` },`);
59
63
  }
60
64
  }
65
+ codes.push(` },`);
61
66
  codes.push(` },`);
62
- codes.push(` },`);
63
67
  }
64
68
 
65
69
  codes.push(` },`);
@@ -105,8 +109,12 @@ function generateEntityLocales(metaDir: string) {
105
109
  const entityLocale = entity.locales?.[lingual];
106
110
  codes.push(` "${entity.code}": {`);
107
111
  if (entityLocale) {
108
- codes.push(` name: "${entityLocale.name}",`);
109
- codes.push(` description: "${entityLocale.description}",`);
112
+ if (entityLocale.name) {
113
+ codes.push(` name: "${entityLocale.name}",`);
114
+ }
115
+ if (entityLocale.description) {
116
+ codes.push(` description: "${entityLocale.description}",`);
117
+ }
110
118
  }
111
119
 
112
120
  codes.push(` fields: {`);
@@ -8,6 +8,8 @@ function convertSdRpdFieldTypeToTypeScriptType(field: RapidField, entities: Rapi
8
8
  switch (type) {
9
9
  case "text":
10
10
  return "string";
11
+ case "richText":
12
+ return "string";
11
13
  case "boolean":
12
14
  return "boolean";
13
15
  case "integer":
@@ -18,6 +20,8 @@ function convertSdRpdFieldTypeToTypeScriptType(field: RapidField, entities: Rapi
18
20
  return "number";
19
21
  case "double":
20
22
  return "number";
23
+ case "decimal":
24
+ return "number";
21
25
  case "date":
22
26
  case "time":
23
27
  case "datetime":
@@ -26,9 +30,18 @@ function convertSdRpdFieldTypeToTypeScriptType(field: RapidField, entities: Rapi
26
30
  return "Record<string, any>";
27
31
  case "option":
28
32
  return dataDictionary;
33
+ case "option[]":
34
+ return `${dataDictionary}[]`;
29
35
  case "relation":
36
+ case "relation[]":
30
37
  const targetCode = find(entities, { singularCode: targetSingularCode })?.code;
31
38
  return relation === "one" ? `Partial<${targetCode}>` : `Partial<${targetCode}>[]`;
39
+ case "file":
40
+ case "image":
41
+ return "FileOrImageFieldType";
42
+ case "file[]":
43
+ case "image[]":
44
+ return "FileOrImageFieldType[]";
32
45
  }
33
46
  return "any";
34
47
  }
@@ -79,6 +92,10 @@ function generateEntityTypes(metaDir: string) {
79
92
  }
80
93
  codes.push(`} from "./data-dictionary-types";`);
81
94
 
95
+ codes.push();
96
+ codes.push(`export type FileOrImageFieldType = { key: string; name: string; size: number; type: string };`);
97
+ codes.push();
98
+
82
99
  // types of entities.
83
100
  for (const entity of entities) {
84
101
  codes.push(`/**`);