ondc-code-generator 0.8.8 → 0.9.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 (127) hide show
  1. package/README.md +1 -1
  2. package/alpha/table/page/index.html +11487 -0
  3. package/alpha/table/page/style.css +449 -0
  4. package/alpha/table/rag-table-docs/confirm.md +60 -0
  5. package/alpha/table/rag-table-docs/init.md +78 -0
  6. package/alpha/table/rag-table-docs/on_confirm.md +161 -0
  7. package/alpha/table/rag-table-docs/on_init.md +143 -0
  8. package/alpha/table/rag-table-docs/on_search.md +160 -0
  9. package/alpha/table/rag-table-docs/on_select.md +96 -0
  10. package/alpha/table/rag-table-docs/on_status.md +150 -0
  11. package/alpha/table/rag-table-docs/on_update.md +161 -0
  12. package/alpha/table/rag-table-docs/raw_table.json +11198 -0
  13. package/alpha/table/rag-table-docs/search.md +125 -0
  14. package/alpha/table/rag-table-docs/select.md +67 -0
  15. package/alpha/table/rag-table-docs/status.md +41 -0
  16. package/alpha/table/rag-table-docs/update.md +48 -0
  17. package/alpha/table/readme.md +1312 -0
  18. package/alpha/table/validPaths.json +34134 -0
  19. package/alpha/table.zip +0 -0
  20. package/dist/bin/cli.js +6 -0
  21. package/dist/generator/config-compiler.js +16 -0
  22. package/dist/generator/generators/documentation/md-generator.d.ts +11 -5
  23. package/dist/generator/generators/documentation/md-generator.js +22 -28
  24. package/dist/generator/generators/documentation/templates/index.mustache +162 -26
  25. package/dist/generator/generators/documentation/templates/style.css +387 -142
  26. package/dist/generator/generators/rag/rag-generator.d.ts +48 -0
  27. package/dist/generator/generators/rag/rag-generator.js +185 -0
  28. package/dist/generator/generators/rag/rag-table-generator.d.ts +55 -0
  29. package/dist/generator/generators/rag/rag-table-generator.js +263 -0
  30. package/dist/types/compiler-types.d.ts +4 -1
  31. package/dist/types/compiler-types.js +3 -0
  32. package/docs/jval-dsl.md +913 -0
  33. package/package.json +1 -1
  34. package/alpha/golang/newPkg/go.mod +0 -3
  35. package/alpha/golang/newPkg/jsonvalidations/cancel.go +0 -1289
  36. package/alpha/golang/newPkg/jsonvalidations/confirm.go +0 -9121
  37. package/alpha/golang/newPkg/jsonvalidations/init.go +0 -4864
  38. package/alpha/golang/newPkg/jsonvalidations/issue.go +0 -4868
  39. package/alpha/golang/newPkg/jsonvalidations/on_cancel.go +0 -7111
  40. package/alpha/golang/newPkg/jsonvalidations/on_confirm.go +0 -8903
  41. package/alpha/golang/newPkg/jsonvalidations/on_init.go +0 -4445
  42. package/alpha/golang/newPkg/jsonvalidations/on_issue.go +0 -2828
  43. package/alpha/golang/newPkg/jsonvalidations/on_issue_status.go +0 -1938
  44. package/alpha/golang/newPkg/jsonvalidations/on_search.go +0 -3356
  45. package/alpha/golang/newPkg/jsonvalidations/on_status.go +0 -8129
  46. package/alpha/golang/newPkg/jsonvalidations/on_track.go +0 -1415
  47. package/alpha/golang/newPkg/jsonvalidations/on_update.go +0 -8700
  48. package/alpha/golang/newPkg/jsonvalidations/search.go +0 -3585
  49. package/alpha/golang/newPkg/jsonvalidations/status.go +0 -1073
  50. package/alpha/golang/newPkg/jsonvalidations/track.go +0 -1073
  51. package/alpha/golang/newPkg/jsonvalidations/update.go +0 -3012
  52. package/alpha/golang/newPkg/main-validator.go +0 -196
  53. package/alpha/golang/newPkg/main-validator_test.go +0 -165
  54. package/alpha/golang/newPkg/storageutils/api_save_utils.go +0 -83
  55. package/alpha/golang/newPkg/storageutils/cancel.go +0 -30
  56. package/alpha/golang/newPkg/storageutils/confirm.go +0 -30
  57. package/alpha/golang/newPkg/storageutils/index.go +0 -132
  58. package/alpha/golang/newPkg/storageutils/init.go +0 -30
  59. package/alpha/golang/newPkg/storageutils/issue.go +0 -30
  60. package/alpha/golang/newPkg/storageutils/on_cancel.go +0 -30
  61. package/alpha/golang/newPkg/storageutils/on_confirm.go +0 -30
  62. package/alpha/golang/newPkg/storageutils/on_init.go +0 -30
  63. package/alpha/golang/newPkg/storageutils/on_issue.go +0 -30
  64. package/alpha/golang/newPkg/storageutils/on_issue_status.go +0 -30
  65. package/alpha/golang/newPkg/storageutils/on_search.go +0 -30
  66. package/alpha/golang/newPkg/storageutils/on_status.go +0 -30
  67. package/alpha/golang/newPkg/storageutils/on_track.go +0 -30
  68. package/alpha/golang/newPkg/storageutils/on_update.go +0 -30
  69. package/alpha/golang/newPkg/storageutils/save_utils.go +0 -75
  70. package/alpha/golang/newPkg/storageutils/search.go +0 -30
  71. package/alpha/golang/newPkg/storageutils/status.go +0 -30
  72. package/alpha/golang/newPkg/storageutils/track.go +0 -30
  73. package/alpha/golang/newPkg/storageutils/update.go +0 -30
  74. package/alpha/golang/newPkg/validationutils/json_normalizer.go +0 -152
  75. package/alpha/golang/newPkg/validationutils/json_path_utils.go +0 -173
  76. package/alpha/golang/newPkg/validationutils/storage-interface.go +0 -107
  77. package/alpha/golang/newPkg/validationutils/test-config.go +0 -69
  78. package/alpha/golang/newPkg/validationutils/validation_utils.go +0 -429
  79. package/alpha/golang/page/index.html +0 -6137
  80. package/alpha/golang/page/style.css +0 -204
  81. package/alpha/golang/readme.md +0 -5939
  82. package/alpha/golang/validationpkg/go.mod +0 -3
  83. package/alpha/golang/validationpkg/jsonvalidations/cancel.go +0 -1289
  84. package/alpha/golang/validationpkg/jsonvalidations/confirm.go +0 -9121
  85. package/alpha/golang/validationpkg/jsonvalidations/init.go +0 -4864
  86. package/alpha/golang/validationpkg/jsonvalidations/issue.go +0 -4868
  87. package/alpha/golang/validationpkg/jsonvalidations/on_cancel.go +0 -7111
  88. package/alpha/golang/validationpkg/jsonvalidations/on_confirm.go +0 -8903
  89. package/alpha/golang/validationpkg/jsonvalidations/on_init.go +0 -4445
  90. package/alpha/golang/validationpkg/jsonvalidations/on_issue.go +0 -2828
  91. package/alpha/golang/validationpkg/jsonvalidations/on_issue_status.go +0 -1938
  92. package/alpha/golang/validationpkg/jsonvalidations/on_search.go +0 -3356
  93. package/alpha/golang/validationpkg/jsonvalidations/on_status.go +0 -8129
  94. package/alpha/golang/validationpkg/jsonvalidations/on_track.go +0 -1415
  95. package/alpha/golang/validationpkg/jsonvalidations/on_update.go +0 -8700
  96. package/alpha/golang/validationpkg/jsonvalidations/search.go +0 -3585
  97. package/alpha/golang/validationpkg/jsonvalidations/status.go +0 -1073
  98. package/alpha/golang/validationpkg/jsonvalidations/track.go +0 -1073
  99. package/alpha/golang/validationpkg/jsonvalidations/update.go +0 -3012
  100. package/alpha/golang/validationpkg/main-validator.go +0 -196
  101. package/alpha/golang/validationpkg/main-validator_test.go +0 -165
  102. package/alpha/golang/validationpkg/storageutils/api_save_utils.go +0 -83
  103. package/alpha/golang/validationpkg/storageutils/cancel.go +0 -30
  104. package/alpha/golang/validationpkg/storageutils/confirm.go +0 -30
  105. package/alpha/golang/validationpkg/storageutils/index.go +0 -132
  106. package/alpha/golang/validationpkg/storageutils/init.go +0 -30
  107. package/alpha/golang/validationpkg/storageutils/issue.go +0 -30
  108. package/alpha/golang/validationpkg/storageutils/on_cancel.go +0 -30
  109. package/alpha/golang/validationpkg/storageutils/on_confirm.go +0 -30
  110. package/alpha/golang/validationpkg/storageutils/on_init.go +0 -30
  111. package/alpha/golang/validationpkg/storageutils/on_issue.go +0 -30
  112. package/alpha/golang/validationpkg/storageutils/on_issue_status.go +0 -30
  113. package/alpha/golang/validationpkg/storageutils/on_search.go +0 -30
  114. package/alpha/golang/validationpkg/storageutils/on_status.go +0 -30
  115. package/alpha/golang/validationpkg/storageutils/on_track.go +0 -30
  116. package/alpha/golang/validationpkg/storageutils/on_update.go +0 -30
  117. package/alpha/golang/validationpkg/storageutils/save_utils.go +0 -75
  118. package/alpha/golang/validationpkg/storageutils/search.go +0 -30
  119. package/alpha/golang/validationpkg/storageutils/status.go +0 -30
  120. package/alpha/golang/validationpkg/storageutils/track.go +0 -30
  121. package/alpha/golang/validationpkg/storageutils/update.go +0 -30
  122. package/alpha/golang/validationpkg/validationutils/json_normalizer.go +0 -152
  123. package/alpha/golang/validationpkg/validationutils/json_path_utils.go +0 -173
  124. package/alpha/golang/validationpkg/validationutils/storage-interface.go +0 -107
  125. package/alpha/golang/validationpkg/validationutils/test-config.go +0 -69
  126. package/alpha/golang/validationpkg/validationutils/validation_utils.go +0 -429
  127. /package/alpha/{golang/validPaths.json → validPaths.json} +0 -0
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_cancel stores data from payload to storage for the on_cancel action
11
- func Store_on_cancel(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_cancel successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_cancel loads stored data for the on_cancel action
22
- func LoadFor_on_cancel(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_cancel: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_confirm stores data from payload to storage for the on_confirm action
11
- func Store_on_confirm(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_confirm successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_confirm loads stored data for the on_confirm action
22
- func LoadFor_on_confirm(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_confirm: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_init stores data from payload to storage for the on_init action
11
- func Store_on_init(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_init successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_init loads stored data for the on_init action
22
- func LoadFor_on_init(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_init: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_issue stores data from payload to storage for the on_issue action
11
- func Store_on_issue(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_issue successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_issue loads stored data for the on_issue action
22
- func LoadFor_on_issue(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_issue: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_issue_status stores data from payload to storage for the on_issue_status action
11
- func Store_on_issue_status(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_issue_status successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_issue_status loads stored data for the on_issue_status action
22
- func LoadFor_on_issue_status(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_issue_status: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_search stores data from payload to storage for the on_search action
11
- func Store_on_search(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_search successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_search loads stored data for the on_search action
22
- func LoadFor_on_search(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_search: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_status stores data from payload to storage for the on_status action
11
- func Store_on_status(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_status successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_status loads stored data for the on_status action
22
- func LoadFor_on_status(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_status: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_track stores data from payload to storage for the on_track action
11
- func Store_on_track(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_track successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_track loads stored data for the on_track action
22
- func LoadFor_on_track(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_track: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_on_update stores data from payload to storage for the on_update action
11
- func Store_on_update(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action on_update successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_on_update loads stored data for the on_update action
22
- func LoadFor_on_update(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action on_update: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,75 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- "time"
9
- )
10
-
11
- // StorageConfig holds configuration for storage operations
12
- type StorageConfig struct {
13
- // RetryAttempts is the number of times to retry a failed operation
14
- RetryAttempts int
15
- // RetryDelayMs is the delay in milliseconds between retry attempts
16
- RetryDelayMs int
17
- }
18
-
19
- // DefaultStorageConfig returns a StorageConfig with sensible defaults
20
- func DefaultStorageConfig() StorageConfig {
21
- return StorageConfig{
22
- RetryAttempts: 3,
23
- RetryDelayMs: 100,
24
- }
25
- }
26
-
27
- // SaveData saves data to storage with retry logic
28
- //
29
- // Parameters:
30
- // - uniquePrefix: The namespace prefix for the key
31
- // - key: The key to store the data under
32
- // - saveData: The string data to save
33
- // - store: The storage interface implementation
34
- // - config: Configuration including retry settings
35
- //
36
- // Returns error if all retry attempts fail
37
- func SaveData(
38
- uniquePrefix string,
39
- key string,
40
- saveData string,
41
- store validationutils.StorageInterface,
42
- config StorageConfig,
43
- ) error {
44
- finalKey := key
45
- retryTimes := config.RetryAttempts
46
- delayMs := config.RetryDelayMs
47
- attempts := 0
48
-
49
- for attempts < retryTimes {
50
- err := store.SaveKey(uniquePrefix, finalKey, saveData)
51
- if err == nil {
52
- return nil
53
- }
54
-
55
- attempts++
56
- if attempts >= retryTimes {
57
- return fmt.Errorf("failed to save data after %d attempts: %w", retryTimes, err)
58
- }
59
-
60
- time.Sleep(time.Duration(delayMs) * time.Millisecond)
61
- }
62
-
63
- return nil
64
- }
65
-
66
- // CreateKey creates a fully qualified storage key from prefix and key
67
- //
68
- // Parameters:
69
- // - uniquePrefix: The namespace prefix
70
- // - key: The key within the namespace
71
- //
72
- // Returns the combined key in format "prefix:key"
73
- func CreateKey(uniquePrefix string, key string) string {
74
- return fmt.Sprintf("%s:%s", uniquePrefix, key)
75
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_search stores data from payload to storage for the search action
11
- func Store_search(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action search successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_search loads stored data for the search action
22
- func LoadFor_search(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action search: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_status stores data from payload to storage for the status action
11
- func Store_status(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action status successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_status loads stored data for the status action
22
- func LoadFor_status(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action status: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_track stores data from payload to storage for the track action
11
- func Store_track(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action track successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_track loads stored data for the track action
22
- func LoadFor_track(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action track: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,30 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package storageutils
4
-
5
- import (
6
- "fmt"
7
- "newPkg/validationutils"
8
- )
9
-
10
- // Store_update stores data from payload to storage for the update action
11
- func Store_update(
12
- uniquePrefix string,
13
- payload interface{},
14
- store validationutils.StorageInterface,
15
- config StorageConfig,
16
- ) error {
17
- fmt.Printf("Stored data for action update successfully\n")
18
- return nil
19
- }
20
-
21
- // LoadFor_update loads stored data for the update action
22
- func LoadFor_update(
23
- uniquePrefix string,
24
- store validationutils.StorageInterface,
25
- ) (validationutils.ExternalData, error) {
26
- result := validationutils.ExternalData{}
27
-
28
- fmt.Printf("Loaded external data for action update: %+v\n", result)
29
- return result, nil
30
- }
@@ -1,152 +0,0 @@
1
- // Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
2
-
3
- package validationutils
4
-
5
- // NormalizeKeys normalizes JSON structures so that:
6
- // - All objects with the same property name share the union of keys seen anywhere
7
- // - All objects inside the same array share the union of keys at that array level
8
- // - Missing keys are filled with nil
9
- func NormalizeKeys(input interface{}) interface{} {
10
- // Step 1: Collect templates by property name
11
- templatesByPropName := make(map[string]map[string]struct{})
12
- collectTemplates(input, templatesByPropName)
13
-
14
- // Step 2: Apply templates and within-array unions
15
- return applyTemplates(input, templatesByPropName)
16
- }
17
-
18
- // collectTemplates walks the data structure and collects all keys for each property name
19
- func collectTemplates(node interface{}, templates map[string]map[string]struct{}) {
20
- switch v := node.(type) {
21
- case []interface{}:
22
- // Recurse into array items
23
- for _, item := range v {
24
- collectTemplates(item, templates)
25
- }
26
-
27
- case map[string]interface{}:
28
- // For each property: if it's an object (non-array), record its keys
29
- for propName, propValue := range v {
30
- if obj, ok := propValue.(map[string]interface{}); ok {
31
- // Initialize set for this property name if needed
32
- if templates[propName] == nil {
33
- templates[propName] = make(map[string]struct{})
34
- }
35
- // Add all keys from this object to the template
36
- for childKey := range obj {
37
- templates[propName][childKey] = struct{}{}
38
- }
39
- }
40
- // Recurse into the value
41
- collectTemplates(propValue, templates)
42
- }
43
- }
44
- }
45
-
46
- // applyTemplates applies the collected templates and array-level unions
47
- func applyTemplates(node interface{}, templates map[string]map[string]struct{}) interface{} {
48
- switch v := node.(type) {
49
- case []interface{}:
50
- // Compute union of keys across all object elements at this array level
51
- arrayUnion := make(map[string]struct{})
52
- for _, item := range v {
53
- if obj, ok := item.(map[string]interface{}); ok {
54
- for key := range obj {
55
- arrayUnion[key] = struct{}{}
56
- }
57
- }
58
- }
59
-
60
- // Apply union to each array element
61
- result := make([]interface{}, len(v))
62
- for i, item := range v {
63
- if obj, ok := item.(map[string]interface{}); ok {
64
- // Create new object with array union keys
65
- next := make(map[string]interface{})
66
-
67
- // Copy existing keys
68
- for k, val := range obj {
69
- next[k] = val
70
- }
71
-
72
- // Add missing keys from array union
73
- for key := range arrayUnion {
74
- if _, exists := next[key]; !exists {
75
- next[key] = nil
76
- }
77
- }
78
-
79
- // Now apply templates per property name for nested objects
80
- for propName, propValue := range next {
81
- if nestedObj, ok := propValue.(map[string]interface{}); ok {
82
- // Align to template for this property name
83
- next[propName] = fillFromTemplate(propName, nestedObj, templates)
84
- } else {
85
- // Recurse for arrays or other structures
86
- next[propName] = applyTemplates(propValue, templates)
87
- }
88
- }
89
- result[i] = next
90
- } else {
91
- // Not an object, just recurse
92
- result[i] = applyTemplates(item, templates)
93
- }
94
- }
95
- return result
96
-
97
- case map[string]interface{}:
98
- out := make(map[string]interface{})
99
- for propName, propValue := range v {
100
- if nestedObj, ok := propValue.(map[string]interface{}); ok {
101
- // Align object to the template for this property name
102
- out[propName] = fillFromTemplate(propName, nestedObj, templates)
103
- } else {
104
- out[propName] = applyTemplates(propValue, templates)
105
- }
106
- }
107
- return out
108
-
109
- default:
110
- // Primitives unchanged
111
- return v
112
- }
113
- }
114
-
115
- // fillFromTemplate applies the template for a given property name
116
- func fillFromTemplate(propName string, obj map[string]interface{}, templates map[string]map[string]struct{}) interface{} {
117
- // First recurse on children so nested arrays/objects also normalize
118
- base := applyTemplates(obj, templates).(map[string]interface{})
119
-
120
- // Get template for this property name
121
- template, hasTemplate := templates[propName]
122
- if !hasTemplate {
123
- return base // No known template keys for this prop
124
- }
125
-
126
- // Fill missing keys with nil
127
- filled := make(map[string]interface{})
128
- for k, v := range base {
129
- filled[k] = v
130
- }
131
- for key := range template {
132
- if _, exists := filled[key]; !exists {
133
- filled[key] = nil
134
- }
135
- }
136
-
137
- return filled
138
- }
139
-
140
- // DeepCloneJSON creates a deep clone of a JSON-serializable structure using sonic
141
- func DeepCloneJSON(v interface{}) interface{} {
142
- /* b, err := sonic.Marshal(v)
143
- if err != nil {
144
- panic(err) // or handle error
145
- }
146
- var out interface{}
147
- if err := sonic.Unmarshal(b, &out); err != nil {
148
- panic(err)
149
- }
150
- return out */
151
- return v
152
- }