@emuanalytics/flow-rdf-core 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.
@@ -0,0 +1,17 @@
1
+ @emuanalytics/flow-rdf-core:build: cache hit, replaying output f26a819889be528a
2
+ @emuanalytics/flow-rdf-core:build: 
3
+ @emuanalytics/flow-rdf-core:build: > @emuanalytics/flow-rdf-core@1.1.0 build /Users/robin/Projects/flow-rdfv3/packages/flow-rdf-core
4
+ @emuanalytics/flow-rdf-core:build: > pnpm run clean && pnpm run build.cjs && pnpm run build.esm
5
+ @emuanalytics/flow-rdf-core:build: 
6
+ @emuanalytics/flow-rdf-core:build: 
7
+ @emuanalytics/flow-rdf-core:build: > @emuanalytics/flow-rdf-core@1.1.0 clean /Users/robin/Projects/flow-rdfv3/packages/flow-rdf-core
8
+ @emuanalytics/flow-rdf-core:build: > rimraf dist
9
+ @emuanalytics/flow-rdf-core:build: 
10
+ @emuanalytics/flow-rdf-core:build: 
11
+ @emuanalytics/flow-rdf-core:build: > @emuanalytics/flow-rdf-core@1.1.0 build.cjs /Users/robin/Projects/flow-rdfv3/packages/flow-rdf-core
12
+ @emuanalytics/flow-rdf-core:build: > tsc -p tsconfig.build.json --module commonjs --outdir dist/cjs
13
+ @emuanalytics/flow-rdf-core:build: 
14
+ @emuanalytics/flow-rdf-core:build: 
15
+ @emuanalytics/flow-rdf-core:build: > @emuanalytics/flow-rdf-core@1.1.0 build.esm /Users/robin/Projects/flow-rdfv3/packages/flow-rdf-core
16
+ @emuanalytics/flow-rdf-core:build: > tsc -p tsconfig.build.json --module es2020 --outdir dist/esm
17
+ @emuanalytics/flow-rdf-core:build: 
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @emuanalytics/flow-rdf-core
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 50193dbf: Update to flow-engine-client v1.3.35
8
+
9
+ ## 1.1.0-alpha.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 50193dbf: Update to flow-engine-client v1.3.35
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/flow-query"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,mDAAiC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AsyncCommitter = void 0;
13
+ class AsyncCommitter {
14
+ constructor() {
15
+ Object.defineProperty(this, "requestId", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: 0
20
+ });
21
+ Object.defineProperty(this, "commitId", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: 0
26
+ });
27
+ }
28
+ resolve(promise) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ this.requestId += 1;
31
+ const currentRequestId = this.requestId;
32
+ const value = yield promise;
33
+ if (currentRequestId <= this.commitId) {
34
+ return { succeeded: false };
35
+ }
36
+ this.commitId = currentRequestId;
37
+ return { succeeded: true, value };
38
+ });
39
+ }
40
+ run(asyncFunction) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ return this.resolve(asyncFunction());
43
+ });
44
+ }
45
+ }
46
+ exports.AsyncCommitter = AsyncCommitter;
47
+ //# sourceMappingURL=async-committer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-committer.js","sourceRoot":"","sources":["../../../src/lib/async-committer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,MAAa,cAAc;IAA3B;QACE;;;;mBAAY,CAAC;WAAC;QACd;;;;mBAAW,CAAC;WAAC;IAgBf,CAAC;IAfO,OAAO,CACX,OAA+C;;YAE/C,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;YACpB,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC;YACxC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC;YAC5B,IAAI,gBAAgB,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACrC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;aAC7B;YACD,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC;YACjC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACpC,CAAC;KAAA;IACK,GAAG,CAAC,aAA+B;;YACvC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QACvC,CAAC;KAAA;CACF;AAlBD,wCAkBC"}
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.flowQueryOne = exports.flowQueryMany = exports.flowQuery = exports.FlowQuery = void 0;
16
+ const mobx_1 = require("mobx");
17
+ const debug_1 = __importDefault(require("debug"));
18
+ const async_committer_1 = require("./async-committer");
19
+ const debug = (0, debug_1.default)('flow:flow-query');
20
+ class FlowQuery {
21
+ constructor(queryFn, transformFn) {
22
+ Object.defineProperty(this, "queryFn", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: queryFn
27
+ });
28
+ Object.defineProperty(this, "committer", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: new async_committer_1.AsyncCommitter()
33
+ });
34
+ Object.defineProperty(this, "disposer", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: null
39
+ });
40
+ Object.defineProperty(this, "store", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: null
45
+ });
46
+ Object.defineProperty(this, "transformFn", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: (results) => results
51
+ });
52
+ Object.defineProperty(this, "flowClient", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ });
58
+ Object.defineProperty(this, "results", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: null
63
+ });
64
+ Object.defineProperty(this, "busy", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: false
69
+ });
70
+ Object.defineProperty(this, "error", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: null
75
+ });
76
+ (0, mobx_1.makeObservable)(this, {
77
+ results: mobx_1.observable.ref,
78
+ busy: mobx_1.observable,
79
+ error: mobx_1.observable.ref
80
+ }, {
81
+ name: 'flowQuery'
82
+ });
83
+ (0, mobx_1.onBecomeObserved)(this, 'results', this.wake.bind(this));
84
+ (0, mobx_1.onBecomeUnobserved)(this, 'results', this.sleep.bind(this));
85
+ if (transformFn) {
86
+ this.transformFn = transformFn;
87
+ }
88
+ this.flowClient = FlowQuery.defaultFlowClient;
89
+ }
90
+ static setFlowClient(flowClient) {
91
+ this.defaultFlowClient = flowClient;
92
+ }
93
+ bind(store) {
94
+ this.store = store;
95
+ return this;
96
+ }
97
+ runImmediately() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const queryDefinition = this.queryFn.call(this.store);
100
+ yield this.runQuery(queryDefinition);
101
+ if (this.error) {
102
+ throw this.error;
103
+ }
104
+ return this.results;
105
+ });
106
+ }
107
+ wake() {
108
+ debug('waking up');
109
+ this.sleep();
110
+ this.disposer = (0, mobx_1.reaction)(() => this.queryFn.call(this.store), (queryDefinition) => {
111
+ this.runQuery(queryDefinition);
112
+ }, { fireImmediately: true, delay: 500 });
113
+ }
114
+ sleep() {
115
+ if (this.disposer) {
116
+ const disposer = this.disposer;
117
+ this.disposer = null;
118
+ disposer();
119
+ debug('sleeping');
120
+ }
121
+ }
122
+ runQuery(queryDefinition) {
123
+ return __awaiter(this, void 0, void 0, function* () {
124
+ debug(`running query:`, queryDefinition);
125
+ try {
126
+ if (queryDefinition === null) {
127
+ (0, mobx_1.runInAction)(() => {
128
+ this.results = null;
129
+ this.error = null;
130
+ this.busy = false;
131
+ });
132
+ }
133
+ else {
134
+ (0, mobx_1.runInAction)(() => {
135
+ this.busy = true;
136
+ this.error = null;
137
+ });
138
+ if (!this.flowClient) {
139
+ throw new Error('No Flo.w client to execute query');
140
+ }
141
+ const response = yield this.committer.run(() => this.flowClient.datasets.query(queryDefinition));
142
+ if (response.succeeded) {
143
+ (0, mobx_1.runInAction)(() => {
144
+ this.results = this.transformFn(response.value);
145
+ this.busy = false;
146
+ });
147
+ }
148
+ }
149
+ }
150
+ catch (e) {
151
+ (0, mobx_1.runInAction)(() => {
152
+ this.results = null;
153
+ this.error = e;
154
+ this.busy = false;
155
+ });
156
+ }
157
+ });
158
+ }
159
+ }
160
+ exports.FlowQuery = FlowQuery;
161
+ function flowQuery(queryFn, transformFn, flowClient) {
162
+ return new FlowQuery(queryFn, transformFn);
163
+ }
164
+ exports.flowQuery = flowQuery;
165
+ function flowQueryMany(queryFn, transformFn, flowClient) {
166
+ return flowQuery(queryFn, transformFn, flowClient);
167
+ }
168
+ exports.flowQueryMany = flowQueryMany;
169
+ function flowQueryOne(queryFn, transformFn, flowClient) {
170
+ const oneTransform = (results) => {
171
+ let oneResult = null;
172
+ if (results === null || results === void 0 ? void 0 : results.length) {
173
+ oneResult = results[0];
174
+ }
175
+ if (transformFn) {
176
+ oneResult = transformFn(oneResult);
177
+ }
178
+ return oneResult;
179
+ };
180
+ return flowQuery(queryFn, oneTransform, flowClient);
181
+ }
182
+ exports.flowQueryOne = flowQueryOne;
183
+ //# sourceMappingURL=flow-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-query.js","sourceRoot":"","sources":["../../../src/lib/flow-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAQc;AACd,kDAA0B;AAC1B,uDAAmD;AAKnD,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,iBAAiB,CAAC,CAAC;AA2EvC,MAAa,SAAS;IAiBpB,YACU,OAA6C,EACrD,WAAkD;;;;;mBAD1C;;QAfV;;;;mBAAoB,IAAI,gC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QAED,IAAI,WAAW,EAAE;YACf,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;SACpC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAU,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC;AAnBD,oCAmBC"}
@@ -0,0 +1,2 @@
1
+ export * from './lib/flow-query';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,43 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export class AsyncCommitter {
11
+ constructor() {
12
+ Object.defineProperty(this, "requestId", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: 0
17
+ });
18
+ Object.defineProperty(this, "commitId", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: 0
23
+ });
24
+ }
25
+ resolve(promise) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ this.requestId += 1;
28
+ const currentRequestId = this.requestId;
29
+ const value = yield promise;
30
+ if (currentRequestId <= this.commitId) {
31
+ return { succeeded: false };
32
+ }
33
+ this.commitId = currentRequestId;
34
+ return { succeeded: true, value };
35
+ });
36
+ }
37
+ run(asyncFunction) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ return this.resolve(asyncFunction());
40
+ });
41
+ }
42
+ }
43
+ //# sourceMappingURL=async-committer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-committer.js","sourceRoot":"","sources":["../../../src/lib/async-committer.ts"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,OAAO,cAAc;IAA3B;QACE;;;;mBAAY,CAAC;WAAC;QACd;;;;mBAAW,CAAC;WAAC;IAgBf,CAAC;IAfO,OAAO,CACX,OAA+C;;YAE/C,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;YACpB,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC;YACxC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC;YAC5B,IAAI,gBAAgB,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACrC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;aAC7B;YACD,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC;YACjC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACpC,CAAC;KAAA;IACK,GAAG,CAAC,aAA+B;;YACvC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QACvC,CAAC;KAAA;CACF"}
@@ -0,0 +1,173 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { makeObservable, observable, onBecomeObserved, onBecomeUnobserved, reaction, runInAction } from 'mobx';
11
+ import Debug from 'debug';
12
+ import { AsyncCommitter } from './async-committer';
13
+ const debug = Debug('flow:flow-query');
14
+ export class FlowQuery {
15
+ constructor(queryFn, transformFn) {
16
+ Object.defineProperty(this, "queryFn", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: queryFn
21
+ });
22
+ Object.defineProperty(this, "committer", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: new AsyncCommitter()
27
+ });
28
+ Object.defineProperty(this, "disposer", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: null
33
+ });
34
+ Object.defineProperty(this, "store", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: null
39
+ });
40
+ Object.defineProperty(this, "transformFn", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: (results) => results
45
+ });
46
+ Object.defineProperty(this, "flowClient", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: void 0
51
+ });
52
+ Object.defineProperty(this, "results", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: null
57
+ });
58
+ Object.defineProperty(this, "busy", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: false
63
+ });
64
+ Object.defineProperty(this, "error", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: null
69
+ });
70
+ makeObservable(this, {
71
+ results: observable.ref,
72
+ busy: observable,
73
+ error: observable.ref
74
+ }, {
75
+ name: 'flowQuery'
76
+ });
77
+ onBecomeObserved(this, 'results', this.wake.bind(this));
78
+ onBecomeUnobserved(this, 'results', this.sleep.bind(this));
79
+ if (transformFn) {
80
+ this.transformFn = transformFn;
81
+ }
82
+ this.flowClient = FlowQuery.defaultFlowClient;
83
+ }
84
+ static setFlowClient(flowClient) {
85
+ this.defaultFlowClient = flowClient;
86
+ }
87
+ bind(store) {
88
+ this.store = store;
89
+ return this;
90
+ }
91
+ runImmediately() {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const queryDefinition = this.queryFn.call(this.store);
94
+ yield this.runQuery(queryDefinition);
95
+ if (this.error) {
96
+ throw this.error;
97
+ }
98
+ return this.results;
99
+ });
100
+ }
101
+ wake() {
102
+ debug('waking up');
103
+ this.sleep();
104
+ this.disposer = reaction(() => this.queryFn.call(this.store), (queryDefinition) => {
105
+ this.runQuery(queryDefinition);
106
+ }, { fireImmediately: true, delay: 500 });
107
+ }
108
+ sleep() {
109
+ if (this.disposer) {
110
+ const disposer = this.disposer;
111
+ this.disposer = null;
112
+ disposer();
113
+ debug('sleeping');
114
+ }
115
+ }
116
+ runQuery(queryDefinition) {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ debug(`running query:`, queryDefinition);
119
+ try {
120
+ if (queryDefinition === null) {
121
+ runInAction(() => {
122
+ this.results = null;
123
+ this.error = null;
124
+ this.busy = false;
125
+ });
126
+ }
127
+ else {
128
+ runInAction(() => {
129
+ this.busy = true;
130
+ this.error = null;
131
+ });
132
+ if (!this.flowClient) {
133
+ throw new Error('No Flo.w client to execute query');
134
+ }
135
+ const response = yield this.committer.run(() => this.flowClient.datasets.query(queryDefinition));
136
+ if (response.succeeded) {
137
+ runInAction(() => {
138
+ this.results = this.transformFn(response.value);
139
+ this.busy = false;
140
+ });
141
+ }
142
+ }
143
+ }
144
+ catch (e) {
145
+ runInAction(() => {
146
+ this.results = null;
147
+ this.error = e;
148
+ this.busy = false;
149
+ });
150
+ }
151
+ });
152
+ }
153
+ }
154
+ export function flowQuery(queryFn, transformFn, flowClient) {
155
+ return new FlowQuery(queryFn, transformFn);
156
+ }
157
+ export function flowQueryMany(queryFn, transformFn, flowClient) {
158
+ return flowQuery(queryFn, transformFn, flowClient);
159
+ }
160
+ export function flowQueryOne(queryFn, transformFn, flowClient) {
161
+ const oneTransform = (results) => {
162
+ let oneResult = null;
163
+ if (results === null || results === void 0 ? void 0 : results.length) {
164
+ oneResult = results[0];
165
+ }
166
+ if (transformFn) {
167
+ oneResult = transformFn(oneResult);
168
+ }
169
+ return oneResult;
170
+ };
171
+ return flowQuery(queryFn, oneTransform, flowClient);
172
+ }
173
+ //# sourceMappingURL=flow-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-query.js","sourceRoot":"","sources":["../../../src/lib/flow-query.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAEL,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACZ,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD,MAAM,KAAK,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC;AA2EvC,MAAM,OAAO,SAAS;IAiBpB,YACU,OAA6C,EACrD,WAAkD;;;;;mBAD1C;;QAfV;;;;mBAAoB,IAAI,cAAc,EAAO;WAAC;QAC9C;;;;mBAA6C,IAAI;WAAC;QAClD;;;;mBAA+B,IAAI;WAAC;QACpC;;;;mBAA4D,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO;WAAC;QAEjF;;;;;WAAuB;QACvB;;;;mBAA2B,IAAI;WAAC;QAChC;;;;mBAAgB,KAAK;WAAC;QACtB;;;;mBAAsB,IAAI;WAAC;QAUzB,cAAc,CACZ,IAAI,EACJ;YACE,OAAO,EAAE,UAAU,CAAC,GAAG;YACvB,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,UAAU,CAAC,GAAG;SACtB,EACD;YACE,IAAI,EAAE,WAAW;SAClB,CACF,CAAC;QAEF,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACxD,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAE3D,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,WAAW,GAA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SAAS,CAAU,OAAO,EAAE,WAAW,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAAsC,EACtC,WAAmD,EACnD,UAAuB;IAEvB,OAAO,SAAS,CAAY,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,OAAsC,EACtC,WAAiD,EACjD,UAAuB;IAEvB,MAAM,YAAY,GAAG,CAAC,OAAc,EAAkB,EAAE;QACtD,IAAI,SAAS,GAAmB,IAAI,CAAC;QACrC,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,EAAE;YACnB,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;SACxB;QAED,IAAI,WAAW,EAAE;YACf,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;SACpC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAU,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './lib/flow-query';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,15 @@
1
+ declare type AsyncCommitterResult<T> = {
2
+ succeeded: false;
3
+ value?: undefined;
4
+ } | {
5
+ succeeded: true;
6
+ value: T | undefined;
7
+ };
8
+ export declare class AsyncCommitter<T> {
9
+ requestId: number;
10
+ commitId: number;
11
+ resolve(promise: Promise<T | undefined> | T | undefined): Promise<AsyncCommitterResult<T>>;
12
+ run(asyncFunction: () => Promise<T>): Promise<AsyncCommitterResult<T>>;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=async-committer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-committer.d.ts","sourceRoot":"","sources":["../../../src/lib/async-committer.ts"],"names":[],"mappings":"AAAA,aAAK,oBAAoB,CAAC,CAAC,IACvB;IAAE,SAAS,EAAE,KAAK,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GACvC;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;CAAE,CAAC;AAE9C,qBAAa,cAAc,CAAC,CAAC;IAC3B,SAAS,SAAK;IACd,QAAQ,SAAK;IACP,OAAO,CACX,OAAO,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,GAC9C,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAU7B,GAAG,CAAC,aAAa,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;CAG7E"}
@@ -0,0 +1,89 @@
1
+ import { StateStore } from '@emuanalytics/flow-state-store';
2
+ import { Client as FlowClient } from '@emuanalytics/flow-engine-client';
3
+ /** Result format of a [[FlowQuery]]. */
4
+ export declare type FlowQueryResultFormat = 'json' | 'geojson' | 'csv';
5
+ /** [[FlowQueryDefinition]] 'attributes' entry. */
6
+ export declare type FlowQueryAttribute = string | [any, string];
7
+ /**
8
+ * [[FlowQueryDefinition]] 'where' clauses.
9
+ */
10
+ export interface FlowQueryWhereClauses {
11
+ [attribute: string]: any;
12
+ }
13
+ /**
14
+ * [[FlowQueryDefinition]] extra parameters.
15
+ */
16
+ export interface FlowQueryExtraParams {
17
+ [key: string]: string | number;
18
+ }
19
+ /**
20
+ * [[FlowQueryDefinition]] 'order' clause.
21
+ *
22
+ * A field name or [field, asc/desc] tuple.
23
+ */
24
+ export declare type FlowQueryOrderClause = string | number | [string | number, 'asc' | 'desc'];
25
+ export interface FlowQuerySampleOptions {
26
+ percentage: number;
27
+ method?: 'system' | 'bernoulli';
28
+ seed?: number;
29
+ }
30
+ /**
31
+ * Definition of a Flo.w reactive dataset query.
32
+ */
33
+ export interface FlowQueryDefinition {
34
+ /** ID of dataset to query. */
35
+ datasetId: string;
36
+ /** Attributes to return in results. */
37
+ attributes?: FlowQueryAttribute[];
38
+ /** DISTINCT ON attributes */
39
+ distinct?: string | string[];
40
+ /** Filter results using 'where' clauses. */
41
+ where?: FlowQueryWhereClauses;
42
+ /** Sort results by attributes. */
43
+ order?: FlowQueryOrderClause[];
44
+ /** Group results by attributes. */
45
+ group?: (string | number)[];
46
+ /** Limit number of returned results */
47
+ limit?: number;
48
+ /** Format of returned data. */
49
+ format?: FlowQueryResultFormat;
50
+ /** Additional query parameters. */
51
+ params?: FlowQueryExtraParams;
52
+ /** Sampling options. */
53
+ sample?: FlowQuerySampleOptions;
54
+ }
55
+ /**
56
+ * [[FlowQuery]] query definition function.
57
+ *
58
+ * @typeParam TState Type of application state.
59
+ */
60
+ export declare type FlowQueryDefinitionFn<TState> = (this: TState) => FlowQueryDefinition | Promise<FlowQueryDefinition> | null;
61
+ /**
62
+ * [[FlowQuery]] result transform function.
63
+ *
64
+ * @typeParam T Type of transformed query results.
65
+ */
66
+ export declare type FlowQueryResultTransformFn<T = any> = (results: any) => T | null;
67
+ export declare class FlowQuery<TResults, TState extends StateStore = any> {
68
+ private queryFn;
69
+ private static defaultFlowClient;
70
+ private committer;
71
+ private disposer;
72
+ private store;
73
+ private transformFn;
74
+ flowClient: FlowClient;
75
+ results: TResults | null;
76
+ busy: boolean;
77
+ error: Error | null;
78
+ static setFlowClient(flowClient: any): void;
79
+ constructor(queryFn: FlowQueryDefinitionFn<TState | null>, transformFn?: FlowQueryResultTransformFn<TResults>);
80
+ bind(store: TState): this;
81
+ runImmediately(): Promise<TResults | null>;
82
+ private wake;
83
+ private sleep;
84
+ private runQuery;
85
+ }
86
+ export declare function flowQuery<TResult = any, TState extends StateStore = any>(queryFn: FlowQueryDefinitionFn<TState>, transformFn?: FlowQueryResultTransformFn<TResult>, flowClient?: FlowClient): FlowQuery<TResult, TState>;
87
+ export declare function flowQueryMany<TResult = any, TState extends StateStore = any>(queryFn: FlowQueryDefinitionFn<TState>, transformFn?: FlowQueryResultTransformFn<TResult[]>, flowClient?: FlowClient): FlowQuery<TResult[], TState>;
88
+ export declare function flowQueryOne<TResult = any, TState extends StateStore = any>(queryFn: FlowQueryDefinitionFn<TState>, transformFn?: FlowQueryResultTransformFn<TResult>, flowClient?: FlowClient): FlowQuery<TResult, TState>;
89
+ //# sourceMappingURL=flow-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-query.d.ts","sourceRoot":"","sources":["../../../src/lib/flow-query.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAKxE,wCAAwC;AACxC,oBAAY,qBAAqB,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;AAE/D,kDAAkD;AAClD,oBAAY,kBAAkB,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,oBAAY,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC;AAEvF,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,8BAA8B;IAC9B,SAAS,EA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IAAI,CAAQ;IAE3B,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,GAAG;gBAK1B,OAAO,EAAE,qBAAqB,CAAC,MAAM,GAAG,IAAI,CAAC,EACrD,WAAW,CAAC,EAAE,0BAA0B,CAAC,QAAQ,CAAC;IAwBpD,IAAI,CAAC,KAAK,EAAE,MAAM;IAKZ,cAAc;IAUpB,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,KAAK;YASC,QAAQ;CAqCvB;AAED,wBAAgB,SAAS,CAAC,OAAO,GAAG,GAAG,EAAE,MAAM,SAAS,UAAU,GAAG,GAAG,EACtE,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,EACtC,WAAW,CAAC,EAAE,0BAA0B,CAAC,OAAO,CAAC,EACjD,UAAU,CAAC,EAAE,UAAU,GACtB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAE5B;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAG,GAAG,EAAE,MAAM,SAAS,UAAU,GAAG,GAAG,EAC1E,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,EACtC,WAAW,CAAC,EAAE,0BAA0B,CAAC,OAAO,EAAE,CAAC,EACnD,UAAU,CAAC,EAAE,UAAU,GACtB,SAAS,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAE9B;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAG,GAAG,EAAE,MAAM,SAAS,UAAU,GAAG,GAAG,EACzE,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,EACtC,WAAW,CAAC,EAAE,0BAA0B,CAAC,OAAO,CAAC,EACjD,UAAU,CAAC,EAAE,UAAU,GACtB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAe5B"}
package/jest.config.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ ...require("../../jest.config"),
3
+ };
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@emuanalytics/flow-rdf-core",
3
+ "version": "1.1.0",
4
+ "description": "",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "@emuanalytics/flow-engine-client": "^1.3.35",
13
+ "@emuanalytics/flow-state-store": "^1.0.0",
14
+ "debug": "^4.3.4"
15
+ },
16
+ "devDependencies": {
17
+ "@types/debug": "^4.1.7",
18
+ "@types/jest": "^28.1.6",
19
+ "esbuild": "^0.14.54",
20
+ "esbuild-jest": "^0.5.0",
21
+ "jest": "^28.1.3",
22
+ "jest-cli": "^28.1.3",
23
+ "jest-mock": "^28.1.3",
24
+ "jest-module-name-mapper": "^0.1.5",
25
+ "mobx": "^6.6.1",
26
+ "mobx-utils": "^6.0.5",
27
+ "rimraf": "^3.0.2",
28
+ "typescript": "^4.7.4"
29
+ },
30
+ "scripts": {
31
+ "clean": "rimraf dist",
32
+ "build.cjs": "tsc -p tsconfig.build.json --module commonjs --outdir dist/cjs",
33
+ "build.esm": "tsc -p tsconfig.build.json --module es2020 --outdir dist/esm",
34
+ "build": "pnpm run clean && pnpm run build.cjs && pnpm run build.esm",
35
+ "test": "jest --silent"
36
+ }
37
+ }
@@ -0,0 +1,116 @@
1
+ import { mocked } from 'jest-mock';
2
+ import { when } from 'mobx';
3
+ import * as flow from '@emuanalytics/flow-engine-client';
4
+ import { flowQuery, FlowQuery } from '../index';
5
+
6
+ jest.mock('@emuanalytics/flow-engine-client', () => {
7
+ return {
8
+ Client: jest.fn().mockImplementation(() => {
9
+ return {
10
+ baseUrl: 'baseUrl',
11
+ apiKey: 'apikey',
12
+ datasets: {
13
+ query: jest.fn()
14
+ }
15
+ };
16
+ })
17
+ };
18
+ });
19
+
20
+ describe('flow-rdf-core', () => {
21
+ const flowClient = new flow.Client('baseUrl', 'apiKey');
22
+ const MockedFlowClient = mocked(flow.Client, true);
23
+ const mockedDatasetQuery = jest.mocked(flowClient.datasets.query);
24
+
25
+ beforeAll(() => {
26
+ FlowQuery.setFlowClient(flowClient);
27
+ });
28
+
29
+ beforeEach(() => {
30
+ // Clears the record of calls to the mocks
31
+ MockedFlowClient.mockClear();
32
+ mockedDatasetQuery.mockReset();
33
+ });
34
+
35
+ it('should provide mocked flow client', async() => {
36
+ expect(flowClient.baseUrl).toBe('baseUrl');
37
+ expect(flowClient.apiKey).toBe('apikey');
38
+
39
+ mockedDatasetQuery.mockResolvedValue([1, 2, 3]);
40
+ const results = await flowClient.datasets.query({});
41
+ expect(results).toStrictEqual([1, 2, 3]);
42
+ expect(mockedDatasetQuery).toHaveBeenCalledTimes(1);
43
+ });
44
+
45
+ it('should exist', () => {
46
+ const query = flowQuery(function () {
47
+ return { datasetId: 'airquality' };
48
+ });
49
+ expect(query).toBeDefined();
50
+ });
51
+
52
+ it('should have initial values', () => {
53
+ const query = flowQuery(function () {
54
+ return { datasetId: 'airquality' };
55
+ });
56
+ expect(query.results).toBeNull();
57
+ expect(query.busy).toBe(false);
58
+ expect(query.error).toBeNull();
59
+ });
60
+
61
+ it('should error if no flowClient to run query', async () => {
62
+ const query = flowQuery(function () {
63
+ return { datasetId: 'airquality' };
64
+ });
65
+
66
+ (query.flowClient as any) = undefined;
67
+
68
+ await when(() => query.results || query.error);
69
+ expect(query.results).toBeNull();
70
+ expect(query.error).toBeInstanceOf(Error);
71
+ expect(query.error!.message).toMatch('No Flo.w client');
72
+ });
73
+
74
+ it('should run query immediately', async () => {
75
+ mockedDatasetQuery.mockResolvedValueOnce([1, 2, 3]);
76
+
77
+ const query = flowQuery(function () {
78
+ return { datasetId: 'airquality' };
79
+ });
80
+
81
+ const results = await query.runImmediately();
82
+ expect(results).toEqual([1, 2, 3]);
83
+ expect(query.busy).toBe(false);
84
+ expect(query.error).toBeNull();
85
+ });
86
+
87
+ it('should fail immediately', async () => {
88
+ const query = flowQuery(function () {
89
+ return { datasetId: 'airquality' };
90
+ });
91
+ (query.flowClient as any) = null;
92
+
93
+ expect.assertions(2);
94
+ try {
95
+ await query.runImmediately();
96
+ } catch (e: any) {
97
+ expect(e).toBeInstanceOf(Error);
98
+ expect(e.message).toMatch('No Flo.w client');
99
+ }
100
+ });
101
+
102
+ it('should run observable query', async () => {
103
+
104
+ const query = flowQuery<number[]>(function () {
105
+ return { datasetId: 'airquality' };
106
+ });
107
+
108
+ query.flowClient.datasets.query = jest.fn().mockResolvedValue([1,2]);
109
+ const m = jest.mocked(query.flowClient.datasets.query);
110
+
111
+ await when(() => !!query.results || !!query.error);
112
+ expect(m).toHaveBeenCalled();
113
+ expect(query.error).toBeNull();
114
+ expect(query.results).toEqual([1, 2]);
115
+ });
116
+ });
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export * from './lib/flow-query';
@@ -0,0 +1,23 @@
1
+ type AsyncCommitterResult<T> =
2
+ | { succeeded: false; value?: undefined }
3
+ | { succeeded: true; value: T | undefined };
4
+
5
+ export class AsyncCommitter<T> {
6
+ requestId = 0;
7
+ commitId = 0;
8
+ async resolve(
9
+ promise: Promise<T | undefined> | T | undefined
10
+ ): Promise<AsyncCommitterResult<T>> {
11
+ this.requestId += 1;
12
+ const currentRequestId = this.requestId;
13
+ const value = await promise;
14
+ if (currentRequestId <= this.commitId) {
15
+ return { succeeded: false };
16
+ }
17
+ this.commitId = currentRequestId;
18
+ return { succeeded: true, value };
19
+ }
20
+ async run(asyncFunction: () => Promise<T>): Promise<AsyncCommitterResult<T>> {
21
+ return this.resolve(asyncFunction());
22
+ }
23
+ }
@@ -0,0 +1,244 @@
1
+ import {
2
+ IReactionDisposer,
3
+ makeObservable,
4
+ observable,
5
+ onBecomeObserved,
6
+ onBecomeUnobserved,
7
+ reaction,
8
+ runInAction
9
+ } from 'mobx';
10
+ import Debug from 'debug';
11
+ import { AsyncCommitter } from './async-committer';
12
+ import { StateStore } from '@emuanalytics/flow-state-store';
13
+ import { Client as FlowClient } from '@emuanalytics/flow-engine-client';
14
+ import { DatasetQuery } from '@emuanalytics/flow-engine-client/dist/types/lib/dataset.endpoints';
15
+
16
+ const debug = Debug('flow:flow-query');
17
+
18
+ /** Result format of a [[FlowQuery]]. */
19
+ export type FlowQueryResultFormat = 'json' | 'geojson' | 'csv';
20
+
21
+ /** [[FlowQueryDefinition]] 'attributes' entry. */
22
+ export type FlowQueryAttribute = string | [any, string];
23
+
24
+ /**
25
+ * [[FlowQueryDefinition]] 'where' clauses.
26
+ */
27
+ export interface FlowQueryWhereClauses {
28
+ [attribute: string]: any;
29
+ }
30
+
31
+ /**
32
+ * [[FlowQueryDefinition]] extra parameters.
33
+ */
34
+ export interface FlowQueryExtraParams {
35
+ [key: string]: string | number;
36
+ }
37
+
38
+ /**
39
+ * [[FlowQueryDefinition]] 'order' clause.
40
+ *
41
+ * A field name or [field, asc/desc] tuple.
42
+ */
43
+ export type FlowQueryOrderClause = string | number | [string | number, 'asc' | 'desc'];
44
+
45
+ export interface FlowQuerySampleOptions {
46
+ percentage: number;
47
+ method?: 'system' | 'bernoulli';
48
+ seed?: number;
49
+ }
50
+
51
+ /**
52
+ * Definition of a Flo.w reactive dataset query.
53
+ */
54
+ export interface FlowQueryDefinition {
55
+ /** ID of dataset to query. */
56
+ datasetId: string;
57
+ /** Attributes to return in results. */
58
+ attributes?: FlowQueryAttribute[];
59
+ /** DISTINCT ON attributes */
60
+ distinct?: string | string[];
61
+ /** Filter results using 'where' clauses. */
62
+ where?: FlowQueryWhereClauses;
63
+ /** Sort results by attributes. */
64
+ order?: FlowQueryOrderClause[];
65
+ /** Group results by attributes. */
66
+ group?: (string | number)[];
67
+ /** Limit number of returned results */
68
+ limit?: number;
69
+ /** Format of returned data. */
70
+ format?: FlowQueryResultFormat;
71
+ /** Additional query parameters. */
72
+ params?: FlowQueryExtraParams;
73
+ /** Sampling options. */
74
+ sample?: FlowQuerySampleOptions;
75
+ }
76
+
77
+ /**
78
+ * [[FlowQuery]] query definition function.
79
+ *
80
+ * @typeParam TState Type of application state.
81
+ */
82
+ export type FlowQueryDefinitionFn<TState> = (this: TState) => FlowQueryDefinition | Promise<FlowQueryDefinition> | null;
83
+
84
+ /**
85
+ * [[FlowQuery]] result transform function.
86
+ *
87
+ * @typeParam T Type of transformed query results.
88
+ */
89
+ export type FlowQueryResultTransformFn<T = any> = (results: any) => T | null;
90
+
91
+ export class FlowQuery<TResults, TState extends StateStore = any> {
92
+ private static defaultFlowClient: FlowClient;
93
+
94
+ private committer = new AsyncCommitter<any>();
95
+ private disposer: IReactionDisposer | null = null;
96
+ private store: TState | null = null;
97
+ private transformFn: FlowQueryResultTransformFn<TResults> = (results) => results;
98
+
99
+ flowClient: FlowClient;
100
+ results: TResults | null = null;
101
+ busy: boolean = false;
102
+ error: Error | null = null;
103
+
104
+ static setFlowClient(flowClient: any) {
105
+ this.defaultFlowClient = flowClient;
106
+ }
107
+
108
+ constructor(
109
+ private queryFn: FlowQueryDefinitionFn<TState | null>,
110
+ transformFn?: FlowQueryResultTransformFn<TResults>
111
+ ) {
112
+ makeObservable(
113
+ this,
114
+ {
115
+ results: observable.ref,
116
+ busy: observable,
117
+ error: observable.ref
118
+ },
119
+ {
120
+ name: 'flowQuery'
121
+ }
122
+ );
123
+
124
+ onBecomeObserved(this, 'results', this.wake.bind(this));
125
+ onBecomeUnobserved(this, 'results', this.sleep.bind(this));
126
+
127
+ if (transformFn) {
128
+ this.transformFn = transformFn;
129
+ }
130
+
131
+ this.flowClient = FlowQuery.defaultFlowClient;
132
+ }
133
+
134
+ bind(store: TState) {
135
+ this.store = store;
136
+ return this;
137
+ }
138
+
139
+ async runImmediately() {
140
+ const queryDefinition = this.queryFn.call(this.store);
141
+ await this.runQuery(queryDefinition);
142
+ if (this.error) {
143
+ throw this.error;
144
+ }
145
+
146
+ return this.results;
147
+ }
148
+
149
+ private wake() {
150
+ debug('waking up');
151
+ this.sleep();
152
+ this.disposer = reaction(
153
+ () => this.queryFn.call(this.store),
154
+ (queryDefinition: any) => {
155
+ this.runQuery(queryDefinition);
156
+ },
157
+ { fireImmediately: true, delay: 500 }
158
+ );
159
+ }
160
+
161
+ private sleep() {
162
+ if (this.disposer) {
163
+ const disposer = this.disposer;
164
+ this.disposer = null;
165
+ disposer();
166
+ debug('sleeping');
167
+ }
168
+ }
169
+
170
+ private async runQuery(queryDefinition: DatasetQuery | null) {
171
+ debug(`running query:`, queryDefinition);
172
+
173
+ try {
174
+ if (queryDefinition === null) {
175
+ runInAction(() => {
176
+ this.results = null;
177
+ this.error = null;
178
+ this.busy = false;
179
+ });
180
+ } else {
181
+ runInAction(() => {
182
+ this.busy = true;
183
+ this.error = null;
184
+ });
185
+
186
+ if (!this.flowClient) {
187
+ throw new Error('No Flo.w client to execute query');
188
+ }
189
+
190
+ const response = await this.committer.run(() => this.flowClient.datasets.query(queryDefinition));
191
+
192
+ if (response.succeeded) {
193
+ runInAction(() => {
194
+ this.results = this.transformFn(response.value);
195
+ this.busy = false;
196
+ });
197
+ }
198
+ }
199
+ } catch (e: any) {
200
+ runInAction(() => {
201
+ this.results = null;
202
+ this.error = e;
203
+ this.busy = false;
204
+ });
205
+ }
206
+ }
207
+ }
208
+
209
+ export function flowQuery<TResult = any, TState extends StateStore = any>(
210
+ queryFn: FlowQueryDefinitionFn<TState>,
211
+ transformFn?: FlowQueryResultTransformFn<TResult>,
212
+ flowClient?: FlowClient
213
+ ): FlowQuery<TResult, TState> {
214
+ return new FlowQuery<TResult>(queryFn, transformFn);
215
+ }
216
+
217
+ export function flowQueryMany<TResult = any, TState extends StateStore = any>(
218
+ queryFn: FlowQueryDefinitionFn<TState>,
219
+ transformFn?: FlowQueryResultTransformFn<TResult[]>,
220
+ flowClient?: FlowClient
221
+ ): FlowQuery<TResult[], TState> {
222
+ return flowQuery<TResult[]>(queryFn, transformFn, flowClient);
223
+ }
224
+
225
+ export function flowQueryOne<TResult = any, TState extends StateStore = any>(
226
+ queryFn: FlowQueryDefinitionFn<TState>,
227
+ transformFn?: FlowQueryResultTransformFn<TResult>,
228
+ flowClient?: FlowClient
229
+ ): FlowQuery<TResult, TState> {
230
+ const oneTransform = (results: any[]): TResult | null => {
231
+ let oneResult: TResult | null = null;
232
+ if (results?.length) {
233
+ oneResult = results[0];
234
+ }
235
+
236
+ if (transformFn) {
237
+ oneResult = transformFn(oneResult);
238
+ }
239
+
240
+ return oneResult;
241
+ };
242
+
243
+ return flowQuery<TResult>(queryFn, oneTransform, flowClient);
244
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "declarationDir": "./dist/types",
6
+ "types": []
7
+ },
8
+ "exclude": [
9
+ "src/**/*.spec.ts",
10
+ "**/__tests__/**/*"
11
+ ]
12
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
16
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
17
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
18
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
19
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
20
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
21
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
22
+ "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
23
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
24
+
25
+ /* Modules */
26
+ "module": "ES2020", /* Specify what module code is generated. */
27
+ //"rootDir": "./src", /* Specify the root folder within your source files. */
28
+ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
29
+ "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
30
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
31
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
32
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
33
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
34
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
35
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
36
+ // "resolveJsonModule": true, /* Enable importing .json files. */
37
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
38
+
39
+ /* JavaScript Support */
40
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
41
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
42
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
43
+
44
+ /* Emit */
45
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
46
+ "declarationMap": true, /* Create sourcemaps for d.ts files. */
47
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
48
+ "sourceMap": true, /* Create source map files for emitted JavaScript files. */
49
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
50
+ // "outDir": "./dist", /* Specify an output folder for all emitted files. */
51
+ // "removeComments": true, /* Disable emitting comments. */
52
+ // "noEmit": true, /* Disable emitting files from a compilation. */
53
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
54
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
55
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
56
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
57
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
58
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
60
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
61
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
62
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
63
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
64
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
65
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
66
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
67
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
68
+
69
+ /* Interop Constraints */
70
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
71
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
72
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
73
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
74
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
75
+
76
+ /* Type Checking */
77
+ "strict": true, /* Enable all strict type-checking options. */
78
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
79
+ "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
80
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
81
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
82
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
83
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
84
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
85
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
86
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
87
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
88
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
89
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
90
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
91
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
92
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
93
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
94
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
95
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
96
+
97
+ /* Completeness */
98
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
99
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
100
+ },
101
+ "include": ["./src/**/*.ts"],
102
+ "types": ["jest"]
103
+ }