ar_sync 1.0.5 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +27 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +26 -28
- data/core/ArSyncApi.d.ts +8 -2
- data/core/ArSyncApi.js +11 -1
- data/core/ArSyncStore.js +208 -162
- data/core/ConnectionManager.d.ts +1 -1
- data/core/ConnectionManager.js +2 -0
- data/core/DataType.d.ts +14 -9
- data/core/hooks.d.ts +1 -0
- data/core/hooks.js +9 -6
- data/gemfiles/Gemfile-rails-6 +9 -0
- data/gemfiles/Gemfile-rails-7 +9 -0
- data/index.js +2 -2
- data/lib/ar_sync/class_methods.rb +64 -23
- data/lib/ar_sync/collection.rb +23 -19
- data/lib/ar_sync/core.rb +3 -3
- data/lib/ar_sync/instance_methods.rb +1 -1
- data/lib/ar_sync/rails.rb +14 -17
- data/lib/ar_sync/version.rb +1 -1
- data/package-lock.json +1706 -227
- data/package.json +1 -1
- data/src/core/ArSyncApi.ts +20 -7
- data/src/core/ArSyncStore.ts +191 -143
- data/src/core/ConnectionManager.ts +1 -0
- data/src/core/DataType.ts +14 -15
- data/src/core/hooks.ts +5 -5
- metadata +9 -7
- data/lib/ar_sync/field.rb +0 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c13bb4ca3915637f310817c9b5c689c12c05f0140cfe2d982da653bc251bf7e
|
4
|
+
data.tar.gz: 447f9877703f3ba4cee8d590b6f63d91bc09486a86d2a709169ac245bcd592be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd149d8f9b3ee83ba0e72cc0924bffdcaa9fc144c29a25b544ed9959f270ab65514fb7f18d0410ed1afc88d9db59b2b3f1c964b1005b6eae3057c2d4416d7174
|
7
|
+
data.tar.gz: c54c4e3b427c7f4bfec039bc4cacab491a413cc8e29a47307a4078e56266e7473c1171ed99bd5f3281b9afd509db298f293c9625250e040a7ef53f93c6d2f5ed
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Test
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
ruby: [ '2.7', '3.0', '3.1' ]
|
9
|
+
gemfiles:
|
10
|
+
- gemfiles/Gemfile-rails-6
|
11
|
+
- gemfiles/Gemfile-rails-7
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
- uses: actions/setup-node@v1
|
19
|
+
with:
|
20
|
+
node-version: '14.x'
|
21
|
+
- run: |
|
22
|
+
sudo apt-get update
|
23
|
+
sudo apt-get install -y libsqlite3-dev
|
24
|
+
- run: bundle install --gemfile ${{ matrix.gemfiles }} --jobs 4 --retry 3
|
25
|
+
- run: npm install
|
26
|
+
- run: npm run build
|
27
|
+
- run: bundle exec --gemfile ${{ matrix.gemfiles }} rake
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,52 +1,50 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ar_sync (1.
|
4
|
+
ar_sync (1.1.1)
|
5
5
|
activerecord
|
6
6
|
ar_serializer
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (
|
12
|
-
activesupport (=
|
13
|
-
activerecord (
|
14
|
-
activemodel (=
|
15
|
-
activesupport (=
|
16
|
-
activerecord-import (1.0
|
17
|
-
activerecord (>=
|
18
|
-
activesupport (
|
11
|
+
activemodel (7.0.2.3)
|
12
|
+
activesupport (= 7.0.2.3)
|
13
|
+
activerecord (7.0.2.3)
|
14
|
+
activemodel (= 7.0.2.3)
|
15
|
+
activesupport (= 7.0.2.3)
|
16
|
+
activerecord-import (1.4.0)
|
17
|
+
activerecord (>= 4.2)
|
18
|
+
activesupport (7.0.2.3)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
-
i18n (>=
|
21
|
-
minitest (
|
22
|
-
tzinfo (~>
|
23
|
-
|
24
|
-
ar_serializer (1.1.0)
|
20
|
+
i18n (>= 1.6, < 2)
|
21
|
+
minitest (>= 5.1)
|
22
|
+
tzinfo (~> 2.0)
|
23
|
+
ar_serializer (1.2.0)
|
25
24
|
activerecord
|
26
25
|
top_n_loader
|
27
|
-
coderay (1.1.
|
28
|
-
concurrent-ruby (1.1.
|
29
|
-
i18n (1.
|
26
|
+
coderay (1.1.3)
|
27
|
+
concurrent-ruby (1.1.10)
|
28
|
+
i18n (1.10.0)
|
30
29
|
concurrent-ruby (~> 1.0)
|
31
|
-
method_source (0.
|
32
|
-
minitest (5.
|
33
|
-
pry (0.
|
34
|
-
coderay (~> 1.1
|
35
|
-
method_source (~>
|
36
|
-
rake (
|
30
|
+
method_source (1.0.0)
|
31
|
+
minitest (5.15.0)
|
32
|
+
pry (0.14.1)
|
33
|
+
coderay (~> 1.1)
|
34
|
+
method_source (~> 1.0)
|
35
|
+
rake (13.0.6)
|
37
36
|
sqlite3 (1.4.2)
|
38
|
-
|
39
|
-
top_n_loader (1.0.1)
|
37
|
+
top_n_loader (1.0.2)
|
40
38
|
activerecord
|
41
|
-
tzinfo (
|
42
|
-
|
43
|
-
zeitwerk (2.2.2)
|
39
|
+
tzinfo (2.0.4)
|
40
|
+
concurrent-ruby (~> 1.0)
|
44
41
|
|
45
42
|
PLATFORMS
|
46
43
|
ruby
|
47
44
|
|
48
45
|
DEPENDENCIES
|
49
46
|
activerecord-import
|
47
|
+
ar_serializer
|
50
48
|
ar_sync!
|
51
49
|
pry
|
52
50
|
rake
|
data/core/ArSyncApi.d.ts
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
declare function apiBatchFetch(endpoint: string, requests: object[]): Promise<any>;
|
2
|
+
declare type Request = {
|
3
|
+
api: string;
|
4
|
+
params?: any;
|
5
|
+
query: any;
|
6
|
+
id?: number;
|
7
|
+
};
|
2
8
|
declare const ArSyncApi: {
|
3
9
|
domain: string | null;
|
4
10
|
_batchFetch: typeof apiBatchFetch;
|
5
|
-
fetch: (request:
|
6
|
-
syncFetch: (request:
|
11
|
+
fetch: (request: Request) => Promise<unknown>;
|
12
|
+
syncFetch: (request: Request) => Promise<unknown>;
|
7
13
|
};
|
8
14
|
export default ArSyncApi;
|
data/core/ArSyncApi.js
CHANGED
@@ -79,6 +79,16 @@ var ApiFetcher = /** @class */ (function () {
|
|
79
79
|
}
|
80
80
|
ApiFetcher.prototype.fetch = function (request) {
|
81
81
|
var _this = this;
|
82
|
+
if (request.id != null) {
|
83
|
+
return new Promise(function (resolve, reject) {
|
84
|
+
_this.fetch({ api: request.api, params: { ids: [request.id] }, query: request.query }).then(function (result) {
|
85
|
+
if (result[0])
|
86
|
+
resolve(result[0]);
|
87
|
+
else
|
88
|
+
reject({ type: 'Not Found', retry: false });
|
89
|
+
}).catch(reject);
|
90
|
+
});
|
91
|
+
}
|
82
92
|
return new Promise(function (resolve, reject) {
|
83
93
|
_this.batches.push([request, { resolve: resolve, reject: reject }]);
|
84
94
|
if (_this.batchFetchTimer)
|
@@ -108,7 +118,7 @@ var ApiFetcher = /** @class */ (function () {
|
|
108
118
|
var callbacks = callbacksList[i];
|
109
119
|
for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
|
110
120
|
var callback = callbacks_1[_i];
|
111
|
-
if (result.data) {
|
121
|
+
if (result.data !== undefined) {
|
112
122
|
callback.resolve(result.data);
|
113
123
|
}
|
114
124
|
else {
|