@journeyapps-labs/reactor-mod-data-browser 2.4.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.
- package/CHANGELOG.md +6 -0
- package/dist/@types/core/AbstractConnection.d.ts +8 -0
- package/dist/@types/core/IndexModel.d.ts +12 -0
- package/dist/@types/core/SchemaModelDefinition.d.ts +4 -0
- package/dist/@types/core/types/ManualConnection.d.ts +2 -0
- package/dist/@types/entities/SchemaModelIndexDefinition.d.ts +7 -0
- package/dist/@types/entities.d.ts +1 -0
- package/dist/DataBrowserModule.js +2 -0
- package/dist/DataBrowserModule.js.map +1 -1
- package/dist/core/AbstractConnection.js +14 -1
- package/dist/core/AbstractConnection.js.map +1 -1
- package/dist/core/IndexModel.js +12 -0
- package/dist/core/IndexModel.js.map +1 -0
- package/dist/core/SchemaModelDefinition.js +144 -110
- package/dist/core/SchemaModelDefinition.js.map +1 -1
- package/dist/core/types/ManualConnection.js +15 -0
- package/dist/core/types/ManualConnection.js.map +1 -1
- package/dist/entities/SchemaModelDefinitionEntityDefinition.js +14 -1
- package/dist/entities/SchemaModelDefinitionEntityDefinition.js.map +1 -1
- package/dist/entities/SchemaModelIndexDefinition.js +33 -0
- package/dist/entities/SchemaModelIndexDefinition.js.map +1 -0
- package/dist/entities.js +1 -0
- package/dist/entities.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist-module/bundle.js +22 -22
- package/dist-module/bundle.js.map +1 -1
- package/package.json +7 -5
- package/src/DataBrowserModule.ts +2 -0
- package/src/core/AbstractConnection.ts +21 -2
- package/src/core/IndexModel.ts +18 -0
- package/src/core/SchemaModelDefinition.ts +18 -0
- package/src/core/types/ManualConnection.ts +16 -0
- package/src/entities/SchemaModelDefinitionEntityDefinition.ts +19 -0
- package/src/entities/SchemaModelIndexDefinition.ts +43 -0
- package/src/entities.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeyapps-labs/reactor-mod-data-browser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"typings": "./dist/@types/index",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@emotion/styled": "^11.14.1",
|
|
18
|
-
"@fortawesome/react-fontawesome": "^3.0
|
|
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-
|
|
21
|
+
"@journeyapps-labs/common-sdk": "^1.0.2",
|
|
22
|
+
"@journeyapps-labs/common-utils": "^1.0.1",
|
|
21
23
|
"@journeyapps-labs/lib-reactor-data-layer": "^1.0.5",
|
|
22
24
|
"@journeyapps-labs/reactor-mod": "2.1.1",
|
|
23
25
|
"@journeyapps-labs/reactor-mod-editor": "^1.1.7",
|
|
@@ -28,12 +30,12 @@
|
|
|
28
30
|
"lodash": "^4.17.21",
|
|
29
31
|
"mobx": "^6.15.0",
|
|
30
32
|
"mobx-react": "^9.2.1",
|
|
31
|
-
"react": "19.
|
|
33
|
+
"react": "19.2.0",
|
|
32
34
|
"uuid": "^13.0.0"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@types/async": "^3.2.25",
|
|
36
|
-
"@types/react": "^19.
|
|
38
|
+
"@types/react": "^19.2.2",
|
|
37
39
|
"@journeyapps-labs/lib-reactor-builder": "^2.0.1",
|
|
38
40
|
"@types/lodash": "^4.17.20",
|
|
39
41
|
"@types/uuid": "^11.0.0"
|
package/src/DataBrowserModule.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { EditSchemaModelAction } from './actions/schema-model/EditSchemaModelAct
|
|
|
17
17
|
import { TypeEngine } from './forms/TypeEngine';
|
|
18
18
|
import { ViewSchemaModelAsJsonAction } from './actions/schema-model/ViewSchemaModelAsJsonAction';
|
|
19
19
|
import { ModelJsonPanelFactory } from './panels/model-json/ModelJsonPanelFactory';
|
|
20
|
+
import { SchemaModelIndexDefinition } from './entities/SchemaModelIndexDefinition';
|
|
20
21
|
|
|
21
22
|
export class DataBrowserModule extends AbstractReactorModule {
|
|
22
23
|
constructor() {
|
|
@@ -47,6 +48,7 @@ export class DataBrowserModule extends AbstractReactorModule {
|
|
|
47
48
|
system.registerDefinition(new ConnectionFactoryEntityDefinition());
|
|
48
49
|
system.registerDefinition(new SchemaModelDefinitionEntityDefinition());
|
|
49
50
|
system.registerDefinition(new SchemaModelObjectEntityDefinition());
|
|
51
|
+
system.registerDefinition(new SchemaModelIndexDefinition());
|
|
50
52
|
system.registerDefinition(new QueryEntityDefinition());
|
|
51
53
|
|
|
52
54
|
workspaceStore.registerFactory(new QueryPanelFactory());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Database, ObjectType
|
|
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
|
-
|
|
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,10 +27,14 @@ 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 {
|
|
@@ -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;
|
|
@@ -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
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DescendantEntityProviderComponent,
|
|
2
3
|
EntityActionHandlerComponent,
|
|
3
4
|
EntityDefinition,
|
|
4
5
|
EntityDescriberComponent,
|
|
@@ -12,6 +13,8 @@ import { ConnectionStore } from '../stores/ConnectionStore';
|
|
|
12
13
|
import { AbstractConnection } from '../core/AbstractConnection';
|
|
13
14
|
import { SchemaModelDefinition } from '../core/SchemaModelDefinition';
|
|
14
15
|
import { QuerySchemaModelAction } from '../actions/schema-definitions/QuerySchemaModelAction';
|
|
16
|
+
import { V4Index } from '@journeyapps-labs/client-backend-v4';
|
|
17
|
+
import { IndexModel } from '../core/IndexModel';
|
|
15
18
|
|
|
16
19
|
export interface SchemaModelDefinitionEntityDefinitionEncoded {
|
|
17
20
|
connection_id: string;
|
|
@@ -43,6 +46,22 @@ export class SchemaModelDefinitionEntityDefinition extends EntityDefinition<Sche
|
|
|
43
46
|
})
|
|
44
47
|
);
|
|
45
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
|
+
|
|
46
65
|
this.registerComponent(
|
|
47
66
|
new InlineEntityEncoderComponent<SchemaModelDefinition, SchemaModelDefinitionEntityDefinitionEncoded>({
|
|
48
67
|
version: 1,
|
|
@@ -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
|
}
|