@voxgig/sdkgen 3.3.2 → 3.4.2
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/cmp/Readme.js +2 -0
- package/dist/cmp/Readme.js.map +1 -1
- package/dist/cmp/ReadmeUnions.d.ts +3 -0
- package/dist/cmp/ReadmeUnions.js +74 -0
- package/dist/cmp/ReadmeUnions.js.map +1 -0
- 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 +27 -2
- package/project/.sdk/src/cmp/go/Main_go.ts +1 -0
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +1 -1
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +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 +30 -1
- package/project/.sdk/src/cmp/lua/Package_lua.ts +1 -0
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +1 -1
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +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 +24 -1
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +1 -1
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +22 -0
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +1 -1
- package/project/.sdk/src/cmp/php/utility_php.ts +57 -6
- package/project/.sdk/src/cmp/py/Config_py.ts +24 -1
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +2 -2
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +2 -2
- package/project/.sdk/src/cmp/py/utility_py.ts +57 -6
- package/project/.sdk/src/cmp/rb/Config_rb.ts +15 -1
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +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/go/test/feature_harness_test.go +1 -1
- package/project/.sdk/tm/go/utility/make_options.go +5 -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/lua/utility/make_options.lua +5 -1
- package/project/.sdk/tm/php/test/FeatureTest.php +1 -1
- package/project/.sdk/tm/py/pkg/utility/make_options.py +5 -1
- package/project/.sdk/tm/py/test/feature_harness.py +2 -2
- package/project/.sdk/tm/rb/test/feature_test.rb +1 -1
- package/project/.sdk/tm/rb/utility/make_options.rb +5 -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/cmp/Readme.ts +2 -0
- package/src/cmp/ReadmeUnions.ts +90 -0
|
@@ -89,13 +89,64 @@ function formatCValue(val: any, indent: number = 0): string {
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
// Deep-remove meta keys (`foo$`) from a model subtree (twin of go/rust clean).
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
93
|
+
//
|
|
94
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
95
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
96
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
97
|
+
// payload — see CONFIG_DEFAULT.
|
|
98
|
+
//
|
|
99
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
100
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
101
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
102
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
103
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
104
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
105
|
+
//
|
|
106
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
107
|
+
// `active` means something different in feature config, where absent reads as
|
|
108
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
109
|
+
// disable the feature.
|
|
110
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
111
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
112
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
113
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
114
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
115
|
+
|
|
116
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
117
|
+
// absent, so emitting them is pure payload.
|
|
118
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
119
|
+
active: true,
|
|
120
|
+
req: false,
|
|
121
|
+
reqd: false,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
125
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
126
|
+
// keys and everything below them is passed through untouched.
|
|
127
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
128
|
+
|
|
129
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
130
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
131
|
+
if (Array.isArray(node)) {
|
|
132
|
+
return node.map((n: any) => prune(n, defaults))
|
|
96
133
|
}
|
|
97
|
-
|
|
98
|
-
|
|
134
|
+
if (null != node && 'object' === typeof node) {
|
|
135
|
+
const out: any = {}
|
|
136
|
+
for (const k of Object.keys(node)) {
|
|
137
|
+
if (MODEL_META.includes(k)) {
|
|
138
|
+
continue
|
|
139
|
+
}
|
|
140
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
144
|
+
}
|
|
145
|
+
return out
|
|
146
|
+
}
|
|
147
|
+
return node
|
|
148
|
+
}
|
|
149
|
+
return prune(o, true === dropDefaults)
|
|
99
150
|
}
|
|
100
151
|
|
|
101
152
|
|
|
@@ -64,13 +64,64 @@ function cljString(s: string): string {
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
// Remove `$`-suffixed model annotation keys (mirrors utility_rb.clean).
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
68
|
+
//
|
|
69
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
70
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
71
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
72
|
+
// payload — see CONFIG_DEFAULT.
|
|
73
|
+
//
|
|
74
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
75
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
76
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
77
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
78
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
79
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
80
|
+
//
|
|
81
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
82
|
+
// `active` means something different in feature config, where absent reads as
|
|
83
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
84
|
+
// disable the feature.
|
|
85
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
86
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
87
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
88
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
89
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
90
|
+
|
|
91
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
92
|
+
// absent, so emitting them is pure payload.
|
|
93
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
94
|
+
active: true,
|
|
95
|
+
req: false,
|
|
96
|
+
reqd: false,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
100
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
101
|
+
// keys and everything below them is passed through untouched.
|
|
102
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
103
|
+
|
|
104
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
105
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
106
|
+
if (Array.isArray(node)) {
|
|
107
|
+
return node.map((n: any) => prune(n, defaults))
|
|
108
|
+
}
|
|
109
|
+
if (null != node && 'object' === typeof node) {
|
|
110
|
+
const out: any = {}
|
|
111
|
+
for (const k of Object.keys(node)) {
|
|
112
|
+
if (MODEL_META.includes(k)) {
|
|
113
|
+
continue
|
|
114
|
+
}
|
|
115
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
116
|
+
continue
|
|
117
|
+
}
|
|
118
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
119
|
+
}
|
|
120
|
+
return out
|
|
71
121
|
}
|
|
72
|
-
return
|
|
73
|
-
}
|
|
122
|
+
return node
|
|
123
|
+
}
|
|
124
|
+
return prune(o, true === dropDefaults)
|
|
74
125
|
}
|
|
75
126
|
|
|
76
127
|
|
|
@@ -30,13 +30,64 @@ function cppVarName(name: string): string {
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
// Deep-remove meta keys (`foo$`) from a model subtree.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
34
|
+
//
|
|
35
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
36
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
37
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
38
|
+
// payload — see CONFIG_DEFAULT.
|
|
39
|
+
//
|
|
40
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
41
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
42
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
43
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
44
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
45
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
46
|
+
//
|
|
47
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
48
|
+
// `active` means something different in feature config, where absent reads as
|
|
49
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
50
|
+
// disable the feature.
|
|
51
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
52
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
53
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
54
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
55
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
56
|
+
|
|
57
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
58
|
+
// absent, so emitting them is pure payload.
|
|
59
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
60
|
+
active: true,
|
|
61
|
+
req: false,
|
|
62
|
+
reqd: false,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
66
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
67
|
+
// keys and everything below them is passed through untouched.
|
|
68
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
69
|
+
|
|
70
|
+
function cleanModel(o: any, dropDefaults?: boolean): any {
|
|
71
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
72
|
+
if (Array.isArray(node)) {
|
|
73
|
+
return node.map((n: any) => prune(n, defaults))
|
|
74
|
+
}
|
|
75
|
+
if (null != node && 'object' === typeof node) {
|
|
76
|
+
const out: any = {}
|
|
77
|
+
for (const k of Object.keys(node)) {
|
|
78
|
+
if (MODEL_META.includes(k)) {
|
|
79
|
+
continue
|
|
80
|
+
}
|
|
81
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
82
|
+
continue
|
|
83
|
+
}
|
|
84
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
85
|
+
}
|
|
86
|
+
return out
|
|
37
87
|
}
|
|
38
|
-
return
|
|
39
|
-
}
|
|
88
|
+
return node
|
|
89
|
+
}
|
|
90
|
+
return prune(o, true === dropDefaults)
|
|
40
91
|
}
|
|
41
92
|
|
|
42
93
|
|
|
@@ -122,13 +122,64 @@ function formatCsValue(val: any, indent: number = 0): string {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
126
|
+
//
|
|
127
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
128
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
129
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
130
|
+
// payload — see CONFIG_DEFAULT.
|
|
131
|
+
//
|
|
132
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
133
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
134
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
135
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
136
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
137
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
138
|
+
//
|
|
139
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
140
|
+
// `active` means something different in feature config, where absent reads as
|
|
141
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
142
|
+
// disable the feature.
|
|
143
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
144
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
145
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
146
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
147
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
148
|
+
|
|
149
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
150
|
+
// absent, so emitting them is pure payload.
|
|
151
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
152
|
+
active: true,
|
|
153
|
+
req: false,
|
|
154
|
+
reqd: false,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
158
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
159
|
+
// keys and everything below them is passed through untouched.
|
|
160
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
161
|
+
|
|
162
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
163
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
164
|
+
if (Array.isArray(node)) {
|
|
165
|
+
return node.map((n: any) => prune(n, defaults))
|
|
129
166
|
}
|
|
130
|
-
|
|
131
|
-
|
|
167
|
+
if (null != node && 'object' === typeof node) {
|
|
168
|
+
const out: any = {}
|
|
169
|
+
for (const k of Object.keys(node)) {
|
|
170
|
+
if (MODEL_META.includes(k)) {
|
|
171
|
+
continue
|
|
172
|
+
}
|
|
173
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
174
|
+
continue
|
|
175
|
+
}
|
|
176
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
177
|
+
}
|
|
178
|
+
return out
|
|
179
|
+
}
|
|
180
|
+
return node
|
|
181
|
+
}
|
|
182
|
+
return prune(o, true === dropDefaults)
|
|
132
183
|
}
|
|
133
184
|
|
|
134
185
|
|
|
@@ -68,13 +68,64 @@ function projectPath(suffix?: string): string {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
72
|
+
//
|
|
73
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
74
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
75
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
76
|
+
// payload — see CONFIG_DEFAULT.
|
|
77
|
+
//
|
|
78
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
79
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
80
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
81
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
82
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
83
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
84
|
+
//
|
|
85
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
86
|
+
// `active` means something different in feature config, where absent reads as
|
|
87
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
88
|
+
// disable the feature.
|
|
89
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
90
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
91
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
92
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
93
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
94
|
+
|
|
95
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
96
|
+
// absent, so emitting them is pure payload.
|
|
97
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
98
|
+
active: true,
|
|
99
|
+
req: false,
|
|
100
|
+
reqd: false,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
104
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
105
|
+
// keys and everything below them is passed through untouched.
|
|
106
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
107
|
+
|
|
108
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
109
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
110
|
+
if (Array.isArray(node)) {
|
|
111
|
+
return node.map((n: any) => prune(n, defaults))
|
|
112
|
+
}
|
|
113
|
+
if (null != node && 'object' === typeof node) {
|
|
114
|
+
const out: any = {}
|
|
115
|
+
for (const k of Object.keys(node)) {
|
|
116
|
+
if (MODEL_META.includes(k)) {
|
|
117
|
+
continue
|
|
118
|
+
}
|
|
119
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
120
|
+
continue
|
|
121
|
+
}
|
|
122
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
123
|
+
}
|
|
124
|
+
return out
|
|
75
125
|
}
|
|
76
|
-
return
|
|
77
|
-
}
|
|
126
|
+
return node
|
|
127
|
+
}
|
|
128
|
+
return prune(o, true === dropDefaults)
|
|
78
129
|
}
|
|
79
130
|
|
|
80
131
|
|
|
@@ -97,13 +97,64 @@ function elixirString(s: string): string {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
101
|
+
//
|
|
102
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
103
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
104
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
105
|
+
// payload — see CONFIG_DEFAULT.
|
|
106
|
+
//
|
|
107
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
108
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
109
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
110
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
111
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
112
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
113
|
+
//
|
|
114
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
115
|
+
// `active` means something different in feature config, where absent reads as
|
|
116
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
117
|
+
// disable the feature.
|
|
118
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
119
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
120
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
121
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
122
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
123
|
+
|
|
124
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
125
|
+
// absent, so emitting them is pure payload.
|
|
126
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
127
|
+
active: true,
|
|
128
|
+
req: false,
|
|
129
|
+
reqd: false,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
133
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
134
|
+
// keys and everything below them is passed through untouched.
|
|
135
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
136
|
+
|
|
137
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
138
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
139
|
+
if (Array.isArray(node)) {
|
|
140
|
+
return node.map((n: any) => prune(n, defaults))
|
|
104
141
|
}
|
|
105
|
-
|
|
106
|
-
|
|
142
|
+
if (null != node && 'object' === typeof node) {
|
|
143
|
+
const out: any = {}
|
|
144
|
+
for (const k of Object.keys(node)) {
|
|
145
|
+
if (MODEL_META.includes(k)) {
|
|
146
|
+
continue
|
|
147
|
+
}
|
|
148
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
149
|
+
continue
|
|
150
|
+
}
|
|
151
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
152
|
+
}
|
|
153
|
+
return out
|
|
154
|
+
}
|
|
155
|
+
return node
|
|
156
|
+
}
|
|
157
|
+
return prune(o, true === dropDefaults)
|
|
107
158
|
}
|
|
108
159
|
|
|
109
160
|
|
|
@@ -67,9 +67,16 @@ const Config = cmp(async function Config(props: any) {
|
|
|
67
67
|
|
|
68
68
|
Content(`package core
|
|
69
69
|
|
|
70
|
+
import (
|
|
71
|
+
"sync"
|
|
72
|
+
)
|
|
73
|
+
|
|
70
74
|
`)
|
|
71
75
|
|
|
72
|
-
Content(
|
|
76
|
+
Content(`// MakeConfig builds a fresh, fully materialised config map. Every call
|
|
77
|
+
// rebuilds the whole structure, so prefer SharedConfig unless you need a
|
|
78
|
+
// private copy you intend to mutate.
|
|
79
|
+
func MakeConfig() map[string]any {
|
|
73
80
|
return map[string]any{
|
|
74
81
|
"main": map[string]any{
|
|
75
82
|
"name": "${model.const.Name}",
|
|
@@ -103,10 +110,28 @@ ${serverBlock}${authBlock} "headers": ${formatGoMap(headers, 3)},
|
|
|
103
110
|
name: n.name,
|
|
104
111
|
op: n.op,
|
|
105
112
|
relations: n.relations,
|
|
106
|
-
}), a), {}), 2)},
|
|
113
|
+
}, true), a), {}), 2)},
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
|
|
117
|
+
var (
|
|
118
|
+
sharedConfigOnce sync.Once
|
|
119
|
+
sharedConfigVal map[string]any
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
// SharedConfig returns the process-wide config, built once on first use.
|
|
123
|
+
// The SDK reads the config on every request and never writes to it, so one
|
|
124
|
+
// instance is shared by every client rather than rebuilt per client.
|
|
125
|
+
//
|
|
126
|
+
// The returned map is shared: treat it as read-only. Callers that need to
|
|
127
|
+
// mutate should use MakeConfig, which always returns a fresh copy.
|
|
128
|
+
func SharedConfig() map[string]any {
|
|
129
|
+
sharedConfigOnce.Do(func() {
|
|
130
|
+
sharedConfigVal = MakeConfig()
|
|
131
|
+
})
|
|
132
|
+
return sharedConfigVal
|
|
133
|
+
}
|
|
134
|
+
|
|
110
135
|
func makeFeature(name string) Feature {
|
|
111
136
|
switch name {
|
|
112
137
|
`)
|
|
@@ -204,6 +204,7 @@ var NewResult = core.NewResult
|
|
|
204
204
|
var NewResponse = core.NewResponse
|
|
205
205
|
var NewOperation = core.NewOperation
|
|
206
206
|
var MakeConfig = core.MakeConfig
|
|
207
|
+
var SharedConfig = core.SharedConfig
|
|
207
208
|
|
|
208
209
|
// No-arg convenience constructors. Go has no default-argument syntax,
|
|
209
210
|
// so these aliases let callers write \`sdk.New()\` / \`sdk.Test()\`
|
|
@@ -153,7 +153,7 @@ ${hasList ? `
|
|
|
153
153
|
|
|
154
154
|
// Inbound: streaming active -> yields each item from the feature iterator.
|
|
155
155
|
hasStreaming := false
|
|
156
|
-
if fm, ok := core.
|
|
156
|
+
if fm, ok := core.SharedConfig()["feature"].(map[string]any); ok {
|
|
157
157
|
_, hasStreaming = fm["streaming"]
|
|
158
158
|
}
|
|
159
159
|
if hasStreaming {
|
|
@@ -140,13 +140,64 @@ function formatGoValue(val: any, indent: number = 0): string {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
// Emission-time normalisation of a model subtree (L0).
|
|
144
|
+
//
|
|
145
|
+
// Always drops jostraca's iteration metadata (`$`-suffixed keys: index$,
|
|
146
|
+
// key$, val$). With `dropDefaults`, also drops keys whose value IS the
|
|
147
|
+
// default the runtime already assumes when the key is absent, which is pure
|
|
148
|
+
// payload — see CONFIG_DEFAULT.
|
|
149
|
+
//
|
|
150
|
+
// Rebuilds the tree rather than mutating during a walk. The previous
|
|
151
|
+
// implementation walked a clone calling `delete p[k]`, but walk() assigns its
|
|
152
|
+
// callback's result back over the child (`setprop(out, ckey, walk(...))`), so
|
|
153
|
+
// the delete was undone on the way out and the helper silently did nothing.
|
|
154
|
+
// Returning `undefined` from the callback does not fix it either: setprop
|
|
155
|
+
// stores undefined rather than removing the key, which then emits as a null.
|
|
156
|
+
//
|
|
157
|
+
// `dropDefaults` is opt-in and must be passed ONLY for the entity subtree.
|
|
158
|
+
// `active` means something different in feature config, where absent reads as
|
|
159
|
+
// INACTIVE (see feature_init) — dropping `active: true` there would silently
|
|
160
|
+
// disable the feature.
|
|
161
|
+
// jostraca's iteration metadata, injected by each()/names() while it walks the
|
|
162
|
+
// model. Listed explicitly rather than matched by trailing-dollar suffix: a
|
|
163
|
+
// trailing dollar is not exclusive to jostraca -- Seneca uses entity$ as real
|
|
164
|
+
// data -- so a blanket suffix match can silently drop a legitimate API field.
|
|
165
|
+
const MODEL_META = ['index$', 'key$', 'val$']
|
|
166
|
+
|
|
167
|
+
// Keys whose value IS the default the runtime already assumes when the key is
|
|
168
|
+
// absent, so emitting them is pure payload.
|
|
169
|
+
const CONFIG_DEFAULT: Record<string, any> = {
|
|
170
|
+
active: true,
|
|
171
|
+
req: false,
|
|
172
|
+
reqd: false,
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Subtrees carrying user payload rather than schema. An active:true inside an
|
|
176
|
+
// OpenAPI example is DATA, not a default, so default-pruning stops at these
|
|
177
|
+
// keys and everything below them is passed through untouched.
|
|
178
|
+
const PAYLOAD_KEYS = ['default', 'example', 'examples']
|
|
179
|
+
|
|
180
|
+
function clean(o: any, dropDefaults?: boolean): any {
|
|
181
|
+
const prune = (node: any, defaults: boolean): any => {
|
|
182
|
+
if (Array.isArray(node)) {
|
|
183
|
+
return node.map((n: any) => prune(n, defaults))
|
|
147
184
|
}
|
|
148
|
-
|
|
149
|
-
|
|
185
|
+
if (null != node && 'object' === typeof node) {
|
|
186
|
+
const out: any = {}
|
|
187
|
+
for (const k of Object.keys(node)) {
|
|
188
|
+
if (MODEL_META.includes(k)) {
|
|
189
|
+
continue
|
|
190
|
+
}
|
|
191
|
+
if (defaults && k in CONFIG_DEFAULT && CONFIG_DEFAULT[k] === node[k]) {
|
|
192
|
+
continue
|
|
193
|
+
}
|
|
194
|
+
out[k] = prune(node[k], defaults && !PAYLOAD_KEYS.includes(k))
|
|
195
|
+
}
|
|
196
|
+
return out
|
|
197
|
+
}
|
|
198
|
+
return node
|
|
199
|
+
}
|
|
200
|
+
return prune(o, true === dropDefaults)
|
|
150
201
|
}
|
|
151
202
|
|
|
152
203
|
|