ondc-code-generator 0.8.9 → 1.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.
- package/alpha/possible-json-paths.json +34134 -0
- package/alpha/table/page/index.html +11487 -0
- package/alpha/table/page/style.css +449 -0
- package/alpha/table/rag-table-docs/confirm.md +63 -0
- package/alpha/table/rag-table-docs/init.md +81 -0
- package/alpha/table/rag-table-docs/on_confirm.md +164 -0
- package/alpha/table/rag-table-docs/on_init.md +146 -0
- package/alpha/table/rag-table-docs/on_search.md +163 -0
- package/alpha/table/rag-table-docs/on_select.md +99 -0
- package/alpha/table/rag-table-docs/on_status.md +153 -0
- package/alpha/table/rag-table-docs/on_update.md +164 -0
- package/alpha/table/rag-table-docs/raw_table.json +11198 -0
- package/alpha/table/rag-table-docs/search.md +128 -0
- package/alpha/table/rag-table-docs/select.md +70 -0
- package/alpha/table/rag-table-docs/status.md +44 -0
- package/alpha/table/rag-table-docs/update.md +51 -0
- package/alpha/table/readme.md +1312 -0
- package/alpha/table/validPaths.json +34134 -0
- package/alpha/table.zip +0 -0
- package/dist/bin/cli.js +4 -0
- package/dist/generator/config-compiler.d.ts +16 -2
- package/dist/generator/config-compiler.js +57 -19
- package/dist/generator/generators/classes/abstract-generator.d.ts +2 -0
- package/dist/generator/generators/documentation/md-generator.d.ts +12 -5
- package/dist/generator/generators/documentation/md-generator.js +23 -28
- package/dist/generator/generators/documentation/templates/index.mustache +162 -26
- package/dist/generator/generators/documentation/templates/style.css +387 -142
- package/dist/generator/generators/go/go-generator.js +1 -1
- package/dist/generator/generators/javascript/js-generator.js +1 -1
- package/dist/generator/generators/python/py-generator.js +1 -1
- package/dist/generator/generators/rag/rag-generator.d.ts +48 -0
- package/dist/generator/generators/rag/rag-generator.js +185 -0
- package/dist/generator/generators/rag/rag-table-generator.d.ts +55 -0
- package/dist/generator/generators/rag/rag-table-generator.js +269 -0
- package/dist/generator/generators/typescript/ts-generator.js +1 -1
- package/dist/index.test.js +12 -3
- package/dist/types/build.d.ts +4 -0
- package/dist/types/compiler-types.d.ts +3 -1
- package/dist/types/compiler-types.js +2 -0
- package/package.json +1 -1
- package/alpha/docs/page/index.html +0 -6137
- package/alpha/docs/page/style.css +0 -204
- package/alpha/docs/readme.md +0 -5939
- package/alpha/docs/validPaths.json +0 -14351
- package/alpha/page/index.html +0 -6137
- package/alpha/page/style.css +0 -204
- package/alpha/readme.md +0 -5939
- package/alpha/validationpkg/examples/search.json +0 -143
- package/alpha/validationpkg/examples_output/search/case-001/output.json +0 -12
- package/alpha/validationpkg/go.mod +0 -8
- package/alpha/validationpkg/go.sum +0 -4
- package/alpha/validationpkg/jsonvalidations/cancel.go +0 -1289
- package/alpha/validationpkg/jsonvalidations/confirm.go +0 -9121
- package/alpha/validationpkg/jsonvalidations/init.go +0 -4864
- package/alpha/validationpkg/jsonvalidations/issue.go +0 -4868
- package/alpha/validationpkg/jsonvalidations/on_cancel.go +0 -7111
- package/alpha/validationpkg/jsonvalidations/on_confirm.go +0 -8903
- package/alpha/validationpkg/jsonvalidations/on_init.go +0 -4445
- package/alpha/validationpkg/jsonvalidations/on_issue.go +0 -2828
- package/alpha/validationpkg/jsonvalidations/on_issue_status.go +0 -1938
- package/alpha/validationpkg/jsonvalidations/on_search.go +0 -3356
- package/alpha/validationpkg/jsonvalidations/on_status.go +0 -8129
- package/alpha/validationpkg/jsonvalidations/on_track.go +0 -1415
- package/alpha/validationpkg/jsonvalidations/on_update.go +0 -8700
- package/alpha/validationpkg/jsonvalidations/search.go +0 -3585
- package/alpha/validationpkg/jsonvalidations/status.go +0 -1073
- package/alpha/validationpkg/jsonvalidations/track.go +0 -1073
- package/alpha/validationpkg/jsonvalidations/update.go +0 -3012
- package/alpha/validationpkg/main-validator.go +0 -196
- package/alpha/validationpkg/main-validator_test.go +0 -165
- package/alpha/validationpkg/storageutils/api_save_utils.go +0 -83
- package/alpha/validationpkg/storageutils/cancel.go +0 -30
- package/alpha/validationpkg/storageutils/confirm.go +0 -30
- package/alpha/validationpkg/storageutils/index.go +0 -132
- package/alpha/validationpkg/storageutils/init.go +0 -30
- package/alpha/validationpkg/storageutils/issue.go +0 -30
- package/alpha/validationpkg/storageutils/on_cancel.go +0 -30
- package/alpha/validationpkg/storageutils/on_confirm.go +0 -30
- package/alpha/validationpkg/storageutils/on_init.go +0 -30
- package/alpha/validationpkg/storageutils/on_issue.go +0 -30
- package/alpha/validationpkg/storageutils/on_issue_status.go +0 -30
- package/alpha/validationpkg/storageutils/on_search.go +0 -30
- package/alpha/validationpkg/storageutils/on_status.go +0 -30
- package/alpha/validationpkg/storageutils/on_track.go +0 -30
- package/alpha/validationpkg/storageutils/on_update.go +0 -30
- package/alpha/validationpkg/storageutils/save_utils.go +0 -75
- package/alpha/validationpkg/storageutils/search.go +0 -30
- package/alpha/validationpkg/storageutils/status.go +0 -30
- package/alpha/validationpkg/storageutils/track.go +0 -30
- package/alpha/validationpkg/storageutils/update.go +0 -30
- package/alpha/validationpkg/validationutils/json_normalizer.go +0 -152
- package/alpha/validationpkg/validationutils/json_path_utils.go +0 -173
- package/alpha/validationpkg/validationutils/storage-interface.go +0 -107
- package/alpha/validationpkg/validationutils/test-config.go +0 -69
- package/alpha/validationpkg/validationutils/validation_utils.go +0 -429
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
// Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
|
|
2
|
-
package validationpkg
|
|
3
|
-
|
|
4
|
-
import (
|
|
5
|
-
"encoding/json"
|
|
6
|
-
"fmt"
|
|
7
|
-
"validationpkg/jsonvalidations"
|
|
8
|
-
"validationpkg/storageutils"
|
|
9
|
-
"validationpkg/validationutils"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
// PerformL1Validations performs Level-1 validations against a payload for a given action.
|
|
13
|
-
//
|
|
14
|
-
// Output shape - ValidationOutput is a slice of:
|
|
15
|
-
// - TestName: string
|
|
16
|
-
// - Valid: boolean
|
|
17
|
-
// - Code: number
|
|
18
|
-
// - Description: *string (optional)
|
|
19
|
-
// - DebugInfo: *DebugInfo (optional) with FedConfig
|
|
20
|
-
//
|
|
21
|
-
// Config - ValidationConfig (all fields optional):
|
|
22
|
-
// - OnlyInvalid (default true)
|
|
23
|
-
// - HideParentErrors (default true)
|
|
24
|
-
// - Debug (default false)
|
|
25
|
-
// - StateFullValidations (default false)
|
|
26
|
-
// - UniqueKey (optional)
|
|
27
|
-
// - Store (optional)
|
|
28
|
-
//
|
|
29
|
-
// Parameters:
|
|
30
|
-
// - action: The action name to validate against
|
|
31
|
-
// - payload: The JSON payload to validate (map[string]interface{} or struct)
|
|
32
|
-
// - config: Partial ValidationConfig. Merged with defaults
|
|
33
|
-
// - externalData: Extra data accessible to rules (Self will be set to normalized payload)
|
|
34
|
-
//
|
|
35
|
-
// Returns: []ValidationOutput
|
|
36
|
-
//
|
|
37
|
-
// Example:
|
|
38
|
-
//
|
|
39
|
-
// results := PerformL1Validations("search", payload, ValidationConfig{OnlyInvalid: false}, ExternalData{})
|
|
40
|
-
// // results[0] => ValidationOutput{ TestName, Valid, Code, Description, DebugInfo }
|
|
41
|
-
func PerformL1validations(
|
|
42
|
-
action string,
|
|
43
|
-
payload interface{},
|
|
44
|
-
config *validationutils.ValidationConfig,
|
|
45
|
-
externalData validationutils.ExternalData,
|
|
46
|
-
) ([]validationutils.ValidationOutput, error) {
|
|
47
|
-
completeConfig := getCompleteConfig(config)
|
|
48
|
-
if completeConfig.SkipTests == nil {
|
|
49
|
-
completeConfig.SkipTests = []string{}
|
|
50
|
-
}
|
|
51
|
-
completeConfig.SkipTestsDict = make(map[string]bool)
|
|
52
|
-
for _, testName := range completeConfig.SkipTests {
|
|
53
|
-
completeConfig.SkipTestsDict[testName] = true
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Validate stateful requirements
|
|
57
|
-
if completeConfig.StateFullValidations {
|
|
58
|
-
if completeConfig.Store == nil {
|
|
59
|
-
return nil, fmt.Errorf("stateful validations require a storage interface to be provided in the config")
|
|
60
|
-
}
|
|
61
|
-
if completeConfig.UniqueKey == nil || *completeConfig.UniqueKey == "" {
|
|
62
|
-
return nil, fmt.Errorf("stateful validations require a uniqueKey to be provided in the config")
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
normalizedPayload := validationutils.NormalizeKeys(payload)
|
|
67
|
-
|
|
68
|
-
// Set _SELF
|
|
69
|
-
externalData["_SELF"] = normalizedPayload
|
|
70
|
-
|
|
71
|
-
// Load stateful data if needed
|
|
72
|
-
if completeConfig.StateFullValidations {
|
|
73
|
-
loadedData, err := PerformL1validationsLoad(action, *completeConfig.UniqueKey, completeConfig.Store)
|
|
74
|
-
if err != nil {
|
|
75
|
-
return nil, fmt.Errorf("failed to load stateful data: %w", err)
|
|
76
|
-
}
|
|
77
|
-
// Merge loaded data with external data
|
|
78
|
-
externalData = mergeExternalData(loadedData, externalData)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Create validation input
|
|
82
|
-
input := validationutils.ValidationInput{
|
|
83
|
-
Payload: normalizedPayload,
|
|
84
|
-
ExternalData: externalData,
|
|
85
|
-
Config: completeConfig,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Route to action-specific validation
|
|
89
|
-
switch action {
|
|
90
|
-
|
|
91
|
-
case "search":
|
|
92
|
-
return jsonvalidations.Search_Tests(input)
|
|
93
|
-
|
|
94
|
-
case "init":
|
|
95
|
-
return jsonvalidations.Init_Tests(input)
|
|
96
|
-
|
|
97
|
-
case "confirm":
|
|
98
|
-
return jsonvalidations.Confirm_Tests(input)
|
|
99
|
-
|
|
100
|
-
case "status":
|
|
101
|
-
return jsonvalidations.Status_Tests(input)
|
|
102
|
-
|
|
103
|
-
case "track":
|
|
104
|
-
return jsonvalidations.Track_Tests(input)
|
|
105
|
-
|
|
106
|
-
case "cancel":
|
|
107
|
-
return jsonvalidations.Cancel_Tests(input)
|
|
108
|
-
|
|
109
|
-
case "update":
|
|
110
|
-
return jsonvalidations.Update_Tests(input)
|
|
111
|
-
|
|
112
|
-
case "on_search":
|
|
113
|
-
return jsonvalidations.On_search_Tests(input)
|
|
114
|
-
|
|
115
|
-
case "on_init":
|
|
116
|
-
return jsonvalidations.On_init_Tests(input)
|
|
117
|
-
|
|
118
|
-
case "on_confirm":
|
|
119
|
-
return jsonvalidations.On_confirm_Tests(input)
|
|
120
|
-
|
|
121
|
-
case "on_track":
|
|
122
|
-
return jsonvalidations.On_track_Tests(input)
|
|
123
|
-
|
|
124
|
-
case "on_cancel":
|
|
125
|
-
return jsonvalidations.On_cancel_Tests(input)
|
|
126
|
-
|
|
127
|
-
case "on_update":
|
|
128
|
-
return jsonvalidations.On_update_Tests(input)
|
|
129
|
-
|
|
130
|
-
case "on_status":
|
|
131
|
-
return jsonvalidations.On_status_Tests(input)
|
|
132
|
-
|
|
133
|
-
case "issue":
|
|
134
|
-
return jsonvalidations.Issue_Tests(input)
|
|
135
|
-
|
|
136
|
-
case "on_issue":
|
|
137
|
-
return jsonvalidations.On_issue_Tests(input)
|
|
138
|
-
|
|
139
|
-
case "on_issue_status":
|
|
140
|
-
return jsonvalidations.On_issue_status_Tests(input)
|
|
141
|
-
|
|
142
|
-
default:
|
|
143
|
-
return nil, fmt.Errorf("action not found: %s", action)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// getCompleteConfig returns a complete config with defaults
|
|
148
|
-
func getCompleteConfig(config *validationutils.ValidationConfig) validationutils.ValidationConfig {
|
|
149
|
-
if config == nil {
|
|
150
|
-
return validationutils.ValidationConfig{
|
|
151
|
-
OnlyInvalid: true,
|
|
152
|
-
HideParentErrors: true,
|
|
153
|
-
StateFullValidations: false,
|
|
154
|
-
Debug: false,
|
|
155
|
-
SkipTestsDict: make(map[string]bool),
|
|
156
|
-
SkipTests: []string{},
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Return copy with defaults for unset fields
|
|
161
|
-
completeConfig := *config
|
|
162
|
-
// Go doesn't have a clean way to check if bool was explicitly set,
|
|
163
|
-
// so we assume false means "use default true" only if it seems intentional
|
|
164
|
-
// In practice, you might want to use pointers for optional bools
|
|
165
|
-
return completeConfig
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// mergeExternalData merges loaded data with provided external data
|
|
169
|
-
// using JSON marshal/unmarshal for a generic merge strategy.
|
|
170
|
-
// Non-null fields in provided override loaded fields.
|
|
171
|
-
func mergeExternalData(loaded, provided validationutils.ExternalData) validationutils.ExternalData {
|
|
172
|
-
// Convert to maps
|
|
173
|
-
loadedBytes, _ := json.Marshal(loaded)
|
|
174
|
-
providedBytes, _ := json.Marshal(provided)
|
|
175
|
-
|
|
176
|
-
var loadedMap, providedMap map[string]interface{}
|
|
177
|
-
json.Unmarshal(loadedBytes, &loadedMap)
|
|
178
|
-
json.Unmarshal(providedBytes, &providedMap)
|
|
179
|
-
|
|
180
|
-
// Merge provided into loaded
|
|
181
|
-
for key, value := range providedMap {
|
|
182
|
-
if value != nil {
|
|
183
|
-
loadedMap[key] = value
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Convert back
|
|
188
|
-
var result validationutils.ExternalData
|
|
189
|
-
mergedBytes, _ := json.Marshal(loadedMap)
|
|
190
|
-
json.Unmarshal(mergedBytes, &result)
|
|
191
|
-
|
|
192
|
-
return result
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
var PerformL1validationsLoad = storageutils.PerformL1validationsLoad
|
|
196
|
-
var PerformL1validationsSave = storageutils.PerformL1validationsSave
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
// Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
package validationpkg
|
|
4
|
-
|
|
5
|
-
// How to run:
|
|
6
|
-
//
|
|
7
|
-
// 1) Create example payload files under ./examples (relative to this package):
|
|
8
|
-
// validationpkg/examples/search.json
|
|
9
|
-
// validationpkg/examples/on_search.json
|
|
10
|
-
// Each file must contain a JSON array of payload objects.
|
|
11
|
-
//
|
|
12
|
-
// 2) From the validationpkg module directory, run:
|
|
13
|
-
// go test -run TestPerformL1validations_Examples -v
|
|
14
|
-
// Or from the repo root:
|
|
15
|
-
// go test ./ondcValidator/validationpkg -run TestPerformL1validations_Examples -v
|
|
16
|
-
//
|
|
17
|
-
// Outputs are written under ./examples_output/<action>/case-XXX/output.json.
|
|
18
|
-
|
|
19
|
-
import (
|
|
20
|
-
"encoding/json"
|
|
21
|
-
"fmt"
|
|
22
|
-
"os"
|
|
23
|
-
"path/filepath"
|
|
24
|
-
"strings"
|
|
25
|
-
"testing"
|
|
26
|
-
|
|
27
|
-
"validationpkg/validationutils"
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
type noopStorage struct{}
|
|
31
|
-
|
|
32
|
-
func (n *noopStorage) SaveKey(uniquePrefix string, key string, value string) error { return nil }
|
|
33
|
-
func (n *noopStorage) GetKey(uniquePrefix string, key string) (string, error) {
|
|
34
|
-
return "", fmt.Errorf("noop storage: key not found")
|
|
35
|
-
}
|
|
36
|
-
func (n *noopStorage) DeleteKey(uniquePrefix string, key string) error { return nil }
|
|
37
|
-
func (n *noopStorage) ListKeys(uniquePrefix string) ([]string, error) {
|
|
38
|
-
return nil, fmt.Errorf("noop storage: list not supported")
|
|
39
|
-
}
|
|
40
|
-
func (n *noopStorage) ClearStorage() error { return nil }
|
|
41
|
-
func (n *noopStorage) KeyExists(uniquePrefix string, key string) (bool, error) { return false, nil }
|
|
42
|
-
|
|
43
|
-
type validationRunOutput struct {
|
|
44
|
-
Action string `json:"action"`
|
|
45
|
-
Case int `json:"case"`
|
|
46
|
-
UniqueKey string `json:"uniqueKey"`
|
|
47
|
-
Error string `json:"error,omitempty"`
|
|
48
|
-
Results []validationutils.ValidationOutput `json:"results,omitempty"`
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
func TestPerformL1validations_Examples(t *testing.T) {
|
|
52
|
-
examplesDir := "examples"
|
|
53
|
-
if _, err := os.Stat(examplesDir); err != nil {
|
|
54
|
-
if os.IsNotExist(err) {
|
|
55
|
-
t.Skipf("%s directory not found; skipping example-based validations", examplesDir)
|
|
56
|
-
}
|
|
57
|
-
t.Fatalf("failed to stat %s: %v", examplesDir, err)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
files, err := filepath.Glob(filepath.Join(examplesDir, "*.json"))
|
|
61
|
-
if err != nil {
|
|
62
|
-
t.Fatalf("failed to glob examples: %v", err)
|
|
63
|
-
}
|
|
64
|
-
if len(files) == 0 {
|
|
65
|
-
t.Skipf("no example files found in %s", examplesDir)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
outputRoot := "examples_output"
|
|
69
|
-
if err := os.MkdirAll(outputRoot, 0o755); err != nil {
|
|
70
|
-
t.Fatalf("failed to create output dir %s: %v", outputRoot, err)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
store := &noopStorage{}
|
|
74
|
-
|
|
75
|
-
for _, filePath := range files {
|
|
76
|
-
action := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
|
|
77
|
-
|
|
78
|
-
t.Run(action, func(t *testing.T) {
|
|
79
|
-
data, err := os.ReadFile(filePath)
|
|
80
|
-
if err != nil {
|
|
81
|
-
t.Fatalf("failed to read %s: %v", filePath, err)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
var payloads []json.RawMessage
|
|
85
|
-
if err := json.Unmarshal(data, &payloads); err != nil {
|
|
86
|
-
t.Fatalf("%s must contain a JSON array of payloads: %v", filePath, err)
|
|
87
|
-
}
|
|
88
|
-
if len(payloads) == 0 {
|
|
89
|
-
t.Skipf("no payloads in %s", filePath)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
for i, raw := range payloads {
|
|
93
|
-
caseNum := i + 1
|
|
94
|
-
|
|
95
|
-
var payload interface{}
|
|
96
|
-
if err := json.Unmarshal(raw, &payload); err != nil {
|
|
97
|
-
t.Errorf("case %d: payload is not valid JSON: %v", caseNum, err)
|
|
98
|
-
continue
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
uniqueKey := extractTransactionID(payload)
|
|
102
|
-
if uniqueKey == "" {
|
|
103
|
-
uniqueKey = fmt.Sprintf("%s-case-%03d", action, caseNum)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
cfg := &validationutils.ValidationConfig{
|
|
107
|
-
StateFullValidations: false,
|
|
108
|
-
Debug: false,
|
|
109
|
-
OnlyInvalid: true,
|
|
110
|
-
HideParentErrors: true,
|
|
111
|
-
UniqueKey: &uniqueKey,
|
|
112
|
-
Store: store,
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
results, runErr := PerformL1validations(action, payload, cfg, validationutils.ExternalData{})
|
|
116
|
-
out := validationRunOutput{
|
|
117
|
-
Action: action,
|
|
118
|
-
Case: caseNum,
|
|
119
|
-
UniqueKey: uniqueKey,
|
|
120
|
-
Results: results,
|
|
121
|
-
}
|
|
122
|
-
if runErr != nil {
|
|
123
|
-
out.Error = runErr.Error()
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
caseDir := filepath.Join(outputRoot, action, fmt.Sprintf("case-%03d", caseNum))
|
|
127
|
-
if err := os.MkdirAll(caseDir, 0o755); err != nil {
|
|
128
|
-
t.Errorf("case %d: failed to create output dir %s: %v", caseNum, caseDir, err)
|
|
129
|
-
continue
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
encoded, err := json.MarshalIndent(out, "", " ")
|
|
133
|
-
if err != nil {
|
|
134
|
-
t.Errorf("case %d: failed to marshal output: %v", caseNum, err)
|
|
135
|
-
continue
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if err := os.WriteFile(filepath.Join(caseDir, "output.json"), encoded, 0o644); err != nil {
|
|
139
|
-
t.Errorf("case %d: failed to write output.json: %v", caseNum, err)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if runErr != nil {
|
|
143
|
-
t.Errorf("case %d: PerformL1validations returned error: %v", caseNum, runErr)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
func extractTransactionID(payload interface{}) string {
|
|
151
|
-
root, ok := payload.(map[string]interface{})
|
|
152
|
-
if !ok {
|
|
153
|
-
return ""
|
|
154
|
-
}
|
|
155
|
-
ctx, ok := root["context"].(map[string]interface{})
|
|
156
|
-
if !ok {
|
|
157
|
-
return ""
|
|
158
|
-
}
|
|
159
|
-
if v, ok := ctx["transaction_id"]; ok {
|
|
160
|
-
if s, ok := v.(string); ok {
|
|
161
|
-
return s
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return ""
|
|
165
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
package storageutils
|
|
4
|
-
|
|
5
|
-
import (
|
|
6
|
-
"encoding/json"
|
|
7
|
-
"fmt"
|
|
8
|
-
"time"
|
|
9
|
-
"validationpkg/validationutils"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
// saveFunction saves extracted data from payload to storage
|
|
13
|
-
func saveFunction(
|
|
14
|
-
payload interface{},
|
|
15
|
-
uniquePrefix string,
|
|
16
|
-
key string,
|
|
17
|
-
path string,
|
|
18
|
-
store validationutils.StorageInterface,
|
|
19
|
-
config StorageConfig,
|
|
20
|
-
action string,
|
|
21
|
-
) error {
|
|
22
|
-
if path == "" || key == "_SELF" {
|
|
23
|
-
return nil
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Extract value using JSONPath
|
|
27
|
-
value := validationutils.GetJsonPath(payload, path, true)
|
|
28
|
-
|
|
29
|
-
// Create data structure
|
|
30
|
-
data := map[string]interface{}{
|
|
31
|
-
"stored_from": action + "_action",
|
|
32
|
-
"key_path": path,
|
|
33
|
-
"value": value,
|
|
34
|
-
"timestamp": time.Now().UTC().Format(time.RFC3339),
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Serialize to JSON
|
|
38
|
-
dataBytes, err := json.Marshal(data)
|
|
39
|
-
if err != nil {
|
|
40
|
-
return fmt.Errorf("failed to marshal data: %w", err)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Save with retry logic
|
|
44
|
-
return SaveData(uniquePrefix, key, string(dataBytes), store, config)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// loadFunction loads and parses stored data from storage
|
|
48
|
-
func loadFunction(
|
|
49
|
-
store validationutils.StorageInterface,
|
|
50
|
-
uniquePrefix string,
|
|
51
|
-
key string,
|
|
52
|
-
) ([]string, error) {
|
|
53
|
-
value, err := store.GetKey(uniquePrefix, key)
|
|
54
|
-
if err != nil {
|
|
55
|
-
// Return empty slice on error (matches TS behavior)
|
|
56
|
-
return []string{}, nil
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if value == "" {
|
|
60
|
-
return []string{}, nil
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Parse JSON
|
|
64
|
-
var data struct {
|
|
65
|
-
Value []interface{} `json:"value"`
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if err := json.Unmarshal([]byte(value), &data); err != nil {
|
|
69
|
-
return []string{}, nil
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Convert to string slice
|
|
73
|
-
result := make([]string, 0, len(data.Value))
|
|
74
|
-
for _, v := range data.Value {
|
|
75
|
-
if v == nil {
|
|
76
|
-
result = append(result, "null")
|
|
77
|
-
} else {
|
|
78
|
-
result = append(result, fmt.Sprintf("%v", v))
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return result, nil
|
|
83
|
-
}
|
|
@@ -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
|
-
"validationpkg/validationutils"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
// Store_cancel stores data from payload to storage for the cancel action
|
|
11
|
-
func Store_cancel(
|
|
12
|
-
uniquePrefix string,
|
|
13
|
-
payload interface{},
|
|
14
|
-
store validationutils.StorageInterface,
|
|
15
|
-
config StorageConfig,
|
|
16
|
-
) error {
|
|
17
|
-
fmt.Printf("Stored data for action cancel successfully\n")
|
|
18
|
-
return nil
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// LoadFor_cancel loads stored data for the cancel action
|
|
22
|
-
func LoadFor_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 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
|
-
"validationpkg/validationutils"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
// Store_confirm stores data from payload to storage for the confirm action
|
|
11
|
-
func Store_confirm(
|
|
12
|
-
uniquePrefix string,
|
|
13
|
-
payload interface{},
|
|
14
|
-
store validationutils.StorageInterface,
|
|
15
|
-
config StorageConfig,
|
|
16
|
-
) error {
|
|
17
|
-
fmt.Printf("Stored data for action confirm successfully\n")
|
|
18
|
-
return nil
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// LoadFor_confirm loads stored data for the confirm action
|
|
22
|
-
func LoadFor_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 confirm: %+v\n", result)
|
|
29
|
-
return result, nil
|
|
30
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// Code generated by github.com/ONDC-Official/automation-validation-compiler, DO NOT EDIT.
|
|
2
|
-
package storageutils
|
|
3
|
-
|
|
4
|
-
import (
|
|
5
|
-
"fmt"
|
|
6
|
-
"validationpkg/validationutils"
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
// PerformL1validationsSave saves validation state data for a given action
|
|
10
|
-
//
|
|
11
|
-
// Parameters:
|
|
12
|
-
// - action: The action name
|
|
13
|
-
// - uniquePrefix: Unique namespace prefix
|
|
14
|
-
// - payload: The payload data to extract and save
|
|
15
|
-
// - store: Storage interface implementation
|
|
16
|
-
// - config: Optional storage configuration (nil uses defaults)
|
|
17
|
-
//
|
|
18
|
-
// Returns error if the action is not found or save fails
|
|
19
|
-
func PerformL1validationsSave(
|
|
20
|
-
action string,
|
|
21
|
-
uniquePrefix string,
|
|
22
|
-
payload interface{},
|
|
23
|
-
store validationutils.StorageInterface,
|
|
24
|
-
config *StorageConfig,
|
|
25
|
-
) error {
|
|
26
|
-
// Set default config if not provided
|
|
27
|
-
completeConfig := StorageConfig{
|
|
28
|
-
RetryAttempts: 3,
|
|
29
|
-
RetryDelayMs: 1000,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if config != nil {
|
|
33
|
-
if config.RetryAttempts > 0 {
|
|
34
|
-
completeConfig.RetryAttempts = config.RetryAttempts
|
|
35
|
-
}
|
|
36
|
-
if config.RetryDelayMs > 0 {
|
|
37
|
-
completeConfig.RetryDelayMs = config.RetryDelayMs
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
switch action {
|
|
42
|
-
case "search":
|
|
43
|
-
return Store_search(uniquePrefix, payload, store, completeConfig)
|
|
44
|
-
case "init":
|
|
45
|
-
return Store_init(uniquePrefix, payload, store, completeConfig)
|
|
46
|
-
case "confirm":
|
|
47
|
-
return Store_confirm(uniquePrefix, payload, store, completeConfig)
|
|
48
|
-
case "status":
|
|
49
|
-
return Store_status(uniquePrefix, payload, store, completeConfig)
|
|
50
|
-
case "track":
|
|
51
|
-
return Store_track(uniquePrefix, payload, store, completeConfig)
|
|
52
|
-
case "cancel":
|
|
53
|
-
return Store_cancel(uniquePrefix, payload, store, completeConfig)
|
|
54
|
-
case "update":
|
|
55
|
-
return Store_update(uniquePrefix, payload, store, completeConfig)
|
|
56
|
-
case "on_search":
|
|
57
|
-
return Store_on_search(uniquePrefix, payload, store, completeConfig)
|
|
58
|
-
case "on_init":
|
|
59
|
-
return Store_on_init(uniquePrefix, payload, store, completeConfig)
|
|
60
|
-
case "on_confirm":
|
|
61
|
-
return Store_on_confirm(uniquePrefix, payload, store, completeConfig)
|
|
62
|
-
case "on_track":
|
|
63
|
-
return Store_on_track(uniquePrefix, payload, store, completeConfig)
|
|
64
|
-
case "on_cancel":
|
|
65
|
-
return Store_on_cancel(uniquePrefix, payload, store, completeConfig)
|
|
66
|
-
case "on_update":
|
|
67
|
-
return Store_on_update(uniquePrefix, payload, store, completeConfig)
|
|
68
|
-
case "on_status":
|
|
69
|
-
return Store_on_status(uniquePrefix, payload, store, completeConfig)
|
|
70
|
-
case "issue":
|
|
71
|
-
return Store_issue(uniquePrefix, payload, store, completeConfig)
|
|
72
|
-
case "on_issue":
|
|
73
|
-
return Store_on_issue(uniquePrefix, payload, store, completeConfig)
|
|
74
|
-
case "on_issue_status":
|
|
75
|
-
return Store_on_issue_status(uniquePrefix, payload, store, completeConfig)
|
|
76
|
-
default:
|
|
77
|
-
return fmt.Errorf("action not found: %s", action)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// PerformL1validationsLoad loads validation state data for a given action
|
|
82
|
-
//
|
|
83
|
-
// Parameters:
|
|
84
|
-
// - action: The action name
|
|
85
|
-
// - uniquePrefix: Unique namespace prefix
|
|
86
|
-
// - store: Storage interface implementation
|
|
87
|
-
//
|
|
88
|
-
// Returns ExternalData with loaded values and error if action not found
|
|
89
|
-
func PerformL1validationsLoad(
|
|
90
|
-
action string,
|
|
91
|
-
uniquePrefix string,
|
|
92
|
-
store validationutils.StorageInterface,
|
|
93
|
-
) (validationutils.ExternalData, error) {
|
|
94
|
-
switch action {
|
|
95
|
-
case "search":
|
|
96
|
-
return LoadFor_search(uniquePrefix, store)
|
|
97
|
-
case "init":
|
|
98
|
-
return LoadFor_init(uniquePrefix, store)
|
|
99
|
-
case "confirm":
|
|
100
|
-
return LoadFor_confirm(uniquePrefix, store)
|
|
101
|
-
case "status":
|
|
102
|
-
return LoadFor_status(uniquePrefix, store)
|
|
103
|
-
case "track":
|
|
104
|
-
return LoadFor_track(uniquePrefix, store)
|
|
105
|
-
case "cancel":
|
|
106
|
-
return LoadFor_cancel(uniquePrefix, store)
|
|
107
|
-
case "update":
|
|
108
|
-
return LoadFor_update(uniquePrefix, store)
|
|
109
|
-
case "on_search":
|
|
110
|
-
return LoadFor_on_search(uniquePrefix, store)
|
|
111
|
-
case "on_init":
|
|
112
|
-
return LoadFor_on_init(uniquePrefix, store)
|
|
113
|
-
case "on_confirm":
|
|
114
|
-
return LoadFor_on_confirm(uniquePrefix, store)
|
|
115
|
-
case "on_track":
|
|
116
|
-
return LoadFor_on_track(uniquePrefix, store)
|
|
117
|
-
case "on_cancel":
|
|
118
|
-
return LoadFor_on_cancel(uniquePrefix, store)
|
|
119
|
-
case "on_update":
|
|
120
|
-
return LoadFor_on_update(uniquePrefix, store)
|
|
121
|
-
case "on_status":
|
|
122
|
-
return LoadFor_on_status(uniquePrefix, store)
|
|
123
|
-
case "issue":
|
|
124
|
-
return LoadFor_issue(uniquePrefix, store)
|
|
125
|
-
case "on_issue":
|
|
126
|
-
return LoadFor_on_issue(uniquePrefix, store)
|
|
127
|
-
case "on_issue_status":
|
|
128
|
-
return LoadFor_on_issue_status(uniquePrefix, store)
|
|
129
|
-
default:
|
|
130
|
-
return validationutils.ExternalData{}, fmt.Errorf("action not found: %s", action)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
@@ -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
|
-
"validationpkg/validationutils"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
// Store_init stores data from payload to storage for the init action
|
|
11
|
-
func Store_init(
|
|
12
|
-
uniquePrefix string,
|
|
13
|
-
payload interface{},
|
|
14
|
-
store validationutils.StorageInterface,
|
|
15
|
-
config StorageConfig,
|
|
16
|
-
) error {
|
|
17
|
-
fmt.Printf("Stored data for action init successfully\n")
|
|
18
|
-
return nil
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// LoadFor_init loads stored data for the init action
|
|
22
|
-
func LoadFor_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 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
|
-
"validationpkg/validationutils"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
// Store_issue stores data from payload to storage for the issue action
|
|
11
|
-
func Store_issue(
|
|
12
|
-
uniquePrefix string,
|
|
13
|
-
payload interface{},
|
|
14
|
-
store validationutils.StorageInterface,
|
|
15
|
-
config StorageConfig,
|
|
16
|
-
) error {
|
|
17
|
-
fmt.Printf("Stored data for action issue successfully\n")
|
|
18
|
-
return nil
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// LoadFor_issue loads stored data for the issue action
|
|
22
|
-
func LoadFor_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 issue: %+v\n", result)
|
|
29
|
-
return result, nil
|
|
30
|
-
}
|