@voxgig/sdkgen 3.4.1 → 3.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/action/target.js +100 -0
- package/dist/action/target.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/c/Config_c.ts +1 -1
- package/project/.sdk/src/cmp/c/utility_c.ts +57 -6
- package/project/.sdk/src/cmp/clojure/Config_clojure.ts +1 -1
- package/project/.sdk/src/cmp/clojure/utility_clojure.ts +57 -6
- package/project/.sdk/src/cmp/cpp/Config_cpp.ts +1 -1
- package/project/.sdk/src/cmp/cpp/utility_cpp.ts +57 -6
- package/project/.sdk/src/cmp/csharp/Config_csharp.ts +1 -1
- package/project/.sdk/src/cmp/csharp/utility_csharp.ts +57 -6
- package/project/.sdk/src/cmp/dart/Config_dart.ts +1 -1
- package/project/.sdk/src/cmp/dart/utility_dart.ts +57 -6
- package/project/.sdk/src/cmp/elixir/Config_elixir.ts +1 -1
- package/project/.sdk/src/cmp/elixir/utility_elixir.ts +57 -6
- package/project/.sdk/src/cmp/go/Config_go.ts +1 -1
- package/project/.sdk/src/cmp/go/utility_go.ts +57 -6
- package/project/.sdk/src/cmp/haskell/Config_haskell.ts +1 -1
- package/project/.sdk/src/cmp/haskell/utility_haskell.ts +57 -6
- package/project/.sdk/src/cmp/java/Config_java.ts +1 -1
- package/project/.sdk/src/cmp/java/utility_java.ts +57 -6
- package/project/.sdk/src/cmp/js/Config_js.ts +1 -1
- package/project/.sdk/src/cmp/js/utility_js.ts +57 -6
- package/project/.sdk/src/cmp/kotlin/Config_kotlin.ts +1 -1
- package/project/.sdk/src/cmp/kotlin/utility_kotlin.ts +57 -6
- package/project/.sdk/src/cmp/lean/Config_lean.ts +1 -1
- package/project/.sdk/src/cmp/lean/utility_lean.ts +57 -6
- package/project/.sdk/src/cmp/lua/Config_lua.ts +1 -1
- package/project/.sdk/src/cmp/lua/utility_lua.ts +57 -6
- package/project/.sdk/src/cmp/ocaml/Config_ocaml.ts +1 -1
- package/project/.sdk/src/cmp/ocaml/utility_ocaml.ts +57 -6
- package/project/.sdk/src/cmp/perl/Config_perl.ts +1 -1
- package/project/.sdk/src/cmp/perl/utility_perl.ts +57 -6
- package/project/.sdk/src/cmp/php/Config_php.ts +1 -1
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +22 -0
- package/project/.sdk/src/cmp/php/utility_php.ts +57 -6
- package/project/.sdk/src/cmp/py/Config_py.ts +1 -1
- package/project/.sdk/src/cmp/py/utility_py.ts +57 -6
- package/project/.sdk/src/cmp/rb/Config_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/utility_rb.ts +57 -6
- package/project/.sdk/src/cmp/rust/Config_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/utility_rust.ts +57 -6
- package/project/.sdk/src/cmp/scala/Config_scala.ts +1 -1
- package/project/.sdk/src/cmp/scala/utility_scala.ts +57 -6
- package/project/.sdk/src/cmp/swift/Config_swift.ts +1 -1
- package/project/.sdk/src/cmp/swift/utility_swift.ts +57 -6
- package/project/.sdk/src/cmp/ts/Config_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/utility_ts.ts +57 -6
- package/project/.sdk/src/cmp/zig/Config_zig.ts +1 -1
- package/project/.sdk/src/cmp/zig/utility_zig.ts +57 -6
- package/project/.sdk/tm/c/core/point.c +2 -1
- package/project/.sdk/tm/csharp/core/Point.cs +3 -1
- package/project/.sdk/tm/dart/lib/Point.dart +2 -1
- package/project/.sdk/tm/java/core/Point.java +3 -1
- package/project/.sdk/tm/js/src/Point.js +3 -1
- package/project/.sdk/tm/kotlin/core/Point.kt +3 -1
- package/project/.sdk/tm/scala/core/Point.scala +2 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Point.swift +3 -1
- package/project/.sdk/tm/ts/src/Point.ts +3 -1
- package/project/.sdk/tm/zig/core/point.zig +2 -1
- package/src/action/target.ts +115 -0
|
@@ -66,13 +66,64 @@ function formatPyValue(val: any, indent: number = 0): string {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
70
|
+
//
|
|
71
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
72
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
73
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
74
|
+
// payload — see CONFIG_DEFAULT.
|
|
75
|
+
//
|
|
76
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
77
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
78
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
79
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
80
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
81
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
82
|
+
//
|
|
83
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
84
|
+
// `active` means something different in feature config, where absent reads as
|
|
85
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
86
|
+
// disable the feature.
|
|
87
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
88
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
89
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
90
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
91
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
92
|
+
|
|
93
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
94
|
+
// absent, so emitting them is pure payload.
|
|
95
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
96
|
+
active: true,
|
|
97
|
+
req: false,
|
|
98
|
+
reqd: false,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
102
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
103
|
+
// keys and everything below them is passed through untouched.
|
|
104
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
105
|
+
|
|
106
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
107
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
108
|
+
if (Array.isArray(node)) {
|
|
109
|
+
return node.map((n: any) => prune(n, defaults))
|
|
73
110
|
}
|
|
74
|
-
|
|
75
|
-
|
|
111
|
+
if (null != node && 'object' === typeof node) {
|
|
112
|
+
const out: any = {}
|
|
113
|
+
for (const k of Object.keys(node)) {
|
|
114
|
+
if (MODEL_META.includes(k)) {
|
|
115
|
+
continue
|
|
116
|
+
}
|
|
117
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
118
|
+
continue
|
|
119
|
+
}
|
|
120
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
121
|
+
}
|
|
122
|
+
return out
|
|
123
|
+
}
|
|
124
|
+
return node
|
|
125
|
+
}
|
|
126
|
+
return prune(o, true === dropDefaults)
|
|
76
127
|
}
|
|
77
128
|
|
|
78
129
|
|
|
@@ -66,13 +66,64 @@ function formatRubyValue(val: any, indent: number = 0): string {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
70
|
+
//
|
|
71
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
72
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
73
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
74
|
+
// payload — see CONFIG_DEFAULT.
|
|
75
|
+
//
|
|
76
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
77
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
78
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
79
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
80
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
81
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
82
|
+
//
|
|
83
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
84
|
+
// `active` means something different in feature config, where absent reads as
|
|
85
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
86
|
+
// disable the feature.
|
|
87
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
88
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
89
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
90
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
91
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
92
|
+
|
|
93
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
94
|
+
// absent, so emitting them is pure payload.
|
|
95
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
96
|
+
active: true,
|
|
97
|
+
req: false,
|
|
98
|
+
reqd: false,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
102
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
103
|
+
// keys and everything below them is passed through untouched.
|
|
104
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
105
|
+
|
|
106
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
107
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
108
|
+
if (Array.isArray(node)) {
|
|
109
|
+
return node.map((n: any) => prune(n, defaults))
|
|
73
110
|
}
|
|
74
|
-
|
|
75
|
-
|
|
111
|
+
if (null != node && 'object' === typeof node) {
|
|
112
|
+
const out: any = {}
|
|
113
|
+
for (const k of Object.keys(node)) {
|
|
114
|
+
if (MODEL_META.includes(k)) {
|
|
115
|
+
continue
|
|
116
|
+
}
|
|
117
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
118
|
+
continue
|
|
119
|
+
}
|
|
120
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
121
|
+
}
|
|
122
|
+
return out
|
|
123
|
+
}
|
|
124
|
+
return node
|
|
125
|
+
}
|
|
126
|
+
return prune(o, true === dropDefaults)
|
|
76
127
|
}
|
|
77
128
|
|
|
78
129
|
|
|
@@ -85,13 +85,64 @@ function formatRustValue(val: any, indent: number = 0): string {
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
// Deep-remove meta keys (`foo$`) from a model subtree (twin of go's clean).
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
89
|
+
//
|
|
90
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
91
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
92
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
93
|
+
// payload — see CONFIG_DEFAULT.
|
|
94
|
+
//
|
|
95
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
96
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
97
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
98
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
99
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
100
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
101
|
+
//
|
|
102
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
103
|
+
// `active` means something different in feature config, where absent reads as
|
|
104
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
105
|
+
// disable the feature.
|
|
106
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
107
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
108
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
109
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
110
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
111
|
+
|
|
112
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
113
|
+
// absent, so emitting them is pure payload.
|
|
114
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
115
|
+
active: true,
|
|
116
|
+
req: false,
|
|
117
|
+
reqd: false,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
121
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
122
|
+
// keys and everything below them is passed through untouched.
|
|
123
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
124
|
+
|
|
125
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
126
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
127
|
+
if (Array.isArray(node)) {
|
|
128
|
+
return node.map((n: any) => prune(n, defaults))
|
|
92
129
|
}
|
|
93
|
-
|
|
94
|
-
|
|
130
|
+
if (null != node && 'object' === typeof node) {
|
|
131
|
+
const out: any = {}
|
|
132
|
+
for (const k of Object.keys(node)) {
|
|
133
|
+
if (MODEL_META.includes(k)) {
|
|
134
|
+
continue
|
|
135
|
+
}
|
|
136
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
137
|
+
continue
|
|
138
|
+
}
|
|
139
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
140
|
+
}
|
|
141
|
+
return out
|
|
142
|
+
}
|
|
143
|
+
return node
|
|
144
|
+
}
|
|
145
|
+
return prune(o, true === dropDefaults)
|
|
95
146
|
}
|
|
96
147
|
|
|
97
148
|
|
|
@@ -65,13 +65,64 @@ function scalaVarName(name: string): string {
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
// Strip model bookkeeping keys (ending in $) from a config subtree.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
69
|
+
//
|
|
70
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
71
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
72
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
73
|
+
// payload — see CONFIG_DEFAULT.
|
|
74
|
+
//
|
|
75
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
76
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
77
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
78
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
79
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
80
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
81
|
+
//
|
|
82
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
83
|
+
// `active` means something different in feature config, where absent reads as
|
|
84
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
85
|
+
// disable the feature.
|
|
86
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
87
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
88
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
89
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
90
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
91
|
+
|
|
92
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
93
|
+
// absent, so emitting them is pure payload.
|
|
94
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
95
|
+
active: true,
|
|
96
|
+
req: false,
|
|
97
|
+
reqd: false,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
101
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
102
|
+
// keys and everything below them is passed through untouched.
|
|
103
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
104
|
+
|
|
105
|
+
function cleanModel(o: any, dropDefaults?: boolean): any {
|
|
106
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
107
|
+
if (Array.isArray(node)) {
|
|
108
|
+
return node.map((n: any) => prune(n, defaults))
|
|
109
|
+
}
|
|
110
|
+
if (null != node && 'object' === typeof node) {
|
|
111
|
+
const out: any = {}
|
|
112
|
+
for (const k of Object.keys(node)) {
|
|
113
|
+
if (MODEL_META.includes(k)) {
|
|
114
|
+
continue
|
|
115
|
+
}
|
|
116
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
117
|
+
continue
|
|
118
|
+
}
|
|
119
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
120
|
+
}
|
|
121
|
+
return out
|
|
72
122
|
}
|
|
73
|
-
return
|
|
74
|
-
}
|
|
123
|
+
return node
|
|
124
|
+
}
|
|
125
|
+
return prune(o, true === dropDefaults)
|
|
75
126
|
}
|
|
76
127
|
|
|
77
128
|
|
|
@@ -57,13 +57,64 @@ function swiftString(val: string): string {
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
// Strip model-internal keys (ending in `$`) from a cloned value graph.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
61
|
+
//
|
|
62
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
63
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
64
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
65
|
+
// payload — see CONFIG_DEFAULT.
|
|
66
|
+
//
|
|
67
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
68
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
69
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
70
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
71
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
72
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
73
|
+
//
|
|
74
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
75
|
+
// `active` means something different in feature config, where absent reads as
|
|
76
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
77
|
+
// disable the feature.
|
|
78
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
79
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
80
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
81
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
82
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
83
|
+
|
|
84
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
85
|
+
// absent, so emitting them is pure payload.
|
|
86
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
87
|
+
active: true,
|
|
88
|
+
req: false,
|
|
89
|
+
reqd: false,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
93
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
94
|
+
// keys and everything below them is passed through untouched.
|
|
95
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
96
|
+
|
|
97
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
98
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
99
|
+
if (Array.isArray(node)) {
|
|
100
|
+
return node.map((n: any) => prune(n, defaults))
|
|
101
|
+
}
|
|
102
|
+
if (null != node && 'object' === typeof node) {
|
|
103
|
+
const out: any = {}
|
|
104
|
+
for (const k of Object.keys(node)) {
|
|
105
|
+
if (MODEL_META.includes(k)) {
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
109
|
+
continue
|
|
110
|
+
}
|
|
111
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
112
|
+
}
|
|
113
|
+
return out
|
|
64
114
|
}
|
|
65
|
-
return
|
|
66
|
-
}
|
|
115
|
+
return node
|
|
116
|
+
}
|
|
117
|
+
return prune(o, true === dropDefaults)
|
|
67
118
|
}
|
|
68
119
|
|
|
69
120
|
|
|
@@ -104,13 +104,64 @@ function formatJson(obj: any, flags?: { line?: boolean, margin?: number }): stri
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
108
|
+
//
|
|
109
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
110
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
111
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
112
|
+
// payload — see CONFIG_DEFAULT.
|
|
113
|
+
//
|
|
114
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
115
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
116
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
117
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
118
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
119
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
120
|
+
//
|
|
121
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
122
|
+
// `active` means something different in feature config, where absent reads as
|
|
123
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
124
|
+
// disable the feature.
|
|
125
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
126
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
127
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
128
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
129
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
130
|
+
|
|
131
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
132
|
+
// absent, so emitting them is pure payload.
|
|
133
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
134
|
+
active: true,
|
|
135
|
+
req: false,
|
|
136
|
+
reqd: false,
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
140
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
141
|
+
// keys and everything below them is passed through untouched.
|
|
142
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
143
|
+
|
|
144
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
145
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
146
|
+
if (Array.isArray(node)) {
|
|
147
|
+
return node.map((n: any) => prune(n, defaults))
|
|
111
148
|
}
|
|
112
|
-
|
|
113
|
-
|
|
149
|
+
if (null != node && 'object' === typeof node) {
|
|
150
|
+
const out: any = {}
|
|
151
|
+
for (const k of Object.keys(node)) {
|
|
152
|
+
if (MODEL_META.includes(k)) {
|
|
153
|
+
continue
|
|
154
|
+
}
|
|
155
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
156
|
+
continue
|
|
157
|
+
}
|
|
158
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
159
|
+
}
|
|
160
|
+
return out
|
|
161
|
+
}
|
|
162
|
+
return node
|
|
163
|
+
}
|
|
164
|
+
return prune(o, true === dropDefaults)
|
|
114
165
|
}
|
|
115
166
|
|
|
116
167
|
|
|
@@ -77,13 +77,64 @@ function formatZigValue(val: any, indent: number = 0): string {
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
// Deep-remove meta keys (`foo$`) from a model subtree (twin of go's clean).
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
81
|
+
//
|
|
82
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
83
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
84
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
85
|
+
// payload — see CONFIG_DEFAULT.
|
|
86
|
+
//
|
|
87
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
88
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
89
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
90
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
91
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
92
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
93
|
+
//
|
|
94
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
95
|
+
// `active` means something different in feature config, where absent reads as
|
|
96
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
97
|
+
// disable the feature.
|
|
98
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
99
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
100
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
101
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
102
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
103
|
+
|
|
104
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
105
|
+
// absent, so emitting them is pure payload.
|
|
106
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
107
|
+
active: true,
|
|
108
|
+
req: false,
|
|
109
|
+
reqd: false,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
113
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
114
|
+
// keys and everything below them is passed through untouched.
|
|
115
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
116
|
+
|
|
117
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
118
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
119
|
+
if (Array.isArray(node)) {
|
|
120
|
+
return node.map((n: any) => prune(n, defaults))
|
|
121
|
+
}
|
|
122
|
+
if (null != node && 'object' === typeof node) {
|
|
123
|
+
const out: any = {}
|
|
124
|
+
for (const k of Object.keys(node)) {
|
|
125
|
+
if (MODEL_META.includes(k)) {
|
|
126
|
+
continue
|
|
127
|
+
}
|
|
128
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
129
|
+
continue
|
|
130
|
+
}
|
|
131
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
132
|
+
}
|
|
133
|
+
return out
|
|
84
134
|
}
|
|
85
|
-
return
|
|
86
|
-
}
|
|
135
|
+
return node
|
|
136
|
+
}
|
|
137
|
+
return prune(o, true === dropDefaults)
|
|
87
138
|
}
|
|
88
139
|
|
|
89
140
|
|
|
@@ -40,7 +40,8 @@ Point* point_new(voxgig_value* altmap) {
|
|
|
40
40
|
p->orig = dup_str(orig ? orig : "");
|
|
41
41
|
|
|
42
42
|
p->select = to_map(getp(altmap, "select"));
|
|
43
|
-
|
|
43
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a default (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
44
|
+
bool active = true;
|
|
44
45
|
get_bool(altmap, "active", &active);
|
|
45
46
|
p->active = active;
|
|
46
47
|
p->relations = getp(altmap, "relations");
|
|
@@ -13,7 +13,9 @@ public class Point
|
|
|
13
13
|
public List<object?> Parts = new();
|
|
14
14
|
public List<object?>? Params;
|
|
15
15
|
public Dictionary<string, object?>? Select;
|
|
16
|
-
|
|
16
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a
|
|
17
|
+
// default (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
18
|
+
public bool Active = true;
|
|
17
19
|
public List<object?>? Relations;
|
|
18
20
|
public Dictionary<string, object?> Alias = new();
|
|
19
21
|
public Dictionary<string, object?> Transform = new();
|
|
@@ -28,7 +28,8 @@ class Point {
|
|
|
28
28
|
parts = vs.getprop(altmap, 'parts', []);
|
|
29
29
|
params = vs.getprop(altmap, 'params', []);
|
|
30
30
|
select = vs.getprop(altmap, 'select');
|
|
31
|
-
active
|
|
31
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a default (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
32
|
+
active = vs.getprop(altmap, 'active', true);
|
|
32
33
|
relations = vs.getprop(altmap, 'relations', []);
|
|
33
34
|
alias = vs.getprop(altmap, 'alias', {});
|
|
34
35
|
transform = vs.getprop(altmap, 'transform', {'req': null, 'res': null});
|
|
@@ -18,7 +18,9 @@ public class Point {
|
|
|
18
18
|
public List<Object> parts = new ArrayList<>();
|
|
19
19
|
public List<Object> params;
|
|
20
20
|
public Map<String, Object> select;
|
|
21
|
-
|
|
21
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a
|
|
22
|
+
// default (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
23
|
+
public boolean active = true;
|
|
22
24
|
public List<Object> relations;
|
|
23
25
|
public Map<String, Object> alias = new LinkedHashMap<>();
|
|
24
26
|
public Map<String, Object> transform = new LinkedHashMap<>();
|
|
@@ -16,7 +16,9 @@ class Point {
|
|
|
16
16
|
this.parts = getprop(altmap, 'parts', [])
|
|
17
17
|
this.params = getprop(altmap, 'params', [])
|
|
18
18
|
this.select = getprop(altmap, 'select')
|
|
19
|
-
|
|
19
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a default
|
|
20
|
+
// (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
21
|
+
this.active = getprop(altmap, 'active', true)
|
|
20
22
|
this.relations = getprop(altmap, 'relations', [])
|
|
21
23
|
this.alias = getprop(altmap, 'alias', {})
|
|
22
24
|
this.transform = getprop(altmap, 'transform', { req: undefined, res: undefined })
|
|
@@ -13,7 +13,9 @@ class Point(pointmap: Map<String, Any?>?) {
|
|
|
13
13
|
var parts: MutableList<Any?> = mutableListOf()
|
|
14
14
|
var params: MutableList<Any?>? = null
|
|
15
15
|
var select: MutableMap<String, Any?>? = null
|
|
16
|
-
|
|
16
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a
|
|
17
|
+
// default (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
18
|
+
var active: Boolean = true
|
|
17
19
|
var relations: MutableList<Any?>? = null
|
|
18
20
|
var alias: MutableMap<String, Any?> = linkedMapOf()
|
|
19
21
|
var transform: MutableMap<String, Any?> = linkedMapOf()
|
|
@@ -13,7 +13,8 @@ class Point(pointmap: JMap[String, Object]) {
|
|
|
13
13
|
var parts: JList[Object] = new ArrayList[Object]()
|
|
14
14
|
var params: JList[Object] = null
|
|
15
15
|
var select: JMap[String, Object] = null
|
|
16
|
-
|
|
16
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a default (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
17
|
+
var active: Boolean = true
|
|
17
18
|
var relations: JList[Object] = null
|
|
18
19
|
var alias: JMap[String, Object] = new LinkedHashMap[String, Object]()
|
|
19
20
|
var transform: JMap[String, Object] = new LinkedHashMap[String, Object]()
|
|
@@ -10,7 +10,9 @@ public final class Point {
|
|
|
10
10
|
public var parts: VList = VList()
|
|
11
11
|
public var params: VList? = nil
|
|
12
12
|
public var select: VMap? = nil
|
|
13
|
-
|
|
13
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a
|
|
14
|
+
// default (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
15
|
+
public var active: Bool = true
|
|
14
16
|
public var relations: VList? = nil
|
|
15
17
|
public var alias: VMap = VMap()
|
|
16
18
|
public var transform: VMap = VMap()
|