@docupace/ihub-config 1.1.19 → 1.1.20
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/README.md +182 -182
- package/dist/model/graphs/config/common.graphql +7 -7
- package/dist/model/graphs/config/fields.graphql +382 -379
- package/dist/model/graphs/config/menu.graphql +54 -54
- package/dist/model/graphs/config/mutation.graphql +30 -30
- package/dist/model/graphs/config/page.graphql +256 -256
- package/dist/model/graphs/config/panel.graphql +30 -30
- package/dist/model/graphs/config/query.graphql +84 -84
- package/dist/model/graphs/config/rules.graphql +80 -80
- package/dist/model/graphs/config/selectOptions.graphql +47 -47
- package/dist/model/graphs/config/table.graphql +182 -182
- package/dist/model/graphs/config/tests.graphql +16 -16
- package/dist/model/graphs/config/theme.graphql +41 -41
- package/dist/model/graphs/config/ui-components.graphql +10 -10
- package/dist/model/graphs/domains/scalars.graphql +3 -3
- package/dist/model/graphs/filter.graphql +5 -5
- package/dist/model/graphs/schema.graphql +7 -7
- package/dist/types/graphql.d.ts +317 -2
- package/dist/types/graphql.d.ts.map +1 -1
- package/dist/types/graphql.js.map +1 -1
- package/model/graphs/config/common.graphql +7 -7
- package/model/graphs/config/fields.graphql +382 -379
- package/model/graphs/config/menu.graphql +54 -54
- package/model/graphs/config/mutation.graphql +30 -30
- package/model/graphs/config/page.graphql +256 -256
- package/model/graphs/config/panel.graphql +30 -30
- package/model/graphs/config/query.graphql +84 -84
- package/model/graphs/config/rules.graphql +80 -80
- package/model/graphs/config/selectOptions.graphql +47 -47
- package/model/graphs/config/table.graphql +182 -182
- package/model/graphs/config/tests.graphql +16 -16
- package/model/graphs/config/theme.graphql +41 -41
- package/model/graphs/config/ui-components.graphql +10 -10
- package/model/graphs/domains/scalars.graphql +3 -3
- package/model/graphs/filter.graphql +5 -5
- package/model/graphs/schema.graphql +7 -7
- package/package.json +81 -79
package/README.md
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
# @docupace/ihub-config
|
|
2
|
-
|
|
3
|
-
Reusable GraphQL config extension and standalone server extracted from the
|
|
4
|
-
Docupace GraphQL server.
|
|
5
|
-
|
|
6
|
-
## Run locally
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
pnpm install
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
To run the package as a standalone GraphQL server, copy
|
|
13
|
-
`.env.example` to `.env`, fill in the required values, and start the dev
|
|
14
|
-
server:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
cp .env.example .env
|
|
18
|
-
pnpm start:dev
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
The standalone server listens on `http://localhost:4000/api/graphql`.
|
|
22
|
-
|
|
23
|
-
## Use as an extension in another server
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
import { getConfigExtension } from '@docupace/ihub-config';
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Then add the returned extension to the host server's extensions array:
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
const configExtension = await getConfigExtension();
|
|
33
|
-
|
|
34
|
-
const serverInfo: ServerConfig = {
|
|
35
|
-
instanceConfig: instanceConfig,
|
|
36
|
-
extensions: [docupaceExtension, configExtension],
|
|
37
|
-
port: 4000,
|
|
38
|
-
createContext,
|
|
39
|
-
};
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Extend the config extension with domain-specific providers, resolvers, etc.
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
import { getConfigExtension } from '@docupace/ihub-config';
|
|
46
|
-
import {
|
|
47
|
-
DashboardPageConfigProvider,
|
|
48
|
-
TablePageConfigProvider,
|
|
49
|
-
AnyPageConfigProvider,
|
|
50
|
-
DetailsPageConfigProvider,
|
|
51
|
-
} from './your-host-config-providers.js';
|
|
52
|
-
import { configResolvers } from './your-host-config-resolvers.js';
|
|
53
|
-
|
|
54
|
-
const APPLICATION_PREFERENCE_PREFIX = 'applicationPreference';
|
|
55
|
-
|
|
56
|
-
const applicationPreferenceResolver = async (keys, context) => {
|
|
57
|
-
const data = await loadApplicationPreferences(keys, context);
|
|
58
|
-
|
|
59
|
-
const result: Record<string, string | undefined> = {};
|
|
60
|
-
keys.forEach((key) => (result[key] = undefined));
|
|
61
|
-
data.records.forEach((record: { name: string; value: string }) => {
|
|
62
|
-
result[record.name] = record.value;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
return result;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const configExtension = await getConfigExtension({
|
|
69
|
-
configInjectorResolvers: {
|
|
70
|
-
[APPLICATION_PREFERENCE_PREFIX]: applicationPreferenceResolver,
|
|
71
|
-
},
|
|
72
|
-
providers: {
|
|
73
|
-
DashboardPage: DashboardPageConfigProvider,
|
|
74
|
-
TablePage: TablePageConfigProvider,
|
|
75
|
-
AnyPage: AnyPageConfigProvider,
|
|
76
|
-
DetailsPage: DetailsPageConfigProvider,
|
|
77
|
-
},
|
|
78
|
-
resolvers: configResolvers,
|
|
79
|
-
});
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### `configInjectorResolvers`
|
|
83
|
-
|
|
84
|
-
Use `configInjectorResolvers` to resolve template expressions embedded in config
|
|
85
|
-
values, for example:
|
|
86
|
-
|
|
87
|
-
```ts
|
|
88
|
-
$${applicationPreference:timezone}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Each key in `configInjectorResolvers` is a template prefix, and each value is an
|
|
92
|
-
async resolver function with this shape:
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
type ResolverFunction = (
|
|
96
|
-
keys: string[],
|
|
97
|
-
context: any,
|
|
98
|
-
) => Promise<Record<string, any>>;
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
When config processing encounters `$${prefix:key}`, it looks up the resolver for
|
|
102
|
-
that `prefix`, batches the requested keys, and replaces the template with the
|
|
103
|
-
resolved value. This is the right place to connect host-specific data sources
|
|
104
|
-
such as application preferences, tenant settings, or user-scoped values.
|
|
105
|
-
|
|
106
|
-
### `providers`
|
|
107
|
-
|
|
108
|
-
Use `providers` to register config processors by `__typename`. A provider runs
|
|
109
|
-
after nested config values have been loaded and template expressions have been
|
|
110
|
-
resolved, and can reshape or enrich the final config object before it is
|
|
111
|
-
returned.
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
providers: {
|
|
115
|
-
DashboardPage: DashboardPageConfigProvider,
|
|
116
|
-
TablePage: TablePageConfigProvider,
|
|
117
|
-
AnyPage: AnyPageConfigProvider,
|
|
118
|
-
DetailsPage: DetailsPageConfigProvider,
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Each provider must be a class with a `processConfig` method:
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
interface ConfigProvider {
|
|
126
|
-
processConfig(config: any, configService: ConfigService, context: any): any;
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
This is useful for page-specific post-processing such as normalizing fragments,
|
|
131
|
-
rewriting references, or deriving extra fields for a particular page type.
|
|
132
|
-
Built-in providers are preserved and host providers are merged in on top.
|
|
133
|
-
|
|
134
|
-
### `resolvers`
|
|
135
|
-
|
|
136
|
-
Use `resolvers` to extend the GraphQL API exposed by the config extension.
|
|
137
|
-
Resolvers are provided as factories so they can receive the initialized
|
|
138
|
-
`configService` instance:
|
|
139
|
-
|
|
140
|
-
```ts
|
|
141
|
-
const configResolvers = {
|
|
142
|
-
query: ({ configService }) => ({
|
|
143
|
-
pages: () => ({
|
|
144
|
-
myCustomPage: async (obj: { path: string }, context: any) => {
|
|
145
|
-
return await configService.getDirectConfig(obj.path, context);
|
|
146
|
-
},
|
|
147
|
-
}),
|
|
148
|
-
}),
|
|
149
|
-
mutation: ({ configService }) => ({
|
|
150
|
-
pages: () => ({
|
|
151
|
-
refreshCustomConfig: async () => {
|
|
152
|
-
await configService.init();
|
|
153
|
-
return true;
|
|
154
|
-
},
|
|
155
|
-
}),
|
|
156
|
-
}),
|
|
157
|
-
};
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Host query and mutation resolvers are deep-merged with the built-in config
|
|
161
|
-
resolvers, so you can add new fields without re-declaring the entire resolver
|
|
162
|
-
tree. If the same field exists in both places, the host resolver wins.
|
|
163
|
-
|
|
164
|
-
If you want to pass config stores programmatically instead of through
|
|
165
|
-
environment variables, `getConfigExtension` also accepts `configStores` (usually used for tests only).
|
|
166
|
-
|
|
167
|
-
## Environment variables
|
|
168
|
-
|
|
169
|
-
Config stores are discovered from environment variables grouped by prefix such
|
|
170
|
-
as `STANDARD` or `SITE`:
|
|
171
|
-
|
|
172
|
-
- `<PREFIX>_CONFIG_LOCAL_PATH`
|
|
173
|
-
- `<PREFIX>_CONFIG_REMOTE_PATH`
|
|
174
|
-
- `<PREFIX>_CONFIG_REMOTE_BRANCH`
|
|
175
|
-
- `<PREFIX>_CONFIG_PRIORITY`
|
|
176
|
-
- `<PREFIX>_CONFIG_NAME`
|
|
177
|
-
|
|
178
|
-
`<PREFIX>_CONFIG_PRIORITY` is required for every configured store.
|
|
179
|
-
|
|
180
|
-
`CONFIG_LOCAL_PATH_ROOT` can be used as a fallback base path when
|
|
181
|
-
`<PREFIX>_CONFIG_LOCAL_PATH` is omitted, but the store still needs enough
|
|
182
|
-
configuration to be discovered.
|
|
1
|
+
# @docupace/ihub-config
|
|
2
|
+
|
|
3
|
+
Reusable GraphQL config extension and standalone server extracted from the
|
|
4
|
+
Docupace GraphQL server.
|
|
5
|
+
|
|
6
|
+
## Run locally
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
To run the package as a standalone GraphQL server, copy
|
|
13
|
+
`.env.example` to `.env`, fill in the required values, and start the dev
|
|
14
|
+
server:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cp .env.example .env
|
|
18
|
+
pnpm start:dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The standalone server listens on `http://localhost:4000/api/graphql`.
|
|
22
|
+
|
|
23
|
+
## Use as an extension in another server
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { getConfigExtension } from '@docupace/ihub-config';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then add the returned extension to the host server's extensions array:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
const configExtension = await getConfigExtension();
|
|
33
|
+
|
|
34
|
+
const serverInfo: ServerConfig = {
|
|
35
|
+
instanceConfig: instanceConfig,
|
|
36
|
+
extensions: [docupaceExtension, configExtension],
|
|
37
|
+
port: 4000,
|
|
38
|
+
createContext,
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Extend the config extension with domain-specific providers, resolvers, etc.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { getConfigExtension } from '@docupace/ihub-config';
|
|
46
|
+
import {
|
|
47
|
+
DashboardPageConfigProvider,
|
|
48
|
+
TablePageConfigProvider,
|
|
49
|
+
AnyPageConfigProvider,
|
|
50
|
+
DetailsPageConfigProvider,
|
|
51
|
+
} from './your-host-config-providers.js';
|
|
52
|
+
import { configResolvers } from './your-host-config-resolvers.js';
|
|
53
|
+
|
|
54
|
+
const APPLICATION_PREFERENCE_PREFIX = 'applicationPreference';
|
|
55
|
+
|
|
56
|
+
const applicationPreferenceResolver = async (keys, context) => {
|
|
57
|
+
const data = await loadApplicationPreferences(keys, context);
|
|
58
|
+
|
|
59
|
+
const result: Record<string, string | undefined> = {};
|
|
60
|
+
keys.forEach((key) => (result[key] = undefined));
|
|
61
|
+
data.records.forEach((record: { name: string; value: string }) => {
|
|
62
|
+
result[record.name] = record.value;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return result;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const configExtension = await getConfigExtension({
|
|
69
|
+
configInjectorResolvers: {
|
|
70
|
+
[APPLICATION_PREFERENCE_PREFIX]: applicationPreferenceResolver,
|
|
71
|
+
},
|
|
72
|
+
providers: {
|
|
73
|
+
DashboardPage: DashboardPageConfigProvider,
|
|
74
|
+
TablePage: TablePageConfigProvider,
|
|
75
|
+
AnyPage: AnyPageConfigProvider,
|
|
76
|
+
DetailsPage: DetailsPageConfigProvider,
|
|
77
|
+
},
|
|
78
|
+
resolvers: configResolvers,
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### `configInjectorResolvers`
|
|
83
|
+
|
|
84
|
+
Use `configInjectorResolvers` to resolve template expressions embedded in config
|
|
85
|
+
values, for example:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
$${applicationPreference:timezone}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Each key in `configInjectorResolvers` is a template prefix, and each value is an
|
|
92
|
+
async resolver function with this shape:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
type ResolverFunction = (
|
|
96
|
+
keys: string[],
|
|
97
|
+
context: any,
|
|
98
|
+
) => Promise<Record<string, any>>;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
When config processing encounters `$${prefix:key}`, it looks up the resolver for
|
|
102
|
+
that `prefix`, batches the requested keys, and replaces the template with the
|
|
103
|
+
resolved value. This is the right place to connect host-specific data sources
|
|
104
|
+
such as application preferences, tenant settings, or user-scoped values.
|
|
105
|
+
|
|
106
|
+
### `providers`
|
|
107
|
+
|
|
108
|
+
Use `providers` to register config processors by `__typename`. A provider runs
|
|
109
|
+
after nested config values have been loaded and template expressions have been
|
|
110
|
+
resolved, and can reshape or enrich the final config object before it is
|
|
111
|
+
returned.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
providers: {
|
|
115
|
+
DashboardPage: DashboardPageConfigProvider,
|
|
116
|
+
TablePage: TablePageConfigProvider,
|
|
117
|
+
AnyPage: AnyPageConfigProvider,
|
|
118
|
+
DetailsPage: DetailsPageConfigProvider,
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Each provider must be a class with a `processConfig` method:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
interface ConfigProvider {
|
|
126
|
+
processConfig(config: any, configService: ConfigService, context: any): any;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
This is useful for page-specific post-processing such as normalizing fragments,
|
|
131
|
+
rewriting references, or deriving extra fields for a particular page type.
|
|
132
|
+
Built-in providers are preserved and host providers are merged in on top.
|
|
133
|
+
|
|
134
|
+
### `resolvers`
|
|
135
|
+
|
|
136
|
+
Use `resolvers` to extend the GraphQL API exposed by the config extension.
|
|
137
|
+
Resolvers are provided as factories so they can receive the initialized
|
|
138
|
+
`configService` instance:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
const configResolvers = {
|
|
142
|
+
query: ({ configService }) => ({
|
|
143
|
+
pages: () => ({
|
|
144
|
+
myCustomPage: async (obj: { path: string }, context: any) => {
|
|
145
|
+
return await configService.getDirectConfig(obj.path, context);
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
}),
|
|
149
|
+
mutation: ({ configService }) => ({
|
|
150
|
+
pages: () => ({
|
|
151
|
+
refreshCustomConfig: async () => {
|
|
152
|
+
await configService.init();
|
|
153
|
+
return true;
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
}),
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Host query and mutation resolvers are deep-merged with the built-in config
|
|
161
|
+
resolvers, so you can add new fields without re-declaring the entire resolver
|
|
162
|
+
tree. If the same field exists in both places, the host resolver wins.
|
|
163
|
+
|
|
164
|
+
If you want to pass config stores programmatically instead of through
|
|
165
|
+
environment variables, `getConfigExtension` also accepts `configStores` (usually used for tests only).
|
|
166
|
+
|
|
167
|
+
## Environment variables
|
|
168
|
+
|
|
169
|
+
Config stores are discovered from environment variables grouped by prefix such
|
|
170
|
+
as `STANDARD` or `SITE`:
|
|
171
|
+
|
|
172
|
+
- `<PREFIX>_CONFIG_LOCAL_PATH`
|
|
173
|
+
- `<PREFIX>_CONFIG_REMOTE_PATH`
|
|
174
|
+
- `<PREFIX>_CONFIG_REMOTE_BRANCH`
|
|
175
|
+
- `<PREFIX>_CONFIG_PRIORITY`
|
|
176
|
+
- `<PREFIX>_CONFIG_NAME`
|
|
177
|
+
|
|
178
|
+
`<PREFIX>_CONFIG_PRIORITY` is required for every configured store.
|
|
179
|
+
|
|
180
|
+
`CONFIG_LOCAL_PATH_ROOT` can be used as a fallback base path when
|
|
181
|
+
`<PREFIX>_CONFIG_LOCAL_PATH` is omitted, but the store still needs enough
|
|
182
|
+
configuration to be discovered.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
interface IElement {
|
|
2
|
-
name: String
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
interface IRowElement implements IElement {
|
|
6
|
-
cols: Int
|
|
7
|
-
name: String
|
|
1
|
+
interface IElement {
|
|
2
|
+
name: String
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
interface IRowElement implements IElement {
|
|
6
|
+
cols: Int
|
|
7
|
+
name: String
|
|
8
8
|
}
|