jason-rails 0.6.8 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -12
- data/app/workers/jason/outbound_message_queue_worker.rb +1 -1
- data/client/lib/addRelations.d.ts +1 -0
- data/client/lib/addRelations.js +39 -0
- data/client/lib/createJasonReducers.js +4 -2
- data/client/lib/createOptDis.d.ts +1 -1
- data/client/lib/createOptDis.js +9 -8
- data/client/lib/createServerActionQueue.d.ts +3 -2
- data/client/lib/createServerActionQueue.js +32 -6
- data/client/lib/createServerActionQueue.test.js +61 -6
- data/client/lib/createThenable.d.ts +1 -0
- data/client/lib/createThenable.js +5 -0
- data/client/lib/transportAdapters/actionCableAdapter.js +24 -4
- data/client/lib/transportAdapters/pusherAdapter.js +1 -1
- data/client/lib/useDraft.d.ts +1 -0
- data/client/lib/useDraft.js +13 -0
- data/client/lib/useEager.d.ts +1 -1
- data/client/lib/useEager.js +10 -5
- data/client/lib/useJason.js +0 -3
- data/client/package.json +1 -1
- data/client/src/addRelations.ts +33 -0
- data/client/src/createJasonReducers.ts +4 -2
- data/client/src/createOptDis.ts +10 -8
- data/client/src/createServerActionQueue.test.ts +60 -6
- data/client/src/createServerActionQueue.ts +41 -6
- data/client/src/transportAdapters/actionCableAdapter.ts +24 -5
- data/client/src/transportAdapters/pusherAdapter.ts +1 -2
- data/client/src/useDraft.ts +17 -0
- data/client/src/useEager.ts +9 -6
- data/client/src/useJason.ts +0 -3
- data/lib/jason.rb +2 -0
- data/lib/jason/api_model.rb +0 -4
- data/lib/jason/channel.rb +0 -7
- data/lib/jason/conditions_matcher.rb +88 -0
- data/lib/jason/consistency_checker.rb +61 -0
- data/lib/jason/graph_helper.rb +4 -0
- data/lib/jason/publisher.rb +34 -5
- data/lib/jason/subscription.rb +49 -13
- data/lib/jason/version.rb +1 -1
- metadata +12 -3
- data/client/src/makeEager.ts +0 -46
data/client/src/makeEager.ts
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
import pluralize from 'pluralize'
|
2
|
-
import _ from 'lodash'
|
3
|
-
import { useSelector } from 'react-redux'
|
4
|
-
|
5
|
-
export default function (schema) {
|
6
|
-
function addRelations(s, objects, objectType, relations) {
|
7
|
-
// first find out relation name
|
8
|
-
if (_.isArray(relations)) {
|
9
|
-
relations.forEach(relation => {
|
10
|
-
objects = addRelations(s, objects, objectType, relation)
|
11
|
-
})
|
12
|
-
} else if (typeof(relations) === 'object') {
|
13
|
-
const relation = Object.keys(relations)[0]
|
14
|
-
const subRelations = relations[relation]
|
15
|
-
|
16
|
-
objects = addRelations(s, objects, objectType, relation)
|
17
|
-
objects[relation] = addRelations(s, objects[relation], pluralize(relation), subRelations)
|
18
|
-
// #
|
19
|
-
} else if (typeof(relations) === 'string') {
|
20
|
-
const relation = relations
|
21
|
-
if (_.isArray(objects)) {
|
22
|
-
objects = objects.map(obj => addRelations(s, obj, objectType, relation))
|
23
|
-
} else {
|
24
|
-
const relatedObjects = _.values(s[pluralize(relation)].entities)
|
25
|
-
|
26
|
-
if(pluralize.isSingular(relation)) {
|
27
|
-
objects = { ...objects, [relation]: _.find(relatedObjects, { id: objects[relation + 'Id'] }) }
|
28
|
-
} else {
|
29
|
-
objects = { ...objects, [relation]: relatedObjects.filter(e => e[pluralize.singular(objectType) + 'Id'] === objects.id) }
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
return objects
|
35
|
-
}
|
36
|
-
|
37
|
-
function useEager(entity, id = null, relations = []) {
|
38
|
-
if (id) {
|
39
|
-
return useSelector(s => addRelations(s, { ...s[entity].entities[String(id)] }, entity, relations), _.isEqual)
|
40
|
-
} else {
|
41
|
-
return useSelector(s => addRelations(s, _.values(s[entity].entities), entity, relations), _.isEqual)
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
return useEager
|
46
|
-
}
|