@journeyapps-labs/reactor-mod-data-browser 2.3.0 → 3.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/@types/actions/schema-model/ViewSchemaModelAsJsonAction.d.ts +9 -0
  3. package/dist/@types/core/AbstractConnection.d.ts +8 -0
  4. package/dist/@types/core/IndexModel.d.ts +12 -0
  5. package/dist/@types/core/SchemaModelDefinition.d.ts +4 -0
  6. package/dist/@types/core/types/ManualConnection.d.ts +2 -0
  7. package/dist/@types/entities/SchemaModelIndexDefinition.d.ts +7 -0
  8. package/dist/@types/entities.d.ts +1 -0
  9. package/dist/@types/forms/TypeEngine.d.ts +13 -2
  10. package/dist/@types/forms/inputs/DirtyWrapperInput.d.ts +1 -0
  11. package/dist/@types/index.d.ts +2 -0
  12. package/dist/@types/panels/_shared/SharedModelPanelFactory.d.ts +22 -0
  13. package/dist/@types/panels/model/ModelPanelFactory.d.ts +4 -20
  14. package/dist/@types/panels/model-json/ModelJsonPanelFactory.d.ts +27 -0
  15. package/dist/@types/panels/model-json/ModelJsonPanelWidget.d.ts +6 -0
  16. package/dist/DataBrowserModule.js +6 -0
  17. package/dist/DataBrowserModule.js.map +1 -1
  18. package/dist/actions/schema-model/ViewSchemaModelAsJsonAction.js +46 -0
  19. package/dist/actions/schema-model/ViewSchemaModelAsJsonAction.js.map +1 -0
  20. package/dist/core/AbstractConnection.js +14 -1
  21. package/dist/core/AbstractConnection.js.map +1 -1
  22. package/dist/core/IndexModel.js +12 -0
  23. package/dist/core/IndexModel.js.map +1 -0
  24. package/dist/core/SchemaModelDefinition.js +144 -110
  25. package/dist/core/SchemaModelDefinition.js.map +1 -1
  26. package/dist/core/query/widgets/CellDisplayWidget.js +14 -81
  27. package/dist/core/query/widgets/CellDisplayWidget.js.map +1 -1
  28. package/dist/core/types/ManualConnection.js +15 -0
  29. package/dist/core/types/ManualConnection.js.map +1 -1
  30. package/dist/entities/ConnectionEntityDefinition.js +5 -0
  31. package/dist/entities/ConnectionEntityDefinition.js.map +1 -1
  32. package/dist/entities/SchemaModelDefinitionEntityDefinition.js +16 -1
  33. package/dist/entities/SchemaModelDefinitionEntityDefinition.js.map +1 -1
  34. package/dist/entities/SchemaModelIndexDefinition.js +33 -0
  35. package/dist/entities/SchemaModelIndexDefinition.js.map +1 -0
  36. package/dist/entities.js +1 -0
  37. package/dist/entities.js.map +1 -1
  38. package/dist/forms/SchemaModelForm.js +1 -1
  39. package/dist/forms/SchemaModelForm.js.map +1 -1
  40. package/dist/forms/TypeEngine.js +223 -5
  41. package/dist/forms/TypeEngine.js.map +1 -1
  42. package/dist/forms/inputs/DirtyWrapperInput.js +14 -0
  43. package/dist/forms/inputs/DirtyWrapperInput.js.map +1 -1
  44. package/dist/forms/inputs/LocationInput.js +13 -7
  45. package/dist/forms/inputs/LocationInput.js.map +1 -1
  46. package/dist/index.js +2 -0
  47. package/dist/index.js.map +1 -1
  48. package/dist/panels/_shared/SharedModelPanelFactory.js +77 -0
  49. package/dist/panels/_shared/SharedModelPanelFactory.js.map +1 -0
  50. package/dist/panels/model/ModelPanelFactory.js +7 -75
  51. package/dist/panels/model/ModelPanelFactory.js.map +1 -1
  52. package/dist/panels/model-json/ModelJsonPanelFactory.js +62 -0
  53. package/dist/panels/model-json/ModelJsonPanelFactory.js.map +1 -0
  54. package/dist/panels/model-json/ModelJsonPanelWidget.js +70 -0
  55. package/dist/panels/model-json/ModelJsonPanelWidget.js.map +1 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/dist-module/bundle.js +47 -26
  58. package/dist-module/bundle.js.map +1 -1
  59. package/package.json +14 -11
  60. package/src/DataBrowserModule.ts +6 -0
  61. package/src/actions/schema-model/ViewSchemaModelAsJsonAction.ts +33 -0
  62. package/src/core/AbstractConnection.ts +21 -2
  63. package/src/core/IndexModel.ts +18 -0
  64. package/src/core/SchemaModelDefinition.ts +19 -1
  65. package/src/core/query/widgets/CellDisplayWidget.tsx +15 -106
  66. package/src/core/types/ManualConnection.ts +16 -0
  67. package/src/entities/ConnectionEntityDefinition.tsx +5 -0
  68. package/src/entities/SchemaModelDefinitionEntityDefinition.ts +23 -0
  69. package/src/entities/SchemaModelIndexDefinition.ts +43 -0
  70. package/src/entities.ts +1 -0
  71. package/src/forms/SchemaModelForm.tsx +1 -1
  72. package/src/forms/TypeEngine.tsx +451 -0
  73. package/src/forms/inputs/DirtyWrapperInput.tsx +20 -0
  74. package/src/forms/inputs/LocationInput.tsx +14 -7
  75. package/src/index.ts +6 -0
  76. package/src/panels/_shared/SharedModelPanelFactory.tsx +54 -0
  77. package/src/panels/model/ModelPanelFactory.tsx +10 -51
  78. package/src/panels/model-json/ModelJsonPanelFactory.tsx +61 -0
  79. package/src/panels/model-json/ModelJsonPanelWidget.tsx +92 -0
  80. package/webpack.config.js +9 -2
  81. package/src/forms/TypeEngine.ts +0 -160
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@journeyapps-labs/reactor-mod-data-browser",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "main": "./dist/index.js",
5
5
  "typings": "./dist/@types/index",
