@plasmicapp/data-sources 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +45 -22
- package/dist/index.esm.js +254 -212
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +254 -212
- package/dist/index.js.map +3 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,19 @@ import { PlasmicDataSourceContextValue } from '@plasmicapp/data-sources-context'
|
|
|
3
3
|
import { default as React_2 } from 'react';
|
|
4
4
|
import { usePlasmicDataConfig } from '@plasmicapp/query';
|
|
5
5
|
|
|
6
|
+
declare interface $StateSpec<T = any> {
|
|
7
|
+
path: string;
|
|
8
|
+
initFunc?: (env: QueryExecutionContext & {
|
|
9
|
+
/** @deprecated This field is here to conform to react-web's $StateSpec. */
|
|
10
|
+
$queries: Record<string, any>;
|
|
11
|
+
/** @deprecated This field is here to conform to react-web's $StateSpec. */
|
|
12
|
+
$refs: Record<string, any>;
|
|
13
|
+
}) => T;
|
|
14
|
+
initVal?: T;
|
|
15
|
+
type: "private" | "readonly" | "writable";
|
|
16
|
+
valueProp?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
7
20
|
export declare type BaseFieldConfig = {
|
|
8
21
|
key?: string;
|
|
@@ -93,6 +106,12 @@ declare interface ExecutePlasmicQueriesResult {
|
|
|
93
106
|
queries: Record<string, PlasmicQueryResult>;
|
|
94
107
|
}
|
|
95
108
|
|
|
109
|
+
/** @deprecated no-op function for compatibility only */
|
|
110
|
+
export declare function executeServerQuery<F extends (...args: any[]) => any>(_query?: any): Promise<{
|
|
111
|
+
data: ReturnType<F>;
|
|
112
|
+
isLoading: boolean;
|
|
113
|
+
}>;
|
|
114
|
+
|
|
96
115
|
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
97
116
|
export declare function Fetcher(props: FetcherProps): React_2.ReactElement | null;
|
|
98
117
|
|
|
@@ -139,9 +158,9 @@ export declare interface Pagination {
|
|
|
139
158
|
}
|
|
140
159
|
|
|
141
160
|
/** @internal */
|
|
142
|
-
export declare interface PlasmicQuery<F extends (...args:
|
|
161
|
+
export declare interface PlasmicQuery<F extends (...args: any[]) => Promise<unknown> = (...args: any[]) => Promise<unknown>> {
|
|
143
162
|
fn: F;
|
|
144
|
-
|
|
163
|
+
args: ContextFn<Parameters<F>>;
|
|
145
164
|
id: string;
|
|
146
165
|
}
|
|
147
166
|
|
|
@@ -176,8 +195,12 @@ declare interface QueryCodeComponentNode {
|
|
|
176
195
|
/** @internal */
|
|
177
196
|
export declare interface QueryComponentNode {
|
|
178
197
|
type: "component";
|
|
179
|
-
queries: Record<string,
|
|
198
|
+
queries: Record<string, PlasmicQuery>;
|
|
180
199
|
propsContext: Record<string, ContextFn<unknown>>;
|
|
200
|
+
/**
|
|
201
|
+
* Lazily initializes $state proxy for this component.
|
|
202
|
+
*/
|
|
203
|
+
stateSpecs: $StateSpec[];
|
|
181
204
|
children: QueryNode[];
|
|
182
205
|
}
|
|
183
206
|
|
|
@@ -189,16 +212,22 @@ declare interface QueryDataProviderNode {
|
|
|
189
212
|
children: QueryNode[];
|
|
190
213
|
}
|
|
191
214
|
|
|
192
|
-
|
|
193
|
-
|
|
215
|
+
/**
|
|
216
|
+
* Context during execution.
|
|
217
|
+
* @internal
|
|
218
|
+
*/
|
|
219
|
+
export declare type QueryExecutionContext = {
|
|
194
220
|
$ctx: Record<string, unknown>;
|
|
221
|
+
$props: Record<string, unknown>;
|
|
195
222
|
$state: Record<string, unknown>;
|
|
196
223
|
$q: Record<string, PlasmicQueryResult>;
|
|
197
|
-
|
|
198
|
-
}
|
|
224
|
+
};
|
|
199
225
|
|
|
200
|
-
/**
|
|
201
|
-
|
|
226
|
+
/**
|
|
227
|
+
* Initial context just before execution.
|
|
228
|
+
* @internal
|
|
229
|
+
*/
|
|
230
|
+
declare type QueryExecutionInitialContext = Pick<QueryExecutionContext, "$ctx" | "$props">;
|
|
202
231
|
|
|
203
232
|
/** @internal */
|
|
204
233
|
declare type QueryNode = QueryComponentNode | QueryCodeComponentNode | QueryRepeatedNode | QueryDataProviderNode | QueryVisibilityNode;
|
|
@@ -227,14 +256,12 @@ declare interface QueryVisibilityNode {
|
|
|
227
256
|
|
|
228
257
|
declare type ResolvableDataOp = DataOp | undefined | null | (() => DataOp | undefined | null);
|
|
229
258
|
|
|
230
|
-
declare interface SerializedServerQuery {
|
|
231
|
-
id: string;
|
|
232
|
-
fn: (...args: unknown[]) => Promise<unknown>;
|
|
233
|
-
args: ContextFn<unknown[]>;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
259
|
declare type SerializedServerRenderingConfig = boolean;
|
|
237
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Wraps a Promise so that it can be easily resolved/rejected
|
|
263
|
+
* outside the executor param of the Promise constructor.
|
|
264
|
+
*/
|
|
238
265
|
declare class SettablePromise<T> {
|
|
239
266
|
readonly promise: Promise<T>;
|
|
240
267
|
private _resolve;
|
|
@@ -262,11 +289,6 @@ export declare class _StatefulQueryResult<T = unknown> implements PlasmicQueryRe
|
|
|
262
289
|
private notifyListeners;
|
|
263
290
|
reset(): void;
|
|
264
291
|
loadingPromise(key: string, promise: Promise<T>): void;
|
|
265
|
-
/**
|
|
266
|
-
* Resolve is allowed if:
|
|
267
|
-
* 1) no key / state is initial, which means we are resolving from cache
|
|
268
|
-
* 2) key / state is loading, which means we need to check the keys match
|
|
269
|
-
*/
|
|
270
292
|
resolvePromise(key: string, data: T): void;
|
|
271
293
|
/**
|
|
272
294
|
* Reject is allowed if:
|
|
@@ -274,6 +296,7 @@ export declare class _StatefulQueryResult<T = unknown> implements PlasmicQueryRe
|
|
|
274
296
|
* 2) key / state is loading, which means we need to check the keys match
|
|
275
297
|
*/
|
|
276
298
|
rejectPromise(key: string | null, error: unknown): void;
|
|
299
|
+
toJSON(): _StatefulQueryState<T>;
|
|
277
300
|
get key(): string | null;
|
|
278
301
|
get data(): T;
|
|
279
302
|
get isLoading(): boolean;
|
|
@@ -358,11 +381,11 @@ export declare function unstable_executePlasmicQueries(rootNode: QueryComponentN
|
|
|
358
381
|
* };
|
|
359
382
|
*
|
|
360
383
|
* export function ClientComponent($props, $ctx) {
|
|
361
|
-
* const $q = usePlasmicQueries(serverQueryTree, $props,
|
|
384
|
+
* const $q = usePlasmicQueries(serverQueryTree, $ctx, $props, null);
|
|
362
385
|
* return <div>{$q.films.data}</div>
|
|
363
386
|
* }
|
|
364
387
|
*/
|
|
365
|
-
export declare function unstable_usePlasmicQueries(tree: QueryComponentNode, $
|
|
388
|
+
export declare function unstable_usePlasmicQueries(tree: QueryComponentNode, $ctx: QueryExecutionContext["$ctx"], $props: QueryExecutionContext["$props"], $state: QueryExecutionContext["$state"] | null): Record<string, PlasmicQueryResult>;
|
|
366
389
|
|
|
367
390
|
/**
|
|
368
391
|
* @internal
|