@plasmicapp/data-sources 1.0.3 → 1.0.5
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.
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +80 -70
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +79 -69
- package/dist/index.js.map +4 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -189,7 +189,7 @@ declare interface QueryDataProviderNode {
|
|
|
189
189
|
children: QueryNode[];
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
declare interface QueryExecutionContext {
|
|
192
|
+
export declare interface QueryExecutionContext {
|
|
193
193
|
$props: Record<string, unknown>;
|
|
194
194
|
$ctx: Record<string, unknown>;
|
|
195
195
|
$state: Record<string, unknown>;
|
|
@@ -325,6 +325,8 @@ export declare interface TableSchema {
|
|
|
325
325
|
fields: TableFieldSchema[];
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
+
export declare function throwIfPlasmicUndefinedDataError(err: unknown): void;
|
|
329
|
+
|
|
328
330
|
/**
|
|
329
331
|
* Executes all queries from a serialized component tree and returns query results.
|
|
330
332
|
*
|
package/dist/index.esm.js
CHANGED
|
@@ -17,6 +17,7 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
21
|
var __async = (__this, __arguments, generator) => {
|
|
21
22
|
return new Promise((resolve, reject) => {
|
|
22
23
|
var fulfilled = (value) => {
|
|
@@ -38,62 +39,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
38
39
|
});
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
// src/serverQueries/client.ts
|
|
42
|
-
import {
|
|
43
|
-
useMutablePlasmicQueryData as useMutablePlasmicQueryData2,
|
|
44
|
-
usePlasmicDataConfig as usePlasmicDataConfig2,
|
|
45
|
-
wrapLoadingFetcher
|
|
46
|
-
} from "@plasmicapp/query";
|
|
47
|
-
import * as React3 from "react";
|
|
48
|
-
|
|
49
|
-
// src/utils.ts
|
|
50
|
-
function noopFn() {
|
|
51
|
-
}
|
|
52
|
-
function pick(obj, ...keys) {
|
|
53
|
-
const res = {};
|
|
54
|
-
for (const key of keys) {
|
|
55
|
-
if (key in obj) {
|
|
56
|
-
res[key] = obj[key];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return res;
|
|
60
|
-
}
|
|
61
|
-
var tuple = (...args) => args;
|
|
62
|
-
function mkIdMap(xs) {
|
|
63
|
-
return new Map(xs.map((x) => tuple(x.id, x)));
|
|
64
|
-
}
|
|
65
|
-
function notNil(x) {
|
|
66
|
-
return x !== null && x !== void 0;
|
|
67
|
-
}
|
|
68
|
-
function withoutNils(xs) {
|
|
69
|
-
return xs.filter(notNil);
|
|
70
|
-
}
|
|
71
|
-
function mapRecordEntries(callback, record1, record2, record3) {
|
|
72
|
-
return Object.entries(record1).map(([k, v1]) => {
|
|
73
|
-
const v2 = record2 == null ? void 0 : record2[k];
|
|
74
|
-
const v3 = record3 == null ? void 0 : record3[k];
|
|
75
|
-
return callback(
|
|
76
|
-
k,
|
|
77
|
-
v1,
|
|
78
|
-
v2,
|
|
79
|
-
v3
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function mapRecords(callback, record1, record2, record3) {
|
|
84
|
-
return Object.fromEntries(
|
|
85
|
-
mapRecordEntries(
|
|
86
|
-
(k, v1, v2, v3) => [k, callback(k, v1, v2, v3)],
|
|
87
|
-
record1,
|
|
88
|
-
record2,
|
|
89
|
-
record3
|
|
90
|
-
)
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// src/serverQueries/common.ts
|
|
95
|
-
import React2 from "react";
|
|
96
|
-
|
|
97
42
|
// src/common.ts
|
|
98
43
|
import {
|
|
99
44
|
useMutablePlasmicQueryData,
|
|
@@ -104,6 +49,11 @@ import React from "react";
|
|
|
104
49
|
function isPlasmicUndefinedDataErrorPromise(x) {
|
|
105
50
|
return !!x && typeof x === "object" && (x == null ? void 0 : x.plasmicType) === "PlasmicUndefinedDataError";
|
|
106
51
|
}
|
|
52
|
+
function throwIfPlasmicUndefinedDataError(err) {
|
|
53
|
+
if (isPlasmicUndefinedDataErrorPromise(err)) {
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
107
57
|
function tagPlasmicUndefinedDataErrorPromise(promise) {
|
|
108
58
|
promise.plasmicType = "PlasmicUndefinedDataError";
|
|
109
59
|
promise.message = "Query is not done";
|
|
@@ -273,7 +223,61 @@ function usePlasmicFetch(key, resolvedParams, fetcherFn, resultMapper, undefined
|
|
|
273
223
|
]);
|
|
274
224
|
}
|
|
275
225
|
|
|
226
|
+
// src/serverQueries/client.ts
|
|
227
|
+
import {
|
|
228
|
+
useMutablePlasmicQueryData as useMutablePlasmicQueryData2,
|
|
229
|
+
usePlasmicDataConfig as usePlasmicDataConfig2,
|
|
230
|
+
wrapLoadingFetcher
|
|
231
|
+
} from "@plasmicapp/query";
|
|
232
|
+
import * as React3 from "react";
|
|
233
|
+
|
|
234
|
+
// src/utils.ts
|
|
235
|
+
function noopFn() {
|
|
236
|
+
}
|
|
237
|
+
function pick(obj, ...keys) {
|
|
238
|
+
const res = {};
|
|
239
|
+
for (const key of keys) {
|
|
240
|
+
if (key in obj) {
|
|
241
|
+
res[key] = obj[key];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return res;
|
|
245
|
+
}
|
|
246
|
+
var tuple = (...args) => args;
|
|
247
|
+
function mkIdMap(xs) {
|
|
248
|
+
return new Map(xs.map((x) => tuple(x.id, x)));
|
|
249
|
+
}
|
|
250
|
+
function notNil(x) {
|
|
251
|
+
return x !== null && x !== void 0;
|
|
252
|
+
}
|
|
253
|
+
function withoutNils(xs) {
|
|
254
|
+
return xs.filter(notNil);
|
|
255
|
+
}
|
|
256
|
+
function mapRecordEntries(callback, record1, record2, record3) {
|
|
257
|
+
return Object.entries(record1).map(([k, v1]) => {
|
|
258
|
+
const v2 = record2 == null ? void 0 : record2[k];
|
|
259
|
+
const v3 = record3 == null ? void 0 : record3[k];
|
|
260
|
+
return callback(
|
|
261
|
+
k,
|
|
262
|
+
v1,
|
|
263
|
+
v2,
|
|
264
|
+
v3
|
|
265
|
+
);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
function mapRecords(callback, record1, record2, record3) {
|
|
269
|
+
return Object.fromEntries(
|
|
270
|
+
mapRecordEntries(
|
|
271
|
+
(k, v1, v2, v3) => [k, callback(k, v1, v2, v3)],
|
|
272
|
+
record1,
|
|
273
|
+
record2,
|
|
274
|
+
record3
|
|
275
|
+
)
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
276
279
|
// src/serverQueries/common.ts
|
|
280
|
+
import React2 from "react";
|
|
277
281
|
function createDollarQueries(queryNames) {
|
|
278
282
|
return Object.fromEntries(
|
|
279
283
|
queryNames.map((queryName) => {
|
|
@@ -283,7 +287,9 @@ function createDollarQueries(queryNames) {
|
|
|
283
287
|
}
|
|
284
288
|
var StatefulQueryResult = class {
|
|
285
289
|
constructor() {
|
|
286
|
-
this
|
|
290
|
+
__publicField(this, "current");
|
|
291
|
+
__publicField(this, "settable");
|
|
292
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
287
293
|
this.current = { state: "initial", key: null };
|
|
288
294
|
this.settable = new SettablePromise();
|
|
289
295
|
tagPlasmicUndefinedDataErrorPromise(this.settable.promise);
|
|
@@ -429,8 +435,8 @@ function resolveParams(params) {
|
|
|
429
435
|
function wrapDollarQueriesForMetadata($queries, ifUndefined, ifError) {
|
|
430
436
|
return wrapDollarQueriesWithFallbacks(
|
|
431
437
|
$queries,
|
|
432
|
-
ifUndefined != null ? ifUndefined : () => "\u2026",
|
|
433
|
-
ifError != null ? ifError : () => "[ERROR]"
|
|
438
|
+
ifUndefined != null ? ifUndefined : (() => "\u2026"),
|
|
439
|
+
ifError != null ? ifError : (() => "[ERROR]")
|
|
434
440
|
);
|
|
435
441
|
}
|
|
436
442
|
function wrapDollarQueriesWithFallbacks($queries, ifUndefined, ifError) {
|
|
@@ -441,9 +447,9 @@ function wrapDollarQueriesWithFallbacks($queries, ifUndefined, ifError) {
|
|
|
441
447
|
}
|
|
442
448
|
var FallbackQueryResult = class {
|
|
443
449
|
constructor($query, ifUndefined, ifError) {
|
|
444
|
-
this
|
|
445
|
-
this
|
|
446
|
-
this
|
|
450
|
+
__publicField(this, "$query", $query);
|
|
451
|
+
__publicField(this, "ifUndefined", ifUndefined);
|
|
452
|
+
__publicField(this, "ifError", ifError);
|
|
447
453
|
}
|
|
448
454
|
get key() {
|
|
449
455
|
return this.$query.key;
|
|
@@ -472,8 +478,8 @@ function createConstantProxy(constant) {
|
|
|
472
478
|
}
|
|
473
479
|
var SyncPromise = class {
|
|
474
480
|
constructor(promise) {
|
|
475
|
-
this
|
|
476
|
-
this
|
|
481
|
+
__publicField(this, "promise", promise);
|
|
482
|
+
__publicField(this, "result");
|
|
477
483
|
promise.then(
|
|
478
484
|
(value) => {
|
|
479
485
|
this.result = {
|
|
@@ -505,6 +511,9 @@ function shallowEqualRecords(a, b) {
|
|
|
505
511
|
}
|
|
506
512
|
var SettablePromise = class {
|
|
507
513
|
constructor() {
|
|
514
|
+
__publicField(this, "promise");
|
|
515
|
+
__publicField(this, "_resolve");
|
|
516
|
+
__publicField(this, "_reject");
|
|
508
517
|
this.promise = new Promise((resolve, reject) => {
|
|
509
518
|
this._resolve = resolve;
|
|
510
519
|
this._reject = reject;
|
|
@@ -658,7 +667,7 @@ function usePlasmicQueries(tree, $props, $ctx, $state) {
|
|
|
658
667
|
}
|
|
659
668
|
}
|
|
660
669
|
let cleanup = false;
|
|
661
|
-
const loop = () => __async(
|
|
670
|
+
const loop = () => __async(null, null, function* () {
|
|
662
671
|
while (true) {
|
|
663
672
|
initPlasmicQueriesSync(
|
|
664
673
|
$queryStates,
|
|
@@ -1211,7 +1220,7 @@ function makeCacheKey(dataOp, opts) {
|
|
|
1211
1220
|
}
|
|
1212
1221
|
function usePlasmicInvalidate() {
|
|
1213
1222
|
const { cache, fallback, mutate } = usePlasmicDataConfig3();
|
|
1214
|
-
return (invalidatedKeys) => __async(
|
|
1223
|
+
return (invalidatedKeys) => __async(null, null, function* () {
|
|
1215
1224
|
const getKeysToInvalidate = () => {
|
|
1216
1225
|
var _a, _b;
|
|
1217
1226
|
if (!invalidatedKeys) {
|
|
@@ -1249,7 +1258,7 @@ function usePlasmicInvalidate() {
|
|
|
1249
1258
|
if (keys.length === 0) {
|
|
1250
1259
|
return;
|
|
1251
1260
|
}
|
|
1252
|
-
const invalidateKey = (key) => __async(
|
|
1261
|
+
const invalidateKey = (key) => __async(null, null, function* () {
|
|
1253
1262
|
const studioInvalidate = globalThis.__PLASMIC_MUTATE_DATA_OP;
|
|
1254
1263
|
if (studioInvalidate) {
|
|
1255
1264
|
yield studioInvalidate(key);
|
|
@@ -1305,8 +1314,8 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
1305
1314
|
function usePlasmicDataMutationOp(dataOp) {
|
|
1306
1315
|
const ctx = usePlasmicDataSourceContext();
|
|
1307
1316
|
const userToken = ctx == null ? void 0 : ctx.userAuthToken;
|
|
1308
|
-
const getRealDataOp = React4.useCallback(() => __async(
|
|
1309
|
-
const tryGetRealDataOp = () => __async(
|
|
1317
|
+
const getRealDataOp = React4.useCallback(() => __async(null, null, function* () {
|
|
1318
|
+
const tryGetRealDataOp = () => __async(null, null, function* () {
|
|
1310
1319
|
const resolved = resolveDataOp(dataOp);
|
|
1311
1320
|
if (!resolved) {
|
|
1312
1321
|
return null;
|
|
@@ -1319,7 +1328,7 @@ function usePlasmicDataMutationOp(dataOp) {
|
|
|
1319
1328
|
});
|
|
1320
1329
|
return yield tryGetRealDataOp();
|
|
1321
1330
|
}), [dataOp]);
|
|
1322
|
-
return React4.useCallback(() => __async(
|
|
1331
|
+
return React4.useCallback(() => __async(null, null, function* () {
|
|
1323
1332
|
var _a;
|
|
1324
1333
|
const { sourceId, opId, userArgs } = (_a = yield getRealDataOp()) != null ? _a : {};
|
|
1325
1334
|
if (!sourceId || !opId) {
|
|
@@ -1502,6 +1511,7 @@ export {
|
|
|
1502
1511
|
makeCacheKey,
|
|
1503
1512
|
makeQueryCacheKey,
|
|
1504
1513
|
normalizeData,
|
|
1514
|
+
throwIfPlasmicUndefinedDataError,
|
|
1505
1515
|
executePlasmicQueries as unstable_executePlasmicQueries,
|
|
1506
1516
|
usePlasmicQueries as unstable_usePlasmicQueries,
|
|
1507
1517
|
wrapDollarQueriesForMetadata as unstable_wrapDollarQueriesForMetadata,
|