6
6
  "publishConfig": {
@@ -15,27 +15,30 @@
15
15
  "license": "Apache-2.0",
16
16
  "dependencies": {
17
17
  "@emotion/styled": "^11.14.1",
18
- "@fortawesome/react-fontawesome": "^3.0.2",
18
+ "@fortawesome/react-fontawesome": "^3.1.0",
19
+ "@journeyapps-labs/client-backend-v4": "1.0.0",
19
20
  "@journeyapps-labs/common-ioc": "^1.0.0",
20
- "@journeyapps-labs/common-utils": "^1.0.0",
21
- "@journeyapps-labs/lib-reactor-data-layer": "^1.0.4",
22
- "@journeyapps-labs/reactor-mod": "^2.0.0",
21
+ "@journeyapps-labs/common-sdk": "^1.0.2",
22
+ "@journeyapps-labs/common-utils": "^1.0.1",
23
+ "@journeyapps-labs/lib-reactor-data-layer": "^1.0.5",
24
+ "@journeyapps-labs/reactor-mod": "2.1.1",
25
+ "@journeyapps-labs/reactor-mod-editor": "^1.1.7",
23
26
  "@journeyapps/db": "^8.1.1",
24
27
  "@journeyapps/parser-schema": "^8.2.5",
25
28
  "@projectstorm/react-workspaces-core": "4.2.2",
26
29
  "async": "^3.2.6",
27
30
  "lodash": "^4.17.21",
28
- "mobx": "^6.13.7",
29
- "mobx-react": "^9.2.0",
30
- "react": "19.1.1",
31
+ "mobx": "^6.15.0",
32
+ "mobx-react": "^9.2.1",
33
+ "react": "19.2.0",
31
34
  "uuid": "^13.0.0"
32
35
  },
33
36
  "devDependencies": {
34
37
  "@types/async": "^3.2.25",
35
- "@types/react": "^19.1.12",
36
- "@journeyapps-labs/lib-reactor-builder": "^2.0.0",
38
+ "@types/react": "^19.2.2",
39
+ "@journeyapps-labs/lib-reactor-builder": "^2.0.1",
37
40
  "@types/lodash": "^4.17.20",
38
- "@types/uuid": "^10.0.0"
41
+ "@types/uuid": "^11.0.0"
39
42
  },
40
43
  "scripts": {
41
44
  "build:module": "reactor build .",
@@ -15,6 +15,9 @@ import { CreateModelAction } from './actions/schema-definitions/CreateModelActio
15
15
  import { SchemaModelObjectEntityDefinition } from './entities/SchemaModelObjectEntityDefinition';
16
16
  import { EditSchemaModelAction } from './actions/schema-model/EditSchemaModelAction';
17
17
  import { TypeEngine } from './forms/TypeEngine';
18
+ import { ViewSchemaModelAsJsonAction } from './actions/schema-model/ViewSchemaModelAsJsonAction';
19
+ import { ModelJsonPanelFactory } from './panels/model-json/ModelJsonPanelFactory';
20
+ import { SchemaModelIndexDefinition } from './entities/SchemaModelIndexDefinition';
18
21
 
19
22
  export class DataBrowserModule extends AbstractReactorModule {
20
23
  constructor() {
@@ -37,6 +40,7 @@ export class DataBrowserModule extends AbstractReactorModule {
37
40
  system.registerAction(new QuerySchemaModelAction());
38
41
  system.registerAction(new CreateModelAction());
39
42
  system.registerAction(new EditSchemaModelAction());
43
+ system.registerAction(new ViewSchemaModelAsJsonAction());
40
44
 
41
45
  system.addStore(ConnectionStore, connectionStore);
42
46
 
@@ -44,10 +48,12 @@ export class DataBrowserModule extends AbstractReactorModule {
44
48
  system.registerDefinition(new ConnectionFactoryEntityDefinition());
45
49
  system.registerDefinition(new SchemaModelDefinitionEntityDefinition());
46
50
  system.registerDefinition(new SchemaModelObjectEntityDefinition());
51
+ system.registerDefinition(new SchemaModelIndexDefinition());
47
52
  system.registerDefinition(new QueryEntityDefinition());
48
53
 
49
54
  workspaceStore.registerFactory(new QueryPanelFactory());
50
55
  workspaceStore.registerFactory(new ModelPanelFactory());
56
+ workspaceStore.registerFactory(new ModelJsonPanelFactory());
51
57
  }
52
58
 
53
59
  async init(ioc: Container): Promise<any> {
@@ -0,0 +1,33 @@
1
+ import { EntityAction, EntityActionEvent, inject, ioc, System, WorkspaceStore } from '@journeyapps-labs/reactor-mod';
2
+ import { DataBrowserEntities } from '../../entities';
3
+ import { SchemaModelObject } from '../../core/SchemaModelObject';
4
+ import { ModelJsonPanelModel } from '../../panels/model-json/ModelJsonPanelFactory';
5
+
6
+ export class ViewSchemaModelAsJsonAction extends EntityAction<SchemaModelObject> {
7
+ static ID = 'VIEW_SCHEMA_MODEL_AS_JSON';
8
+
9
+ @inject(WorkspaceStore)
10
+ accessor workspaceStore: WorkspaceStore;
11
+
12
+ constructor() {
13
+ super({
14
+ id: ViewSchemaModelAsJsonAction.ID,
15
+ name: 'View schema model as JSON',
16
+ icon: 'eye',
17
+ target: DataBrowserEntities.SCHEMA_MODEL_OBJECT
18
+ });
19
+ }
20
+
21
+ async fireEvent(event: EntityActionEvent<SchemaModelObject>): Promise<any> {
22
+ this.workspaceStore.addModel(
23
+ new ModelJsonPanelModel({
24
+ definition: event.targetEntity.definition,
25
+ model: event.targetEntity
26
+ })
27
+ );
28
+ }
29
+
30
+ static get() {
31
+ return ioc.get(System).getActionByID<ViewSchemaModelAsJsonAction>(ViewSchemaModelAsJsonAction.ID);
32
+ }
33
+ }
@@ -1,4 +1,4 @@
1
- import { Database, ObjectType, Query } from '@journeyapps/db';
1
+ import { Database, ObjectType } from '@journeyapps/db';
2
2
  import { Schema } from '@journeyapps/parser-schema';
3
3
  import { AbstractConnectionFactory } from './AbstractConnectionFactory';
4
4
  import * as _ from 'lodash';
@@ -8,6 +8,7 @@ import { BaseObserver } from '@journeyapps-labs/common-utils';
8
8
  import { Collection, LifecycleCollection } from '@journeyapps-labs/lib-reactor-data-layer';
9
9
  import { when } from 'mobx';
10
10
  import { EntityDescription } from '@journeyapps-labs/reactor-mod';
11
+ import { V4BackendClient, V4Index, V4Indexes } from '@journeyapps-labs/client-backend-v4';
11
12
  import { SchemaModelObject } from './SchemaModelObject';
12
13
 
13
14
  export interface AbstractConnectionSerialized {
@@ -25,6 +26,7 @@ export abstract class AbstractConnection extends BaseObserver<AbstractConnection
25
26
 
26
27
  schema_models_collection: Collection<ObjectType>;
27
28
  schema_models: LifecycleCollection<ObjectType, SchemaModelDefinition>;
29
+ private fetch_indexes_promise: Promise<V4Indexes['models']>;
28
30
 
29
31
  constructor(public factory: AbstractConnectionFactory) {
30
32
  super();
@@ -33,10 +35,13 @@ export abstract class AbstractConnection extends BaseObserver<AbstractConnection
33
35
  this.schema_models = new LifecycleCollection({
34
36
  collection: this.schema_models_collection,
35
37
  generateModel: (o) => {
36
- return new SchemaModelDefinition({
38
+ let model = new SchemaModelDefinition({
37
39
  definition: o,
38
40
  connection: this
39
41
  });
42
+
43
+ model.init();
44
+ return model;
40
45
  },
41
46
  getKeyForSerialized: (o) => {
42
47
  return o.name;
@@ -44,6 +49,20 @@ export abstract class AbstractConnection extends BaseObserver<AbstractConnection
44
49
  });
45
50
  }
46
51
 
52
+ abstract getBackendClient(): V4BackendClient;
53
+
54
+ async getIndexes() {
55
+ if (!this.fetch_indexes_promise) {
56
+ this.fetch_indexes_promise = this.getBackendClient()
57
+ .getIndexes()
58
+ .then((res) => res.models)
59
+ .finally(() => {
60
+ this.fetch_indexes_promise = null;
61
+ });
62
+ }
63
+ return this.fetch_indexes_promise;
64
+ }
65
+
47
66
  async batchSave(models: SchemaModelObject[]) {
48
67
  if (models.length === 0) {
49
68
  return;
@@ -0,0 +1,18 @@
1
+ import { SchemaModelDefinition } from './SchemaModelDefinition';
2
+ import { V4Index } from '@journeyapps-labs/client-backend-v4';
3
+
4
+ export interface IndexModelOptions {
5
+ definition: SchemaModelDefinition;
6
+ index: V4Index;
7
+ }
8
+ export class IndexModel {
9
+ constructor(protected options: IndexModelOptions) {}
10
+
11
+ get index() {
12
+ return this.options.index;
13
+ }
14
+
15
+ get definition() {
16
+ return this.options.definition;
17
+ }
18
+ }
@@ -6,6 +6,9 @@ import { LifecycleModel } from '@journeyapps-labs/lib-reactor-data-layer';
6
6
  import { BaseObserver } from '@journeyapps-labs/common-utils';
7
7
  import { queue, QueueObject } from 'async';
8
8
  import { v4 } from 'uuid';
9
+ import { V4Index } from '@journeyapps-labs/client-backend-v4';
10
+ import { action, observable } from 'mobx';
11
+ import { IndexModel } from './IndexModel';
9
12
 
10
13
  export interface SchemaModelDefinitionListener {
11
14
  resolved: (event: { object: SchemaModelObject }) => any;
@@ -24,14 +27,18 @@ export class SchemaModelDefinition
24
27
  queue: QueueObject<string>;
25
28
  enqueued: Set<string>;
26
29
 
30
+ @observable
31
+ accessor indexes: IndexModel[];
32
+
27
33
  constructor(protected options: SchemaModelDefinitionOptions) {
28
34
  super();
29
35
  this.cache = new Map<string, SchemaModelObject>();
30
36
  this.enqueued = new Set<string>();
37
+ this.indexes = [];
31
38
  this.queue = queue(async (id) => {
32
39
  let collection = await this.getCollection();
33
40
  try {
34
- let models = await this.executeQuery(collection.where(`id = ?`, id));
41
+ let models = await this.executeQuery(collection.where(`id = ?`, id).limit(1));
35
42
  if (models[0]) {
36
43
  this.cache.set(id, models[0]);
37
44
  this.enqueued.delete(id);
@@ -48,6 +55,17 @@ export class SchemaModelDefinition
48
55
  }, 6);
49
56
  }
50
57
 
58
+ async loadIndexes() {
59
+ let indexes = await this.connection.getIndexes();
60
+ this.indexes = (indexes[this.definition.name]?.indexes || []).map(
61
+ (i) => new IndexModel({ definition: this, index: i })
62
+ );
63
+ }
64
+
65
+ async init() {
66
+ await this.loadIndexes();
67
+ }
68
+
51
69
  async search(text: string): Promise<SchemaModelObject[]> {
52
70
  let collection = await this.getCollection();
53
71
  let adapter = collection.adapter as JourneyAPIAdapter;
@@ -1,12 +1,4 @@
1
- import {
2
- CheckboxWidget,
3
- ImageMedia,
4
- ioc,
5
- MetadataWidget,
6
- SmartDateDisplayWidget,
7
- styled
8
- } from '@journeyapps-labs/reactor-mod';
9
- import { Attachment, Day, Location } from '@journeyapps/db';
1
+ import { ioc, SmartDateDisplayWidget, styled } from '@journeyapps-labs/reactor-mod';
10
2
  import * as _ from 'lodash';
11
3
  import * as React from 'react';
12
4
  import { PageRow } from '../Page';
@@ -16,33 +8,6 @@ namespace S {
16
8
  export const Empty = styled.div`
17
9
  opacity: 0.2;
18
10
  `;
19
-
20
- export const Preview = styled.img`
21
- max-height: 40px;
22
- max-width: 40px;
23
- cursor: pointer;
24
- `;
25
-
26
- export const pill = styled.div`
27
- padding: 2px 4px;
28
- background: ${(p) => p.theme.table.pills};
29
- border-radius: 3px;
30
- font-size: 12px;
31
- `;
32
-
33
- export const Pills = styled.div`
34
- display: flex;
35
- column-gap: 2px;
36
- row-gap: 2px;
37
- `;
38
-
39
- export const Max = styled.div`
40
- max-width: 500px;
41
- white-space: pre;
42
- display: inline;
43
- overflow: hidden;
44
- text-overflow: ellipsis;
45
- `;
46
11
  }
47
12
 
48
13
  export interface CellDisplayWidgetProps {
@@ -51,83 +16,27 @@ export interface CellDisplayWidgetProps {
51
16
  name: string;
52
17
  }
53
18
 
54
- const MAX_NUMBER_OF_ARR_ITEMS_TO_DISPLAY = 3;
55
-
56
19
  export const CellDisplayWidget: React.FC<CellDisplayWidgetProps> = (props) => {
57
20
  const { row, cell, name } = props;
58
21
  if (cell == null) {
59
22
  return <S.Empty>null</S.Empty>;
60
23
  }
61
- if (_.isString(cell)) {
62
- if (cell.trim() === '') {
63
- return <S.Empty>empty</S.Empty>;
64
- }
65
- return <S.Max>{cell}</S.Max>;
66
- }
67
- if (_.isNumber(cell)) {
68
- return cell;
69
- }
70
- if (_.isArray(cell)) {
71
- if (cell.length === 0) {
72
- return <S.Empty>empty array</S.Empty>;
73
- }
74
- let items = _.slice(cell, 0, MAX_NUMBER_OF_ARR_ITEMS_TO_DISPLAY);
75
- return (
76
- <S.Pills>
77
- {items.map((c) => {
78
- return <S.pill key={c}>{c}</S.pill>;
79
- })}
80
- {items.length !== cell.length ? '...' : null}
81
- </S.Pills>
82
- );
83
- }
84
- if (cell instanceof Date) {
24
+
25
+ if (name === 'updated_at') {
85
26
  return <SmartDateDisplayWidget date={cell} />;
86
27
  }
87
- if (cell instanceof Day) {
88
- return <SmartDateDisplayWidget date={cell.toDate()} />;
89
- }
90
- if (_.isBoolean(cell)) {
91
- return (
92
- <CheckboxWidget
93
- checked={cell}
94
- onChange={(checked) => {
95
- row.model.set(name, checked);
96
- }}
97
- />
98
- );
99
- }
100
- if (cell instanceof Location) {
101
- return (
102
- <>
103
- <MetadataWidget label={'Lat'} value={`${cell.latitude}`} />
104
- <MetadataWidget label={'Long'} value={`${cell.longitude}`} />
105
- </>
106
- );
107
- }
108
- if (cell instanceof Attachment) {
109
- if (cell.uploaded()) {
110
- return (
111
- <S.Preview
112
- onClick={() => {
113
- ioc
114
- .get(TypeEngine)
115
- .getHandler(row.definition.definition.attributes[name].type)
116
- .decode(cell)
117
- .then((media: ImageMedia) => {
118
- if (media instanceof ImageMedia) {
119
- media.open();
120
- } else {
121
- window.open(cell.url(), '_blank');
122
- }
123
- });
124
- }}
125
- src={cell.urls['thumbnail']}
126
- />
127
- );
128
- }
129
- return <S.Empty>Not uploaded</S.Empty>;
28
+
29
+ let display = ioc.get(TypeEngine).getHandler(row.definition.definition.attributes[name].type)?.generateDisplay({
30
+ model: row.model,
31
+ value: cell,
32
+ label: row.definition.definition.attributes[name].label,
33
+ name,
34
+ type: row.definition.definition.attributes[name].type
35
+ });
36
+ if (display) {
37
+ return display;
130
38
  }
131
- console.log('unknown type', cell);
39
+
40
+ console.log('unknown type', cell, row.definition.definition.attributes[name].type);
132
41
  return null;
133
42
  };
@@ -2,6 +2,9 @@ import { ApiCredentialOptions, Database } from '@journeyapps/db';
2
2
  import { AbstractConnection } from '../AbstractConnection';
3
3
  import { ManualConnectionFactory } from './ManualConnectionFactory';
4
4
  import { EntityDescription } from '@journeyapps-labs/reactor-mod';
5
+ import { createWebNetworkClient } from '@journeyapps-labs/common-sdk';
6
+ import { V4BackendClient } from '@journeyapps-labs/client-backend-v4';
7
+ import * as path from 'path';
5
8
 
6
9
  export interface ManualConnectionDetails extends ApiCredentialOptions {
7
10
  name: string;
@@ -32,4 +35,17 @@ export class ManualConnection extends AbstractConnection {
32
35
  simpleName: this.options.name
33
36
  };
34
37
  }
38
+
39
+ getBackendClient(): V4BackendClient {
40
+ let url = new URL(this.options.baseUrl);
41
+ return new V4BackendClient({
42
+ account_id: path.basename(url.pathname),
43
+ endpoint: `${url.origin}`,
44
+ client: createWebNetworkClient({
45
+ headers: {
46
+ Authorization: `Bearer ${this.options.token}`
47
+ }
48
+ })
49
+ });
50
+ }
35
51
  }
@@ -50,6 +50,11 @@ export class ConnectionEntityDefinition extends EntityDefinition<AbstractConnect
50
50
  descendantType: DataBrowserEntities.SCHEMA_MODEL_DEFINITION,
51
51
  generateOptions: (parent) => {
52
52
  return {
53
+ category: {
54
+ label: 'Models',
55
+ icon: 'cube',
56
+ openDefault: true
57
+ },
53
58
  descendants: parent.schema_models.items
54
59
  };
55
60
  }
@@ -1,4 +1,6 @@
1
1
  import {
2
+ DescendantEntityProviderComponent,
3
+ EntityActionHandlerComponent,
2
4
  EntityDefinition,
3
5
  EntityDescriberComponent,
4
6
  inject,
@@ -10,6 +12,9 @@ import { DataBrowserEntities } from '../entities';
10
12
  import { ConnectionStore } from '../stores/ConnectionStore';
11
13
  import { AbstractConnection } from '../core/AbstractConnection';
12
14
  import { SchemaModelDefinition } from '../core/SchemaModelDefinition';
15
+ import { QuerySchemaModelAction } from '../actions/schema-definitions/QuerySchemaModelAction';
16
+ import { V4Index } from '@journeyapps-labs/client-backend-v4';
17
+ import { IndexModel } from '../core/IndexModel';
13
18
 
14
19
  export interface SchemaModelDefinitionEntityDefinitionEncoded {
15
20
  connection_id: string;
@@ -41,6 +46,22 @@ export class SchemaModelDefinitionEntityDefinition extends EntityDefinition<Sche
41
46
  })
42
47
  );
43
48
 
49
+ this.registerComponent(
50
+ new DescendantEntityProviderComponent<SchemaModelDefinition, IndexModel>({
51
+ descendantType: DataBrowserEntities.SCHEMA_MODEL_INDEX,
52
+ generateOptions: (parent) => {
53
+ return {
54
+ category: {
55
+ label: 'Indexes',
56
+ icon: 'search',
57
+ openDefault: false
58
+ },
59
+ descendants: parent.indexes
60
+ };
61
+ }
62
+ })
63
+ );
64
+
44
65
  this.registerComponent(
45
66
  new InlineEntityEncoderComponent<SchemaModelDefinition, SchemaModelDefinitionEntityDefinitionEncoded>({
46
67
  version: 1,
@@ -68,6 +89,8 @@ export class SchemaModelDefinitionEntityDefinition extends EntityDefinition<Sche
68
89
  }
69
90
  })
70
91
  );
92
+
93
+ this.registerComponent(new EntityActionHandlerComponent(QuerySchemaModelAction.ID));
71
94
  }
72
95
 
73
96
  matchEntity(t: any): boolean {
@@ -0,0 +1,43 @@
1
+ import {
2
+ EntityDefinition,
3
+ EntityDescriberComponent,
4
+ InlineTreePresenterComponent
5
+ } from '@journeyapps-labs/reactor-mod';
6
+ import { DataBrowserEntities } from '../entities';
7
+ import { IndexModel } from '../core/IndexModel';
8
+
9
+ export class SchemaModelIndexDefinition extends EntityDefinition<IndexModel> {
10
+ constructor() {
11
+ super({
12
+ type: DataBrowserEntities.SCHEMA_MODEL_INDEX,
13
+ category: 'DataBrowser',
14
+ label: 'Schema model index',
15
+ icon: 'search',
16
+ iconColor: 'cyan'
17
+ });
18
+
19
+ this.registerComponent(
20
+ new EntityDescriberComponent<IndexModel>({
21
+ label: 'Simple',
22
+ describe: (entity: IndexModel) => {
23
+ return {
24
+ simpleName: entity.index.name,
25
+ complexName: entity.index.type
26
+ };
27
+ }
28
+ })
29
+ );
30
+
31
+ this.registerComponent(new InlineTreePresenterComponent());
32
+ }
33
+
34
+ matchEntity(t: any): boolean {
35
+ if (t instanceof IndexModel) {
36
+ return true;
37
+ }
38
+ }
39
+
40
+ getEntityUID(t: IndexModel) {
41
+ return `${t.definition.definition.media}-${t.index.name}`;
42
+ }
43
+ }
package/src/entities.ts CHANGED
@@ -2,6 +2,7 @@ export enum DataBrowserEntities {
2
2
  CONNECTION = 'databrowser/connection',
3
3
  CONNECTION_FACTORY = 'databrowser/connection_factory',
4
4
  SCHEMA_MODEL_DEFINITION = 'databrowser/schema_model_definition',
5
+ SCHEMA_MODEL_INDEX = 'databrowser/schema_model_index',
5
6
  SCHEMA_MODEL_OBJECT = 'databrowser/schema_model_object',
6
7
  QUERY = 'databrowser/query'
7
8
  }
@@ -42,7 +42,7 @@ export class Binding {
42
42
  });
43
43
  this.listener1 = autorun(async () => {
44
44
  let value = model.patch.get(name);
45
- if (value == null) {
45
+ if (!model.patch.has(name)) {
46
46
  value = await options.resolve();
47
47
  }
48
48
  this.setting_value_via_autorun = true;