@projectcaluma/ember-core 14.7.0 → 14.7.1
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.
|
@@ -2,12 +2,7 @@ import { getOwner, setOwner } from "@ember/application";
|
|
|
2
2
|
import { assert } from "@ember/debug";
|
|
3
3
|
import { tracked } from "@glimmer/tracking";
|
|
4
4
|
import { queryManager } from "ember-apollo-client";
|
|
5
|
-
import {
|
|
6
|
-
enqueueTask,
|
|
7
|
-
lastValue,
|
|
8
|
-
restartableTask,
|
|
9
|
-
task,
|
|
10
|
-
} from "ember-concurrency";
|
|
5
|
+
import { task } from "ember-concurrency";
|
|
11
6
|
import { gql } from "graphql-tag";
|
|
12
7
|
import { TrackedArray } from "tracked-built-ins";
|
|
13
8
|
|
|
@@ -85,30 +80,33 @@ export default class BaseQuery {
|
|
|
85
80
|
return this._fetch.perform({ filter: this.filter, order: this.order });
|
|
86
81
|
}
|
|
87
82
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
_fetch = task(
|
|
84
|
+
{ restartable: true },
|
|
85
|
+
async ({ filter = [], order = [], queryOptions = {} } = {}) => {
|
|
86
|
+
await this._fetchPage.cancelAll({ resetState: true });
|
|
91
87
|
|
|
92
|
-
|
|
88
|
+
this.items = new TrackedArray();
|
|
93
89
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
this.filter = filter;
|
|
91
|
+
this.order = order;
|
|
92
|
+
this.queryOptions = { ...(this.queryOptions ?? {}), ...queryOptions };
|
|
97
93
|
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
return await this._fetchPage.linked().perform();
|
|
95
|
+
},
|
|
96
|
+
);
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
*_fetchMore() {
|
|
98
|
+
_fetchMore = task({ enqueue: true }, async () => {
|
|
103
99
|
if (!this._data) return;
|
|
104
100
|
|
|
105
|
-
return
|
|
101
|
+
return await this._fetchPage.linked().perform();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
get _data() {
|
|
105
|
+
return this._fetchPage.lastSuccessful?.value;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*_fetchPage() {
|
|
111
|
-
const data = yield this.apollo.query({
|
|
108
|
+
_fetchPage = task(async () => {
|
|
109
|
+
const data = await this.apollo.query({
|
|
112
110
|
query: gql`
|
|
113
111
|
${this.query}
|
|
114
112
|
`,
|
|
@@ -124,10 +122,10 @@ export default class BaseQuery {
|
|
|
124
122
|
|
|
125
123
|
const rawNewItems = data[this.dataKey].edges.map(({ node }) => node);
|
|
126
124
|
|
|
127
|
-
|
|
125
|
+
await this.#parsePage(rawNewItems);
|
|
128
126
|
|
|
129
127
|
return data;
|
|
130
|
-
}
|
|
128
|
+
});
|
|
131
129
|
|
|
132
130
|
#createModel(item) {
|
|
133
131
|
const instance = new this.modelClass(item);
|
|
@@ -9,15 +9,22 @@ import { pluralize } from "ember-inflector";
|
|
|
9
9
|
|
|
10
10
|
const toArrayIsDeprecated = dependencySatisfies("ember-data", "^4.7.0");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
export default class PrivateSchedulerService extends Service {
|
|
13
|
+
@service calumaOptions;
|
|
14
|
+
|
|
15
|
+
@tracked groupCache = [];
|
|
16
|
+
@tracked userCache = [];
|
|
17
|
+
|
|
18
|
+
resolveGroup = task(
|
|
19
|
+
{ enqueue: true },
|
|
20
|
+
async () => await this.#resolveType("group"),
|
|
21
|
+
);
|
|
22
|
+
resolveUser = task(
|
|
23
|
+
{ enqueue: true },
|
|
24
|
+
async () => await this.#resolveType("user"),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
async #resolveType(type) {
|
|
21
28
|
const identifiers = [...(this[type]?.identifiers ?? [])];
|
|
22
29
|
const callbacks = [...(this[type]?.callbacks ?? [])];
|
|
23
30
|
|
|
@@ -37,7 +44,7 @@ function typeResolver(type) {
|
|
|
37
44
|
|
|
38
45
|
const methodName = camelize(`resolve-${pluralize(type)}`);
|
|
39
46
|
const result = uncachedIdentifiers.length
|
|
40
|
-
?
|
|
47
|
+
? await this.calumaOptions[methodName]?.(uncachedIdentifiers)
|
|
41
48
|
: [];
|
|
42
49
|
|
|
43
50
|
const allResults = toArrayIsDeprecated
|
|
@@ -48,20 +55,10 @@ function typeResolver(type) {
|
|
|
48
55
|
this[`${type}Cache`] = allResults;
|
|
49
56
|
}
|
|
50
57
|
|
|
51
|
-
|
|
58
|
+
await Promise.all(callbacks.map((callback) => callback(allResults)));
|
|
52
59
|
|
|
53
60
|
return allResults;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default class PrivateSchedulerService extends Service {
|
|
58
|
-
@service calumaOptions;
|
|
59
|
-
|
|
60
|
-
@tracked groupCache = [];
|
|
61
|
-
@tracked userCache = [];
|
|
62
|
-
|
|
63
|
-
@typeResolver("group") resolveGroup;
|
|
64
|
-
@typeResolver("user") resolveUser;
|
|
61
|
+
}
|
|
65
62
|
|
|
66
63
|
/**
|
|
67
64
|
* Resolve a certain object of a type only once in the runloop.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-core",
|
|
3
|
-
"version": "14.7.
|
|
3
|
+
"version": "14.7.1",
|
|
4
4
|
"description": "Ember core addon for working with Caluma.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"ember-auto-import": "^2.10.0",
|
|
18
18
|
"ember-cli-babel": "^8.2.0",
|
|
19
19
|
"ember-cli-htmlbars": "^6.3.0",
|
|
20
|
-
"ember-concurrency": "^4.0.2",
|
|
20
|
+
"ember-concurrency": "^4.0.2 || ^5.1.0",
|
|
21
21
|
"ember-inflector": "^4.0.3 || ^5.0.1",
|
|
22
22
|
"ember-intl": "^7.1.1",
|
|
23
23
|
"ember-modify-based-class-resource": "^1.1.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"sinon": "21.0.1",
|
|
62
62
|
"uikit": "3.25.6",
|
|
63
63
|
"webpack": "5.104.1",
|
|
64
|
-
"@projectcaluma/ember-testing": "14.7.
|
|
64
|
+
"@projectcaluma/ember-testing": "14.7.1"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"ember-data": "*",
|