Skip to content

Commit 1a8a64e

Browse files
committed
feat(entities-config-editor): migrate from PoC
1 parent ad4765d commit 1a8a64e

25 files changed

+2482
-20
lines changed

packages/core/entities-config-editor/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"devDependencies": {
4242
"@kong/design-tokens": "1.17.3",
4343
"@kong/kongponents": "9.25.0",
44+
"monaco-editor": "^0.52.2",
45+
"uuid": "^10.0.0",
46+
"vscode-json-languageservice": "^5.4.4",
4447
"vue": "^3.5.13"
4548
},
4649
"repository": {
Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,86 @@
11
<template>
22
<div class="sandbox-container">
3-
<main>
4-
<p>This is the component sandbox.</p>
5-
<EntitiesConfigEditor />
6-
</main>
3+
<div class="stage-container">
4+
<KCard class="controls-card">
5+
<div class="controls">
6+
<KSelect
7+
v-model="language"
8+
:items="LANGUAGE_SELECT_ITEMS"
9+
label="Language"
10+
/>
11+
12+
<KSelect
13+
v-model="entityKind"
14+
:items="ENTITY_KIND"
15+
label="Entity Kind"
16+
/>
17+
</div>
18+
</KCard>
19+
20+
<div class="editor-container">
21+
<Suspense>
22+
<EntitiesConfigEditor
23+
:language="language"
24+
:lua-schema="luaSchema"
25+
/>
26+
</Suspense>
27+
</div>
28+
</div>
729
</div>
830
</template>
931

1032
<script setup lang="ts">
11-
import { EntitiesConfigEditor } from '../src'
33+
import type { SelectItem } from '@kong/kongponents'
34+
import { ref, watch } from 'vue'
35+
import EntitiesConfigEditor from '../src/components/EntitiesConfigEditor.vue'
36+
import type { EditorLanguage } from '../src/types'
37+
38+
const LANGUAGE_SELECT_ITEMS: SelectItem[] = [
39+
{ label: 'JSON', value: 'json' },
40+
{ label: 'YAML', value: 'yaml' },
41+
]
42+
43+
const ENTITY_KIND: SelectItem[] = [
44+
{ label: 'Service', value: 'services' },
45+
{ label: 'Route', value: 'routes' },
46+
{ label: 'Consumer', value: 'consumers' },
47+
{ label: 'Plugin', value: 'plugins' },
48+
{ label: 'Upstream', value: 'upstreams' },
49+
{ label: 'Target', value: 'targets' },
50+
{ label: 'Certificate', value: 'certificates' },
51+
{ label: 'SNI', value: 'snis' },
52+
]
53+
54+
const language = ref<EditorLanguage>('json')
55+
const entityKind = ref('services')
56+
57+
const luaSchema = ref(undefined)
58+
59+
watch(entityKind, async (kind) => {
60+
luaSchema.value = (await import (`./fixture/${kind}.json`)).default
61+
}, { immediate: true })
1262
</script>
63+
64+
<style lang="scss" scoped>
65+
.stage-container {
66+
width: 100%;
67+
max-width: 1200px;
68+
margin: auto;
69+
70+
.controls-card {
71+
margin-bottom: 8px;
72+
}
73+
74+
.controls {
75+
width: 100%;
76+
max-width: 800px;
77+
gap: 18px;
78+
display: grid;
79+
grid-template-columns: repeat(2, 1fr);
80+
}
81+
82+
.editor-container {
83+
height: 800px;
84+
}
85+
}
86+
</style>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"fields": [
3+
{
4+
"id": {
5+
"description": "A string representing a UUID (universally unique identifier).",
6+
"uuid": true,
7+
"type": "string",
8+
"auto": true
9+
}
10+
},
11+
{
12+
"created_at": {
13+
"description": "An integer representing an automatic Unix timestamp in seconds.",
14+
"timestamp": true,
15+
"type": "integer",
16+
"auto": true
17+
}
18+
},
19+
{
20+
"updated_at": {
21+
"description": "An integer representing an automatic Unix timestamp in seconds.",
22+
"timestamp": true,
23+
"type": "integer",
24+
"auto": true
25+
}
26+
},
27+
{ "cert": { "description": "A string representing a certificate.", "type": "string", "required": true } },
28+
{ "cert_digest": { "description": "The digest of the CA certificate.", "type": "string", "unique": true } },
29+
{
30+
"tags": {
31+
"description": "A set of strings representing tags.",
32+
"elements": { "description": "A string representing a tag.", "type": "string", "required": true },
33+
"type": "set"
34+
}
35+
}
36+
],
37+
"entity_checks": [{ "custom_entity_check": { "field_sources": ["cert"] } }]
38+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"fields": [
3+
{
4+
"id": {
5+
"description": "A string representing a UUID (universally unique identifier).",
6+
"uuid": true,
7+
"type": "string",
8+
"auto": true
9+
}
10+
},
11+
{
12+
"created_at": {
13+
"description": "An integer representing an automatic Unix timestamp in seconds.",
14+
"timestamp": true,
15+
"type": "integer",
16+
"auto": true
17+
}
18+
},
19+
{
20+
"updated_at": {
21+
"description": "An integer representing an automatic Unix timestamp in seconds.",
22+
"timestamp": true,
23+
"type": "integer",
24+
"auto": true
25+
}
26+
},
27+
{
28+
"cert": {
29+
"description": "A string representing a certificate.",
30+
"referenceable": true,
31+
"type": "string",
32+
"required": true
33+
}
34+
},
35+
{
36+
"key": {
37+
"description": "A string representing a key.",
38+
"referenceable": true,
39+
"type": "string",
40+
"encrypted": true,
41+
"required": true
42+
}
43+
},
44+
{
45+
"cert_alt": {
46+
"description": "A string representing a certificate.",
47+
"referenceable": true,
48+
"type": "string",
49+
"required": false
50+
}
51+
},
52+
{
53+
"key_alt": {
54+
"description": "A string representing a key.",
55+
"referenceable": true,
56+
"type": "string",
57+
"encrypted": true,
58+
"required": false
59+
}
60+
},
61+
{
62+
"tags": {
63+
"description": "A set of strings representing tags.",
64+
"elements": { "description": "A string representing a tag.", "type": "string", "required": true },
65+
"type": "set"
66+
}
67+
},
68+
{
69+
"snis": {
70+
"transient": true,
71+
"elements": {
72+
"type": "string",
73+
"description": "A string representing a wildcard host name, such as *.example.com."
74+
},
75+
"type": "array",
76+
"required": false
77+
}
78+
}
79+
],
80+
"entity_checks": [
81+
{ "mutually_required": ["cert_alt", "key_alt"] },
82+
{ "custom_entity_check": { "field_sources": ["cert", "key"] } },
83+
{ "custom_entity_check": { "field_sources": ["cert_alt", "key_alt"] } },
84+
{ "custom_entity_check": { "field_sources": ["cert", "cert_alt"] } }
85+
]
86+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"fields": [
3+
{
4+
"id": {
5+
"description": "A string representing a UUID (universally unique identifier).",
6+
"uuid": true,
7+
"type": "string",
8+
"auto": true
9+
}
10+
},
11+
{
12+
"created_at": {
13+
"description": "An integer representing an automatic Unix timestamp in seconds.",
14+
"timestamp": true,
15+
"type": "integer",
16+
"auto": true
17+
}
18+
},
19+
{
20+
"updated_at": {
21+
"description": "An integer representing an automatic Unix timestamp in seconds.",
22+
"timestamp": true,
23+
"type": "integer",
24+
"auto": true
25+
}
26+
},
27+
{
28+
"username": {
29+
"description": "The unique username of the Consumer. You must send at least one of username or custom_id with the request.",
30+
"indexed": true,
31+
"type": "string",
32+
"unique": true
33+
}
34+
},
35+
{
36+
"custom_id": {
37+
"description": "Stores the existing unique ID of the consumer. You must send at least one of username or custom_id with the request.",
38+
"indexed": true,
39+
"type": "string",
40+
"unique": true
41+
}
42+
},
43+
{ "type": { "indexed": true, "default": 0, "type": "integer", "required": true } },
44+
{
45+
"tags": {
46+
"description": "A set of strings representing tags.",
47+
"elements": { "description": "A string representing a tag.", "type": "string", "required": true },
48+
"type": "set"
49+
}
50+
},
51+
{
52+
"username_lower": {
53+
"db_export": false,
54+
"description": "The lowercase representation of a username",
55+
"type": "string",
56+
"prefix_ws": true
57+
}
58+
}
59+
],
60+
"entity_checks": [{ "at_least_one_of": ["custom_id", "username"] }]
61+
}

0 commit comments

Comments
 (0)