jason-rails 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e0d37099f467ff5bd4ab868732ce57c53bf055e6ecb8d0f0506bb14ee723d77
4
- data.tar.gz: 6912d141317dbc95edb96bc11ed29235a90fc6dd8575a4dcba18017b81a9964f
3
+ metadata.gz: e7f9c248374aaa06055ef47cfaed1c131b9341bee90708d215986e551ac4d9cc
4
+ data.tar.gz: 6e414392f9658ddcfe77b299c2edcd352977652d07f046d8d707d6d9b3b37d8b
5
5
  SHA512:
6
- metadata.gz: 3cce0310a94bba9c73237d3d18bcd7aa949fb35905b7dd76c69c05b6d8259f1fc6d0b79da2a01b3db34b372cf438ea96777c14d2bd3bdbfacf9ba27578e81f19
7
- data.tar.gz: f2460fea5f459d24966741cce29855b97b9361a900a848e8655ccdfb4cbaa03aa4d47135b2fa661961f7c8d46d37f5e9bc821ff97a6f5cdd22265f7a8d755758
6
+ metadata.gz: 34c5b26b7b909e8f4a24ce47b5c74ca584f9aca49d379c70972bdea1899c74a333acce67c4afdb21b86ef7c9ee31fb5cadfe4cbc91528380c37f5482d6f4ec1c
7
+ data.tar.gz: d6c760e610ddac664d3a95a60fce8c535b6485e745d3f58701bf67489f8a50f8b05d487af555e1ea392c8efaacaed8d8ca0f3fae36607d0bc90df129860398f9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.7.2
2
+ - Add JasonContext to exports, for use in scenarios where you need to forward the context into some other React reconciler (e.g. `react-three-fiber`)
3
+ - Fixed: Unneeded `reload` in Publisher resulting in extra database calls
4
+
1
5
  ## v0.7.1
2
6
  - Added: Authorization for REST endpoints. Previously these just inherited logic from ApplicationController. Pass a `update_authorization_service` option to the Jason initializer to use this.
3
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jason-rails (0.7.0)
4
+ jason-rails (0.7.1)
5
5
  connection_pool (>= 2.2.3)
6
6
  jsondiff
7
7
  rails (>= 5)
@@ -89,9 +89,10 @@ GEM
89
89
  marcel (0.3.3)
90
90
  mimemagic (~> 0.3.2)
91
91
  method_source (1.0.0)
92
- mimemagic (0.3.8)
92
+ mimemagic (0.3.10)
93
93
  nokogiri (~> 1)
94
- mini_mime (1.0.2)
94
+ rake
95
+ mini_mime (1.1.0)
95
96
  mini_portile2 (2.5.0)
96
97
  minitest (5.14.3)
