@plasmicapp/data-sources 0.1.208 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +35 -15
- package/dist/index.esm.js +0 -46
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +0 -46
- package/dist/index.js.map +4 -4
- package/package.json +9 -12
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { default as React_2 } from 'react';
|
|
|
4
4
|
import { SWRResponse } from '@plasmicapp/query';
|
|
5
5
|
import { usePlasmicDataConfig } from '@plasmicapp/query';
|
|
6
6
|
|
|
7
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
7
8
|
export declare type BaseFieldConfig = {
|
|
8
9
|
key?: string;
|
|
9
10
|
fieldId?: string;
|
|
@@ -11,6 +12,7 @@ export declare type BaseFieldConfig = {
|
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Represents the result of a client-side query.
|
|
15
|
+
* @deprecated See https://docs.plasmic.app/learn/integrations
|
|
14
16
|
*/
|
|
15
17
|
export declare interface ClientQueryResult<T = any> {
|
|
16
18
|
/**
|
|
@@ -42,6 +44,7 @@ export declare interface ClientQueryResult<T = any> {
|
|
|
42
44
|
isLoading?: boolean;
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
45
48
|
export declare interface DataOp {
|
|
46
49
|
sourceId: string;
|
|
47
50
|
opId: string;
|
|
@@ -51,22 +54,19 @@ export declare interface DataOp {
|
|
|
51
54
|
roleId?: string | null;
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
54
58
|
declare interface DataOpConfig {
|
|
55
59
|
name?: string;
|
|
56
60
|
pageIndex?: number;
|
|
57
61
|
pageSize?: number;
|
|
58
62
|
}
|
|
59
63
|
|
|
64
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
60
65
|
export declare interface DataSourceSchema {
|
|
61
66
|
tables: TableSchema[];
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
$queries: Record<string, any>;
|
|
66
|
-
setDollarQueries: ($queries: Record<string, any>) => void;
|
|
67
|
-
getDataOp: () => DataOp;
|
|
68
|
-
}
|
|
69
|
-
|
|
69
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
70
70
|
export declare function deriveFieldConfigs<T extends BaseFieldConfig>(specifiedFieldsPartial: Partial<T>[], schema: TableSchema | undefined, makeDefaultConfig: (field: TableFieldSchema | undefined) => T): {
|
|
71
71
|
mergedFields: T[];
|
|
72
72
|
minimalFullLengthFields: Partial<T>[];
|
|
@@ -78,26 +78,32 @@ declare interface ExecuteOpts {
|
|
|
78
78
|
paginate?: Pagination;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
81
82
|
export declare function executePlasmicDataOp<T extends SingleRowResult | ManyRowsResult>(op: DataOp, opts?: ExecuteOpts): Promise<T>;
|
|
82
83
|
|
|
84
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
83
85
|
export declare function Fetcher(props: FetcherProps): React_2.ReactElement | null;
|
|
84
86
|
|
|
87
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
85
88
|
export declare const FetcherMeta: CodeComponentMeta<FetcherProps>;
|
|
86
89
|
|
|
90
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
87
91
|
export declare interface FetcherProps extends DataOpConfig {
|
|
88
92
|
dataOp?: DataOp;
|
|
89
93
|
children?: ($queries: Record<string, any>) => React_2.ReactElement | null;
|
|
90
94
|
queries?: Record<string, any>;
|
|
91
95
|
}
|
|
92
96
|
|
|
97
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
93
98
|
export declare function makeCacheKey(dataOp: DataOp, opts?: {
|
|
94
99
|
paginate?: Pagination;
|
|
95
100
|
userAuthToken?: string | null;
|
|
96
101
|
}): string;
|
|
97
102
|
|
|
98
|
-
/** Make a cache key for a query */
|
|
103
|
+
/** @internal Make a cache key for a query */
|
|
99
104
|
export declare function makeQueryCacheKey(id: string, params: any[]): string;
|
|
100
105
|
|
|
106
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
101
107
|
export declare interface ManyRowsResult<T = any> {
|
|
102
108
|
data: T[];
|
|
103
109
|
total?: number;
|
|
@@ -105,24 +111,29 @@ export declare interface ManyRowsResult<T = any> {
|
|
|
105
111
|
paginate?: Pagination;
|
|
106
112
|
}
|
|
107
113
|
|
|
114
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
108
115
|
export declare function normalizeData(rawData: unknown): NormalizedData | undefined;
|
|
109
116
|
|
|
117
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
110
118
|
export declare interface NormalizedData {
|
|
111
119
|
data: Record<string, unknown>[];
|
|
112
120
|
schema?: TableSchema;
|
|
113
121
|
}
|
|
114
122
|
|
|
123
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
115
124
|
export declare interface Pagination {
|
|
116
125
|
pageSize: number;
|
|
117
126
|
pageIndex: number;
|
|
118
127
|
}
|
|
119
128
|
|
|
129
|
+
/** @internal */
|
|
120
130
|
export declare interface PlasmicQuery<F extends (...args: unknown[]) => Promise<unknown> = (...args: unknown[]) => Promise<unknown>> {
|
|
121
131
|
fn: F;
|
|
122
132
|
execParams: () => Parameters<F>;
|
|
123
133
|
id: string;
|
|
124
134
|
}
|
|
125
135
|
|
|
136
|
+
/** @internal */
|
|
126
137
|
export declare interface PlasmicQueryResult<T = unknown> {
|
|
127
138
|
/**
|
|
128
139
|
* Returns the key if params have resolved.
|
|
@@ -142,6 +153,7 @@ declare interface PlasmicUndefinedDataErrorPromise extends Promise<any> {
|
|
|
142
153
|
message: string;
|
|
143
154
|
}
|
|
144
155
|
|
|
156
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
145
157
|
export declare type QueryResult = Partial<ManyRowsResult<any>> & {
|
|
146
158
|
error?: any;
|
|
147
159
|
isLoading?: boolean;
|
|
@@ -162,6 +174,7 @@ declare class SettablePromise<T> {
|
|
|
162
174
|
reject(error: unknown): void;
|
|
163
175
|
}
|
|
164
176
|
|
|
177
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
165
178
|
export declare interface SingleRowResult<T = any> {
|
|
166
179
|
data: T;
|
|
167
180
|
schema: TableSchema;
|
|
@@ -221,6 +234,7 @@ export declare type _StatefulQueryState<T = unknown> = {
|
|
|
221
234
|
/** @internal */
|
|
222
235
|
export declare type _StateListener<T = unknown> = (state: _StatefulQueryState<T>, prevState: _StatefulQueryState<T>) => void;
|
|
223
236
|
|
|
237
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
224
238
|
export declare interface TableFieldSchema {
|
|
225
239
|
id: string;
|
|
226
240
|
label?: string;
|
|
@@ -230,8 +244,10 @@ export declare interface TableFieldSchema {
|
|
|
230
244
|
options?: string[];
|
|
231
245
|
}
|
|
232
246
|
|
|
247
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
233
248
|
export declare type TableFieldType = "string" | "boolean" | "number" | "date" | "datetime" | "enum" | "json" | "unknown";
|
|
234
249
|
|
|
250
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
235
251
|
export declare interface TableSchema {
|
|
236
252
|
id: string;
|
|
237
253
|
schema?: string;
|
|
@@ -240,6 +256,7 @@ export declare interface TableSchema {
|
|
|
240
256
|
}
|
|
241
257
|
|
|
242
258
|
/**
|
|
259
|
+
* @internal
|
|
243
260
|
* Creates a $queries variable that can be used before queries are completed.
|
|
244
261
|
*
|
|
245
262
|
* Each query gets a StatefulQueryResult which implements PlasmicQueryResult.
|
|
@@ -253,6 +270,7 @@ export declare interface TableSchema {
|
|
|
253
270
|
export declare function unstable_createDollarQueries<QueryName extends string>(queryNames: QueryName[]): Record<QueryName, PlasmicQueryResult>;
|
|
254
271
|
|
|
255
272
|
/**
|
|
273
|
+
* @internal
|
|
256
274
|
* Executes all queries and returns the query data keyed by cache key.
|
|
257
275
|
*
|
|
258
276
|
* Example codegen:
|
|
@@ -296,6 +314,7 @@ export declare function unstable_executePlasmicQueries<QueryName extends string>
|
|
|
296
314
|
}>;
|
|
297
315
|
|
|
298
316
|
/**
|
|
317
|
+
* @internal
|
|
299
318
|
* This hook's job is to execute queries and re-render when query state changes.
|
|
300
319
|
* Data caching can be controlled via @plasmicapp/query.
|
|
301
320
|
*
|
|
@@ -339,33 +358,34 @@ export declare function unstable_executePlasmicQueries<QueryName extends string>
|
|
|
339
358
|
export declare function unstable_usePlasmicQueries<QueryName extends string>($queries: Record<QueryName, PlasmicQueryResult>, queries: Record<QueryName, PlasmicQuery>): Record<QueryName, ReturnType<typeof usePlasmicQuery>>;
|
|
340
359
|
|
|
341
360
|
/**
|
|
361
|
+
* @internal
|
|
342
362
|
* Wraps each PlasmicQueryResult so that they return a hardcoded string for
|
|
343
363
|
* undefined/loading and error cases.
|
|
344
364
|
*/
|
|
345
365
|
export declare function unstable_wrapDollarQueriesForMetadata<T extends Record<string, PlasmicQueryResult>>($queries: T, ifUndefined?: (promise: PlasmicUndefinedDataErrorPromise) => unknown, ifError?: (err: unknown) => unknown): T;
|
|
346
366
|
|
|
347
|
-
/**
|
|
348
|
-
* @deprecated Prefer using `usePlasmicDataOp` directly instead.
|
|
349
|
-
*/
|
|
350
|
-
export declare function useDependencyAwareQuery({ $queries, getDataOp, setDollarQueries, name, pageIndex, pageSize, }: DependencyAwareQueryConfig): void;
|
|
351
|
-
|
|
367
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
352
368
|
export declare function useNormalizedData(rawData: unknown): NormalizedData | undefined;
|
|
353
369
|
|
|
354
370
|
export { usePlasmicDataConfig }
|
|
355
371
|
|
|
372
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
356
373
|
export declare function usePlasmicDataMutationOp<T extends SingleRowResult | ManyRowsResult>(dataOp: ResolvableDataOp): () => Promise<T | undefined>;
|
|
357
374
|
|
|
375
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
358
376
|
export declare function usePlasmicDataOp<T extends SingleRowResult | ManyRowsResult, E = any>(dataOp: ResolvableDataOp, opts?: {
|
|
359
377
|
paginate?: Pagination;
|
|
360
378
|
noUndefinedDataProxy?: boolean;
|
|
361
379
|
}): ClientQueryResult<T["data"]>;
|
|
362
380
|
|
|
363
|
-
/**
|
|
364
|
-
* Returns a function that can be used to invalidate Plasmic query groups.
|
|
365
|
-
*/
|
|
381
|
+
/** @deprecated See https://docs.plasmic.app/learn/integrations */
|
|
366
382
|
export declare function usePlasmicInvalidate(): (invalidatedKeys: string[] | null | undefined) => Promise<any[] | undefined>;
|
|
367
383
|
|
|
368
384
|
/**
|
|
385
|
+
* @deprecated
|
|
386
|
+
* This export will be deleted before RSC release.
|
|
387
|
+
* TODO: Rename to usePlasmicQuery
|
|
388
|
+
* TODO: Reference $query directly.
|
|
369
389
|
* TODO: Use paramsResult from usePlasmicQueries
|
|
370
390
|
*/
|
|
371
391
|
declare function usePlasmicQuery<T, F extends (...args: any[]) => Promise<T>>($query: PlasmicQueryResult<T>, query: PlasmicQuery<F>, settledCount?: number): SWRResponse<T, unknown>;
|
package/dist/index.esm.js
CHANGED
|
@@ -49,13 +49,6 @@ import * as React3 from "react";
|
|
|
49
49
|
// src/utils.ts
|
|
50
50
|
function noopFn() {
|
|
51
51
|
}
|
|
52
|
-
function swallow(f) {
|
|
53
|
-
try {
|
|
54
|
-
return f();
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return void 0;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
52
|
function pick(obj, ...keys) {
|
|
60
53
|
const res = {};
|
|
61
54
|
for (const key of keys) {
|
|
@@ -1212,44 +1205,6 @@ function deriveFieldConfigs(specifiedFieldsPartial, schema, makeDefaultConfig) {
|
|
|
1212
1205
|
];
|
|
1213
1206
|
return { mergedFields, minimalFullLengthFields };
|
|
1214
1207
|
}
|
|
1215
|
-
|
|
1216
|
-
// src/hooks/useDependencyAwareQuery.tsx
|
|
1217
|
-
import React6 from "react";
|
|
1218
|
-
function usePrevious(value) {
|
|
1219
|
-
const prevValue = React6.useRef(void 0);
|
|
1220
|
-
React6.useEffect(() => {
|
|
1221
|
-
prevValue.current = value;
|
|
1222
|
-
return () => {
|
|
1223
|
-
prevValue.current = void 0;
|
|
1224
|
-
};
|
|
1225
|
-
});
|
|
1226
|
-
return prevValue.current;
|
|
1227
|
-
}
|
|
1228
|
-
function useDependencyAwareQuery({
|
|
1229
|
-
$queries,
|
|
1230
|
-
getDataOp,
|
|
1231
|
-
setDollarQueries,
|
|
1232
|
-
name,
|
|
1233
|
-
pageIndex,
|
|
1234
|
-
pageSize
|
|
1235
|
-
}) {
|
|
1236
|
-
const data = usePlasmicDataOp(swallow(getDataOp), __spreadValues({}, !!pageIndex && !!pageSize && {
|
|
1237
|
-
paginate: { pageIndex, pageSize }
|
|
1238
|
-
}));
|
|
1239
|
-
const finalName = name != null ? name : "data";
|
|
1240
|
-
const prevName = usePrevious(finalName);
|
|
1241
|
-
React6.useEffect(() => {
|
|
1242
|
-
if (!(finalName in $queries) || $queries[finalName] !== data) {
|
|
1243
|
-
const $queries2 = __spreadProps(__spreadValues({}, $queries), {
|
|
1244
|
-
[finalName]: data
|
|
1245
|
-
});
|
|
1246
|
-
if (prevName && finalName !== prevName && prevName in $queries) {
|
|
1247
|
-
delete $queries2[prevName];
|
|
1248
|
-
}
|
|
1249
|
-
setDollarQueries($queries2);
|
|
1250
|
-
}
|
|
1251
|
-
}, [finalName, prevName, data, $queries, setDollarQueries]);
|
|
1252
|
-
}
|
|
1253
1208
|
export {
|
|
1254
1209
|
Fetcher,
|
|
1255
1210
|
FetcherMeta,
|
|
@@ -1263,7 +1218,6 @@ export {
|
|
|
1263
1218
|
executePlasmicQueries as unstable_executePlasmicQueries,
|
|
1264
1219
|
usePlasmicQueries as unstable_usePlasmicQueries,
|
|
1265
1220
|
wrapDollarQueriesForMetadata as unstable_wrapDollarQueriesForMetadata,
|
|
1266
|
-
useDependencyAwareQuery,
|
|
1267
1221
|
useNormalizedData,
|
|
1268
1222
|
usePlasmicDataConfig4 as usePlasmicDataConfig,
|
|
1269
1223
|
usePlasmicDataMutationOp,
|