@plasmicapp/data-sources 0.1.148 → 0.1.150
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.esm.js +15 -13
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +28 -26
- package/dist/index.js.map +3 -3
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
useMutablePlasmicQueryData,
|
|
52
52
|
usePlasmicDataConfig
|
|
53
53
|
} from "@plasmicapp/query";
|
|
54
|
-
import React from "react";
|
|
54
|
+
import * as React from "react";
|
|
55
55
|
|
|
56
56
|
// src/executor.tsx
|
|
57
57
|
import fetch from "@plasmicapp/isomorphic-unfetch";
|
|
@@ -153,6 +153,7 @@ function withoutNils(xs) {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// src/hooks/usePlasmicDataOp.tsx
|
|
156
|
+
var isRSC2 = React.isRSC;
|
|
156
157
|
function makeCacheKey(dataOp, opts) {
|
|
157
158
|
const queryDependencies = JSON.stringify({
|
|
158
159
|
sourceId: dataOp.sourceId,
|
|
@@ -272,7 +273,7 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
272
273
|
const resolvedDataOp = resolveDataOp(dataOp);
|
|
273
274
|
const ctx = usePlasmicDataSourceContext();
|
|
274
275
|
const enableLoadingBoundary = !!((_b = (_a = ph.useDataEnv) == null ? void 0 : _a()) == null ? void 0 : _b[enableLoadingBoundaryKey]);
|
|
275
|
-
const { mutate, cache } = usePlasmicDataConfig();
|
|
276
|
+
const { mutate, cache } = isRSC2 ? {} : usePlasmicDataConfig();
|
|
276
277
|
const isNullDataOp = !resolvedDataOp;
|
|
277
278
|
const isWaitingOnDependentQuery = isPlasmicUndefinedDataErrorPromise(resolvedDataOp);
|
|
278
279
|
const key = !resolvedDataOp || isPlasmicUndefinedDataErrorPromise(resolvedDataOp) ? null : makeCacheKey(resolvedDataOp, {
|
|
@@ -337,11 +338,11 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
337
338
|
if (!key) {
|
|
338
339
|
throw new Error(`Expected key to be non-null`);
|
|
339
340
|
}
|
|
340
|
-
const cached = cache.get(key);
|
|
341
|
+
const cached = cache == null ? void 0 : cache.get(key);
|
|
341
342
|
if (cached) {
|
|
342
343
|
return Promise.resolve(cached);
|
|
343
344
|
}
|
|
344
|
-
const cachedError = cache.get(`$swr$${key}`);
|
|
345
|
+
const cachedError = cache == null ? void 0 : cache.get(`$swr$${key}`);
|
|
345
346
|
if (cachedError) {
|
|
346
347
|
return Promise.reject(cachedError.error);
|
|
347
348
|
}
|
|
@@ -350,13 +351,14 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
350
351
|
fetcher().then(resolve, reject);
|
|
351
352
|
}, 1);
|
|
352
353
|
});
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
354
|
+
if (!isRSC2)
|
|
355
|
+
fetcherPromise.then((data2) => {
|
|
356
|
+
mutate == null ? void 0 : mutate(key, data2);
|
|
357
|
+
}).catch((err) => {
|
|
358
|
+
var _a2;
|
|
359
|
+
const keyInfo = key ? "$swr$" + key : "";
|
|
360
|
+
cache == null ? void 0 : cache.set(keyInfo, __spreadProps(__spreadValues({}, (_a2 = cache == null ? void 0 : cache.get(keyInfo)) != null ? _a2 : {}), { error: err }));
|
|
361
|
+
});
|
|
360
362
|
return fetcherPromise;
|
|
361
363
|
};
|
|
362
364
|
}, [fetcher, fetchingData, cache, key, dependentKeyDataErrorPromise]);
|
|
@@ -475,7 +477,7 @@ var FetcherMeta = {
|
|
|
475
477
|
};
|
|
476
478
|
|
|
477
479
|
// src/helpers.ts
|
|
478
|
-
import { useMemo } from "react";
|
|
480
|
+
import { useMemo as useMemo2 } from "react";
|
|
479
481
|
function normalizeData(rawData) {
|
|
480
482
|
var _a;
|
|
481
483
|
if (!rawData) {
|
|
@@ -492,7 +494,7 @@ function normalizeData(rawData) {
|
|
|
492
494
|
return { data: dataArray, schema };
|
|
493
495
|
}
|
|
494
496
|
function useNormalizedData(rawData) {
|
|
495
|
-
return
|
|
497
|
+
return useMemo2(() => normalizeData(rawData), [rawData]);
|
|
496
498
|
}
|
|
497
499
|
function tryGetDataArray(rawData) {
|
|
498
500
|
if (rawData == null || typeof rawData !== "object") {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.tsx", "../src/components/Fetcher.tsx", "../src/hooks/usePlasmicDataOp.tsx", "../src/executor.tsx", "../src/placeholders.ts", "../src/utils.ts", "../src/helpers.ts", "../src/hooks/useDependencyAwareQuery.tsx"],
|
|
4
|
-
"sourcesContent": ["export { usePlasmicDataConfig } from \"@plasmicapp/query\";\nexport { Fetcher, FetcherMeta } from \"./components/Fetcher\";\nexport type { FetcherProps } from \"./components/Fetcher\";\nexport { executePlasmicDataOp } from \"./executor\";\nexport type { DataOp } from \"./executor\";\nexport {\n deriveFieldConfigs,\n normalizeData,\n useNormalizedData,\n} from \"./helpers\";\nexport type { BaseFieldConfig, NormalizedData, QueryResult } from \"./helpers\";\nexport { useDependencyAwareQuery } from \"./hooks/useDependencyAwareQuery\";\nexport {\n makeCacheKey,\n usePlasmicDataMutationOp,\n usePlasmicDataOp,\n usePlasmicInvalidate,\n} from \"./hooks/usePlasmicDataOp\";\nexport type {\n DataSourceSchema,\n ManyRowsResult,\n Pagination,\n SingleRowResult,\n TableFieldSchema,\n TableFieldType,\n TableSchema,\n} from \"./types\";\n", "import { ComponentMeta } from '@plasmicapp/host';\nimport React from 'react';\nimport { DataOp } from '../executor';\nimport { usePlasmicDataOp } from '../hooks/usePlasmicDataOp';\n\nexport interface DataOpConfig {\n name?: string;\n pageIndex?: number;\n pageSize?: number;\n}\n\nexport interface FetcherProps extends DataOpConfig {\n dataOp?: DataOp;\n children?: ($queries: Record<string, any>) => React.ReactElement | null;\n queries?: Record<string, any>;\n}\n\nexport function Fetcher(props: FetcherProps): React.ReactElement | null {\n const { dataOp, children, name, pageIndex, pageSize } = props;\n const data = usePlasmicDataOp(dataOp, {\n ...(!!pageIndex &&\n !!pageSize && {\n paginate: { pageIndex, pageSize },\n }),\n });\n\n const $queries = React.useMemo(\n () => ({ ...props.queries, [name ?? 'data']: data }),\n [props.queries, name, data]\n );\n\n return children?.($queries) ?? null;\n}\n\nexport const FetcherMeta: ComponentMeta<FetcherProps> = {\n name: 'plasmic-data-source-fetcher',\n displayName: 'Data Fetcher',\n props: {\n dataOp: {\n type: 'dataSourceOp' as any,\n displayName: 'Data',\n },\n name: {\n type: 'string',\n displayName: 'Variable name',\n },\n children: {\n type: 'slot',\n renderPropParams: ['$queries'],\n },\n pageSize: {\n type: 'number',\n advanced: true,\n displayName: 'Page size',\n description: 'Only fetch in batches of this size; for pagination',\n },\n pageIndex: {\n type: 'number',\n advanced: true,\n displayName: 'Page index',\n description: '0-based index of the paginated page to fetch',\n },\n },\n importPath: '@plasmicapp/react-web/lib/data-sources',\n importName: 'Fetcher',\n alwaysAutoName: true,\n styleSections: false,\n};\n", "import { usePlasmicDataSourceContext } from \"@plasmicapp/data-sources-context\";\n// eslint-disable-next-line no-restricted-imports\nimport * as ph from \"@plasmicapp/host\";\nimport {\n useMutablePlasmicQueryData,\n usePlasmicDataConfig,\n} from \"@plasmicapp/query\";\nimport React from \"react\";\nimport { DataOp, executePlasmicDataOp } from \"../executor\";\nimport { ManyRowsResult, Pagination, SingleRowResult } from \"../types\";\nimport { pick } from \"../utils\";\n\nexport function makeCacheKey(\n dataOp: DataOp,\n opts?: { paginate?: Pagination; userAuthToken?: string | null }\n) {\n const queryDependencies = JSON.stringify({\n sourceId: dataOp.sourceId,\n opId: dataOp.opId,\n args: dataOp.userArgs,\n userAuthToken: opts?.userAuthToken,\n paginate: opts?.paginate,\n });\n return dataOp.cacheKey\n ? `${dataOp.cacheKey}${queryDependencies}`\n : queryDependencies;\n}\n\n/**\n * Returns a function that can be used to invalidate Plasmic query groups.\n */\nexport function usePlasmicInvalidate() {\n // NOTE: we use `revalidateIfStale: false` with SWR.\n // One quirk of this is that if you supply fallback data to swr,\n // that data doesn't get entered into the cache if `revalidateIfStale: false`,\n // so you won't see it if you iterate over keys of the cache. That's why\n // we have usePlasmicInvalidate() which will iterate over both the cache\n // and the fallback data.\n const { cache, fallback, mutate } = usePlasmicDataConfig();\n return async (invalidatedKeys: string[] | null | undefined) => {\n const getKeysToInvalidate = () => {\n if (!invalidatedKeys) {\n return [];\n }\n const allKeys = Array.from(\n new Set([\n ...Array.from((cache as any).keys()),\n ...(fallback ? Object.keys(fallback) : []),\n // If this is running within the Studio, we also take the\n // opportunity to invalidate the Studio cache. The keys that\n // Studio may have can be a superset of `cache` here, because\n // `cache` is updated as swr hooks are mounted and unmounted,\n // but Studio's data cache keys don't get removed when hooks\n // are unmounted. This makes it possible for Studio to hold\n // onto a stale cache entry that doesn't get invalidated.\n // For example, Studio may render page1, with key X, then goes\n // to page 2, which performs a mutate. At this point, Studio\n // has a cache entry for key X, but `cache` does not, because\n // page2 does not use that query. But page 2 may perform a\n // mutation that invalidates X. So we need to invalidate not\n // only keys in `cache`, but also keys that Studio is still\n // holding onto.\n ...((globalThis as any).__PLASMIC_GET_ALL_CACHE_KEYS?.() ?? []),\n ])\n ).filter((key): key is string => typeof key === \"string\");\n if (invalidatedKeys.includes(\"plasmic_refresh_all\")) {\n return allKeys;\n }\n return allKeys.filter((key) =>\n invalidatedKeys.some((k) => key.includes(`.$.${k}.$.`))\n );\n };\n\n const keys = getKeysToInvalidate();\n if (keys.length === 0) {\n return;\n }\n\n const invalidateKey = async (key: string) => {\n const studioInvalidate = (globalThis as any).__PLASMIC_MUTATE_DATA_OP;\n if (studioInvalidate) {\n await studioInvalidate(key);\n }\n return mutate(key);\n };\n\n return await Promise.all(keys.map((key) => invalidateKey(key)));\n };\n}\n\nconst enableLoadingBoundaryKey = \"plasmicInternalEnableLoadingBoundary\";\n\nfunction mkUndefinedDataProxy(\n promiseRef: { fetchingPromise: Promise<any> | undefined },\n fetchAndUpdateCache: (() => Promise<any>) | undefined\n) {\n let fetchAndUpdatePromise: Promise<any> | undefined = undefined;\n\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n if (prop === \"isPlasmicUndefinedDataProxy\") {\n return true;\n }\n\n if (!fetchAndUpdateCache) {\n // There's no key so no fetch to kick off yet; when computing key,\n // we encountered some thrown exception (that's not an undefined data promise),\n // and so we can't fetch yet. This might be dependent on a $state or $prop value\n // that's currently undefined, etc. We will act like an undefined data object,\n // and trigger the usual fallback behavior\n return undefined;\n }\n\n const doFetchAndUpdate = () => {\n // We hold onto the promise last returned by fetchAndUpdateCache()\n // and keep reusing it until it is resolved. The reason is that the\n // Promise thrown here will be used as a dependency for memoized\n // fetchAndUpdateCache, which is a dependency on the memoized returned value\n // from usePlasmicDataOp(). If we have a fetch that's taking a long time,\n // we want to make sure that our memoized returned value is stable,\n // so that we don't keep calling setDollarQueries() (otherwise, for each\n // render, we find an unstable result, and call setDollarQueries(),\n // resulting in an infinite loop while fetch is happening).\n if (!fetchAndUpdatePromise) {\n fetchAndUpdatePromise = fetchAndUpdateCache().finally(() => {\n fetchAndUpdatePromise = undefined;\n });\n }\n return fetchAndUpdatePromise;\n };\n\n const promise =\n // existing fetch\n promiseRef.fetchingPromise ||\n // No existing fetch, so kick off a fetch\n doFetchAndUpdate();\n (promise as any).plasmicType = \"PlasmicUndefinedDataError\";\n (promise as any).message = `Cannot read property ${String(\n prop\n )} - data is still loading`;\n throw promise;\n },\n }\n ) as any;\n}\n\ninterface PlasmicUndefinedDataErrorPromise extends Promise<any> {\n plasmicType: \"PlasmicUndefinedDataError\";\n message: string;\n}\n\nfunction isPlasmicUndefinedDataErrorPromise(\n x: any\n): x is PlasmicUndefinedDataErrorPromise {\n return (\n !!x &&\n typeof x === \"object\" &&\n (x as any).plasmicType === \"PlasmicUndefinedDataError\"\n );\n}\n\nconst reactMajorVersion = +React.version.split(\".\")[0];\n\ntype ResolvableDataOp =\n | DataOp\n | undefined\n | null\n | (() => DataOp | undefined | null);\n\n/**\n * This returns either:\n * * DataOp to perform\n * * undefined/null, if no data op can be performed\n * * PlasmicUndefinedDataErrorPromise, if when trying to evaluate the DataOp to perform,\n * we encounter a PlasmicUndefinedDataErrorPromise, so this operation cannot be\n * performed until that promise is resolved.\n */\nfunction resolveDataOp(dataOp: ResolvableDataOp) {\n if (typeof dataOp === \"function\") {\n try {\n return dataOp();\n } catch (err) {\n if (isPlasmicUndefinedDataErrorPromise(err)) {\n return err;\n }\n return null;\n }\n } else {\n return dataOp;\n }\n}\n\n/**\n * Fetches can be kicked off two ways -- normally, by useSWR(), or by some\n * expression accessing the `$queries.*` proxy when not ready yet. We need\n * a global cache for proxy-invoked caches, so that different components\n * with the same key can share the same fetch.\n *\n * The life cycle for this cache is short -- only the duration of a\n * proxy-invoked fetch, and once the fetch is done. That's because we really\n * just want SWR to be managing the cache, not us! Once the data is in SWR,\n * we will use SWR for getting data.\n */\nconst PRE_FETCHES = new Map<string, Promise<any>>();\n\nexport function usePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult,\n E = any\n>(\n dataOp: ResolvableDataOp,\n opts?: {\n paginate?: Pagination;\n noUndefinedDataProxy?: boolean;\n }\n): Partial<T> & {\n error?: E;\n isLoading?: boolean;\n} {\n const resolvedDataOp = resolveDataOp(dataOp);\n const ctx = usePlasmicDataSourceContext();\n const enableLoadingBoundary = !!ph.useDataEnv?.()?.[enableLoadingBoundaryKey];\n const { mutate, cache } = usePlasmicDataConfig();\n // Cannot perform this operation\n const isNullDataOp = !resolvedDataOp;\n // This operation depends on another data query to resolve first\n const isWaitingOnDependentQuery =\n isPlasmicUndefinedDataErrorPromise(resolvedDataOp);\n const key =\n !resolvedDataOp || isPlasmicUndefinedDataErrorPromise(resolvedDataOp)\n ? null\n : makeCacheKey(resolvedDataOp, {\n paginate: opts?.paginate,\n userAuthToken: ctx?.userAuthToken,\n });\n const fetchingData = React.useMemo(\n () => ({\n fetchingPromise: undefined as Promise<T> | undefined,\n }),\n [key]\n );\n const fetcher = React.useMemo(\n () => () => {\n // If we are in this function, that means SWR cache missed.\n if (!key) {\n throw new Error(`Fetcher should never be called without a proper key`);\n }\n\n // dataOp is guaranteed to be a DataOp, and not an undefined promise or null\n\n if (fetchingData.fetchingPromise) {\n // Fetch is already underway from this hook\n return fetchingData.fetchingPromise;\n }\n\n if (key && PRE_FETCHES.has(key)) {\n // Some other usePlasmicDataOp() hook elsewhere has already\n // started this fetch as well; re-use it here.\n const existing = PRE_FETCHES.get(key) as Promise<T>;\n fetchingData.fetchingPromise = existing;\n return existing;\n }\n\n // Else we really need to kick off this fetch now...\n const fetcherFn = () =>\n executePlasmicDataOp<T>(resolvedDataOp as DataOp, {\n userAuthToken: ctx?.userAuthToken || undefined,\n user: ctx?.user,\n paginate: opts?.paginate,\n });\n const fetcherPromise = fetcherFn();\n fetchingData.fetchingPromise = fetcherPromise;\n if (key) {\n PRE_FETCHES.set(key, fetcherPromise);\n // Once we have a result, we rely on swr to perform the caching,\n // so remove from our cache as quickly as possible.\n fetcherPromise.then(\n () => {\n PRE_FETCHES.delete(key);\n },\n () => {\n PRE_FETCHES.delete(key);\n }\n );\n }\n return fetcherPromise;\n },\n [key, fetchingData]\n );\n\n const dependentKeyDataErrorPromise = isPlasmicUndefinedDataErrorPromise(\n resolvedDataOp\n )\n ? resolvedDataOp\n : undefined;\n const fetchAndUpdateCache = React.useMemo(() => {\n if (!key && !dependentKeyDataErrorPromise) {\n // If there's no key, and no data query we're waiting for, then there's\n // no way to perform a fetch\n return undefined;\n }\n return () => {\n // This function is called when the undefined data proxy is invoked.\n // USUALLY, this means the data is not available in SWR yet, and\n // we need to kick off a fetch.\n\n if (fetchingData.fetchingPromise) {\n // No need to update cache as the exist promise call site will do it\n return fetchingData.fetchingPromise;\n }\n\n if (dependentKeyDataErrorPromise) {\n // We can't actually fetch yet, because we couldn't even evaluate the dataOp\n // to fetch for, because we depend on unfetched data. Once _that_\n // dataOp we depend on is finished, then we can try again. So we\n // will throw and wait for _that_ promise to be resolved instead.\n return dependentKeyDataErrorPromise;\n }\n\n if (!key) {\n throw new Error(`Expected key to be non-null`);\n }\n\n // SOMETIMES, SWR actually _does_ have the cache, but we still end up\n // here. That's because of how we update $queries, which takes two\n // cycles; each time we render, we build a `new$Queries`, and\n // `set$Queries(new$Queries)`. So once the data is ready, at the\n // first render, we will have data in `new$Queries` but not `$queries`,\n // but we will still finish rendering that pass, which means any `$queries`\n // access will still end up here. So we look into the SWR cache and\n // return any data that's here.\n const cached = cache.get(key);\n if (cached) {\n return Promise.resolve(cached);\n }\n const cachedError = cache.get(`$swr$${key}`);\n if (cachedError) {\n return Promise.reject(cachedError.error);\n }\n\n // Now, upon this proxy.get() miss, we want to kick off the fetch. We can't\n // wait for useSWR() to kick off the fetch, because upon data miss we are\n // throwing a promise, and useSWR() won't kick off the fetch till the effect,\n // so it will never get a chance to fetch. Instead, we fetch, and then we\n // put the fetched data into the SWR cache, so that next time useSWR() is called,\n // it will just find it in the cache.\n //\n // However, we don't want to fetch SYNCHRONOUSLY RIGHT NOW, becase we are in\n // the rendering phase (presumably, we're here because some component is trying\n // to read fetched data while rendering). Doing a fetch right now would invoke\n // the fetcher, which is wrapped by @plasmicapp/query to tracking loading state,\n // and upon loading state toggled to true, it will fire loading event listeners,\n // and for example, our antd's <GlobalLoadingIndicator /> will listen to this\n // event and immediately ask antd to show the loading indicator, which mutates\n // antd component's state. It is NOT LEGAL to call setState() on some other\n // component's state during rendering phase!\n //\n // We therefore will delay kicking off the fetch by a tick, so that we will safely\n // start the fetch outside of React rendering phase.\n const fetcherPromise = new Promise((resolve, reject) => {\n setTimeout(() => {\n fetcher().then(resolve, reject);\n }, 1);\n });\n fetcherPromise\n .then((data) => {\n // Insert the fetched data into the SWR cache\n mutate(key, data);\n })\n .catch((err) => {\n // Cache the error here to avoid infinite loop\n const keyInfo = key ? \"$swr$\" + key : \"\";\n cache.set(keyInfo, { ...(cache.get(keyInfo) ?? {}), error: err });\n });\n return fetcherPromise;\n };\n }, [fetcher, fetchingData, cache, key, dependentKeyDataErrorPromise]);\n const res = useMutablePlasmicQueryData<T, E>(key, fetcher, {\n shouldRetryOnError: false,\n\n // If revalidateIfStale is true, then if there's a cache entry with a key,\n // but no mounted hook with that key yet, and when the hook mounts with the key,\n // swr will revalidate. This may be reasonable behavior, but for us, this\n // happens all the time -- we prepopulate the cache with proxy-invoked fetch,\n // sometimes before swr had a chance to run the effect. So we turn off\n // revalidateIfStale here, and just let the user manage invalidation.\n revalidateIfStale: false,\n });\n const { data, error, isLoading } = res;\n if (fetchingData.fetchingPromise != null && data !== undefined) {\n // Clear the fetching promise as the actual data is now used (so\n // revalidation is possible)\n fetchingData.fetchingPromise = undefined;\n }\n return React.useMemo(() => {\n const result = {\n ...(data ?? ({} as Partial<T>)),\n ...pick(res, \"isLoading\", \"error\"),\n };\n if (\n !opts?.noUndefinedDataProxy &&\n reactMajorVersion >= 18 &&\n enableLoadingBoundary &&\n (isLoading || isNullDataOp || isWaitingOnDependentQuery) &&\n result.data === undefined &&\n result.schema === undefined &&\n result.error === undefined\n ) {\n result.data = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);\n result.schema = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);\n }\n return result;\n }, [\n isNullDataOp,\n isWaitingOnDependentQuery,\n data,\n error,\n isLoading,\n opts?.noUndefinedDataProxy,\n enableLoadingBoundary,\n fetchingData,\n fetchAndUpdateCache,\n ]);\n}\n\nexport function usePlasmicDataMutationOp<\n T extends SingleRowResult | ManyRowsResult\n>(dataOp: ResolvableDataOp) {\n const ctx = usePlasmicDataSourceContext();\n const userToken = ctx?.userAuthToken;\n\n const getRealDataOp = React.useCallback(async () => {\n const tryGetRealDataOp = async (): Promise<DataOp | null> => {\n const resolved = resolveDataOp(dataOp);\n if (!resolved) {\n return null;\n } else if (isPlasmicUndefinedDataErrorPromise(resolved)) {\n // If calling the dataOp function resulted in a data fetch,\n // then we wait for the data fetch to finish and try\n // again\n await resolved;\n return tryGetRealDataOp();\n } else {\n return resolved;\n }\n };\n return await tryGetRealDataOp();\n }, [dataOp]);\n\n return React.useCallback(async () => {\n const { sourceId, opId, userArgs } = (await getRealDataOp()) ?? {};\n\n if (!sourceId || !opId) {\n return undefined;\n }\n\n return executePlasmicDataOp<T>(\n { sourceId, opId, userArgs },\n {\n userAuthToken: userToken || undefined,\n user: ctx?.user,\n }\n );\n }, [getRealDataOp, userToken]);\n}\n", "import { PlasmicDataSourceContextValue } from \"@plasmicapp/data-sources-context\";\nimport fetch from \"@plasmicapp/isomorphic-unfetch\";\nimport { wrapLoadingFetcher } from \"@plasmicapp/query\";\nimport stringify from \"fast-stringify\";\nimport { addPlaceholdersToUserArgs } from \"./placeholders\";\nimport { ManyRowsResult, Pagination, SingleRowResult } from \"./types\";\n\nconst DEFAULT_HOST = \"https://data.plasmic.app\";\n\nexport interface DataOp {\n sourceId: string;\n opId: string;\n userArgs?: Record<string, any>;\n cacheKey?: string;\n invalidatedKeys?: string[] | null;\n roleId?: string | null;\n}\n\ninterface ExecuteOpts {\n userAuthToken?: string;\n user?: PlasmicDataSourceContextValue[\"user\"];\n paginate?: Pagination;\n}\n\nconst UNAUTHORIZED_MESSAGE =\n \"You do not have permission to perform this operation. Login to get access or contact the app owner to get access.\";\n\nexport async function executePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult\n>(op: DataOp, opts?: ExecuteOpts) {\n const func = getConfig(\n \"__PLASMIC_EXECUTE_DATA_OP\",\n _executePlasmicDataOp\n ) as typeof _executePlasmicDataOp;\n op.userArgs = addPlaceholdersToUserArgs(op.userArgs);\n const res = await wrapLoadingFetcher(func)(op, opts);\n return res as T;\n}\n\nasync function _executePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult\n>(op: DataOp, opts?: ExecuteOpts) {\n if (op.roleId) {\n if (!opts?.user || !opts.user.roleIds.includes(op.roleId)) {\n console.error(UNAUTHORIZED_MESSAGE);\n throw new Error(UNAUTHORIZED_MESSAGE);\n }\n }\n\n const host = getConfig(\"__PLASMIC_DATA_HOST\", DEFAULT_HOST);\n\n const url = `${host}/api/v1/server-data/sources/${op.sourceId}/execute`;\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(opts?.userAuthToken && {\n \"x-plasmic-data-user-auth-token\": opts.userAuthToken,\n }),\n },\n body: stringify({\n opId: op.opId,\n userArgs: op.userArgs ?? {},\n paginate: opts?.paginate,\n }),\n });\n if (resp.status !== 200) {\n const text = await resp.text();\n throw new Error(text);\n }\n return (await resp.json()) as T;\n}\n\nfunction getConfig<T>(key: string, defaultValue: T) {\n if (typeof globalThis === \"undefined\") {\n return defaultValue;\n } else {\n return (globalThis as any)[key] ?? defaultValue;\n }\n}\n", "const PLASMIC_UNDEFINED = \"__PLASMIC_UNDEFINED\";\n\nfunction addPlaceholders(val: any) {\n return val === undefined ? PLASMIC_UNDEFINED : val;\n}\n\nexport function addPlaceholdersToUserArgs(\n userArgs: Record<string, any> | undefined\n) {\n if (!userArgs) {\n return userArgs;\n }\n Object.entries(userArgs).forEach(([key, val]) => {\n userArgs[key] = Array.isArray(val)\n ? val.map((v) => addPlaceholders(v))\n : addPlaceholders(val);\n });\n return userArgs;\n}\n", "export function swallow<T>(f: () => T): T | undefined {\n try {\n return f();\n } catch {\n return undefined;\n }\n}\n\nexport function pick<T extends object, K extends keyof T>(\n obj: T,\n ...keys: K[]\n): Pick<T, K> {\n const res: any = {};\n for (const key of keys) {\n if (key in obj) {\n res[key] = obj[key as keyof T];\n }\n }\n return res;\n}\n\ntype ReactElt = {\n children: ReactElt | ReactElt[];\n props: {\n children: ReactElt | ReactElt[];\n [prop: string]: any;\n } | null;\n type: React.ComponentType<any> | null;\n key: string | null;\n} | null;\n\nexport function traverseReactEltTree(\n children: React.ReactNode,\n callback: (elt: ReactElt) => void\n) {\n const rec = (elts: ReactElt | ReactElt[] | null) => {\n (Array.isArray(elts) ? elts : [elts]).forEach((elt) => {\n if (elt) {\n callback(elt);\n if (elt.children) {\n rec(elt.children);\n }\n if (elt.props?.children && elt.props.children !== elt.children) {\n rec(elt.props.children);\n }\n }\n });\n };\n rec(children as any);\n}\n\nexport function asArray<T>(x: T[] | T | undefined | null) {\n if (Array.isArray(x)) {\n return x;\n } else if (x == null) {\n return [];\n } else {\n return [x];\n }\n}\n\nexport function ensureNumber(x: number | string): number {\n return x as number;\n}\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n throw new Error('Expected non-null or non-undefined value');\n }\n return x;\n}\n\nexport function isOneOf<T, U extends T>(elem: T, arr: readonly U[]): elem is U {\n return arr.includes(elem as any);\n}\n\nexport function maybe<T, U>(\n x: T | undefined | null,\n f: (y: T) => U\n): U | undefined {\n if (x === undefined || x === null) return undefined;\n return f(x);\n}\n\nexport function isLikeImage(value: unknown) {\n return typeof value === 'string'\n ? value.match(/\\.(png|jpg|jpeg|gif|svg|webp|avif|ico|bmp|tiff)$/i)\n : false;\n}\n\nexport function ensureArray<T>(xs: T | T[]): T[] {\n return Array.isArray(xs) ? xs : [xs];\n}\n\nexport const tuple = <T extends any[]>(...args: T): T => args;\n\nexport interface HasId {\n id: string;\n}\n\nexport function mkIdMap<T extends HasId>(xs: ReadonlyArray<T>): Map<string, T> {\n return new Map(xs.map((x) => tuple(x.id, x) as [string, T]));\n}\n\nexport const mkShortId = () => `${Math.random()}`;\n\nexport function withoutNils<T>(xs: Array<T | undefined | null>): T[] {\n return xs.filter((x): x is T => x != null);\n}\n\nexport type Falsey = null | undefined | false | '' | 0 | 0n;\nexport type Truthy<T> = T extends Falsey ? never : T;\n\nexport function withoutFalsey<T>(xs: Array<T | Falsey>): T[] {\n return xs.filter((x): x is T => !!x);\n}\n", "import { useMemo } from \"react\";\nimport {\n ManyRowsResult,\n TableFieldSchema,\n TableFieldType,\n TableSchema,\n} from \"./types\";\nimport { mkIdMap, withoutNils } from \"./utils\";\n\nexport type QueryResult = Partial<ManyRowsResult<any>> & {\n error?: any;\n isLoading?: boolean;\n};\n\nexport interface NormalizedData {\n data: Record<string, unknown>[];\n schema?: TableSchema;\n}\n\nexport function normalizeData(rawData: unknown): NormalizedData | undefined {\n if (!rawData) {\n return undefined;\n }\n\n const dataArray = tryGetDataArray(rawData);\n if (!dataArray) {\n return undefined;\n }\n const schema = (rawData as any).schema ?? tryGetSchema(dataArray);\n if (!schema) {\n return undefined;\n }\n return { data: dataArray, schema };\n}\n\nexport function useNormalizedData(\n rawData: unknown\n): NormalizedData | undefined {\n return useMemo(() => normalizeData(rawData), [rawData]);\n}\n\nfunction tryGetDataArray(rawData: unknown): any[] | undefined {\n if (rawData == null || typeof rawData !== \"object\") {\n return undefined;\n }\n\n if (Array.isArray(rawData)) {\n if (isArrayOfObjects(rawData)) {\n return rawData;\n } else {\n // TODO: array of primitives? Maybe we can wrap this?\n return undefined;\n }\n }\n\n if (rawData == null) {\n return undefined;\n }\n\n if (\"data\" in rawData && typeof (rawData as any).data === \"object\") {\n if (\n Array.isArray((rawData as any).data) &&\n isArrayOfObjects((rawData as any).data)\n ) {\n return (rawData as any).data;\n } else if ((rawData as any).data != null) {\n return [(rawData as any).data];\n } else {\n return undefined;\n }\n }\n if (\"isLoading\" in rawData || \"error\" in rawData) {\n return undefined;\n }\n\n // Maybe a singleton record?\n return [rawData];\n}\n\nfunction isArrayOfObjects(arr: unknown[]) {\n return arr.every((x) => typeof x === \"object\" && !Array.isArray(x));\n}\n\nfunction tryGetSchema(data: any[]): TableSchema | undefined {\n const fieldMap: Record<string, TableFieldType> = {};\n data.forEach((entry: any) => {\n if (entry && typeof entry === \"object\") {\n Array.from(Object.entries(entry)).forEach(([k, v]) => {\n const inferredType: TableFieldType =\n typeof v === \"string\"\n ? \"string\"\n : typeof v === \"boolean\"\n ? \"boolean\"\n : typeof v === \"number\"\n ? \"number\"\n : \"unknown\";\n if (fieldMap[k] && fieldMap[k] !== inferredType) {\n fieldMap[k] = \"unknown\";\n } else {\n fieldMap[k] = inferredType;\n }\n });\n }\n });\n return {\n id: \"inferred\",\n fields: Object.entries(fieldMap).map(([f, t]) => ({\n id: f,\n type: t,\n readOnly: false,\n })),\n };\n}\n\nexport type BaseFieldConfig = {\n key?: string;\n fieldId?: string;\n};\n\nconst mkShortId = () => `${Math.random()}`;\n\nexport function deriveFieldConfigs<T extends BaseFieldConfig>(\n specifiedFieldsPartial: Partial<T>[],\n schema: TableSchema | undefined,\n makeDefaultConfig: (field: TableFieldSchema | undefined) => T\n): {\n mergedFields: T[];\n minimalFullLengthFields: Partial<T>[];\n} {\n const schemaFields = schema?.fields ?? [];\n const fieldById = mkIdMap(schemaFields);\n const specifiedFieldIds = new Set(\n withoutNils(specifiedFieldsPartial.map((f) => f.fieldId))\n );\n const keptSpecifiedFields = specifiedFieldsPartial.flatMap((f): T[] => {\n if (!f.fieldId) {\n return [\n { key: mkShortId(), ...makeDefaultConfig(undefined), ...f },\n ] as T[];\n }\n const field = fieldById.get(f.fieldId as string);\n\n // Drop configs with fieldIds no longer in the data.\n if (!field) {\n return [];\n }\n\n return [\n {\n key: mkShortId(),\n ...makeDefaultConfig(field),\n ...f,\n },\n ] as T[];\n });\n const newVirtualFields = schemaFields\n .filter((f) => !specifiedFieldIds.has(f.id))\n .map(\n (f): T => ({\n key: mkShortId(),\n ...makeDefaultConfig(f),\n })\n );\n const mergedFields = [...keptSpecifiedFields, ...newVirtualFields];\n const minimalFullLengthFields: Partial<T>[] = [\n ...specifiedFieldsPartial,\n ...newVirtualFields.map((f) => ({ key: f.key, fieldId: f.fieldId })),\n ] as Partial<T>[];\n return { mergedFields, minimalFullLengthFields };\n}\n", "import React from 'react';\nimport { DataOpConfig } from '../components/Fetcher';\nimport { DataOp } from '../executor';\nimport { swallow } from '../utils';\nimport { usePlasmicDataOp } from './usePlasmicDataOp';\n\nfunction usePrevious<T>(value: T | undefined): T | undefined {\n const prevValue = React.useRef<T | undefined>(undefined);\n\n React.useEffect(() => {\n prevValue.current = value;\n\n return () => {\n prevValue.current = undefined;\n };\n });\n\n return prevValue.current;\n}\n\nexport interface DependencyAwareQueryConfig extends DataOpConfig {\n $queries: Record<string, any>;\n setDollarQueries: ($queries: Record<string, any>) => void;\n getDataOp: () => DataOp;\n}\n\n/**\n * @deprecated Prefer using `usePlasmicDataOp` directly instead.\n */\nexport function useDependencyAwareQuery({\n $queries,\n getDataOp,\n setDollarQueries,\n name,\n pageIndex,\n pageSize,\n}: DependencyAwareQueryConfig) {\n const data = usePlasmicDataOp(swallow(getDataOp), {\n ...(!!pageIndex &&\n !!pageSize && {\n paginate: { pageIndex, pageSize },\n }),\n });\n const finalName = name ?? 'data';\n const prevName = usePrevious(finalName);\n React.useEffect(() => {\n if (!(finalName in $queries) || $queries[finalName] !== data) {\n const $queries2 = {\n ...$queries,\n [finalName]: data,\n };\n if (prevName && finalName !== prevName && prevName in $queries) {\n delete $queries2[prevName];\n }\n setDollarQueries($queries2);\n }\n }, [finalName, prevName, data, $queries, setDollarQueries]);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,wBAAAA,6BAA4B;;;ACCrC,OAAOC,YAAW;;;ACDlB,SAAS,mCAAmC;AAE5C,YAAY,QAAQ;AACpB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,OAAO,WAAW;;;ACNlB,OAAO,WAAW;AAClB,SAAS,0BAA0B;AACnC,OAAO,eAAe;;;ACHtB,IAAM,oBAAoB;AAE1B,SAAS,gBAAgB,KAAU;AACjC,SAAO,QAAQ,SAAY,oBAAoB;AACjD;AAEO,SAAS,0BACd,UACA;AACA,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,QAAQ,EAAE,QAAQ,CAAC,CAAC,KAAK,GAAG,MAAM;AAC/C,aAAS,GAAG,IAAI,MAAM,QAAQ,GAAG,IA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AC1B,QAAM,WAAW,YAAY,SAAS;AACtC,EAAAA,OAAM,UAAU,MAAM;AACpB,QAAI,EAAE,aAAa,aAAa,SAAS,SAAS,MAAM,MAAM;AAC5D,YAAM,YAAY,iCACb,WADa;AAAA,QAEhB,CAAC,SAAS,GAAG;AAAA,MACf;AACA,UAAI,YAAY,cAAc,YAAY,YAAY,UAAU;AAC9D,eAAO,UAAU,QAAQ;AAAA,MAC3B;AACA,uBAAiB,SAAS;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,WAAW,UAAU,MAAM,UAAU,gBAAgB,CAAC;AAC5D;",
|
|
6
|
-
"names": ["usePlasmicDataConfig", "React", "data", "_a", "React", "React", "React"]
|
|
4
|
+
"sourcesContent": ["export { usePlasmicDataConfig } from \"@plasmicapp/query\";\nexport { Fetcher, FetcherMeta } from \"./components/Fetcher\";\nexport type { FetcherProps } from \"./components/Fetcher\";\nexport { executePlasmicDataOp } from \"./executor\";\nexport type { DataOp } from \"./executor\";\nexport {\n deriveFieldConfigs,\n normalizeData,\n useNormalizedData,\n} from \"./helpers\";\nexport type { BaseFieldConfig, NormalizedData, QueryResult } from \"./helpers\";\nexport { useDependencyAwareQuery } from \"./hooks/useDependencyAwareQuery\";\nexport {\n makeCacheKey,\n usePlasmicDataMutationOp,\n usePlasmicDataOp,\n usePlasmicInvalidate,\n} from \"./hooks/usePlasmicDataOp\";\nexport type {\n DataSourceSchema,\n ManyRowsResult,\n Pagination,\n SingleRowResult,\n TableFieldSchema,\n TableFieldType,\n TableSchema,\n} from \"./types\";\n", "import { ComponentMeta } from '@plasmicapp/host';\nimport React from 'react';\nimport { DataOp } from '../executor';\nimport { usePlasmicDataOp } from '../hooks/usePlasmicDataOp';\n\nexport interface DataOpConfig {\n name?: string;\n pageIndex?: number;\n pageSize?: number;\n}\n\nexport interface FetcherProps extends DataOpConfig {\n dataOp?: DataOp;\n children?: ($queries: Record<string, any>) => React.ReactElement | null;\n queries?: Record<string, any>;\n}\n\nexport function Fetcher(props: FetcherProps): React.ReactElement | null {\n const { dataOp, children, name, pageIndex, pageSize } = props;\n const data = usePlasmicDataOp(dataOp, {\n ...(!!pageIndex &&\n !!pageSize && {\n paginate: { pageIndex, pageSize },\n }),\n });\n\n const $queries = React.useMemo(\n () => ({ ...props.queries, [name ?? 'data']: data }),\n [props.queries, name, data]\n );\n\n return children?.($queries) ?? null;\n}\n\nexport const FetcherMeta: ComponentMeta<FetcherProps> = {\n name: 'plasmic-data-source-fetcher',\n displayName: 'Data Fetcher',\n props: {\n dataOp: {\n type: 'dataSourceOp' as any,\n displayName: 'Data',\n },\n name: {\n type: 'string',\n displayName: 'Variable name',\n },\n children: {\n type: 'slot',\n renderPropParams: ['$queries'],\n },\n pageSize: {\n type: 'number',\n advanced: true,\n displayName: 'Page size',\n description: 'Only fetch in batches of this size; for pagination',\n },\n pageIndex: {\n type: 'number',\n advanced: true,\n displayName: 'Page index',\n description: '0-based index of the paginated page to fetch',\n },\n },\n importPath: '@plasmicapp/react-web/lib/data-sources',\n importName: 'Fetcher',\n alwaysAutoName: true,\n styleSections: false,\n};\n", "import { usePlasmicDataSourceContext } from \"@plasmicapp/data-sources-context\";\n// eslint-disable-next-line no-restricted-imports\nimport * as ph from \"@plasmicapp/host\";\nimport {\n useMutablePlasmicQueryData,\n usePlasmicDataConfig,\n} from \"@plasmicapp/query\";\nimport * as React from \"react\";\nimport { DataOp, executePlasmicDataOp } from \"../executor\";\nimport { ManyRowsResult, Pagination, SingleRowResult } from \"../types\";\nimport { pick } from \"../utils\";\n\nconst isRSC = (React as any).isRSC;\n\nexport function makeCacheKey(\n dataOp: DataOp,\n opts?: { paginate?: Pagination; userAuthToken?: string | null }\n) {\n const queryDependencies = JSON.stringify({\n sourceId: dataOp.sourceId,\n opId: dataOp.opId,\n args: dataOp.userArgs,\n userAuthToken: opts?.userAuthToken,\n paginate: opts?.paginate,\n });\n return dataOp.cacheKey\n ? `${dataOp.cacheKey}${queryDependencies}`\n : queryDependencies;\n}\n\n/**\n * Returns a function that can be used to invalidate Plasmic query groups.\n */\nexport function usePlasmicInvalidate() {\n // NOTE: we use `revalidateIfStale: false` with SWR.\n // One quirk of this is that if you supply fallback data to swr,\n // that data doesn't get entered into the cache if `revalidateIfStale: false`,\n // so you won't see it if you iterate over keys of the cache. That's why\n // we have usePlasmicInvalidate() which will iterate over both the cache\n // and the fallback data.\n const { cache, fallback, mutate } = usePlasmicDataConfig();\n return async (invalidatedKeys: string[] | null | undefined) => {\n const getKeysToInvalidate = () => {\n if (!invalidatedKeys) {\n return [];\n }\n const allKeys = Array.from(\n new Set([\n ...Array.from((cache as any).keys()),\n ...(fallback ? Object.keys(fallback) : []),\n // If this is running within the Studio, we also take the\n // opportunity to invalidate the Studio cache. The keys that\n // Studio may have can be a superset of `cache` here, because\n // `cache` is updated as swr hooks are mounted and unmounted,\n // but Studio's data cache keys don't get removed when hooks\n // are unmounted. This makes it possible for Studio to hold\n // onto a stale cache entry that doesn't get invalidated.\n // For example, Studio may render page1, with key X, then goes\n // to page 2, which performs a mutate. At this point, Studio\n // has a cache entry for key X, but `cache` does not, because\n // page2 does not use that query. But page 2 may perform a\n // mutation that invalidates X. So we need to invalidate not\n // only keys in `cache`, but also keys that Studio is still\n // holding onto.\n ...((globalThis as any).__PLASMIC_GET_ALL_CACHE_KEYS?.() ?? []),\n ])\n ).filter((key): key is string => typeof key === \"string\");\n if (invalidatedKeys.includes(\"plasmic_refresh_all\")) {\n return allKeys;\n }\n return allKeys.filter((key) =>\n invalidatedKeys.some((k) => key.includes(`.$.${k}.$.`))\n );\n };\n\n const keys = getKeysToInvalidate();\n if (keys.length === 0) {\n return;\n }\n\n const invalidateKey = async (key: string) => {\n const studioInvalidate = (globalThis as any).__PLASMIC_MUTATE_DATA_OP;\n if (studioInvalidate) {\n await studioInvalidate(key);\n }\n return mutate(key);\n };\n\n return await Promise.all(keys.map((key) => invalidateKey(key)));\n };\n}\n\nconst enableLoadingBoundaryKey = \"plasmicInternalEnableLoadingBoundary\";\n\nfunction mkUndefinedDataProxy(\n promiseRef: { fetchingPromise: Promise<any> | undefined },\n fetchAndUpdateCache: (() => Promise<any>) | undefined\n) {\n let fetchAndUpdatePromise: Promise<any> | undefined = undefined;\n\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n if (prop === \"isPlasmicUndefinedDataProxy\") {\n return true;\n }\n\n if (!fetchAndUpdateCache) {\n // There's no key so no fetch to kick off yet; when computing key,\n // we encountered some thrown exception (that's not an undefined data promise),\n // and so we can't fetch yet. This might be dependent on a $state or $prop value\n // that's currently undefined, etc. We will act like an undefined data object,\n // and trigger the usual fallback behavior\n return undefined;\n }\n\n const doFetchAndUpdate = () => {\n // We hold onto the promise last returned by fetchAndUpdateCache()\n // and keep reusing it until it is resolved. The reason is that the\n // Promise thrown here will be used as a dependency for memoized\n // fetchAndUpdateCache, which is a dependency on the memoized returned value\n // from usePlasmicDataOp(). If we have a fetch that's taking a long time,\n // we want to make sure that our memoized returned value is stable,\n // so that we don't keep calling setDollarQueries() (otherwise, for each\n // render, we find an unstable result, and call setDollarQueries(),\n // resulting in an infinite loop while fetch is happening).\n if (!fetchAndUpdatePromise) {\n fetchAndUpdatePromise = fetchAndUpdateCache().finally(() => {\n fetchAndUpdatePromise = undefined;\n });\n }\n return fetchAndUpdatePromise;\n };\n\n const promise =\n // existing fetch\n promiseRef.fetchingPromise ||\n // No existing fetch, so kick off a fetch\n doFetchAndUpdate();\n (promise as any).plasmicType = \"PlasmicUndefinedDataError\";\n (promise as any).message = `Cannot read property ${String(\n prop\n )} - data is still loading`;\n throw promise;\n },\n }\n ) as any;\n}\n\ninterface PlasmicUndefinedDataErrorPromise extends Promise<any> {\n plasmicType: \"PlasmicUndefinedDataError\";\n message: string;\n}\n\nfunction isPlasmicUndefinedDataErrorPromise(\n x: any\n): x is PlasmicUndefinedDataErrorPromise {\n return (\n !!x &&\n typeof x === \"object\" &&\n (x as any).plasmicType === \"PlasmicUndefinedDataError\"\n );\n}\n\nconst reactMajorVersion = +React.version.split(\".\")[0];\n\ntype ResolvableDataOp =\n | DataOp\n | undefined\n | null\n | (() => DataOp | undefined | null);\n\n/**\n * This returns either:\n * * DataOp to perform\n * * undefined/null, if no data op can be performed\n * * PlasmicUndefinedDataErrorPromise, if when trying to evaluate the DataOp to perform,\n * we encounter a PlasmicUndefinedDataErrorPromise, so this operation cannot be\n * performed until that promise is resolved.\n */\nfunction resolveDataOp(dataOp: ResolvableDataOp) {\n if (typeof dataOp === \"function\") {\n try {\n return dataOp();\n } catch (err) {\n if (isPlasmicUndefinedDataErrorPromise(err)) {\n return err;\n }\n return null;\n }\n } else {\n return dataOp;\n }\n}\n\n/**\n * Fetches can be kicked off two ways -- normally, by useSWR(), or by some\n * expression accessing the `$queries.*` proxy when not ready yet. We need\n * a global cache for proxy-invoked caches, so that different components\n * with the same key can share the same fetch.\n *\n * The life cycle for this cache is short -- only the duration of a\n * proxy-invoked fetch, and once the fetch is done. That's because we really\n * just want SWR to be managing the cache, not us! Once the data is in SWR,\n * we will use SWR for getting data.\n */\nconst PRE_FETCHES = new Map<string, Promise<any>>();\n\nexport function usePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult,\n E = any\n>(\n dataOp: ResolvableDataOp,\n opts?: {\n paginate?: Pagination;\n noUndefinedDataProxy?: boolean;\n }\n): Partial<T> & {\n error?: E;\n isLoading?: boolean;\n} {\n const resolvedDataOp = resolveDataOp(dataOp);\n const ctx = usePlasmicDataSourceContext();\n const enableLoadingBoundary = !!ph.useDataEnv?.()?.[enableLoadingBoundaryKey];\n const { mutate, cache } = isRSC\n ? ({} as any as Partial<ReturnType<typeof usePlasmicDataConfig>>)\n : usePlasmicDataConfig();\n // Cannot perform this operation\n const isNullDataOp = !resolvedDataOp;\n // This operation depends on another data query to resolve first\n const isWaitingOnDependentQuery =\n isPlasmicUndefinedDataErrorPromise(resolvedDataOp);\n const key =\n !resolvedDataOp || isPlasmicUndefinedDataErrorPromise(resolvedDataOp)\n ? null\n : makeCacheKey(resolvedDataOp, {\n paginate: opts?.paginate,\n userAuthToken: ctx?.userAuthToken,\n });\n const fetchingData = React.useMemo(\n () => ({\n fetchingPromise: undefined as Promise<T> | undefined,\n }),\n [key]\n );\n const fetcher = React.useMemo(\n () => () => {\n // If we are in this function, that means SWR cache missed.\n if (!key) {\n throw new Error(`Fetcher should never be called without a proper key`);\n }\n\n // dataOp is guaranteed to be a DataOp, and not an undefined promise or null\n\n if (fetchingData.fetchingPromise) {\n // Fetch is already underway from this hook\n return fetchingData.fetchingPromise;\n }\n\n if (key && PRE_FETCHES.has(key)) {\n // Some other usePlasmicDataOp() hook elsewhere has already\n // started this fetch as well; re-use it here.\n const existing = PRE_FETCHES.get(key) as Promise<T>;\n fetchingData.fetchingPromise = existing;\n return existing;\n }\n\n // Else we really need to kick off this fetch now...\n const fetcherFn = () =>\n executePlasmicDataOp<T>(resolvedDataOp as DataOp, {\n userAuthToken: ctx?.userAuthToken || undefined,\n user: ctx?.user,\n paginate: opts?.paginate,\n });\n const fetcherPromise = fetcherFn();\n fetchingData.fetchingPromise = fetcherPromise;\n if (key) {\n PRE_FETCHES.set(key, fetcherPromise);\n // Once we have a result, we rely on swr to perform the caching,\n // so remove from our cache as quickly as possible.\n fetcherPromise.then(\n () => {\n PRE_FETCHES.delete(key);\n },\n () => {\n PRE_FETCHES.delete(key);\n }\n );\n }\n return fetcherPromise;\n },\n [key, fetchingData]\n );\n\n const dependentKeyDataErrorPromise = isPlasmicUndefinedDataErrorPromise(\n resolvedDataOp\n )\n ? resolvedDataOp\n : undefined;\n const fetchAndUpdateCache = React.useMemo(() => {\n if (!key && !dependentKeyDataErrorPromise) {\n // If there's no key, and no data query we're waiting for, then there's\n // no way to perform a fetch\n return undefined;\n }\n return () => {\n // This function is called when the undefined data proxy is invoked.\n // USUALLY, this means the data is not available in SWR yet, and\n // we need to kick off a fetch.\n\n if (fetchingData.fetchingPromise) {\n // No need to update cache as the exist promise call site will do it\n return fetchingData.fetchingPromise;\n }\n\n if (dependentKeyDataErrorPromise) {\n // We can't actually fetch yet, because we couldn't even evaluate the dataOp\n // to fetch for, because we depend on unfetched data. Once _that_\n // dataOp we depend on is finished, then we can try again. So we\n // will throw and wait for _that_ promise to be resolved instead.\n return dependentKeyDataErrorPromise;\n }\n\n if (!key) {\n throw new Error(`Expected key to be non-null`);\n }\n\n // SOMETIMES, SWR actually _does_ have the cache, but we still end up\n // here. That's because of how we update $queries, which takes two\n // cycles; each time we render, we build a `new$Queries`, and\n // `set$Queries(new$Queries)`. So once the data is ready, at the\n // first render, we will have data in `new$Queries` but not `$queries`,\n // but we will still finish rendering that pass, which means any `$queries`\n // access will still end up here. So we look into the SWR cache and\n // return any data that's here.\n const cached = cache?.get(key);\n if (cached) {\n return Promise.resolve(cached);\n }\n const cachedError = cache?.get(`$swr$${key}`);\n if (cachedError) {\n return Promise.reject(cachedError.error);\n }\n\n // Now, upon this proxy.get() miss, we want to kick off the fetch. We can't\n // wait for useSWR() to kick off the fetch, because upon data miss we are\n // throwing a promise, and useSWR() won't kick off the fetch till the effect,\n // so it will never get a chance to fetch. Instead, we fetch, and then we\n // put the fetched data into the SWR cache, so that next time useSWR() is called,\n // it will just find it in the cache.\n //\n // However, we don't want to fetch SYNCHRONOUSLY RIGHT NOW, becase we are in\n // the rendering phase (presumably, we're here because some component is trying\n // to read fetched data while rendering). Doing a fetch right now would invoke\n // the fetcher, which is wrapped by @plasmicapp/query to tracking loading state,\n // and upon loading state toggled to true, it will fire loading event listeners,\n // and for example, our antd's <GlobalLoadingIndicator /> will listen to this\n // event and immediately ask antd to show the loading indicator, which mutates\n // antd component's state. It is NOT LEGAL to call setState() on some other\n // component's state during rendering phase!\n //\n // We therefore will delay kicking off the fetch by a tick, so that we will safely\n // start the fetch outside of React rendering phase.\n const fetcherPromise = new Promise((resolve, reject) => {\n setTimeout(() => {\n fetcher().then(resolve, reject);\n }, 1);\n });\n if (!isRSC)\n fetcherPromise\n .then((data) => {\n // Insert the fetched data into the SWR cache\n mutate?.(key, data);\n })\n .catch((err) => {\n // Cache the error here to avoid infinite loop\n const keyInfo = key ? \"$swr$\" + key : \"\";\n cache?.set(keyInfo, { ...(cache?.get(keyInfo) ?? {}), error: err });\n });\n return fetcherPromise;\n };\n }, [fetcher, fetchingData, cache, key, dependentKeyDataErrorPromise]);\n const res = useMutablePlasmicQueryData<T, E>(key, fetcher, {\n shouldRetryOnError: false,\n\n // If revalidateIfStale is true, then if there's a cache entry with a key,\n // but no mounted hook with that key yet, and when the hook mounts with the key,\n // swr will revalidate. This may be reasonable behavior, but for us, this\n // happens all the time -- we prepopulate the cache with proxy-invoked fetch,\n // sometimes before swr had a chance to run the effect. So we turn off\n // revalidateIfStale here, and just let the user manage invalidation.\n revalidateIfStale: false,\n });\n const { data, error, isLoading } = res;\n if (fetchingData.fetchingPromise != null && data !== undefined) {\n // Clear the fetching promise as the actual data is now used (so\n // revalidation is possible)\n fetchingData.fetchingPromise = undefined;\n }\n return React.useMemo(() => {\n const result = {\n ...(data ?? ({} as Partial<T>)),\n ...pick(res, \"isLoading\", \"error\"),\n };\n if (\n !opts?.noUndefinedDataProxy &&\n reactMajorVersion >= 18 &&\n enableLoadingBoundary &&\n (isLoading || isNullDataOp || isWaitingOnDependentQuery) &&\n result.data === undefined &&\n result.schema === undefined &&\n result.error === undefined\n ) {\n result.data = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);\n result.schema = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);\n }\n return result;\n }, [\n isNullDataOp,\n isWaitingOnDependentQuery,\n data,\n error,\n isLoading,\n opts?.noUndefinedDataProxy,\n enableLoadingBoundary,\n fetchingData,\n fetchAndUpdateCache,\n ]);\n}\n\nexport function usePlasmicDataMutationOp<\n T extends SingleRowResult | ManyRowsResult\n>(dataOp: ResolvableDataOp) {\n const ctx = usePlasmicDataSourceContext();\n const userToken = ctx?.userAuthToken;\n\n const getRealDataOp = React.useCallback(async () => {\n const tryGetRealDataOp = async (): Promise<DataOp | null> => {\n const resolved = resolveDataOp(dataOp);\n if (!resolved) {\n return null;\n } else if (isPlasmicUndefinedDataErrorPromise(resolved)) {\n // If calling the dataOp function resulted in a data fetch,\n // then we wait for the data fetch to finish and try\n // again\n await resolved;\n return tryGetRealDataOp();\n } else {\n return resolved;\n }\n };\n return await tryGetRealDataOp();\n }, [dataOp]);\n\n return React.useCallback(async () => {\n const { sourceId, opId, userArgs } = (await getRealDataOp()) ?? {};\n\n if (!sourceId || !opId) {\n return undefined;\n }\n\n return executePlasmicDataOp<T>(\n { sourceId, opId, userArgs },\n {\n userAuthToken: userToken || undefined,\n user: ctx?.user,\n }\n );\n }, [getRealDataOp, userToken]);\n}\n", "import { PlasmicDataSourceContextValue } from \"@plasmicapp/data-sources-context\";\nimport fetch from \"@plasmicapp/isomorphic-unfetch\";\nimport { wrapLoadingFetcher } from \"@plasmicapp/query\";\nimport stringify from \"fast-stringify\";\nimport { addPlaceholdersToUserArgs } from \"./placeholders\";\nimport { ManyRowsResult, Pagination, SingleRowResult } from \"./types\";\n\nconst DEFAULT_HOST = \"https://data.plasmic.app\";\n\nexport interface DataOp {\n sourceId: string;\n opId: string;\n userArgs?: Record<string, any>;\n cacheKey?: string;\n invalidatedKeys?: string[] | null;\n roleId?: string | null;\n}\n\ninterface ExecuteOpts {\n userAuthToken?: string;\n user?: PlasmicDataSourceContextValue[\"user\"];\n paginate?: Pagination;\n}\n\nconst UNAUTHORIZED_MESSAGE =\n \"You do not have permission to perform this operation. Login to get access or contact the app owner to get access.\";\n\nexport async function executePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult\n>(op: DataOp, opts?: ExecuteOpts) {\n const func = getConfig(\n \"__PLASMIC_EXECUTE_DATA_OP\",\n _executePlasmicDataOp\n ) as typeof _executePlasmicDataOp;\n op.userArgs = addPlaceholdersToUserArgs(op.userArgs);\n const res = await wrapLoadingFetcher(func)(op, opts);\n return res as T;\n}\n\nasync function _executePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult\n>(op: DataOp, opts?: ExecuteOpts) {\n if (op.roleId) {\n if (!opts?.user || !opts.user.roleIds.includes(op.roleId)) {\n console.error(UNAUTHORIZED_MESSAGE);\n throw new Error(UNAUTHORIZED_MESSAGE);\n }\n }\n\n const host = getConfig(\"__PLASMIC_DATA_HOST\", DEFAULT_HOST);\n\n const url = `${host}/api/v1/server-data/sources/${op.sourceId}/execute`;\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(opts?.userAuthToken && {\n \"x-plasmic-data-user-auth-token\": opts.userAuthToken,\n }),\n },\n body: stringify({\n opId: op.opId,\n userArgs: op.userArgs ?? {},\n paginate: opts?.paginate,\n }),\n });\n if (resp.status !== 200) {\n const text = await resp.text();\n throw new Error(text);\n }\n return (await resp.json()) as T;\n}\n\nfunction getConfig<T>(key: string, defaultValue: T) {\n if (typeof globalThis === \"undefined\") {\n return defaultValue;\n } else {\n return (globalThis as any)[key] ?? defaultValue;\n }\n}\n", "const PLASMIC_UNDEFINED = \"__PLASMIC_UNDEFINED\";\n\nfunction addPlaceholders(val: any) {\n return val === undefined ? PLASMIC_UNDEFINED : val;\n}\n\nexport function addPlaceholdersToUserArgs(\n userArgs: Record<string, any> | undefined\n) {\n if (!userArgs) {\n return userArgs;\n }\n Object.entries(userArgs).forEach(([key, val]) => {\n userArgs[key] = Array.isArray(val)\n ? val.map((v) => addPlaceholders(v))\n : addPlaceholders(val);\n });\n return userArgs;\n}\n", "export function swallow<T>(f: () => T): T | undefined {\n try {\n return f();\n } catch {\n return undefined;\n }\n}\n\nexport function pick<T extends object, K extends keyof T>(\n obj: T,\n ...keys: K[]\n): Pick<T, K> {\n const res: any = {};\n for (const key of keys) {\n if (key in obj) {\n res[key] = obj[key as keyof T];\n }\n }\n return res;\n}\n\ntype ReactElt = {\n children: ReactElt | ReactElt[];\n props: {\n children: ReactElt | ReactElt[];\n [prop: string]: any;\n } | null;\n type: React.ComponentType<any> | null;\n key: string | null;\n} | null;\n\nexport function traverseReactEltTree(\n children: React.ReactNode,\n callback: (elt: ReactElt) => void\n) {\n const rec = (elts: ReactElt | ReactElt[] | null) => {\n (Array.isArray(elts) ? elts : [elts]).forEach((elt) => {\n if (elt) {\n callback(elt);\n if (elt.children) {\n rec(elt.children);\n }\n if (elt.props?.children && elt.props.children !== elt.children) {\n rec(elt.props.children);\n }\n }\n });\n };\n rec(children as any);\n}\n\nexport function asArray<T>(x: T[] | T | undefined | null) {\n if (Array.isArray(x)) {\n return x;\n } else if (x == null) {\n return [];\n } else {\n return [x];\n }\n}\n\nexport function ensureNumber(x: number | string): number {\n return x as number;\n}\n\nexport function ensure<T>(x: T | null | undefined, msg: string): T {\n if (x === null || x === undefined) {\n throw new Error(\"Expected non-null or non-undefined value: \" + msg);\n }\n return x;\n}\n\nexport function isOneOf<T, U extends T>(elem: T, arr: readonly U[]): elem is U {\n return arr.includes(elem as any);\n}\n\nexport function maybe<T, U>(\n x: T | undefined | null,\n f: (y: T) => U\n): U | undefined {\n if (x === undefined || x === null) return undefined;\n return f(x);\n}\n\nexport function isLikeImage(value: unknown) {\n return typeof value === \"string\"\n ? value.match(/\\.(png|jpg|jpeg|gif|svg|webp|avif|ico|bmp|tiff)$/i)\n : false;\n}\n\nexport function ensureArray<T>(xs: T | T[]): T[] {\n return Array.isArray(xs) ? xs : [xs];\n}\n\nexport const tuple = <T extends any[]>(...args: T): T => args;\n\nexport interface HasId {\n id: string;\n}\n\nexport function mkIdMap<T extends HasId>(xs: ReadonlyArray<T>): Map<string, T> {\n return new Map(xs.map((x) => tuple(x.id, x) as [string, T]));\n}\n\nexport const mkShortId = () => `${Math.random()}`;\n\nexport function withoutNils<T>(xs: Array<T | undefined | null>): T[] {\n return xs.filter((x): x is T => x != null);\n}\n\nexport type Falsey = null | undefined | false | \"\" | 0 | 0n;\nexport type Truthy<T> = T extends Falsey ? never : T;\n\nexport function withoutFalsey<T>(xs: Array<T | Falsey>): T[] {\n return xs.filter((x): x is T => !!x);\n}\n", "import { useMemo } from \"react\";\nimport {\n ManyRowsResult,\n TableFieldSchema,\n TableFieldType,\n TableSchema,\n} from \"./types\";\nimport { mkIdMap, withoutNils } from \"./utils\";\n\nexport type QueryResult = Partial<ManyRowsResult<any>> & {\n error?: any;\n isLoading?: boolean;\n};\n\nexport interface NormalizedData {\n data: Record<string, unknown>[];\n schema?: TableSchema;\n}\n\nexport function normalizeData(rawData: unknown): NormalizedData | undefined {\n if (!rawData) {\n return undefined;\n }\n\n const dataArray = tryGetDataArray(rawData);\n if (!dataArray) {\n return undefined;\n }\n const schema = (rawData as any).schema ?? tryGetSchema(dataArray);\n if (!schema) {\n return undefined;\n }\n return { data: dataArray, schema };\n}\n\nexport function useNormalizedData(\n rawData: unknown\n): NormalizedData | undefined {\n return useMemo(() => normalizeData(rawData), [rawData]);\n}\n\nfunction tryGetDataArray(rawData: unknown): any[] | undefined {\n if (rawData == null || typeof rawData !== \"object\") {\n return undefined;\n }\n\n if (Array.isArray(rawData)) {\n if (isArrayOfObjects(rawData)) {\n return rawData;\n } else {\n // TODO: array of primitives? Maybe we can wrap this?\n return undefined;\n }\n }\n\n if (rawData == null) {\n return undefined;\n }\n\n if (\"data\" in rawData && typeof (rawData as any).data === \"object\") {\n if (\n Array.isArray((rawData as any).data) &&\n isArrayOfObjects((rawData as any).data)\n ) {\n return (rawData as any).data;\n } else if ((rawData as any).data != null) {\n return [(rawData as any).data];\n } else {\n return undefined;\n }\n }\n if (\"isLoading\" in rawData || \"error\" in rawData) {\n return undefined;\n }\n\n // Maybe a singleton record?\n return [rawData];\n}\n\nfunction isArrayOfObjects(arr: unknown[]) {\n return arr.every((x) => typeof x === \"object\" && !Array.isArray(x));\n}\n\nfunction tryGetSchema(data: any[]): TableSchema | undefined {\n const fieldMap: Record<string, TableFieldType> = {};\n data.forEach((entry: any) => {\n if (entry && typeof entry === \"object\") {\n Array.from(Object.entries(entry)).forEach(([k, v]) => {\n const inferredType: TableFieldType =\n typeof v === \"string\"\n ? \"string\"\n : typeof v === \"boolean\"\n ? \"boolean\"\n : typeof v === \"number\"\n ? \"number\"\n : \"unknown\";\n if (fieldMap[k] && fieldMap[k] !== inferredType) {\n fieldMap[k] = \"unknown\";\n } else {\n fieldMap[k] = inferredType;\n }\n });\n }\n });\n return {\n id: \"inferred\",\n fields: Object.entries(fieldMap).map(([f, t]) => ({\n id: f,\n type: t,\n readOnly: false,\n })),\n };\n}\n\nexport type BaseFieldConfig = {\n key?: string;\n fieldId?: string;\n};\n\nconst mkShortId = () => `${Math.random()}`;\n\nexport function deriveFieldConfigs<T extends BaseFieldConfig>(\n specifiedFieldsPartial: Partial<T>[],\n schema: TableSchema | undefined,\n makeDefaultConfig: (field: TableFieldSchema | undefined) => T\n): {\n mergedFields: T[];\n minimalFullLengthFields: Partial<T>[];\n} {\n const schemaFields = schema?.fields ?? [];\n const fieldById = mkIdMap(schemaFields);\n const specifiedFieldIds = new Set(\n withoutNils(specifiedFieldsPartial.map((f) => f.fieldId))\n );\n const keptSpecifiedFields = specifiedFieldsPartial.flatMap((f): T[] => {\n if (!f.fieldId) {\n return [\n { key: mkShortId(), ...makeDefaultConfig(undefined), ...f },\n ] as T[];\n }\n const field = fieldById.get(f.fieldId as string);\n\n // Drop configs with fieldIds no longer in the data.\n if (!field) {\n return [];\n }\n\n return [\n {\n key: mkShortId(),\n ...makeDefaultConfig(field),\n ...f,\n },\n ] as T[];\n });\n const newVirtualFields = schemaFields\n .filter((f) => !specifiedFieldIds.has(f.id))\n .map(\n (f): T => ({\n key: mkShortId(),\n ...makeDefaultConfig(f),\n })\n );\n const mergedFields = [...keptSpecifiedFields, ...newVirtualFields];\n const minimalFullLengthFields: Partial<T>[] = [\n ...specifiedFieldsPartial,\n ...newVirtualFields.map((f) => ({ key: f.key, fieldId: f.fieldId })),\n ] as Partial<T>[];\n return { mergedFields, minimalFullLengthFields };\n}\n", "import React from 'react';\nimport { DataOpConfig } from '../components/Fetcher';\nimport { DataOp } from '../executor';\nimport { swallow } from '../utils';\nimport { usePlasmicDataOp } from './usePlasmicDataOp';\n\nfunction usePrevious<T>(value: T | undefined): T | undefined {\n const prevValue = React.useRef<T | undefined>(undefined);\n\n React.useEffect(() => {\n prevValue.current = value;\n\n return () => {\n prevValue.current = undefined;\n };\n });\n\n return prevValue.current;\n}\n\nexport interface DependencyAwareQueryConfig extends DataOpConfig {\n $queries: Record<string, any>;\n setDollarQueries: ($queries: Record<string, any>) => void;\n getDataOp: () => DataOp;\n}\n\n/**\n * @deprecated Prefer using `usePlasmicDataOp` directly instead.\n */\nexport function useDependencyAwareQuery({\n $queries,\n getDataOp,\n setDollarQueries,\n name,\n pageIndex,\n pageSize,\n}: DependencyAwareQueryConfig) {\n const data = usePlasmicDataOp(swallow(getDataOp), {\n ...(!!pageIndex &&\n !!pageSize && {\n paginate: { pageIndex, pageSize },\n }),\n });\n const finalName = name ?? 'data';\n const prevName = usePrevious(finalName);\n React.useEffect(() => {\n if (!(finalName in $queries) || $queries[finalName] !== data) {\n const $queries2 = {\n ...$queries,\n [finalName]: data,\n };\n if (prevName && finalName !== prevName && prevName in $queries) {\n delete $queries2[prevName];\n }\n setDollarQueries($queries2);\n }\n }, [finalName, prevName, data, $queries, setDollarQueries]);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,wBAAAA,6BAA4B;;;ACCrC,OAAOC,YAAW;;;ACDlB,SAAS,mCAAmC;AAE5C,YAAY,QAAQ;AACpB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,YAAY,WAAW;;;ACNvB,OAAO,WAAW;AAClB,SAAS,0BAA0B;AACnC,OAAO,eAAe;;;ACHtB,IAAM,oBAAoB;AAE1B,SAAS,gBAAgB,KAAU;AACjC,SAAO,QAAQ,SAAY,oBAAoB;AACjD;AAEO,SAAS,0BACd,UACA;AACA,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,QAAQ,EAAE,QAAQ,CAAC,CAAC,KAAK,G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EAAE,WAAW,SAAS;AAAA,EAClC,EACH;AACD,QAAM,YAAY,sBAAQ;AAC1B,QAAM,WAAW,YAAY,SAAS;AACtC,EAAAA,OAAM,UAAU,MAAM;AACpB,QAAI,EAAE,aAAa,aAAa,SAAS,SAAS,MAAM,MAAM;AAC5D,YAAM,YAAY,iCACb,WADa;AAAA,QAEhB,CAAC,SAAS,GAAG;AAAA,MACf;AACA,UAAI,YAAY,cAAc,YAAY,YAAY,UAAU;AAC9D,eAAO,UAAU,QAAQ;AAAA,MAC3B;AACA,uBAAiB,SAAS;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,WAAW,UAAU,MAAM,UAAU,gBAAgB,CAAC;AAC5D;",
|
|
6
|
+
"names": ["usePlasmicDataConfig", "React", "isRSC", "data", "_a", "React", "useMemo", "useMemo", "React", "React"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -84,13 +84,13 @@ module.exports = __toCommonJS(src_exports);
|
|
|
84
84
|
var import_query3 = require("@plasmicapp/query");
|
|
85
85
|
|
|
86
86
|
// src/components/Fetcher.tsx
|
|
87
|
-
var
|
|
87
|
+
var import_react = __toESM(require("react"));
|
|
88
88
|
|
|
89
89
|
// src/hooks/usePlasmicDataOp.tsx
|
|
90
90
|
var import_data_sources_context = require("@plasmicapp/data-sources-context");
|
|
91
91
|
var ph = __toESM(require("@plasmicapp/host"));
|
|
92
92
|
var import_query2 = require("@plasmicapp/query");
|
|
93
|
-
var
|
|
93
|
+
var React = __toESM(require("react"));
|
|
94
94
|
|
|
95
95
|
// src/executor.tsx
|
|
96
96
|
var import_isomorphic_unfetch = __toESM(require("@plasmicapp/isomorphic-unfetch"));
|
|
@@ -192,6 +192,7 @@ function withoutNils(xs) {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// src/hooks/usePlasmicDataOp.tsx
|
|
195
|
+
var isRSC2 = React.isRSC;
|
|
195
196
|
function makeCacheKey(dataOp, opts) {
|
|
196
197
|
const queryDependencies = JSON.stringify({
|
|
197
198
|
sourceId: dataOp.sourceId,
|
|
@@ -290,7 +291,7 @@ function mkUndefinedDataProxy(promiseRef, fetchAndUpdateCache) {
|
|
|
290
291
|
function isPlasmicUndefinedDataErrorPromise(x) {
|
|
291
292
|
return !!x && typeof x === "object" && x.plasmicType === "PlasmicUndefinedDataError";
|
|
292
293
|
}
|
|
293
|
-
var reactMajorVersion = +
|
|
294
|
+
var reactMajorVersion = +React.version.split(".")[0];
|
|
294
295
|
function resolveDataOp(dataOp) {
|
|
295
296
|
if (typeof dataOp === "function") {
|
|
296
297
|
try {
|
|
@@ -311,20 +312,20 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
311
312
|
const resolvedDataOp = resolveDataOp(dataOp);
|
|
312
313
|
const ctx = (0, import_data_sources_context.usePlasmicDataSourceContext)();
|
|
313
314
|
const enableLoadingBoundary = !!((_b = (_a = ph.useDataEnv) == null ? void 0 : _a()) == null ? void 0 : _b[enableLoadingBoundaryKey]);
|
|
314
|
-
const { mutate, cache } = (0, import_query2.usePlasmicDataConfig)();
|
|
315
|
+
const { mutate, cache } = isRSC2 ? {} : (0, import_query2.usePlasmicDataConfig)();
|
|
315
316
|
const isNullDataOp = !resolvedDataOp;
|
|
316
317
|
const isWaitingOnDependentQuery = isPlasmicUndefinedDataErrorPromise(resolvedDataOp);
|
|
317
318
|
const key = !resolvedDataOp || isPlasmicUndefinedDataErrorPromise(resolvedDataOp) ? null : makeCacheKey(resolvedDataOp, {
|
|
318
319
|
paginate: opts == null ? void 0 : opts.paginate,
|
|
319
320
|
userAuthToken: ctx == null ? void 0 : ctx.userAuthToken
|
|
320
321
|
});
|
|
321
|
-
const fetchingData =
|
|
322
|
+
const fetchingData = React.useMemo(
|
|
322
323
|
() => ({
|
|
323
324
|
fetchingPromise: void 0
|
|
324
325
|
}),
|
|
325
326
|
[key]
|
|
326
327
|
);
|
|
327
|
-
const fetcher =
|
|
328
|
+
const fetcher = React.useMemo(
|
|
328
329
|
() => () => {
|
|
329
330
|
if (!key) {
|
|
330
331
|
throw new Error(`Fetcher should never be called without a proper key`);
|
|
@@ -362,7 +363,7 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
362
363
|
const dependentKeyDataErrorPromise = isPlasmicUndefinedDataErrorPromise(
|
|
363
364
|
resolvedDataOp
|
|
364
365
|
) ? resolvedDataOp : void 0;
|
|
365
|
-
const fetchAndUpdateCache =
|
|
366
|
+
const fetchAndUpdateCache = React.useMemo(() => {
|
|
366
367
|
if (!key && !dependentKeyDataErrorPromise) {
|
|
367
368
|
return void 0;
|
|
368
369
|
}
|
|
@@ -376,11 +377,11 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
376
377
|
if (!key) {
|
|
377
378
|
throw new Error(`Expected key to be non-null`);
|
|
378
379
|
}
|
|
379
|
-
const cached = cache.get(key);
|
|
380
|
+
const cached = cache == null ? void 0 : cache.get(key);
|
|
380
381
|
if (cached) {
|
|
381
382
|
return Promise.resolve(cached);
|
|
382
383
|
}
|
|
383
|
-
const cachedError = cache.get(`$swr$${key}`);
|
|
384
|
+
const cachedError = cache == null ? void 0 : cache.get(`$swr$${key}`);
|
|
384
385
|
if (cachedError) {
|
|
385
386
|
return Promise.reject(cachedError.error);
|
|
386
387
|
}
|
|
@@ -389,13 +390,14 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
389
390
|
fetcher().then(resolve, reject);
|
|
390
391
|
}, 1);
|
|
391
392
|
});
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
393
|
+
if (!isRSC2)
|
|
394
|
+
fetcherPromise.then((data2) => {
|
|
395
|
+
mutate == null ? void 0 : mutate(key, data2);
|
|
396
|
+
}).catch((err) => {
|
|
397
|
+
var _a2;
|
|
398
|
+
const keyInfo = key ? "$swr$" + key : "";
|
|
399
|
+
cache == null ? void 0 : cache.set(keyInfo, __spreadProps(__spreadValues({}, (_a2 = cache == null ? void 0 : cache.get(keyInfo)) != null ? _a2 : {}), { error: err }));
|
|
400
|
+
});
|
|
399
401
|
return fetcherPromise;
|
|
400
402
|
};
|
|
401
403
|
}, [fetcher, fetchingData, cache, key, dependentKeyDataErrorPromise]);
|
|
@@ -413,7 +415,7 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
413
415
|
if (fetchingData.fetchingPromise != null && data !== void 0) {
|
|
414
416
|
fetchingData.fetchingPromise = void 0;
|
|
415
417
|
}
|
|
416
|
-
return
|
|
418
|
+
return React.useMemo(() => {
|
|
417
419
|
const result = __spreadValues(__spreadValues({}, data != null ? data : {}), pick(res, "isLoading", "error"));
|
|
418
420
|
if (!(opts == null ? void 0 : opts.noUndefinedDataProxy) && reactMajorVersion >= 18 && enableLoadingBoundary && (isLoading || isNullDataOp || isWaitingOnDependentQuery) && result.data === void 0 && result.schema === void 0 && result.error === void 0) {
|
|
419
421
|
result.data = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);
|
|
@@ -435,7 +437,7 @@ function usePlasmicDataOp(dataOp, opts) {
|
|
|
435
437
|
function usePlasmicDataMutationOp(dataOp) {
|
|
436
438
|
const ctx = (0, import_data_sources_context.usePlasmicDataSourceContext)();
|
|
437
439
|
const userToken = ctx == null ? void 0 : ctx.userAuthToken;
|
|
438
|
-
const getRealDataOp =
|
|
440
|
+
const getRealDataOp = React.useCallback(() => __async(this, null, function* () {
|
|
439
441
|
const tryGetRealDataOp = () => __async(this, null, function* () {
|
|
440
442
|
const resolved = resolveDataOp(dataOp);
|
|
441
443
|
if (!resolved) {
|
|
@@ -449,7 +451,7 @@ function usePlasmicDataMutationOp(dataOp) {
|
|
|
449
451
|
});
|
|
450
452
|
return yield tryGetRealDataOp();
|
|
451
453
|
}), [dataOp]);
|
|
452
|
-
return
|
|
454
|
+
return React.useCallback(() => __async(this, null, function* () {
|
|
453
455
|
var _a;
|
|
454
456
|
const { sourceId, opId, userArgs } = (_a = yield getRealDataOp()) != null ? _a : {};
|
|
455
457
|
if (!sourceId || !opId) {
|
|
@@ -472,7 +474,7 @@ function Fetcher(props) {
|
|
|
472
474
|
const data = usePlasmicDataOp(dataOp, __spreadValues({}, !!pageIndex && !!pageSize && {
|
|
473
475
|
paginate: { pageIndex, pageSize }
|
|
474
476
|
}));
|
|
475
|
-
const $queries =
|
|
477
|
+
const $queries = import_react.default.useMemo(
|
|
476
478
|
() => __spreadProps(__spreadValues({}, props.queries), { [name != null ? name : "data"]: data }),
|
|
477
479
|
[props.queries, name, data]
|
|
478
480
|
);
|
|
@@ -514,7 +516,7 @@ var FetcherMeta = {
|
|
|
514
516
|
};
|
|
515
517
|
|
|
516
518
|
// src/helpers.ts
|
|
517
|
-
var
|
|
519
|
+
var import_react2 = require("react");
|
|
518
520
|
function normalizeData(rawData) {
|
|
519
521
|
var _a;
|
|
520
522
|
if (!rawData) {
|
|
@@ -531,7 +533,7 @@ function normalizeData(rawData) {
|
|
|
531
533
|
return { data: dataArray, schema };
|
|
532
534
|
}
|
|
533
535
|
function useNormalizedData(rawData) {
|
|
534
|
-
return (0,
|
|
536
|
+
return (0, import_react2.useMemo)(() => normalizeData(rawData), [rawData]);
|
|
535
537
|
}
|
|
536
538
|
function tryGetDataArray(rawData) {
|
|
537
539
|
if (rawData == null || typeof rawData !== "object") {
|
|
@@ -625,10 +627,10 @@ function deriveFieldConfigs(specifiedFieldsPartial, schema, makeDefaultConfig) {
|
|
|
625
627
|
}
|
|
626
628
|
|
|
627
629
|
// src/hooks/useDependencyAwareQuery.tsx
|
|
628
|
-
var
|
|
630
|
+
var import_react3 = __toESM(require("react"));
|
|
629
631
|
function usePrevious(value) {
|
|
630
|
-
const prevValue =
|
|
631
|
-
|
|
632
|
+
const prevValue = import_react3.default.useRef(void 0);
|
|
633
|
+
import_react3.default.useEffect(() => {
|
|
632
634
|
prevValue.current = value;
|
|
633
635
|
return () => {
|
|
634
636
|
prevValue.current = void 0;
|
|
@@ -649,7 +651,7 @@ function useDependencyAwareQuery({
|
|
|
649
651
|
}));
|
|
650
652
|
const finalName = name != null ? name : "data";
|
|
651
653
|
const prevName = usePrevious(finalName);
|
|
652
|
-
|
|
654
|
+
import_react3.default.useEffect(() => {
|
|
653
655
|
if (!(finalName in $queries) || $queries[finalName] !== data) {
|
|
654
656
|
const $queries2 = __spreadProps(__spreadValues({}, $queries), {
|
|
655
657
|
[finalName]: data
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.tsx", "../src/components/Fetcher.tsx", "../src/hooks/usePlasmicDataOp.tsx", "../src/executor.tsx", "../src/placeholders.ts", "../src/utils.ts", "../src/helpers.ts", "../src/hooks/useDependencyAwareQuery.tsx"],
|
|
4
|
-
"sourcesContent": ["export { usePlasmicDataConfig } from \"@plasmicapp/query\";\nexport { Fetcher, FetcherMeta } from \"./components/Fetcher\";\nexport type { FetcherProps } from \"./components/Fetcher\";\nexport { executePlasmicDataOp } from \"./executor\";\nexport type { DataOp } from \"./executor\";\nexport {\n deriveFieldConfigs,\n normalizeData,\n useNormalizedData,\n} from \"./helpers\";\nexport type { BaseFieldConfig, NormalizedData, QueryResult } from \"./helpers\";\nexport { useDependencyAwareQuery } from \"./hooks/useDependencyAwareQuery\";\nexport {\n makeCacheKey,\n usePlasmicDataMutationOp,\n usePlasmicDataOp,\n usePlasmicInvalidate,\n} from \"./hooks/usePlasmicDataOp\";\nexport type {\n DataSourceSchema,\n ManyRowsResult,\n Pagination,\n SingleRowResult,\n TableFieldSchema,\n TableFieldType,\n TableSchema,\n} from \"./types\";\n", "import { ComponentMeta } from '@plasmicapp/host';\nimport React from 'react';\nimport { DataOp } from '../executor';\nimport { usePlasmicDataOp } from '../hooks/usePlasmicDataOp';\n\nexport interface DataOpConfig {\n name?: string;\n pageIndex?: number;\n pageSize?: number;\n}\n\nexport interface FetcherProps extends DataOpConfig {\n dataOp?: DataOp;\n children?: ($queries: Record<string, any>) => React.ReactElement | null;\n queries?: Record<string, any>;\n}\n\nexport function Fetcher(props: FetcherProps): React.ReactElement | null {\n const { dataOp, children, name, pageIndex, pageSize } = props;\n const data = usePlasmicDataOp(dataOp, {\n ...(!!pageIndex &&\n !!pageSize && {\n paginate: { pageIndex, pageSize },\n }),\n });\n\n const $queries = React.useMemo(\n () => ({ ...props.queries, [name ?? 'data']: data }),\n [props.queries, name, data]\n );\n\n return children?.($queries) ?? null;\n}\n\nexport const FetcherMeta: ComponentMeta<FetcherProps> = {\n name: 'plasmic-data-source-fetcher',\n displayName: 'Data Fetcher',\n props: {\n dataOp: {\n type: 'dataSourceOp' as any,\n displayName: 'Data',\n },\n name: {\n type: 'string',\n displayName: 'Variable name',\n },\n children: {\n type: 'slot',\n renderPropParams: ['$queries'],\n },\n pageSize: {\n type: 'number',\n advanced: true,\n displayName: 'Page size',\n description: 'Only fetch in batches of this size; for pagination',\n },\n pageIndex: {\n type: 'number',\n advanced: true,\n displayName: 'Page index',\n description: '0-based index of the paginated page to fetch',\n },\n },\n importPath: '@plasmicapp/react-web/lib/data-sources',\n importName: 'Fetcher',\n alwaysAutoName: true,\n styleSections: false,\n};\n", "import { usePlasmicDataSourceContext } from \"@plasmicapp/data-sources-context\";\n// eslint-disable-next-line no-restricted-imports\nimport * as ph from \"@plasmicapp/host\";\nimport {\n useMutablePlasmicQueryData,\n usePlasmicDataConfig,\n} from \"@plasmicapp/query\";\nimport React from \"react\";\nimport { DataOp, executePlasmicDataOp } from \"../executor\";\nimport { ManyRowsResult, Pagination, SingleRowResult } from \"../types\";\nimport { pick } from \"../utils\";\n\nexport function makeCacheKey(\n dataOp: DataOp,\n opts?: { paginate?: Pagination; userAuthToken?: string | null }\n) {\n const queryDependencies = JSON.stringify({\n sourceId: dataOp.sourceId,\n opId: dataOp.opId,\n args: dataOp.userArgs,\n userAuthToken: opts?.userAuthToken,\n paginate: opts?.paginate,\n });\n return dataOp.cacheKey\n ? `${dataOp.cacheKey}${queryDependencies}`\n : queryDependencies;\n}\n\n/**\n * Returns a function that can be used to invalidate Plasmic query groups.\n */\nexport function usePlasmicInvalidate() {\n // NOTE: we use `revalidateIfStale: false` with SWR.\n // One quirk of this is that if you supply fallback data to swr,\n // that data doesn't get entered into the cache if `revalidateIfStale: false`,\n // so you won't see it if you iterate over keys of the cache. That's why\n // we have usePlasmicInvalidate() which will iterate over both the cache\n // and the fallback data.\n const { cache, fallback, mutate } = usePlasmicDataConfig();\n return async (invalidatedKeys: string[] | null | undefined) => {\n const getKeysToInvalidate = () => {\n if (!invalidatedKeys) {\n return [];\n }\n const allKeys = Array.from(\n new Set([\n ...Array.from((cache as any).keys()),\n ...(fallback ? Object.keys(fallback) : []),\n // If this is running within the Studio, we also take the\n // opportunity to invalidate the Studio cache. The keys that\n // Studio may have can be a superset of `cache` here, because\n // `cache` is updated as swr hooks are mounted and unmounted,\n // but Studio's data cache keys don't get removed when hooks\n // are unmounted. This makes it possible for Studio to hold\n // onto a stale cache entry that doesn't get invalidated.\n // For example, Studio may render page1, with key X, then goes\n // to page 2, which performs a mutate. At this point, Studio\n // has a cache entry for key X, but `cache` does not, because\n // page2 does not use that query. But page 2 may perform a\n // mutation that invalidates X. So we need to invalidate not\n // only keys in `cache`, but also keys that Studio is still\n // holding onto.\n ...((globalThis as any).__PLASMIC_GET_ALL_CACHE_KEYS?.() ?? []),\n ])\n ).filter((key): key is string => typeof key === \"string\");\n if (invalidatedKeys.includes(\"plasmic_refresh_all\")) {\n return allKeys;\n }\n return allKeys.filter((key) =>\n invalidatedKeys.some((k) => key.includes(`.$.${k}.$.`))\n );\n };\n\n const keys = getKeysToInvalidate();\n if (keys.length === 0) {\n return;\n }\n\n const invalidateKey = async (key: string) => {\n const studioInvalidate = (globalThis as any).__PLASMIC_MUTATE_DATA_OP;\n if (studioInvalidate) {\n await studioInvalidate(key);\n }\n return mutate(key);\n };\n\n return await Promise.all(keys.map((key) => invalidateKey(key)));\n };\n}\n\nconst enableLoadingBoundaryKey = \"plasmicInternalEnableLoadingBoundary\";\n\nfunction mkUndefinedDataProxy(\n promiseRef: { fetchingPromise: Promise<any> | undefined },\n fetchAndUpdateCache: (() => Promise<any>) | undefined\n) {\n let fetchAndUpdatePromise: Promise<any> | undefined = undefined;\n\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n if (prop === \"isPlasmicUndefinedDataProxy\") {\n return true;\n }\n\n if (!fetchAndUpdateCache) {\n // There's no key so no fetch to kick off yet; when computing key,\n // we encountered some thrown exception (that's not an undefined data promise),\n // and so we can't fetch yet. This might be dependent on a $state or $prop value\n // that's currently undefined, etc. We will act like an undefined data object,\n // and trigger the usual fallback behavior\n return undefined;\n }\n\n const doFetchAndUpdate = () => {\n // We hold onto the promise last returned by fetchAndUpdateCache()\n // and keep reusing it until it is resolved. The reason is that the\n // Promise thrown here will be used as a dependency for memoized\n // fetchAndUpdateCache, which is a dependency on the memoized returned value\n // from usePlasmicDataOp(). If we have a fetch that's taking a long time,\n // we want to make sure that our memoized returned value is stable,\n // so that we don't keep calling setDollarQueries() (otherwise, for each\n // render, we find an unstable result, and call setDollarQueries(),\n // resulting in an infinite loop while fetch is happening).\n if (!fetchAndUpdatePromise) {\n fetchAndUpdatePromise = fetchAndUpdateCache().finally(() => {\n fetchAndUpdatePromise = undefined;\n });\n }\n return fetchAndUpdatePromise;\n };\n\n const promise =\n // existing fetch\n promiseRef.fetchingPromise ||\n // No existing fetch, so kick off a fetch\n doFetchAndUpdate();\n (promise as any).plasmicType = \"PlasmicUndefinedDataError\";\n (promise as any).message = `Cannot read property ${String(\n prop\n )} - data is still loading`;\n throw promise;\n },\n }\n ) as any;\n}\n\ninterface PlasmicUndefinedDataErrorPromise extends Promise<any> {\n plasmicType: \"PlasmicUndefinedDataError\";\n message: string;\n}\n\nfunction isPlasmicUndefinedDataErrorPromise(\n x: any\n): x is PlasmicUndefinedDataErrorPromise {\n return (\n !!x &&\n typeof x === \"object\" &&\n (x as any).plasmicType === \"PlasmicUndefinedDataError\"\n );\n}\n\nconst reactMajorVersion = +React.version.split(\".\")[0];\n\ntype ResolvableDataOp =\n | DataOp\n | undefined\n | null\n | (() => DataOp | undefined | null);\n\n/**\n * This returns either:\n * * DataOp to perform\n * * undefined/null, if no data op can be performed\n * * PlasmicUndefinedDataErrorPromise, if when trying to evaluate the DataOp to perform,\n * we encounter a PlasmicUndefinedDataErrorPromise, so this operation cannot be\n * performed until that promise is resolved.\n */\nfunction resolveDataOp(dataOp: ResolvableDataOp) {\n if (typeof dataOp === \"function\") {\n try {\n return dataOp();\n } catch (err) {\n if (isPlasmicUndefinedDataErrorPromise(err)) {\n return err;\n }\n return null;\n }\n } else {\n return dataOp;\n }\n}\n\n/**\n * Fetches can be kicked off two ways -- normally, by useSWR(), or by some\n * expression accessing the `$queries.*` proxy when not ready yet. We need\n * a global cache for proxy-invoked caches, so that different components\n * with the same key can share the same fetch.\n *\n * The life cycle for this cache is short -- only the duration of a\n * proxy-invoked fetch, and once the fetch is done. That's because we really\n * just want SWR to be managing the cache, not us! Once the data is in SWR,\n * we will use SWR for getting data.\n */\nconst PRE_FETCHES = new Map<string, Promise<any>>();\n\nexport function usePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult,\n E = any\n>(\n dataOp: ResolvableDataOp,\n opts?: {\n paginate?: Pagination;\n noUndefinedDataProxy?: boolean;\n }\n): Partial<T> & {\n error?: E;\n isLoading?: boolean;\n} {\n const resolvedDataOp = resolveDataOp(dataOp);\n const ctx = usePlasmicDataSourceContext();\n const enableLoadingBoundary = !!ph.useDataEnv?.()?.[enableLoadingBoundaryKey];\n const { mutate, cache } = usePlasmicDataConfig();\n // Cannot perform this operation\n const isNullDataOp = !resolvedDataOp;\n // This operation depends on another data query to resolve first\n const isWaitingOnDependentQuery =\n isPlasmicUndefinedDataErrorPromise(resolvedDataOp);\n const key =\n !resolvedDataOp || isPlasmicUndefinedDataErrorPromise(resolvedDataOp)\n ? null\n : makeCacheKey(resolvedDataOp, {\n paginate: opts?.paginate,\n userAuthToken: ctx?.userAuthToken,\n });\n const fetchingData = React.useMemo(\n () => ({\n fetchingPromise: undefined as Promise<T> | undefined,\n }),\n [key]\n );\n const fetcher = React.useMemo(\n () => () => {\n // If we are in this function, that means SWR cache missed.\n if (!key) {\n throw new Error(`Fetcher should never be called without a proper key`);\n }\n\n // dataOp is guaranteed to be a DataOp, and not an undefined promise or null\n\n if (fetchingData.fetchingPromise) {\n // Fetch is already underway from this hook\n return fetchingData.fetchingPromise;\n }\n\n if (key && PRE_FETCHES.has(key)) {\n // Some other usePlasmicDataOp() hook elsewhere has already\n // started this fetch as well; re-use it here.\n const existing = PRE_FETCHES.get(key) as Promise<T>;\n fetchingData.fetchingPromise = existing;\n return existing;\n }\n\n // Else we really need to kick off this fetch now...\n const fetcherFn = () =>\n executePlasmicDataOp<T>(resolvedDataOp as DataOp, {\n userAuthToken: ctx?.userAuthToken || undefined,\n user: ctx?.user,\n paginate: opts?.paginate,\n });\n const fetcherPromise = fetcherFn();\n fetchingData.fetchingPromise = fetcherPromise;\n if (key) {\n PRE_FETCHES.set(key, fetcherPromise);\n // Once we have a result, we rely on swr to perform the caching,\n // so remove from our cache as quickly as possible.\n fetcherPromise.then(\n () => {\n PRE_FETCHES.delete(key);\n },\n () => {\n PRE_FETCHES.delete(key);\n }\n );\n }\n return fetcherPromise;\n },\n [key, fetchingData]\n );\n\n const dependentKeyDataErrorPromise = isPlasmicUndefinedDataErrorPromise(\n resolvedDataOp\n )\n ? resolvedDataOp\n : undefined;\n const fetchAndUpdateCache = React.useMemo(() => {\n if (!key && !dependentKeyDataErrorPromise) {\n // If there's no key, and no data query we're waiting for, then there's\n // no way to perform a fetch\n return undefined;\n }\n return () => {\n // This function is called when the undefined data proxy is invoked.\n // USUALLY, this means the data is not available in SWR yet, and\n // we need to kick off a fetch.\n\n if (fetchingData.fetchingPromise) {\n // No need to update cache as the exist promise call site will do it\n return fetchingData.fetchingPromise;\n }\n\n if (dependentKeyDataErrorPromise) {\n // We can't actually fetch yet, because we couldn't even evaluate the dataOp\n // to fetch for, because we depend on unfetched data. Once _that_\n // dataOp we depend on is finished, then we can try again. So we\n // will throw and wait for _that_ promise to be resolved instead.\n return dependentKeyDataErrorPromise;\n }\n\n if (!key) {\n throw new Error(`Expected key to be non-null`);\n }\n\n // SOMETIMES, SWR actually _does_ have the cache, but we still end up\n // here. That's because of how we update $queries, which takes two\n // cycles; each time we render, we build a `new$Queries`, and\n // `set$Queries(new$Queries)`. So once the data is ready, at the\n // first render, we will have data in `new$Queries` but not `$queries`,\n // but we will still finish rendering that pass, which means any `$queries`\n // access will still end up here. So we look into the SWR cache and\n // return any data that's here.\n const cached = cache.get(key);\n if (cached) {\n return Promise.resolve(cached);\n }\n const cachedError = cache.get(`$swr$${key}`);\n if (cachedError) {\n return Promise.reject(cachedError.error);\n }\n\n // Now, upon this proxy.get() miss, we want to kick off the fetch. We can't\n // wait for useSWR() to kick off the fetch, because upon data miss we are\n // throwing a promise, and useSWR() won't kick off the fetch till the effect,\n // so it will never get a chance to fetch. Instead, we fetch, and then we\n // put the fetched data into the SWR cache, so that next time useSWR() is called,\n // it will just find it in the cache.\n //\n // However, we don't want to fetch SYNCHRONOUSLY RIGHT NOW, becase we are in\n // the rendering phase (presumably, we're here because some component is trying\n // to read fetched data while rendering). Doing a fetch right now would invoke\n // the fetcher, which is wrapped by @plasmicapp/query to tracking loading state,\n // and upon loading state toggled to true, it will fire loading event listeners,\n // and for example, our antd's <GlobalLoadingIndicator /> will listen to this\n // event and immediately ask antd to show the loading indicator, which mutates\n // antd component's state. It is NOT LEGAL to call setState() on some other\n // component's state during rendering phase!\n //\n // We therefore will delay kicking off the fetch by a tick, so that we will safely\n // start the fetch outside of React rendering phase.\n const fetcherPromise = new Promise((resolve, reject) => {\n setTimeout(() => {\n fetcher().then(resolve, reject);\n }, 1);\n });\n fetcherPromise\n .then((data) => {\n // Insert the fetched data into the SWR cache\n mutate(key, data);\n })\n .catch((err) => {\n // Cache the error here to avoid infinite loop\n const keyInfo = key ? \"$swr$\" + key : \"\";\n cache.set(keyInfo, { ...(cache.get(keyInfo) ?? {}), error: err });\n });\n return fetcherPromise;\n };\n }, [fetcher, fetchingData, cache, key, dependentKeyDataErrorPromise]);\n const res = useMutablePlasmicQueryData<T, E>(key, fetcher, {\n shouldRetryOnError: false,\n\n // If revalidateIfStale is true, then if there's a cache entry with a key,\n // but no mounted hook with that key yet, and when the hook mounts with the key,\n // swr will revalidate. This may be reasonable behavior, but for us, this\n // happens all the time -- we prepopulate the cache with proxy-invoked fetch,\n // sometimes before swr had a chance to run the effect. So we turn off\n // revalidateIfStale here, and just let the user manage invalidation.\n revalidateIfStale: false,\n });\n const { data, error, isLoading } = res;\n if (fetchingData.fetchingPromise != null && data !== undefined) {\n // Clear the fetching promise as the actual data is now used (so\n // revalidation is possible)\n fetchingData.fetchingPromise = undefined;\n }\n return React.useMemo(() => {\n const result = {\n ...(data ?? ({} as Partial<T>)),\n ...pick(res, \"isLoading\", \"error\"),\n };\n if (\n !opts?.noUndefinedDataProxy &&\n reactMajorVersion >= 18 &&\n enableLoadingBoundary &&\n (isLoading || isNullDataOp || isWaitingOnDependentQuery) &&\n result.data === undefined &&\n result.schema === undefined &&\n result.error === undefined\n ) {\n result.data = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);\n result.schema = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);\n }\n return result;\n }, [\n isNullDataOp,\n isWaitingOnDependentQuery,\n data,\n error,\n isLoading,\n opts?.noUndefinedDataProxy,\n enableLoadingBoundary,\n fetchingData,\n fetchAndUpdateCache,\n ]);\n}\n\nexport function usePlasmicDataMutationOp<\n T extends SingleRowResult | ManyRowsResult\n>(dataOp: ResolvableDataOp) {\n const ctx = usePlasmicDataSourceContext();\n const userToken = ctx?.userAuthToken;\n\n const getRealDataOp = React.useCallback(async () => {\n const tryGetRealDataOp = async (): Promise<DataOp | null> => {\n const resolved = resolveDataOp(dataOp);\n if (!resolved) {\n return null;\n } else if (isPlasmicUndefinedDataErrorPromise(resolved)) {\n // If calling the dataOp function resulted in a data fetch,\n // then we wait for the data fetch to finish and try\n // again\n await resolved;\n return tryGetRealDataOp();\n } else {\n return resolved;\n }\n };\n return await tryGetRealDataOp();\n }, [dataOp]);\n\n return React.useCallback(async () => {\n const { sourceId, opId, userArgs } = (await getRealDataOp()) ?? {};\n\n if (!sourceId || !opId) {\n return undefined;\n }\n\n return executePlasmicDataOp<T>(\n { sourceId, opId, userArgs },\n {\n userAuthToken: userToken || undefined,\n user: ctx?.user,\n }\n );\n }, [getRealDataOp, userToken]);\n}\n", "import { PlasmicDataSourceContextValue } from \"@plasmicapp/data-sources-context\";\nimport fetch from \"@plasmicapp/isomorphic-unfetch\";\nimport { wrapLoadingFetcher } from \"@plasmicapp/query\";\nimport stringify from \"fast-stringify\";\nimport { addPlaceholdersToUserArgs } from \"./placeholders\";\nimport { ManyRowsResult, Pagination, SingleRowResult } from \"./types\";\n\nconst DEFAULT_HOST = \"https://data.plasmic.app\";\n\nexport interface DataOp {\n sourceId: string;\n opId: string;\n userArgs?: Record<string, any>;\n cacheKey?: string;\n invalidatedKeys?: string[] | null;\n roleId?: string | null;\n}\n\ninterface ExecuteOpts {\n userAuthToken?: string;\n user?: PlasmicDataSourceContextValue[\"user\"];\n paginate?: Pagination;\n}\n\nconst UNAUTHORIZED_MESSAGE =\n \"You do not have permission to perform this operation. Login to get access or contact the app owner to get access.\";\n\nexport async function executePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult\n>(op: DataOp, opts?: ExecuteOpts) {\n const func = getConfig(\n \"__PLASMIC_EXECUTE_DATA_OP\",\n _executePlasmicDataOp\n ) as typeof _executePlasmicDataOp;\n op.userArgs = addPlaceholdersToUserArgs(op.userArgs);\n const res = await wrapLoadingFetcher(func)(op, opts);\n return res as T;\n}\n\nasync function _executePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult\n>(op: DataOp, opts?: ExecuteOpts) {\n if (op.roleId) {\n if (!opts?.user || !opts.user.roleIds.includes(op.roleId)) {\n console.error(UNAUTHORIZED_MESSAGE);\n throw new Error(UNAUTHORIZED_MESSAGE);\n }\n }\n\n const host = getConfig(\"__PLASMIC_DATA_HOST\", DEFAULT_HOST);\n\n const url = `${host}/api/v1/server-data/sources/${op.sourceId}/execute`;\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(opts?.userAuthToken && {\n \"x-plasmic-data-user-auth-token\": opts.userAuthToken,\n }),\n },\n body: stringify({\n opId: op.opId,\n userArgs: op.userArgs ?? {},\n paginate: opts?.paginate,\n }),\n });\n if (resp.status !== 200) {\n const text = await resp.text();\n throw new Error(text);\n }\n return (await resp.json()) as T;\n}\n\nfunction getConfig<T>(key: string, defaultValue: T) {\n if (typeof globalThis === \"undefined\") {\n return defaultValue;\n } else {\n return (globalThis as any)[key] ?? defaultValue;\n }\n}\n", "const PLASMIC_UNDEFINED = \"__PLASMIC_UNDEFINED\";\n\nfunction addPlaceholders(val: any) {\n return val === undefined ? PLASMIC_UNDEFINED : val;\n}\n\nexport function addPlaceholdersToUserArgs(\n userArgs: Record<string, any> | undefined\n) {\n if (!userArgs) {\n return userArgs;\n }\n Object.entries(userArgs).forEach(([key, val]) => {\n userArgs[key] = Array.isArray(val)\n ? val.map((v) => addPlaceholders(v))\n : addPlaceholders(val);\n });\n return userArgs;\n}\n", "export function swallow<T>(f: () => T): T | undefined {\n try {\n return f();\n } catch {\n return undefined;\n }\n}\n\nexport function pick<T extends object, K extends keyof T>(\n obj: T,\n ...keys: K[]\n): Pick<T, K> {\n const res: any = {};\n for (const key of keys) {\n if (key in obj) {\n res[key] = obj[key as keyof T];\n }\n }\n return res;\n}\n\ntype ReactElt = {\n children: ReactElt | ReactElt[];\n props: {\n children: ReactElt | ReactElt[];\n [prop: string]: any;\n } | null;\n type: React.ComponentType<any> | null;\n key: string | null;\n} | null;\n\nexport function traverseReactEltTree(\n children: React.ReactNode,\n callback: (elt: ReactElt) => void\n) {\n const rec = (elts: ReactElt | ReactElt[] | null) => {\n (Array.isArray(elts) ? elts : [elts]).forEach((elt) => {\n if (elt) {\n callback(elt);\n if (elt.children) {\n rec(elt.children);\n }\n if (elt.props?.children && elt.props.children !== elt.children) {\n rec(elt.props.children);\n }\n }\n });\n };\n rec(children as any);\n}\n\nexport function asArray<T>(x: T[] | T | undefined | null) {\n if (Array.isArray(x)) {\n return x;\n } else if (x == null) {\n return [];\n } else {\n return [x];\n }\n}\n\nexport function ensureNumber(x: number | string): number {\n return x as number;\n}\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n throw new Error('Expected non-null or non-undefined value');\n }\n return x;\n}\n\nexport function isOneOf<T, U extends T>(elem: T, arr: readonly U[]): elem is U {\n return arr.includes(elem as any);\n}\n\nexport function maybe<T, U>(\n x: T | undefined | null,\n f: (y: T) => U\n): U | undefined {\n if (x === undefined || x === null) return undefined;\n return f(x);\n}\n\nexport function isLikeImage(value: unknown) {\n return typeof value === 'string'\n ? value.match(/\\.(png|jpg|jpeg|gif|svg|webp|avif|ico|bmp|tiff)$/i)\n : false;\n}\n\nexport function ensureArray<T>(xs: T | T[]): T[] {\n return Array.isArray(xs) ? xs : [xs];\n}\n\nexport const tuple = <T extends any[]>(...args: T): T => args;\n\nexport interface HasId {\n id: string;\n}\n\nexport function mkIdMap<T extends HasId>(xs: ReadonlyArray<T>): Map<string, T> {\n return new Map(xs.map((x) => tuple(x.id, x) as [string, T]));\n}\n\nexport const mkShortId = () => `${Math.random()}`;\n\nexport function withoutNils<T>(xs: Array<T | undefined | null>): T[] {\n return xs.filter((x): x is T => x != null);\n}\n\nexport type Falsey = null | undefined | false | '' | 0 | 0n;\nexport type Truthy<T> = T extends Falsey ? never : T;\n\nexport function withoutFalsey<T>(xs: Array<T | Falsey>): T[] {\n return xs.filter((x): x is T => !!x);\n}\n", "import { useMemo } from \"react\";\nimport {\n ManyRowsResult,\n TableFieldSchema,\n TableFieldType,\n TableSchema,\n} from \"./types\";\nimport { mkIdMap, withoutNils } from \"./utils\";\n\nexport type QueryResult = Partial<ManyRowsResult<any>> & {\n error?: any;\n isLoading?: boolean;\n};\n\nexport interface NormalizedData {\n data: Record<string, unknown>[];\n schema?: TableSchema;\n}\n\nexport function normalizeData(rawData: unknown): NormalizedData | undefined {\n if (!rawData) {\n return undefined;\n }\n\n const dataArray = tryGetDataArray(rawData);\n if (!dataArray) {\n return undefined;\n }\n const schema = (rawData as any).schema ?? tryGetSchema(dataArray);\n if (!schema) {\n return undefined;\n }\n return { data: dataArray, schema };\n}\n\nexport function useNormalizedData(\n rawData: unknown\n): NormalizedData | undefined {\n return useMemo(() => normalizeData(rawData), [rawData]);\n}\n\nfunction tryGetDataArray(rawData: unknown): any[] | undefined {\n if (rawData == null || typeof rawData !== \"object\") {\n return undefined;\n }\n\n if (Array.isArray(rawData)) {\n if (isArrayOfObjects(rawData)) {\n return rawData;\n } else {\n // TODO: array of primitives? Maybe we can wrap this?\n return undefined;\n }\n }\n\n if (rawData == null) {\n return undefined;\n }\n\n if (\"data\" in rawData && typeof (rawData as any).data === \"object\") {\n if (\n Array.isArray((rawData as any).data) &&\n isArrayOfObjects((rawData as any).data)\n ) {\n return (rawData as any).data;\n } else if ((rawData as any).data != null) {\n return [(rawData as any).data];\n } else {\n return undefined;\n }\n }\n if (\"isLoading\" in rawData || \"error\" in rawData) {\n return undefined;\n }\n\n // Maybe a singleton record?\n return [rawData];\n}\n\nfunction isArrayOfObjects(arr: unknown[]) {\n return arr.every((x) => typeof x === \"object\" && !Array.isArray(x));\n}\n\nfunction tryGetSchema(data: any[]): TableSchema | undefined {\n const fieldMap: Record<string, TableFieldType> = {};\n data.forEach((entry: any) => {\n if (entry && typeof entry === \"object\") {\n Array.from(Object.entries(entry)).forEach(([k, v]) => {\n const inferredType: TableFieldType =\n typeof v === \"string\"\n ? \"string\"\n : typeof v === \"boolean\"\n ? \"boolean\"\n : typeof v === \"number\"\n ? \"number\"\n : \"unknown\";\n if (fieldMap[k] && fieldMap[k] !== inferredType) {\n fieldMap[k] = \"unknown\";\n } else {\n fieldMap[k] = inferredType;\n }\n });\n }\n });\n return {\n id: \"inferred\",\n fields: Object.entries(fieldMap).map(([f, t]) => ({\n id: f,\n type: t,\n readOnly: false,\n })),\n };\n}\n\nexport type BaseFieldConfig = {\n key?: string;\n fieldId?: string;\n};\n\nconst mkShortId = () => `${Math.random()}`;\n\nexport function deriveFieldConfigs<T extends BaseFieldConfig>(\n specifiedFieldsPartial: Partial<T>[],\n schema: TableSchema | undefined,\n makeDefaultConfig: (field: TableFieldSchema | undefined) => T\n): {\n mergedFields: T[];\n minimalFullLengthFields: Partial<T>[];\n} {\n const schemaFields = schema?.fields ?? [];\n const fieldById = mkIdMap(schemaFields);\n const specifiedFieldIds = new Set(\n withoutNils(specifiedFieldsPartial.map((f) => f.fieldId))\n );\n const keptSpecifiedFields = specifiedFieldsPartial.flatMap((f): T[] => {\n if (!f.fieldId) {\n return [\n { key: mkShortId(), ...makeDefaultConfig(undefined), ...f },\n ] as T[];\n }\n const field = fieldById.get(f.fieldId as string);\n\n // Drop configs with fieldIds no longer in the data.\n if (!field) {\n return [];\n }\n\n return [\n {\n key: mkShortId(),\n ...makeDefaultConfig(field),\n ...f,\n },\n ] as T[];\n });\n const newVirtualFields = schemaFields\n .filter((f) => !specifiedFieldIds.has(f.id))\n .map(\n (f): T => ({\n key: mkShortId(),\n ...makeDefaultConfig(f),\n })\n );\n const mergedFields = [...keptSpecifiedFields, ...newVirtualFields];\n const minimalFullLengthFields: Partial<T>[] = [\n ...specifiedFieldsPartial,\n ...newVirtualFields.map((f) => ({ key: f.key, fieldId: f.fieldId })),\n ] as Partial<T>[];\n return { mergedFields, minimalFullLengthFields };\n}\n", "import React from 'react';\nimport { DataOpConfig } from '../components/Fetcher';\nimport { DataOp } from '../executor';\nimport { swallow } from '../utils';\nimport { usePlasmicDataOp } from './usePlasmicDataOp';\n\nfunction usePrevious<T>(value: T | undefined): T | undefined {\n const prevValue = React.useRef<T | undefined>(undefined);\n\n React.useEffect(() => {\n prevValue.current = value;\n\n return () => {\n prevValue.current = undefined;\n };\n });\n\n return prevValue.current;\n}\n\nexport interface DependencyAwareQueryConfig extends DataOpConfig {\n $queries: Record<string, any>;\n setDollarQueries: ($queries: Record<string, any>) => void;\n getDataOp: () => DataOp;\n}\n\n/**\n * @deprecated Prefer using `usePlasmicDataOp` directly instead.\n */\nexport function useDependencyAwareQuery({\n $queries,\n getDataOp,\n setDollarQueries,\n name,\n pageIndex,\n pageSize,\n}: DependencyAwareQueryConfig) {\n const data = usePlasmicDataOp(swallow(getDataOp), {\n ...(!!pageIndex &&\n !!pageSize && {\n paginate: { pageIndex, pageSize },\n }),\n });\n const finalName = name ?? 'data';\n const prevName = usePrevious(finalName);\n React.useEffect(() => {\n if (!(finalName in $queries) || $queries[finalName] !== data) {\n const $queries2 = {\n ...$queries,\n [finalName]: data,\n };\n if (prevName && finalName !== prevName && prevName in $queries) {\n delete $queries2[prevName];\n }\n setDollarQueries($queries2);\n }\n }, [finalName, prevName, data, $queries, setDollarQueries]);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAAqC;;;ACCrC,IAAAC,gBAAkB;;;ACDlB,kCAA4C;AAE5C,SAAoB;AACpB,IAAAC,gBAGO;AACP,mBAAkB;;;ACNlB,gCAAkB;AAClB,mBAAmC;AACnC,4BAAsB;;;ACHtB,IAAM,oBAAoB;AAE1B,SAAS,gBAAgB,KAAU;AACjC,SAAO,QAAQ,SAAY,oBAAoB;AACjD;AAEO,SAAS,0BACd,UACA;AACA,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,QAAQ,EAAE,QAAQ,CAAC,CAAC,KAAK,GAAG,MAAM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SAAS,GAAG,mBAC5C,CAAC,CAAC,aACJ,CAAC,CAAC,YAAY;AAAA,IACZ,UAAU,EAAE,WAAW,SAAS;AAAA,EAClC,EACH;AACD,QAAM,YAAY,sBAAQ;AAC1B,QAAM,WAAW,YAAY,SAAS;AACtC,gBAAAA,QAAM,UAAU,MAAM;AACpB,QAAI,EAAE,aAAa,aAAa,SAAS,SAAS,MAAM,MAAM;AAC5D,YAAM,YAAY,iCACb,WADa;AAAA,QAEhB,CAAC,SAAS,GAAG;AAAA,MACf;AACA,UAAI,YAAY,cAAc,YAAY,YAAY,UAAU;AAC9D,eAAO,UAAU,QAAQ;AAAA,MAC3B;AACA,uBAAiB,SAAS;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,WAAW,UAAU,MAAM,UAAU,gBAAgB,CAAC;AAC5D;",
|
|
6
|
-
"names": ["import_query", "
|
|
4
|
+
"sourcesContent": ["export { usePlasmicDataConfig } from \"@plasmicapp/query\";\nexport { Fetcher, FetcherMeta } from \"./components/Fetcher\";\nexport type { FetcherProps } from \"./components/Fetcher\";\nexport { executePlasmicDataOp } from \"./executor\";\nexport type { DataOp } from \"./executor\";\nexport {\n deriveFieldConfigs,\n normalizeData,\n useNormalizedData,\n} from \"./helpers\";\nexport type { BaseFieldConfig, NormalizedData, QueryResult } from \"./helpers\";\nexport { useDependencyAwareQuery } from \"./hooks/useDependencyAwareQuery\";\nexport {\n makeCacheKey,\n usePlasmicDataMutationOp,\n usePlasmicDataOp,\n usePlasmicInvalidate,\n} from \"./hooks/usePlasmicDataOp\";\nexport type {\n DataSourceSchema,\n ManyRowsResult,\n Pagination,\n SingleRowResult,\n TableFieldSchema,\n TableFieldType,\n TableSchema,\n} from \"./types\";\n", "import { ComponentMeta } from '@plasmicapp/host';\nimport React from 'react';\nimport { DataOp } from '../executor';\nimport { usePlasmicDataOp } from '../hooks/usePlasmicDataOp';\n\nexport interface DataOpConfig {\n name?: string;\n pageIndex?: number;\n pageSize?: number;\n}\n\nexport interface FetcherProps extends DataOpConfig {\n dataOp?: DataOp;\n children?: ($queries: Record<string, any>) => React.ReactElement | null;\n queries?: Record<string, any>;\n}\n\nexport function Fetcher(props: FetcherProps): React.ReactElement | null {\n const { dataOp, children, name, pageIndex, pageSize } = props;\n const data = usePlasmicDataOp(dataOp, {\n ...(!!pageIndex &&\n !!pageSize && {\n paginate: { pageIndex, pageSize },\n }),\n });\n\n const $queries = React.useMemo(\n () => ({ ...props.queries, [name ?? 'data']: data }),\n [props.queries, name, data]\n );\n\n return children?.($queries) ?? null;\n}\n\nexport const FetcherMeta: ComponentMeta<FetcherProps> = {\n name: 'plasmic-data-source-fetcher',\n displayName: 'Data Fetcher',\n props: {\n dataOp: {\n type: 'dataSourceOp' as any,\n displayName: 'Data',\n },\n name: {\n type: 'string',\n displayName: 'Variable name',\n },\n children: {\n type: 'slot',\n renderPropParams: ['$queries'],\n },\n pageSize: {\n type: 'number',\n advanced: true,\n displayName: 'Page size',\n description: 'Only fetch in batches of this size; for pagination',\n },\n pageIndex: {\n type: 'number',\n advanced: true,\n displayName: 'Page index',\n description: '0-based index of the paginated page to fetch',\n },\n },\n importPath: '@plasmicapp/react-web/lib/data-sources',\n importName: 'Fetcher',\n alwaysAutoName: true,\n styleSections: false,\n};\n", "import { usePlasmicDataSourceContext } from \"@plasmicapp/data-sources-context\";\n// eslint-disable-next-line no-restricted-imports\nimport * as ph from \"@plasmicapp/host\";\nimport {\n useMutablePlasmicQueryData,\n usePlasmicDataConfig,\n} from \"@plasmicapp/query\";\nimport * as React from \"react\";\nimport { DataOp, executePlasmicDataOp } from \"../executor\";\nimport { ManyRowsResult, Pagination, SingleRowResult } from \"../types\";\nimport { pick } from \"../utils\";\n\nconst isRSC = (React as any).isRSC;\n\nexport function makeCacheKey(\n dataOp: DataOp,\n opts?: { paginate?: Pagination; userAuthToken?: string | null }\n) {\n const queryDependencies = JSON.stringify({\n sourceId: dataOp.sourceId,\n opId: dataOp.opId,\n args: dataOp.userArgs,\n userAuthToken: opts?.userAuthToken,\n paginate: opts?.paginate,\n });\n return dataOp.cacheKey\n ? `${dataOp.cacheKey}${queryDependencies}`\n : queryDependencies;\n}\n\n/**\n * Returns a function that can be used to invalidate Plasmic query groups.\n */\nexport function usePlasmicInvalidate() {\n // NOTE: we use `revalidateIfStale: false` with SWR.\n // One quirk of this is that if you supply fallback data to swr,\n // that data doesn't get entered into the cache if `revalidateIfStale: false`,\n // so you won't see it if you iterate over keys of the cache. That's why\n // we have usePlasmicInvalidate() which will iterate over both the cache\n // and the fallback data.\n const { cache, fallback, mutate } = usePlasmicDataConfig();\n return async (invalidatedKeys: string[] | null | undefined) => {\n const getKeysToInvalidate = () => {\n if (!invalidatedKeys) {\n return [];\n }\n const allKeys = Array.from(\n new Set([\n ...Array.from((cache as any).keys()),\n ...(fallback ? Object.keys(fallback) : []),\n // If this is running within the Studio, we also take the\n // opportunity to invalidate the Studio cache. The keys that\n // Studio may have can be a superset of `cache` here, because\n // `cache` is updated as swr hooks are mounted and unmounted,\n // but Studio's data cache keys don't get removed when hooks\n // are unmounted. This makes it possible for Studio to hold\n // onto a stale cache entry that doesn't get invalidated.\n // For example, Studio may render page1, with key X, then goes\n // to page 2, which performs a mutate. At this point, Studio\n // has a cache entry for key X, but `cache` does not, because\n // page2 does not use that query. But page 2 may perform a\n // mutation that invalidates X. So we need to invalidate not\n // only keys in `cache`, but also keys that Studio is still\n // holding onto.\n ...((globalThis as any).__PLASMIC_GET_ALL_CACHE_KEYS?.() ?? []),\n ])\n ).filter((key): key is string => typeof key === \"string\");\n if (invalidatedKeys.includes(\"plasmic_refresh_all\")) {\n return allKeys;\n }\n return allKeys.filter((key) =>\n invalidatedKeys.some((k) => key.includes(`.$.${k}.$.`))\n );\n };\n\n const keys = getKeysToInvalidate();\n if (keys.length === 0) {\n return;\n }\n\n const invalidateKey = async (key: string) => {\n const studioInvalidate = (globalThis as any).__PLASMIC_MUTATE_DATA_OP;\n if (studioInvalidate) {\n await studioInvalidate(key);\n }\n return mutate(key);\n };\n\n return await Promise.all(keys.map((key) => invalidateKey(key)));\n };\n}\n\nconst enableLoadingBoundaryKey = \"plasmicInternalEnableLoadingBoundary\";\n\nfunction mkUndefinedDataProxy(\n promiseRef: { fetchingPromise: Promise<any> | undefined },\n fetchAndUpdateCache: (() => Promise<any>) | undefined\n) {\n let fetchAndUpdatePromise: Promise<any> | undefined = undefined;\n\n return new Proxy(\n {},\n {\n get: (_target, prop) => {\n if (prop === \"isPlasmicUndefinedDataProxy\") {\n return true;\n }\n\n if (!fetchAndUpdateCache) {\n // There's no key so no fetch to kick off yet; when computing key,\n // we encountered some thrown exception (that's not an undefined data promise),\n // and so we can't fetch yet. This might be dependent on a $state or $prop value\n // that's currently undefined, etc. We will act like an undefined data object,\n // and trigger the usual fallback behavior\n return undefined;\n }\n\n const doFetchAndUpdate = () => {\n // We hold onto the promise last returned by fetchAndUpdateCache()\n // and keep reusing it until it is resolved. The reason is that the\n // Promise thrown here will be used as a dependency for memoized\n // fetchAndUpdateCache, which is a dependency on the memoized returned value\n // from usePlasmicDataOp(). If we have a fetch that's taking a long time,\n // we want to make sure that our memoized returned value is stable,\n // so that we don't keep calling setDollarQueries() (otherwise, for each\n // render, we find an unstable result, and call setDollarQueries(),\n // resulting in an infinite loop while fetch is happening).\n if (!fetchAndUpdatePromise) {\n fetchAndUpdatePromise = fetchAndUpdateCache().finally(() => {\n fetchAndUpdatePromise = undefined;\n });\n }\n return fetchAndUpdatePromise;\n };\n\n const promise =\n // existing fetch\n promiseRef.fetchingPromise ||\n // No existing fetch, so kick off a fetch\n doFetchAndUpdate();\n (promise as any).plasmicType = \"PlasmicUndefinedDataError\";\n (promise as any).message = `Cannot read property ${String(\n prop\n )} - data is still loading`;\n throw promise;\n },\n }\n ) as any;\n}\n\ninterface PlasmicUndefinedDataErrorPromise extends Promise<any> {\n plasmicType: \"PlasmicUndefinedDataError\";\n message: string;\n}\n\nfunction isPlasmicUndefinedDataErrorPromise(\n x: any\n): x is PlasmicUndefinedDataErrorPromise {\n return (\n !!x &&\n typeof x === \"object\" &&\n (x as any).plasmicType === \"PlasmicUndefinedDataError\"\n );\n}\n\nconst reactMajorVersion = +React.version.split(\".\")[0];\n\ntype ResolvableDataOp =\n | DataOp\n | undefined\n | null\n | (() => DataOp | undefined | null);\n\n/**\n * This returns either:\n * * DataOp to perform\n * * undefined/null, if no data op can be performed\n * * PlasmicUndefinedDataErrorPromise, if when trying to evaluate the DataOp to perform,\n * we encounter a PlasmicUndefinedDataErrorPromise, so this operation cannot be\n * performed until that promise is resolved.\n */\nfunction resolveDataOp(dataOp: ResolvableDataOp) {\n if (typeof dataOp === \"function\") {\n try {\n return dataOp();\n } catch (err) {\n if (isPlasmicUndefinedDataErrorPromise(err)) {\n return err;\n }\n return null;\n }\n } else {\n return dataOp;\n }\n}\n\n/**\n * Fetches can be kicked off two ways -- normally, by useSWR(), or by some\n * expression accessing the `$queries.*` proxy when not ready yet. We need\n * a global cache for proxy-invoked caches, so that different components\n * with the same key can share the same fetch.\n *\n * The life cycle for this cache is short -- only the duration of a\n * proxy-invoked fetch, and once the fetch is done. That's because we really\n * just want SWR to be managing the cache, not us! Once the data is in SWR,\n * we will use SWR for getting data.\n */\nconst PRE_FETCHES = new Map<string, Promise<any>>();\n\nexport function usePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult,\n E = any\n>(\n dataOp: ResolvableDataOp,\n opts?: {\n paginate?: Pagination;\n noUndefinedDataProxy?: boolean;\n }\n): Partial<T> & {\n error?: E;\n isLoading?: boolean;\n} {\n const resolvedDataOp = resolveDataOp(dataOp);\n const ctx = usePlasmicDataSourceContext();\n const enableLoadingBoundary = !!ph.useDataEnv?.()?.[enableLoadingBoundaryKey];\n const { mutate, cache } = isRSC\n ? ({} as any as Partial<ReturnType<typeof usePlasmicDataConfig>>)\n : usePlasmicDataConfig();\n // Cannot perform this operation\n const isNullDataOp = !resolvedDataOp;\n // This operation depends on another data query to resolve first\n const isWaitingOnDependentQuery =\n isPlasmicUndefinedDataErrorPromise(resolvedDataOp);\n const key =\n !resolvedDataOp || isPlasmicUndefinedDataErrorPromise(resolvedDataOp)\n ? null\n : makeCacheKey(resolvedDataOp, {\n paginate: opts?.paginate,\n userAuthToken: ctx?.userAuthToken,\n });\n const fetchingData = React.useMemo(\n () => ({\n fetchingPromise: undefined as Promise<T> | undefined,\n }),\n [key]\n );\n const fetcher = React.useMemo(\n () => () => {\n // If we are in this function, that means SWR cache missed.\n if (!key) {\n throw new Error(`Fetcher should never be called without a proper key`);\n }\n\n // dataOp is guaranteed to be a DataOp, and not an undefined promise or null\n\n if (fetchingData.fetchingPromise) {\n // Fetch is already underway from this hook\n return fetchingData.fetchingPromise;\n }\n\n if (key && PRE_FETCHES.has(key)) {\n // Some other usePlasmicDataOp() hook elsewhere has already\n // started this fetch as well; re-use it here.\n const existing = PRE_FETCHES.get(key) as Promise<T>;\n fetchingData.fetchingPromise = existing;\n return existing;\n }\n\n // Else we really need to kick off this fetch now...\n const fetcherFn = () =>\n executePlasmicDataOp<T>(resolvedDataOp as DataOp, {\n userAuthToken: ctx?.userAuthToken || undefined,\n user: ctx?.user,\n paginate: opts?.paginate,\n });\n const fetcherPromise = fetcherFn();\n fetchingData.fetchingPromise = fetcherPromise;\n if (key) {\n PRE_FETCHES.set(key, fetcherPromise);\n // Once we have a result, we rely on swr to perform the caching,\n // so remove from our cache as quickly as possible.\n fetcherPromise.then(\n () => {\n PRE_FETCHES.delete(key);\n },\n () => {\n PRE_FETCHES.delete(key);\n }\n );\n }\n return fetcherPromise;\n },\n [key, fetchingData]\n );\n\n const dependentKeyDataErrorPromise = isPlasmicUndefinedDataErrorPromise(\n resolvedDataOp\n )\n ? resolvedDataOp\n : undefined;\n const fetchAndUpdateCache = React.useMemo(() => {\n if (!key && !dependentKeyDataErrorPromise) {\n // If there's no key, and no data query we're waiting for, then there's\n // no way to perform a fetch\n return undefined;\n }\n return () => {\n // This function is called when the undefined data proxy is invoked.\n // USUALLY, this means the data is not available in SWR yet, and\n // we need to kick off a fetch.\n\n if (fetchingData.fetchingPromise) {\n // No need to update cache as the exist promise call site will do it\n return fetchingData.fetchingPromise;\n }\n\n if (dependentKeyDataErrorPromise) {\n // We can't actually fetch yet, because we couldn't even evaluate the dataOp\n // to fetch for, because we depend on unfetched data. Once _that_\n // dataOp we depend on is finished, then we can try again. So we\n // will throw and wait for _that_ promise to be resolved instead.\n return dependentKeyDataErrorPromise;\n }\n\n if (!key) {\n throw new Error(`Expected key to be non-null`);\n }\n\n // SOMETIMES, SWR actually _does_ have the cache, but we still end up\n // here. That's because of how we update $queries, which takes two\n // cycles; each time we render, we build a `new$Queries`, and\n // `set$Queries(new$Queries)`. So once the data is ready, at the\n // first render, we will have data in `new$Queries` but not `$queries`,\n // but we will still finish rendering that pass, which means any `$queries`\n // access will still end up here. So we look into the SWR cache and\n // return any data that's here.\n const cached = cache?.get(key);\n if (cached) {\n return Promise.resolve(cached);\n }\n const cachedError = cache?.get(`$swr$${key}`);\n if (cachedError) {\n return Promise.reject(cachedError.error);\n }\n\n // Now, upon this proxy.get() miss, we want to kick off the fetch. We can't\n // wait for useSWR() to kick off the fetch, because upon data miss we are\n // throwing a promise, and useSWR() won't kick off the fetch till the effect,\n // so it will never get a chance to fetch. Instead, we fetch, and then we\n // put the fetched data into the SWR cache, so that next time useSWR() is called,\n // it will just find it in the cache.\n //\n // However, we don't want to fetch SYNCHRONOUSLY RIGHT NOW, becase we are in\n // the rendering phase (presumably, we're here because some component is trying\n // to read fetched data while rendering). Doing a fetch right now would invoke\n // the fetcher, which is wrapped by @plasmicapp/query to tracking loading state,\n // and upon loading state toggled to true, it will fire loading event listeners,\n // and for example, our antd's <GlobalLoadingIndicator /> will listen to this\n // event and immediately ask antd to show the loading indicator, which mutates\n // antd component's state. It is NOT LEGAL to call setState() on some other\n // component's state during rendering phase!\n //\n // We therefore will delay kicking off the fetch by a tick, so that we will safely\n // start the fetch outside of React rendering phase.\n const fetcherPromise = new Promise((resolve, reject) => {\n setTimeout(() => {\n fetcher().then(resolve, reject);\n }, 1);\n });\n if (!isRSC)\n fetcherPromise\n .then((data) => {\n // Insert the fetched data into the SWR cache\n mutate?.(key, data);\n })\n .catch((err) => {\n // Cache the error here to avoid infinite loop\n const keyInfo = key ? \"$swr$\" + key : \"\";\n cache?.set(keyInfo, { ...(cache?.get(keyInfo) ?? {}), error: err });\n });\n return fetcherPromise;\n };\n }, [fetcher, fetchingData, cache, key, dependentKeyDataErrorPromise]);\n const res = useMutablePlasmicQueryData<T, E>(key, fetcher, {\n shouldRetryOnError: false,\n\n // If revalidateIfStale is true, then if there's a cache entry with a key,\n // but no mounted hook with that key yet, and when the hook mounts with the key,\n // swr will revalidate. This may be reasonable behavior, but for us, this\n // happens all the time -- we prepopulate the cache with proxy-invoked fetch,\n // sometimes before swr had a chance to run the effect. So we turn off\n // revalidateIfStale here, and just let the user manage invalidation.\n revalidateIfStale: false,\n });\n const { data, error, isLoading } = res;\n if (fetchingData.fetchingPromise != null && data !== undefined) {\n // Clear the fetching promise as the actual data is now used (so\n // revalidation is possible)\n fetchingData.fetchingPromise = undefined;\n }\n return React.useMemo(() => {\n const result = {\n ...(data ?? ({} as Partial<T>)),\n ...pick(res, \"isLoading\", \"error\"),\n };\n if (\n !opts?.noUndefinedDataProxy &&\n reactMajorVersion >= 18 &&\n enableLoadingBoundary &&\n (isLoading || isNullDataOp || isWaitingOnDependentQuery) &&\n result.data === undefined &&\n result.schema === undefined &&\n result.error === undefined\n ) {\n result.data = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);\n result.schema = mkUndefinedDataProxy(fetchingData, fetchAndUpdateCache);\n }\n return result;\n }, [\n isNullDataOp,\n isWaitingOnDependentQuery,\n data,\n error,\n isLoading,\n opts?.noUndefinedDataProxy,\n enableLoadingBoundary,\n fetchingData,\n fetchAndUpdateCache,\n ]);\n}\n\nexport function usePlasmicDataMutationOp<\n T extends SingleRowResult | ManyRowsResult\n>(dataOp: ResolvableDataOp) {\n const ctx = usePlasmicDataSourceContext();\n const userToken = ctx?.userAuthToken;\n\n const getRealDataOp = React.useCallback(async () => {\n const tryGetRealDataOp = async (): Promise<DataOp | null> => {\n const resolved = resolveDataOp(dataOp);\n if (!resolved) {\n return null;\n } else if (isPlasmicUndefinedDataErrorPromise(resolved)) {\n // If calling the dataOp function resulted in a data fetch,\n // then we wait for the data fetch to finish and try\n // again\n await resolved;\n return tryGetRealDataOp();\n } else {\n return resolved;\n }\n };\n return await tryGetRealDataOp();\n }, [dataOp]);\n\n return React.useCallback(async () => {\n const { sourceId, opId, userArgs } = (await getRealDataOp()) ?? {};\n\n if (!sourceId || !opId) {\n return undefined;\n }\n\n return executePlasmicDataOp<T>(\n { sourceId, opId, userArgs },\n {\n userAuthToken: userToken || undefined,\n user: ctx?.user,\n }\n );\n }, [getRealDataOp, userToken]);\n}\n", "import { PlasmicDataSourceContextValue } from \"@plasmicapp/data-sources-context\";\nimport fetch from \"@plasmicapp/isomorphic-unfetch\";\nimport { wrapLoadingFetcher } from \"@plasmicapp/query\";\nimport stringify from \"fast-stringify\";\nimport { addPlaceholdersToUserArgs } from \"./placeholders\";\nimport { ManyRowsResult, Pagination, SingleRowResult } from \"./types\";\n\nconst DEFAULT_HOST = \"https://data.plasmic.app\";\n\nexport interface DataOp {\n sourceId: string;\n opId: string;\n userArgs?: Record<string, any>;\n cacheKey?: string;\n invalidatedKeys?: string[] | null;\n roleId?: string | null;\n}\n\ninterface ExecuteOpts {\n userAuthToken?: string;\n user?: PlasmicDataSourceContextValue[\"user\"];\n paginate?: Pagination;\n}\n\nconst UNAUTHORIZED_MESSAGE =\n \"You do not have permission to perform this operation. Login to get access or contact the app owner to get access.\";\n\nexport async function executePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult\n>(op: DataOp, opts?: ExecuteOpts) {\n const func = getConfig(\n \"__PLASMIC_EXECUTE_DATA_OP\",\n _executePlasmicDataOp\n ) as typeof _executePlasmicDataOp;\n op.userArgs = addPlaceholdersToUserArgs(op.userArgs);\n const res = await wrapLoadingFetcher(func)(op, opts);\n return res as T;\n}\n\nasync function _executePlasmicDataOp<\n T extends SingleRowResult | ManyRowsResult\n>(op: DataOp, opts?: ExecuteOpts) {\n if (op.roleId) {\n if (!opts?.user || !opts.user.roleIds.includes(op.roleId)) {\n console.error(UNAUTHORIZED_MESSAGE);\n throw new Error(UNAUTHORIZED_MESSAGE);\n }\n }\n\n const host = getConfig(\"__PLASMIC_DATA_HOST\", DEFAULT_HOST);\n\n const url = `${host}/api/v1/server-data/sources/${op.sourceId}/execute`;\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(opts?.userAuthToken && {\n \"x-plasmic-data-user-auth-token\": opts.userAuthToken,\n }),\n },\n body: stringify({\n opId: op.opId,\n userArgs: op.userArgs ?? {},\n paginate: opts?.paginate,\n }),\n });\n if (resp.status !== 200) {\n const text = await resp.text();\n throw new Error(text);\n }\n return (await resp.json()) as T;\n}\n\nfunction getConfig<T>(key: string, defaultValue: T) {\n if (typeof globalThis === \"undefined\") {\n return defaultValue;\n } else {\n return (globalThis as any)[key] ?? defaultValue;\n }\n}\n", "const PLASMIC_UNDEFINED = \"__PLASMIC_UNDEFINED\";\n\nfunction addPlaceholders(val: any) {\n return val === undefined ? PLASMIC_UNDEFINED : val;\n}\n\nexport function addPlaceholdersToUserArgs(\n userArgs: Record<string, any> | undefined\n) {\n if (!userArgs) {\n return userArgs;\n }\n Object.entries(userArgs).forEach(([key, val]) => {\n userArgs[key] = Array.isArray(val)\n ? val.map((v) => addPlaceholders(v))\n : addPlaceholders(val);\n });\n return userArgs;\n}\n", "export function swallow<T>(f: () => T): T | undefined {\n try {\n return f();\n } catch {\n return undefined;\n }\n}\n\nexport function pick<T extends object, K extends keyof T>(\n obj: T,\n ...keys: K[]\n): Pick<T, K> {\n const res: any = {};\n for (const key of keys) {\n if (key in obj) {\n res[key] = obj[key as keyof T];\n }\n }\n return res;\n}\n\ntype ReactElt = {\n children: ReactElt | ReactElt[];\n props: {\n children: ReactElt | ReactElt[];\n [prop: string]: any;\n } | null;\n type: React.ComponentType<any> | null;\n key: string | null;\n} | null;\n\nexport function traverseReactEltTree(\n children: React.ReactNode,\n callback: (elt: ReactElt) => void\n) {\n const rec = (elts: ReactElt | ReactElt[] | null) => {\n (Array.isArray(elts) ? elts : [elts]).forEach((elt) => {\n if (elt) {\n callback(elt);\n if (elt.children) {\n rec(elt.children);\n }\n if (elt.props?.children && elt.props.children !== elt.children) {\n rec(elt.props.children);\n }\n }\n });\n };\n rec(children as any);\n}\n\nexport function asArray<T>(x: T[] | T | undefined | null) {\n if (Array.isArray(x)) {\n return x;\n } else if (x == null) {\n return [];\n } else {\n return [x];\n }\n}\n\nexport function ensureNumber(x: number | string): number {\n return x as number;\n}\n\nexport function ensure<T>(x: T | null | undefined, msg: string): T {\n if (x === null || x === undefined) {\n throw new Error(\"Expected non-null or non-undefined value: \" + msg);\n }\n return x;\n}\n\nexport function isOneOf<T, U extends T>(elem: T, arr: readonly U[]): elem is U {\n return arr.includes(elem as any);\n}\n\nexport function maybe<T, U>(\n x: T | undefined | null,\n f: (y: T) => U\n): U | undefined {\n if (x === undefined || x === null) return undefined;\n return f(x);\n}\n\nexport function isLikeImage(value: unknown) {\n return typeof value === \"string\"\n ? value.match(/\\.(png|jpg|jpeg|gif|svg|webp|avif|ico|bmp|tiff)$/i)\n : false;\n}\n\nexport function ensureArray<T>(xs: T | T[]): T[] {\n return Array.isArray(xs) ? xs : [xs];\n}\n\nexport const tuple = <T extends any[]>(...args: T): T => args;\n\nexport interface HasId {\n id: string;\n}\n\nexport function mkIdMap<T extends HasId>(xs: ReadonlyArray<T>): Map<string, T> {\n return new Map(xs.map((x) => tuple(x.id, x) as [string, T]));\n}\n\nexport const mkShortId = () => `${Math.random()}`;\n\nexport function withoutNils<T>(xs: Array<T | undefined | null>): T[] {\n return xs.filter((x): x is T => x != null);\n}\n\nexport type Falsey = null | undefined | false | \"\" | 0 | 0n;\nexport type Truthy<T> = T extends Falsey ? never : T;\n\nexport function withoutFalsey<T>(xs: Array<T | Falsey>): T[] {\n return xs.filter((x): x is T => !!x);\n}\n", "import { useMemo } from \"react\";\nimport {\n ManyRowsResult,\n TableFieldSchema,\n TableFieldType,\n TableSchema,\n} from \"./types\";\nimport { mkIdMap, withoutNils } from \"./utils\";\n\nexport type QueryResult = Partial<ManyRowsResult<any>> & {\n error?: any;\n isLoading?: boolean;\n};\n\nexport interface NormalizedData {\n data: Record<string, unknown>[];\n schema?: TableSchema;\n}\n\nexport function normalizeData(rawData: unknown): NormalizedData | undefined {\n if (!rawData) {\n return undefined;\n }\n\n const dataArray = tryGetDataArray(rawData);\n if (!dataArray) {\n return undefined;\n }\n const schema = (rawData as any).schema ?? tryGetSchema(dataArray);\n if (!schema) {\n return undefined;\n }\n return { data: dataArray, schema };\n}\n\nexport function useNormalizedData(\n rawData: unknown\n): NormalizedData | undefined {\n return useMemo(() => normalizeData(rawData), [rawData]);\n}\n\nfunction tryGetDataArray(rawData: unknown): any[] | undefined {\n if (rawData == null || typeof rawData !== \"object\") {\n return undefined;\n }\n\n if (Array.isArray(rawData)) {\n if (isArrayOfObjects(rawData)) {\n return rawData;\n } else {\n // TODO: array of primitives? Maybe we can wrap this?\n return undefined;\n }\n }\n\n if (rawData == null) {\n return undefined;\n }\n\n if (\"data\" in rawData && typeof (rawData as any).data === \"object\") {\n if (\n Array.isArray((rawData as any).data) &&\n isArrayOfObjects((rawData as any).data)\n ) {\n return (rawData as any).data;\n } else if ((rawData as any).data != null) {\n return [(rawData as any).data];\n } else {\n return undefined;\n }\n }\n if (\"isLoading\" in rawData || \"error\" in rawData) {\n return undefined;\n }\n\n // Maybe a singleton record?\n return [rawData];\n}\n\nfunction isArrayOfObjects(arr: unknown[]) {\n return arr.every((x) => typeof x === \"object\" && !Array.isArray(x));\n}\n\nfunction tryGetSchema(data: any[]): TableSchema | undefined {\n const fieldMap: Record<string, TableFieldType> = {};\n data.forEach((entry: any) => {\n if (entry && typeof entry === \"object\") {\n Array.from(Object.entries(entry)).forEach(([k, v]) => {\n const inferredType: TableFieldType =\n typeof v === \"string\"\n ? \"string\"\n : typeof v === \"boolean\"\n ? \"boolean\"\n : typeof v === \"number\"\n ? \"number\"\n : \"unknown\";\n if (fieldMap[k] && fieldMap[k] !== inferredType) {\n fieldMap[k] = \"unknown\";\n } else {\n fieldMap[k] = inferredType;\n }\n });\n }\n });\n return {\n id: \"inferred\",\n fields: Object.entries(fieldMap).map(([f, t]) => ({\n id: f,\n type: t,\n readOnly: false,\n })),\n };\n}\n\nexport type BaseFieldConfig = {\n key?: string;\n fieldId?: string;\n};\n\nconst mkShortId = () => `${Math.random()}`;\n\nexport function deriveFieldConfigs<T extends BaseFieldConfig>(\n specifiedFieldsPartial: Partial<T>[],\n schema: TableSchema | undefined,\n makeDefaultConfig: (field: TableFieldSchema | undefined) => T\n): {\n mergedFields: T[];\n minimalFullLengthFields: Partial<T>[];\n} {\n const schemaFields = schema?.fields ?? [];\n const fieldById = mkIdMap(schemaFields);\n const specifiedFieldIds = new Set(\n withoutNils(specifiedFieldsPartial.map((f) => f.fieldId))\n );\n const keptSpecifiedFields = specifiedFieldsPartial.flatMap((f): T[] => {\n if (!f.fieldId) {\n return [\n { key: mkShortId(), ...makeDefaultConfig(undefined), ...f },\n ] as T[];\n }\n const field = fieldById.get(f.fieldId as string);\n\n // Drop configs with fieldIds no longer in the data.\n if (!field) {\n return [];\n }\n\n return [\n {\n key: mkShortId(),\n ...makeDefaultConfig(field),\n ...f,\n },\n ] as T[];\n });\n const newVirtualFields = schemaFields\n .filter((f) => !specifiedFieldIds.has(f.id))\n .map(\n (f): T => ({\n key: mkShortId(),\n ...makeDefaultConfig(f),\n })\n );\n const mergedFields = [...keptSpecifiedFields, ...newVirtualFields];\n const minimalFullLengthFields: Partial<T>[] = [\n ...specifiedFieldsPartial,\n ...newVirtualFields.map((f) => ({ key: f.key, fieldId: f.fieldId })),\n ] as Partial<T>[];\n return { mergedFields, minimalFullLengthFields };\n}\n", "import React from 'react';\nimport { DataOpConfig } from '../components/Fetcher';\nimport { DataOp } from '../executor';\nimport { swallow } from '../utils';\nimport { usePlasmicDataOp } from './usePlasmicDataOp';\n\nfunction usePrevious<T>(value: T | undefined): T | undefined {\n const prevValue = React.useRef<T | undefined>(undefined);\n\n React.useEffect(() => {\n prevValue.current = value;\n\n return () => {\n prevValue.current = undefined;\n };\n });\n\n return prevValue.current;\n}\n\nexport interface DependencyAwareQueryConfig extends DataOpConfig {\n $queries: Record<string, any>;\n setDollarQueries: ($queries: Record<string, any>) => void;\n getDataOp: () => DataOp;\n}\n\n/**\n * @deprecated Prefer using `usePlasmicDataOp` directly instead.\n */\nexport function useDependencyAwareQuery({\n $queries,\n getDataOp,\n setDollarQueries,\n name,\n pageIndex,\n pageSize,\n}: DependencyAwareQueryConfig) {\n const data = usePlasmicDataOp(swallow(getDataOp), {\n ...(!!pageIndex &&\n !!pageSize && {\n paginate: { pageIndex, pageSize },\n }),\n });\n const finalName = name ?? 'data';\n const prevName = usePrevious(finalName);\n React.useEffect(() => {\n if (!(finalName in $queries) || $queries[finalName] !== data) {\n const $queries2 = {\n ...$queries,\n [finalName]: data,\n };\n if (prevName && finalName !== prevName && prevName in $queries) {\n delete $queries2[prevName];\n }\n setDollarQueries($queries2);\n }\n }, [finalName, prevName, data, $queries, setDollarQueries]);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAAqC;;;ACCrC,mBAAkB;;;ACDlB,kCAA4C;AAE5C,SAAoB;AACpB,IAAAC,gBAGO;AACP,YAAuB;;;ACNvB,gCAAkB;AAClB,mBAAmC;AACnC,4BAAsB;;;ACHtB,IAAM,oBAAoB;AAE1B,SAAS,gBAAgB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AS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA+B;AAC7B,QAAM,OAAO,iBAAiB,QAAQ,SAAS,GAAG,mBAC5C,CAAC,CAAC,aACJ,CAAC,CAAC,YAAY;AAAA,IACZ,UAAU,EAAE,WAAW,SAAS;AAAA,EAClC,EACH;AACD,QAAM,YAAY,sBAAQ;AAC1B,QAAM,WAAW,YAAY,SAAS;AACtC,gBAAAA,QAAM,UAAU,MAAM;AACpB,QAAI,EAAE,aAAa,aAAa,SAAS,SAAS,MAAM,MAAM;AAC5D,YAAM,YAAY,iCACb,WADa;AAAA,QAEhB,CAAC,SAAS,GAAG;AAAA,MACf;AACA,UAAI,YAAY,cAAc,YAAY,YAAY,UAAU;AAC9D,eAAO,UAAU,QAAQ;AAAA,MAC3B;AACA,uBAAiB,SAAS;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,WAAW,UAAU,MAAM,UAAU,gBAAgB,CAAC;AAC5D;",
|
|
6
|
+
"names": ["import_query", "import_query", "fetch", "stringify", "isRSC", "data", "_a", "React", "import_react", "import_react", "React"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.150",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@plasmicapp/data-sources-context": "0.1.21",
|
|
50
|
-
"@plasmicapp/host": "1.0.
|
|
50
|
+
"@plasmicapp/host": "1.0.191",
|
|
51
51
|
"@plasmicapp/isomorphic-unfetch": "1.0.3",
|
|
52
52
|
"@plasmicapp/query": "0.1.78",
|
|
53
53
|
"fast-stringify": "^2.0.0"
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "5d165d4f3e6dc2174d6f6dfd7e0e0f8d97519c89"
|
|
59
59
|
}
|