97
98
  nio4r (2.5.7)
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- declare const JasonProvider: ({ reducers, middleware, extraActions, children }: {
2
+ declare const JasonProvider: ({ reducers, middleware, enhancers, extraActions, children }: {
3
3
  reducers?: any;
4
4
  middleware?: any;
5
+ enhancers?: any;
5
6
  extraActions?: any;
6
7
  children?: React.FC<{}> | undefined;
7
8
  }) => JSX.Element;
@@ -7,8 +7,8 @@ const react_1 = __importDefault(require("react"));
7
7
  const useJason_1 = __importDefault(require("./useJason"));
8
8
  const react_redux_1 = require("react-redux");
9
9
  const JasonContext_1 = __importDefault(require("./JasonContext"));
10
- const JasonProvider = ({ reducers, middleware, extraActions, children }) => {
11
- const [store, value] = useJason_1.default({ reducers, middleware, extraActions });
10
+ const JasonProvider = ({ reducers, middleware, enhancers, extraActions, children }) => {
11
+ const [store, value] = useJason_1.default({ reducers, middleware, enhancers, extraActions });
12
12
  if (!(store && value))
13
13
  return react_1.default.createElement("div", null); // Wait for async fetch of schema to complete
14
14
  return react_1.default.createElement(react_redux_1.Provider, { store: store },
@@ -2,9 +2,15 @@
2
2
  import _useAct from './useAct';
3
3
  import _useSub from './useSub';
4
4
  import _useEager from './useEager';
5
- export declare const JasonProvider: ({ reducers, middleware, extraActions, children }: {
5
+ export declare const JasonContext: import("react").Context<{
6
+ actions: any;
7
+ subscribe: null;
8
+ eager: (entity: any, id: any, relations: any) => void;
9
+ }>;
10
+ export declare const JasonProvider: ({ reducers, middleware, enhancers, extraActions, children }: {
6
11
  reducers?: any;
7
12
  middleware?: any;
13
+ enhancers?: any;
8
14
  extraActions?: any;
9
15
  children?: import("react").FC<{}> | undefined;
10
16
  }) => JSX.Element;
data/client/lib/index.js CHANGED
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useEager = exports.useSub = exports.useAct = exports.JasonProvider = void 0;
6
+ exports.useEager = exports.useSub = exports.useAct = exports.JasonProvider = exports.JasonContext = void 0;
7
+ const JasonContext_1 = __importDefault(require("./JasonContext"));
7
8
  const JasonProvider_1 = __importDefault(require("./JasonProvider"));
8
9
  const useAct_1 = __importDefault(require("./useAct"));
9
10
  const useSub_1 = __importDefault(require("./useSub"));
10
11
  const useEager_1 = __importDefault(require("./useEager"));
12
+ exports.JasonContext = JasonContext_1.default;
11
13
  exports.JasonProvider = JasonProvider_1.default;
12
14
  exports.useAct = useAct_1.default;
13
15
  exports.useSub = useSub_1.default;
@@ -1,5 +1,6 @@
1
- export default function useJason({ reducers, middleware, extraActions }: {
1
+ export default function useJason({ reducers, middleware, enhancers, extraActions }: {
2
2
  reducers?: any;
3
3
  middleware?: any[];
4
+ enhancers?: any[];
4
5
  extraActions?: any;
5
6
  }): any[];
@@ -16,7 +16,7 @@ const humps_1 = require("humps");
16
16
  const blueimp_md5_1 = __importDefault(require("blueimp-md5"));
17
17
  const lodash_1 = __importDefault(require("lodash"));
18
18
  const react_1 = require("react");
19
- function useJason({ reducers, middleware = [], extraActions }) {
19
+ function useJason({ reducers, middleware = [], enhancers = [], extraActions }) {
20
20
  const [store, setStore] = react_1.useState(null);
21
21
  const [value, setValue] = react_1.useState(null);
22
22
  react_1.useEffect(() => {
@@ -28,7 +28,7 @@ function useJason({ reducers, middleware = [], extraActions }) {
28
28
  const serverActionQueue = createServerActionQueue_1.default();
29
29
  const allReducers = Object.assign(Object.assign({}, reducers), createJasonReducers_1.default(schema));
30
30
  console.debug({ allReducers });
31
- const store = toolkit_1.configureStore({ reducer: allReducers, middleware: [...middleware, pruneIdsMiddleware_1.default(schema)] });
31
+ const store = toolkit_1.configureStore({ reducer: allReducers, middleware: [...middleware, pruneIdsMiddleware_1.default(schema)], enhancers });
32
32
  const dispatch = store.dispatch;
33
33
  const optDis = createOptDis_1.default(schema, dispatch, restClient_1.default, serverActionQueue);
34
34
  const actions = createActions_1.default(schema, store, restClient_1.default, optDis, extraActions);
data/client/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesr2323/jason",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "module": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {
@@ -3,8 +3,8 @@ import useJason from './useJason'
3
3
  import { Provider } from 'react-redux'
4
4
  import JasonContext from './JasonContext'
5
5
 
6
- const JasonProvider = ({ reducers, middleware, extraActions, children }: { reducers?: any, middleware?: any, extraActions?: any, children?: React.FC }) => {
7
- const [store, value] = useJason({ reducers, middleware, extraActions })
6
+ const JasonProvider = ({ reducers, middleware, enhancers, extraActions, children }: { reducers?: any, middleware?: any, enhancers?: any, extraActions?: any, children?: React.FC }) => {
7
+ const [store, value] = useJason({ reducers, middleware, enhancers, extraActions })
8
8
 
9
9
  if(!(store && value)) return <div /> // Wait for async fetch of schema to complete
10
10
 
data/client/src/index.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import _JasonContext from './JasonContext'
1
2
  import _JasonProvider from './JasonProvider'
2
3
  import _useAct from './useAct'
3
4
  import _useSub from './useSub'
4
5
  import _useEager from './useEager'
5
6
 
7
+ export const JasonContext = _JasonContext
6
8
  export const JasonProvider = _JasonProvider
7
9
  export const useAct = _useAct
8
10
  export const useSub = _useSub
@@ -14,7 +14,7 @@ import md5 from 'blueimp-md5'
14
14
  import _ from 'lodash'
15
15
  import React, { useState, useEffect } from 'react'
16
16
 
17
- export default function useJason({ reducers, middleware = [], extraActions }: { reducers?: any, middleware?: any[], extraActions?: any }) {
17
+ export default function useJason({ reducers, middleware = [], enhancers = [], extraActions }: { reducers?: any, middleware?: any[], enhancers?: any[], extraActions?: any }) {
18
18
  const [store, setStore] = useState(null as any)
19
19
  const [value, setValue] = useState(null as any)
20
20
 
@@ -35,7 +35,7 @@ export default function useJason({ reducers, middleware = [], extraActions }: {
35
35
 
36
36
  console.debug({ allReducers })
37
37
 
38
- const store = configureStore({ reducer: allReducers, middleware: [...middleware, pruneIdsMiddleware(schema)] })
38
+ const store = configureStore({ reducer: allReducers, middleware: [...middleware, pruneIdsMiddleware(schema)], enhancers })
39
39
  const dispatch = store.dispatch
40
40
 
41
41
  const optDis = createOptDis(schema, dispatch, restClient, serverActionQueue)
@@ -21,6 +21,10 @@ class Jason::ConsistencyChecker
21
21
  check_all(fix: true)
22
22
  end
23
23
 
24
+ def wipe_all_subs
25
+
26
+ end
27
+
24
28
  def initialize(subscription)
25
29
  @subscription = subscription
26
30
  @inconsistent = false
@@ -16,7 +16,7 @@ module Jason::Publisher
16
16
 
17
17
  # Exists
18
18
  if self.persisted? && (scope.blank? || self.class.unscoped.send(scope).exists?(self.id))
19
- payload = self.reload.as_json(as_json_config)
19
+ payload = self.as_json(as_json_config)
20
20
  gidx = Jason::LuaGenerator.new.cache_json(self.class.name.underscore, self.id, payload)
21
21
  return [payload, gidx]
22
22
  # Has been destroyed
@@ -129,7 +129,7 @@ module Jason::Publisher
129
129
 
130
130
  class_methods do
131
131
  def cache_all
132
- all.each(&:cache_json)
132
+ all.find_each(&:cache_json)
133
133
  end
134
134
 
135
135
  def has_jason?
data/lib/jason/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jason
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jason-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Rees
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-05 00:00:00.000000000 Z
11
+ date: 2021-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails