ar_sync 1.0.5 → 1.1.0
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.
- 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 +192 -138
- 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 +1 -1
- 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 +177 -125
- 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: ab145d5094c25600e95e01ab625c0128782b2a0592be95d8c9333539a5128bd1
|
4
|
+
data.tar.gz: 062fcf8cb8996e145dfa35eb25b31f2ecc2b4a486183bc70678d055db2bf2bc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 556a1c954088cea90d44bb61cec1fc250804f1fc5ec4e1c4101ff642343af49bc4ce8870be152de4627802931409d3c5f25707fa34b59ba8e53e9873a99e9b54
|
7
|
+
data.tar.gz: 28846608f3314be4a117d1ffbf265702f2170755f027696300f991b01a9228302d7e218fce757826c7528c8643d98f66e1073741305c1d851f1fe6602c9f185b
|
@@ -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.0
|
4
|
+
ar_sync (1.1.0)
|
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 {
|