@meeovi/directus-client 1.0.6 → 1.0.7
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.
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { readItem, readItems, createItem, updateItem, deleteItem, uploadFiles, readSingleton, readFieldsByCollection
|
|
1
|
+
import { readItem, readItems, createItem, updateItem, deleteItem, uploadFiles, readSingleton, readFieldsByCollection } from '@directus/sdk';
|
|
2
|
+
import type { RestClient } from '@directus/sdk';
|
|
2
3
|
export interface MeeoviDirectusClient<Schema> {
|
|
3
|
-
client:
|
|
4
|
-
request:
|
|
4
|
+
client: RestClient<Schema>;
|
|
5
|
+
request: RestClient<Schema>['request'];
|
|
5
6
|
readItem: typeof readItem;
|
|
6
7
|
readItems: typeof readItems;
|
|
7
8
|
createItem: typeof createItem;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { DirectusField } from '../schema/types';
|
|
2
|
-
export
|
|
2
|
+
export interface TableColumn {
|
|
3
3
|
key: string;
|
|
4
4
|
label: string;
|
|
5
5
|
type: string;
|
|
6
|
-
|
|
6
|
+
sortable?: boolean;
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Convert Directus fields into a table schema.
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateTableSchema(fields: DirectusField[]): TableColumn[];
|
|
13
|
+
/**
|
|
14
|
+
* Fetch table rows from Directus.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fetchTableRows(directus: any, collection: string): Promise<any[]>;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert Directus fields into a table schema.
|
|
3
|
+
*/
|
|
1
4
|
export function generateTableSchema(fields) {
|
|
2
5
|
return fields
|
|
3
|
-
.filter(f => !f.hidden)
|
|
4
|
-
.map(f => ({
|
|
6
|
+
.filter((f) => !f.hidden)
|
|
7
|
+
.map((f) => ({
|
|
5
8
|
key: f.field,
|
|
6
|
-
label: f.field
|
|
7
|
-
type: f.type
|
|
9
|
+
label: prettifyLabel(f.field),
|
|
10
|
+
type: f.type,
|
|
11
|
+
sortable: true,
|
|
12
|
+
hidden: false
|
|
8
13
|
}));
|
|
9
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Convert "product_name" → "Product Name"
|
|
17
|
+
*/
|
|
18
|
+
function prettifyLabel(str) {
|
|
19
|
+
return str
|
|
20
|
+
.replace(/_/g, ' ')
|
|
21
|
+
.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetch table rows from Directus.
|
|
25
|
+
*/
|
|
26
|
+
export async function fetchTableRows(directus, collection) {
|
|
27
|
+
return await directus.request(directus.readItems(collection));
|
|
28
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as DirectusVueProvider } from './vue/DirectusProvider';
|
|
|
3
3
|
export * from './vue/useDirectus';
|
|
4
4
|
export { DirectusProvider as DirectusReactProvider } from './react/DirectusProvider';
|
|
5
5
|
export * from './react/useDirectus';
|
|
6
|
+
export * from './client/createClient';
|
|
6
7
|
export * from './schema/types';
|
|
7
8
|
export * from './schema/introspect';
|
|
8
9
|
export * from './utils/collections';
|
|
@@ -11,3 +12,5 @@ export * from './generators/form-engine';
|
|
|
11
12
|
export * from './generators/table-engine';
|
|
12
13
|
export * from './generators/validation-engine';
|
|
13
14
|
export * from './generators/widget-registry';
|
|
15
|
+
export * from './utils/visualEditing';
|
|
16
|
+
export * from './utils/livePreview';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from './vue/useDirectus';
|
|
|
7
7
|
export { DirectusProvider as DirectusReactProvider } from './react/DirectusProvider';
|
|
8
8
|
export * from './react/useDirectus';
|
|
9
9
|
// Schema + generators + utils
|
|
10
|
+
export * from './client/createClient';
|
|
10
11
|
export * from './schema/types';
|
|
11
12
|
export * from './schema/introspect';
|
|
12
13
|
export * from './utils/collections';
|
|
@@ -15,3 +16,5 @@ export * from './generators/form-engine';
|
|
|
15
16
|
export * from './generators/table-engine';
|
|
16
17
|
export * from './generators/validation-engine';
|
|
17
18
|
export * from './generators/widget-registry';
|
|
19
|
+
export * from './utils/visualEditing';
|
|
20
|
+
export * from './utils/livePreview';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meeovi/directus-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Directus Client Library with auto generating forms and tables, Directus SDK and Types, and vue/react components for Directus Visual Editing.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
package/src/index.ts
CHANGED
|
@@ -11,11 +11,18 @@ export { DirectusProvider as DirectusReactProvider } from './react/DirectusProvi
|
|
|
11
11
|
export * from './react/useDirectus';
|
|
12
12
|
|
|
13
13
|
// Schema + generators + utils
|
|
14
|
+
export * from './client/createClient';
|
|
15
|
+
|
|
14
16
|
export * from './schema/types';
|
|
15
17
|
export * from './schema/introspect';
|
|
18
|
+
|
|
16
19
|
export * from './utils/collections';
|
|
17
20
|
export * from './utils/fields';
|
|
21
|
+
|
|
18
22
|
export * from './generators/form-engine';
|
|
19
23
|
export * from './generators/table-engine';
|
|
20
24
|
export * from './generators/validation-engine';
|
|
21
25
|
export * from './generators/widget-registry';
|
|
26
|
+
|
|
27
|
+
export * from './utils/visualEditing';
|
|
28
|
+
export * from './utils/livePreview';
|