@plasmicapp/data-sources 1.0.16 → 1.0.18

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.js CHANGED
@@ -74,6 +74,7 @@ __export(index_exports, {
74
74
  _safeExecResult: () => safeExecResult,
75
75
  deriveFieldConfigs: () => deriveFieldConfigs,
76
76
  executePlasmicDataOp: () => executePlasmicDataOp,
77
+ executePlasmicQueries: () => executePlasmicQueries,
77
78
  executeServerQuery: () => executeServerQuery,
78
79
  isPlasmicUndefinedDataErrorPromise: () => isPlasmicUndefinedDataErrorPromise,
79
80
  makeCacheKey: () => makeCacheKey,
@@ -81,14 +82,13 @@ __export(index_exports, {
81
82
  matchesQueryCacheKey: () => matchesQueryCacheKey,
82
83
  normalizeData: () => normalizeData,
83
84
  throwIfPlasmicUndefinedDataError: () => throwIfPlasmicUndefinedDataError,
84
- unstable_executePlasmicQueries: () => executePlasmicQueries,
85
- unstable_usePlasmicQueries: () => usePlasmicQueries,
86
- unstable_wrapDollarQueriesForMetadata: () => wrapDollarQueriesForMetadata,
87
85
  useNormalizedData: () => useNormalizedData,
88
86
  usePlasmicDataConfig: () => import_query5.usePlasmicDataConfig,
89
87
  usePlasmicDataMutationOp: () => usePlasmicDataMutationOp,
90
88
  usePlasmicDataOp: () => usePlasmicDataOp,
91
- usePlasmicInvalidate: () => usePlasmicInvalidate
89
+ usePlasmicInvalidate: () => usePlasmicInvalidate,
90
+ usePlasmicQueries: () => usePlasmicQueries,
91
+ wrapPlasmicQueriesForMetadata: () => wrapPlasmicQueriesForMetadata
92
92
  });
93
93
  module.exports = __toCommonJS(index_exports);
94
94
 
@@ -279,7 +279,6 @@ var import_query3 = require("@plasmicapp/query");
279
279
  var React2 = __toESM(require("react"));
280
280
 
281
281
  // src/executor.tsx
282
- var import_isomorphic_unfetch = __toESM(require("@plasmicapp/isomorphic-unfetch"));
283
282
  var import_query2 = require("@plasmicapp/query");
284
283
  var import_fast_stringify = __toESM(require("fast-stringify"));
285
284
 
@@ -323,7 +322,7 @@ function _executePlasmicDataOp(op, opts) {
323
322
  }
324
323
  const host = getConfig("__PLASMIC_DATA_HOST", DEFAULT_HOST);
325
324
  const url = `${host}/api/v1/server-data/sources/${op.sourceId}/execute`;
326
- const resp = yield (0, import_isomorphic_unfetch.default)(url, {
325
+ const resp = yield fetch(url, {
327
326
  method: "POST",
328
327
  headers: __spreadValues({
329
328
  "Content-Type": "application/json"
@@ -762,17 +761,17 @@ function resolveParams(queryId, params) {
762
761
  })
763
762
  );
764
763
  }
765
- function wrapDollarQueriesForMetadata($queries, ifUndefined, ifError) {
766
- return wrapDollarQueriesWithFallbacks(
767
- $queries,
764
+ function wrapPlasmicQueriesForMetadata(queries, ifUndefined, ifError) {
765
+ return wrapPlasmicQueriesWithFallbacks(
766
+ queries,
768
767
  ifUndefined != null ? ifUndefined : (() => "\u2026"),
769
768
  ifError != null ? ifError : (() => "[ERROR]")
770
769
  );
771
770
  }
772
- function wrapDollarQueriesWithFallbacks($queries, ifUndefined, ifError) {
771
+ function wrapPlasmicQueriesWithFallbacks(queries, ifUndefined, ifError) {
773
772
  return mapRecords(
774
773
  (_queryName, $query) => new FallbackQueryResult($query, ifUndefined, ifError),
775
- $queries
774
+ queries
776
775
  );
777
776
  }
778
777
  var FallbackQueryResult = class {
@@ -898,14 +897,16 @@ function createInitial$State($ctx, $props, $q, stateSpecs) {
898
897
 
899
898
  // src/serverQueries/client.ts
900
899
  var GLOBAL_CACHE = /* @__PURE__ */ new Map();
901
- function usePlasmicQueries(tree, $ctx, $props, $state) {
900
+ function usePlasmicQueries(tree, env) {
902
901
  var _a;
902
+ const { $ctx, $props } = env;
903
903
  const wrappedQueries = React4.useMemo(() => wrapQueries(tree.queries), [tree]);
904
904
  const $queries = React4.useMemo(
905
905
  () => createDollarQueries(Object.keys(tree.queries)),
906
906
  [tree]
907
907
  );
908
908
  const $queryStates = $queries;
909
+ let $state = env.$state;
909
910
  if (!$state) {
910
911
  $state = createInitial$State($ctx, $props, $queryStates, tree.stateSpecs);
911
912
  }
@@ -1145,8 +1146,8 @@ var ROOT_COMPONENT_KEY_PATH = "root";
1145
1146
  function appendKeyPath(currentKeyPath, currentInput) {
1146
1147
  return currentKeyPath ? `${currentKeyPath}/${currentInput}` : currentInput;
1147
1148
  }
1148
- function executeQueryTree(rootNode, options, queriesByComponent) {
1149
- const { $props, $ctx } = options;
1149
+ function executeQueryTree(rootNode, env, queriesByComponent) {
1150
+ const { $props, $ctx } = env;
1150
1151
  const initialContext = {
1151
1152
  $props,
1152
1153
  $ctx,
@@ -1344,12 +1345,12 @@ function executeRepeatedNode(node, params) {
1344
1345
  );
1345
1346
  });
1346
1347
  }
1347
- function executePlasmicQueries(rootNode, options) {
1348
+ function executePlasmicQueries(rootNode, env) {
1348
1349
  return __async(this, null, function* () {
1349
1350
  const queriesByComponent = /* @__PURE__ */ new Map();
1350
1351
  const discoveredQueries = [];
1351
1352
  while (true) {
1352
- const newQueries = executeQueryTree(rootNode, options, queriesByComponent);
1353
+ const newQueries = executeQueryTree(rootNode, env, queriesByComponent);
1353
1354
  if (newQueries.length === 0) {
1354
1355
  break;
1355
1356
  }