entodicton 9.5.1-beta.22 → 9.5.1-beta.24
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/client.js +1 -1
- package/package.json +1 -1
- package/src/config.js +50 -5
- package/src/configHelpers.js +3 -2
- package/src/fragments.js +5 -1
- package/src/project2.js +7 -0
package/client.js
CHANGED
|
@@ -973,7 +973,7 @@ const rebuildTemplate = async ({ config, instance, target, previousResultss, reb
|
|
|
973
973
|
if (instance.fragments) {
|
|
974
974
|
pr = instance.fragments[index]
|
|
975
975
|
}
|
|
976
|
-
return Object.assign({}, toProperties(query), { property: 'fragments', previousResults: pr, skipSemantics:
|
|
976
|
+
return Object.assign({}, toProperties(query), { property: 'fragments', previousResults: pr, skipSemantics: true })
|
|
977
977
|
}
|
|
978
978
|
|
|
979
979
|
const looper = async (configs) => {
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -515,8 +515,43 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
|
515
515
|
if (moreConfig.bridges) {
|
|
516
516
|
moreConfig.bridges = moreConfig.bridges.map((bridge) => {
|
|
517
517
|
bridge = { ...bridge }
|
|
518
|
-
const valid = [
|
|
519
|
-
'
|
|
518
|
+
const valid = [
|
|
519
|
+
'after',
|
|
520
|
+
'associations',
|
|
521
|
+
'before',
|
|
522
|
+
'bridge',
|
|
523
|
+
'check',
|
|
524
|
+
'children',
|
|
525
|
+
'conditional',
|
|
526
|
+
'convolution',
|
|
527
|
+
'disabled',
|
|
528
|
+
'enhanced_associations',
|
|
529
|
+
'evaluator',
|
|
530
|
+
'evaluators',
|
|
531
|
+
'generatorp',
|
|
532
|
+
'generatorpr',
|
|
533
|
+
'generatorr',
|
|
534
|
+
'generators',
|
|
535
|
+
'id',
|
|
536
|
+
'inverted',
|
|
537
|
+
'isA',
|
|
538
|
+
'level',
|
|
539
|
+
'levelSpecificHierarchy',
|
|
540
|
+
'localHierarchy',
|
|
541
|
+
'operator',
|
|
542
|
+
'optional',
|
|
543
|
+
'parents',
|
|
544
|
+
'return_type_selector',
|
|
545
|
+
'scope',
|
|
546
|
+
'selector',
|
|
547
|
+
'semantic',
|
|
548
|
+
'semantics',
|
|
549
|
+
'separators',
|
|
550
|
+
'skipable',
|
|
551
|
+
'uuid',
|
|
552
|
+
'where',
|
|
553
|
+
'words', /Bridge$/,
|
|
554
|
+
]
|
|
520
555
|
helpers.validProps(valid, bridge, 'bridge')
|
|
521
556
|
handleBridgeProps(baseConfig, bridge, { addFirst, uuid })
|
|
522
557
|
return bridge
|
|
@@ -679,7 +714,7 @@ function setWordsUUIDs (words, uuid) {
|
|
|
679
714
|
for (const key in literals) {
|
|
680
715
|
literals[key] = literals[key].map((o) => Object.assign(o, { uuid }))
|
|
681
716
|
}
|
|
682
|
-
const patterns = words.patterns
|
|
717
|
+
const patterns = words.patterns || []
|
|
683
718
|
for (const pattern of patterns) {
|
|
684
719
|
pattern.defs.map((def) => Object.assign(def, { uuid }))
|
|
685
720
|
}
|
|
@@ -1137,10 +1172,20 @@ class Config {
|
|
|
1137
1172
|
}
|
|
1138
1173
|
}
|
|
1139
1174
|
|
|
1140
|
-
|
|
1175
|
+
// mappings are optional
|
|
1176
|
+
async fragment (args, query, mappings) {
|
|
1141
1177
|
const fragment = this.getFragment(query)
|
|
1142
1178
|
if (fragment) {
|
|
1143
|
-
|
|
1179
|
+
let fi = fragmentInstantiator(args, fragment.contexts)
|
|
1180
|
+
if (mappings) {
|
|
1181
|
+
fi = await fi
|
|
1182
|
+
return fi.instantiate([{
|
|
1183
|
+
match: ({context}) => !!mappings[context.value], // is the value in the mappings
|
|
1184
|
+
apply: ({context}) => Object.assign(context, mappings[context.value]),
|
|
1185
|
+
}])
|
|
1186
|
+
} else {
|
|
1187
|
+
return fi
|
|
1188
|
+
}
|
|
1144
1189
|
}
|
|
1145
1190
|
}
|
|
1146
1191
|
|
package/src/configHelpers.js
CHANGED
|
@@ -118,8 +118,9 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
118
118
|
// args.listable = listable(hierarchy)
|
|
119
119
|
// args.asList = asList
|
|
120
120
|
args.retry = () => { throw new RetryError() }
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
// mappings are optional
|
|
122
|
+
args.fragments = (query, mappings) => {
|
|
123
|
+
return config.fragment(args, query, mappings)
|
|
123
124
|
}
|
|
124
125
|
args.fragmentMapper = (values, fromModelQuery, toModelQuery) => {
|
|
125
126
|
return config.fragmentMapper(args, values, fromModelQuery, toModelQuery)
|
package/src/fragments.js
CHANGED
|
@@ -30,7 +30,11 @@ function fragmentInstantiator (args, contexts) {
|
|
|
30
30
|
todo.push({ context: context[key], path: [...path, key] })
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
if (contexts.length == 1 && instantiated.length == 1) {
|
|
34
|
+
return instantiated[0]
|
|
35
|
+
} else {
|
|
36
|
+
return instantiated
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
})
|
|
36
40
|
}
|
package/src/project2.js
CHANGED
|
@@ -3,6 +3,13 @@ function project(source, filters) {
|
|
|
3
3
|
return source
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
function isPlainObject(obj) {
|
|
7
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
8
|
+
}
|
|
9
|
+
if (!isPlainObject(source) && !Array.isArray(source)) {
|
|
10
|
+
return source
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
if (Object.keys(source).length === 0 && filters.length === 0) {
|
|
7
14
|
return {};
|
|
8
15
|
}
|