@plasmicapp/data-sources 0.1.136 → 0.1.137
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 +137 -10
- package/package.json +5 -5
- package/dist/components/Fetcher.d.ts +0 -15
- package/dist/executor.d.ts +0 -17
- package/dist/helpers.d.ts +0 -19
- package/dist/hooks/useDependencyAwareQuery.d.ts +0 -11
- package/dist/hooks/usePlasmicDataOp.d.ts +0 -20
- package/dist/placeholders.d.ts +0 -1
- package/dist/types.d.ts +0 -32
- package/dist/utils.d.ts +0 -31
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { ComponentMeta } from '@plasmicapp/host';
|
|
2
|
+
import { PlasmicDataSourceContextValue } from '@plasmicapp/data-sources-context';
|
|
3
|
+
import { default as React_2 } from 'react';
|
|
4
|
+
import { usePlasmicDataConfig } from '@plasmicapp/query';
|
|
5
|
+
|
|
6
|
+
export declare type BaseFieldConfig = {
|
|
7
|
+
key?: string;
|
|
8
|
+
fieldId?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export declare interface DataOp {
|
|
12
|
+
sourceId: string;
|
|
13
|
+
opId: string;
|
|
14
|
+
userArgs?: Record<string, any>;
|
|
15
|
+
cacheKey?: string;
|
|
16
|
+
invalidatedKeys?: string[] | null;
|
|
17
|
+
roleId?: string | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare interface DataOpConfig {
|
|
21
|
+
name?: string;
|
|
22
|
+
pageIndex?: number;
|
|
23
|
+
pageSize?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare interface DataSourceSchema {
|
|
27
|
+
tables: TableSchema[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare interface DependencyAwareQueryConfig extends DataOpConfig {
|
|
31
|
+
$queries: Record<string, any>;
|
|
32
|
+
setDollarQueries: ($queries: Record<string, any>) => void;
|
|
33
|
+
getDataOp: () => DataOp;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare function deriveFieldConfigs<T extends BaseFieldConfig>(specifiedFieldsPartial: Partial<T>[], schema: TableSchema | undefined, makeDefaultConfig: (field: TableFieldSchema | undefined) => T): {
|
|
37
|
+
mergedFields: T[];
|
|
38
|
+
minimalFullLengthFields: Partial<T>[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
declare interface ExecuteOpts {
|
|
42
|
+
userAuthToken?: string;
|
|
43
|
+
user?: PlasmicDataSourceContextValue["user"];
|
|
44
|
+
paginate?: Pagination;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare function executePlasmicDataOp<T extends SingleRowResult | ManyRowsResult>(op: DataOp, opts?: ExecuteOpts): Promise<T>;
|
|
48
|
+
|
|
49
|
+
export declare function Fetcher(props: FetcherProps): React_2.ReactElement | null;
|
|
50
|
+
|
|
51
|
+
export declare const FetcherMeta: ComponentMeta<FetcherProps>;
|
|
52
|
+
|
|
53
|
+
export declare interface FetcherProps extends DataOpConfig {
|
|
54
|
+
dataOp?: DataOp;
|
|
55
|
+
children?: ($queries: Record<string, any>) => React_2.ReactElement | null;
|
|
56
|
+
queries?: Record<string, any>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare function makeCacheKey(dataOp: DataOp, opts?: {
|
|
60
|
+
paginate?: Pagination;
|
|
61
|
+
userAuthToken?: string | null;
|
|
62
|
+
}): string;
|
|
63
|
+
|
|
64
|
+
export declare interface ManyRowsResult<T = any> {
|
|
65
|
+
data: T[];
|
|
66
|
+
total?: number;
|
|
67
|
+
schema: TableSchema;
|
|
68
|
+
paginate?: Pagination;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export declare function normalizeData(rawData: unknown): NormalizedData | undefined;
|
|
72
|
+
|
|
73
|
+
export declare interface NormalizedData {
|
|
74
|
+
data: Record<string, unknown>[];
|
|
75
|
+
schema?: TableSchema;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export declare interface Pagination {
|
|
79
|
+
pageSize: number;
|
|
80
|
+
pageIndex: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export declare type QueryResult = Partial<ManyRowsResult<any>> & {
|
|
84
|
+
error?: any;
|
|
85
|
+
isLoading?: boolean;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
declare type ResolvableDataOp = DataOp | undefined | null | (() => DataOp | undefined | null);
|
|
89
|
+
|
|
90
|
+
export declare interface SingleRowResult<T = any> {
|
|
91
|
+
data: T;
|
|
92
|
+
schema: TableSchema;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export declare interface TableFieldSchema {
|
|
96
|
+
id: string;
|
|
97
|
+
label?: string;
|
|
98
|
+
type: TableFieldType;
|
|
99
|
+
readOnly: boolean;
|
|
100
|
+
primaryKey?: boolean;
|
|
101
|
+
options?: string[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export declare type TableFieldType = "string" | "boolean" | "number" | "date" | "datetime" | "enum" | "json" | "unknown";
|
|
105
|
+
|
|
106
|
+
export declare interface TableSchema {
|
|
107
|
+
id: string;
|
|
108
|
+
schema?: string;
|
|
109
|
+
label?: string;
|
|
110
|
+
fields: TableFieldSchema[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Prefer using `usePlasmicDataOp` directly instead.
|
|
115
|
+
*/
|
|
116
|
+
export declare function useDependencyAwareQuery({ $queries, getDataOp, setDollarQueries, name, pageIndex, pageSize, }: DependencyAwareQueryConfig): void;
|
|
117
|
+
|
|
118
|
+
export declare function useNormalizedData(rawData: unknown): NormalizedData | undefined;
|
|
119
|
+
|
|
120
|
+
export { usePlasmicDataConfig }
|
|
121
|
+
|
|
122
|
+
export declare function usePlasmicDataMutationOp<T extends SingleRowResult | ManyRowsResult>(dataOp: ResolvableDataOp): () => Promise<T | undefined>;
|
|
123
|
+
|
|
124
|
+
export declare function usePlasmicDataOp<T extends SingleRowResult | ManyRowsResult, E = any>(dataOp: ResolvableDataOp, opts?: {
|
|
125
|
+
paginate?: Pagination;
|
|
126
|
+
noUndefinedDataProxy?: boolean;
|
|
127
|
+
}): Partial<T> & {
|
|
128
|
+
error?: E;
|
|
129
|
+
isLoading?: boolean;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns a function that can be used to invalidate Plasmic query groups.
|
|
134
|
+
*/
|
|
135
|
+
export declare function usePlasmicInvalidate(): (invalidatedKeys: string[] | null | undefined) => Promise<any[] | undefined>;
|
|
136
|
+
|
|
137
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.137",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.js",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"react-dom": "^18.2.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@plasmicapp/data-sources-context": "0.1.
|
|
49
|
-
"@plasmicapp/host": "1.0.
|
|
48
|
+
"@plasmicapp/data-sources-context": "0.1.19",
|
|
49
|
+
"@plasmicapp/host": "1.0.179",
|
|
50
50
|
"@plasmicapp/isomorphic-unfetch": "1.0.3",
|
|
51
|
-
"@plasmicapp/query": "0.1.
|
|
51
|
+
"@plasmicapp/query": "0.1.76",
|
|
52
52
|
"fast-stringify": "^2.0.0"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "48a2877c3dc093d101508fcdde2fd213055fdab9"
|
|
58
58
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ComponentMeta } from '@plasmicapp/host';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { DataOp } from '../executor';
|
|
4
|
-
export interface DataOpConfig {
|
|
5
|
-
name?: string;
|
|
6
|
-
pageIndex?: number;
|
|
7
|
-
pageSize?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface FetcherProps extends DataOpConfig {
|
|
10
|
-
dataOp?: DataOp;
|
|
11
|
-
children?: ($queries: Record<string, any>) => React.ReactElement | null;
|
|
12
|
-
queries?: Record<string, any>;
|
|
13
|
-
}
|
|
14
|
-
export declare function Fetcher(props: FetcherProps): React.ReactElement | null;
|
|
15
|
-
export declare const FetcherMeta: ComponentMeta<FetcherProps>;
|
package/dist/executor.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PlasmicDataSourceContextValue } from "@plasmicapp/data-sources-context";
|
|
2
|
-
import { ManyRowsResult, Pagination, SingleRowResult } from "./types";
|
|
3
|
-
export interface DataOp {
|
|
4
|
-
sourceId: string;
|
|
5
|
-
opId: string;
|
|
6
|
-
userArgs?: Record<string, any>;
|
|
7
|
-
cacheKey?: string;
|
|
8
|
-
invalidatedKeys?: string[] | null;
|
|
9
|
-
roleId?: string | null;
|
|
10
|
-
}
|
|
11
|
-
interface ExecuteOpts {
|
|
12
|
-
userAuthToken?: string;
|
|
13
|
-
user?: PlasmicDataSourceContextValue["user"];
|
|
14
|
-
paginate?: Pagination;
|
|
15
|
-
}
|
|
16
|
-
export declare function executePlasmicDataOp<T extends SingleRowResult | ManyRowsResult>(op: DataOp, opts?: ExecuteOpts): Promise<T>;
|
|
17
|
-
export {};
|
package/dist/helpers.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ManyRowsResult, TableFieldSchema, TableSchema } from "./types";
|
|
2
|
-
export type QueryResult = Partial<ManyRowsResult<any>> & {
|
|
3
|
-
error?: any;
|
|
4
|
-
isLoading?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export interface NormalizedData {
|
|
7
|
-
data: Record<string, unknown>[];
|
|
8
|
-
schema?: TableSchema;
|
|
9
|
-
}
|
|
10
|
-
export declare function normalizeData(rawData: unknown): NormalizedData | undefined;
|
|
11
|
-
export declare function useNormalizedData(rawData: unknown): NormalizedData | undefined;
|
|
12
|
-
export type BaseFieldConfig = {
|
|
13
|
-
key?: string;
|
|
14
|
-
fieldId?: string;
|
|
15
|
-
};
|
|
16
|
-
export declare function deriveFieldConfigs<T extends BaseFieldConfig>(specifiedFieldsPartial: Partial<T>[], schema: TableSchema | undefined, makeDefaultConfig: (field: TableFieldSchema | undefined) => T): {
|
|
17
|
-
mergedFields: T[];
|
|
18
|
-
minimalFullLengthFields: Partial<T>[];
|
|
19
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DataOpConfig } from '../components/Fetcher';
|
|
2
|
-
import { DataOp } from '../executor';
|
|
3
|
-
export interface DependencyAwareQueryConfig extends DataOpConfig {
|
|
4
|
-
$queries: Record<string, any>;
|
|
5
|
-
setDollarQueries: ($queries: Record<string, any>) => void;
|
|
6
|
-
getDataOp: () => DataOp;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Prefer using `usePlasmicDataOp` directly instead.
|
|
10
|
-
*/
|
|
11
|
-
export declare function useDependencyAwareQuery({ $queries, getDataOp, setDollarQueries, name, pageIndex, pageSize, }: DependencyAwareQueryConfig): void;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { DataOp } from '../executor';
|
|
2
|
-
import { ManyRowsResult, Pagination, SingleRowResult } from '../types';
|
|
3
|
-
export declare function makeCacheKey(dataOp: DataOp, opts?: {
|
|
4
|
-
paginate?: Pagination;
|
|
5
|
-
userAuthToken?: string | null;
|
|
6
|
-
}): string;
|
|
7
|
-
/**
|
|
8
|
-
* Returns a function that can be used to invalidate Plasmic query groups.
|
|
9
|
-
*/
|
|
10
|
-
export declare function usePlasmicInvalidate(): (invalidatedKeys: string[] | null | undefined) => Promise<any[] | undefined>;
|
|
11
|
-
type ResolvableDataOp = DataOp | undefined | null | (() => DataOp | undefined | null);
|
|
12
|
-
export declare function usePlasmicDataOp<T extends SingleRowResult | ManyRowsResult, E = any>(dataOp: ResolvableDataOp, opts?: {
|
|
13
|
-
paginate?: Pagination;
|
|
14
|
-
noUndefinedDataProxy?: boolean;
|
|
15
|
-
}): Partial<T> & {
|
|
16
|
-
error?: E;
|
|
17
|
-
isLoading?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare function usePlasmicDataMutationOp<T extends SingleRowResult | ManyRowsResult>(dataOp: ResolvableDataOp): () => Promise<T | undefined>;
|
|
20
|
-
export {};
|
package/dist/placeholders.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function addPlaceholdersToUserArgs(userArgs: Record<string, any> | undefined): Record<string, any> | undefined;
|
package/dist/types.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface Pagination {
|
|
2
|
-
pageSize: number;
|
|
3
|
-
pageIndex: number;
|
|
4
|
-
}
|
|
5
|
-
export interface DataSourceSchema {
|
|
6
|
-
tables: TableSchema[];
|
|
7
|
-
}
|
|
8
|
-
export interface TableSchema {
|
|
9
|
-
id: string;
|
|
10
|
-
schema?: string;
|
|
11
|
-
label?: string;
|
|
12
|
-
fields: TableFieldSchema[];
|
|
13
|
-
}
|
|
14
|
-
export interface TableFieldSchema {
|
|
15
|
-
id: string;
|
|
16
|
-
label?: string;
|
|
17
|
-
type: TableFieldType;
|
|
18
|
-
readOnly: boolean;
|
|
19
|
-
primaryKey?: boolean;
|
|
20
|
-
options?: string[];
|
|
21
|
-
}
|
|
22
|
-
export type TableFieldType = "string" | "boolean" | "number" | "date" | "datetime" | "enum" | "json" | "unknown";
|
|
23
|
-
export interface SingleRowResult<T = any> {
|
|
24
|
-
data: T;
|
|
25
|
-
schema: TableSchema;
|
|
26
|
-
}
|
|
27
|
-
export interface ManyRowsResult<T = any> {
|
|
28
|
-
data: T[];
|
|
29
|
-
total?: number;
|
|
30
|
-
schema: TableSchema;
|
|
31
|
-
paginate?: Pagination;
|
|
32
|
-
}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare function swallow<T>(f: () => T): T | undefined;
|
|
3
|
-
export declare function pick<T extends object, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
|
4
|
-
type ReactElt = {
|
|
5
|
-
children: ReactElt | ReactElt[];
|
|
6
|
-
props: {
|
|
7
|
-
children: ReactElt | ReactElt[];
|
|
8
|
-
[prop: string]: any;
|
|
9
|
-
} | null;
|
|
10
|
-
type: React.ComponentType<any> | null;
|
|
11
|
-
key: string | null;
|
|
12
|
-
} | null;
|
|
13
|
-
export declare function traverseReactEltTree(children: React.ReactNode, callback: (elt: ReactElt) => void): void;
|
|
14
|
-
export declare function asArray<T>(x: T[] | T | undefined | null): T[];
|
|
15
|
-
export declare function ensureNumber(x: number | string): number;
|
|
16
|
-
export declare function ensure<T>(x: T | null | undefined): T;
|
|
17
|
-
export declare function isOneOf<T, U extends T>(elem: T, arr: readonly U[]): elem is U;
|
|
18
|
-
export declare function maybe<T, U>(x: T | undefined | null, f: (y: T) => U): U | undefined;
|
|
19
|
-
export declare function isLikeImage(value: unknown): false | RegExpMatchArray | null;
|
|
20
|
-
export declare function ensureArray<T>(xs: T | T[]): T[];
|
|
21
|
-
export declare const tuple: <T extends any[]>(...args: T) => T;
|
|
22
|
-
export interface HasId {
|
|
23
|
-
id: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function mkIdMap<T extends HasId>(xs: ReadonlyArray<T>): Map<string, T>;
|
|
26
|
-
export declare const mkShortId: () => string;
|
|
27
|
-
export declare function withoutNils<T>(xs: Array<T | undefined | null>): T[];
|
|
28
|
-
export type Falsey = null | undefined | false | '' | 0 | 0n;
|
|
29
|
-
export type Truthy<T> = T extends Falsey ? never : T;
|
|
30
|
-
export declare function withoutFalsey<T>(xs: Array<T | Falsey>): T[];
|
|
31
|
-
export {};
|