File tree Expand file tree Collapse file tree 4 files changed +26
-28
lines changed
data-plugins/lib/collections Expand file tree Collapse file tree 4 files changed +26
-28
lines changed Original file line number Diff line number Diff line change 1- export interface SchemaFieldString {
2- type : 'string' ;
1+ interface FieldBase < T > {
2+ type : T ;
33 'ui:widget' ?: string ;
44 label ?: string | string [ ] ;
5- enum ?: [ string , string ] [ ] ;
65}
76
8- export interface SchemaFieldNumber {
9- type : 'number' ;
10- 'ui:widget' ?: string ;
11- label ?: string | string [ ] ;
12- }
7+ export type SchemaFieldString =
8+ | ( FieldBase < 'string' > & { enum ?: never ; allowOther ?: never } )
9+ | ( FieldBase < 'string' > & {
10+ allowOther ?: {
11+ type : 'string' ;
12+ } ;
13+ enum : [ string , string ] [ ] ;
14+ } ) ;
1315
14- export interface SchemaFieldJson {
15- type : 'json' ;
16- 'ui:widget' ?: string ;
17- label ?: string ;
18- }
16+ export type SchemaFieldNumber = FieldBase < 'number' > ;
1917
20- export interface SchemaFieldArray < I extends SchemaField = SchemaField > {
21- type : 'array' ;
22- 'ui:widget' ?: string ;
23- label ?: string | string [ ] ;
18+ export type SchemaFieldJson = FieldBase < 'json' > ;
19+
20+ export interface SchemaFieldArray < I extends SchemaField = SchemaField >
21+ extends FieldBase < 'array' > {
2422 minItems ?: number ;
2523 maxItems ?: number ;
2624 items : I ;
2725}
2826
29- export interface SchemaFieldObject {
30- type : 'object' | 'root' ;
31- 'ui:widget' ?: string ;
32- label ?: string | string [ ] ;
27+ export interface SchemaFieldObject extends FieldBase < 'object' | 'root' > {
3328 properties : Record < string , SchemaField > ;
3429 additionalProperties ?: boolean ;
3530 required ?: string [ ] ;
Original file line number Diff line number Diff line change 1- import { Plugin , SchemaFieldObject } from '@stac-manager/data-core' ;
1+ import { Plugin , PluginEditSchema } from '@stac-manager/data-core' ;
22import { emptyString2Null , fieldIf , null2EmptyString } from '../utils' ;
33
44export class PluginCore extends Plugin {
@@ -10,7 +10,7 @@ export class PluginCore extends Plugin {
1010 this . isNew = ! data ?. id ;
1111 }
1212
13- editSchema ( ) : SchemaFieldObject {
13+ editSchema ( ) : PluginEditSchema {
1414 return {
1515 type : 'root' ,
1616 required : [
@@ -47,6 +47,9 @@ export class PluginCore extends Plugin {
4747 label : 'License' ,
4848 type : 'string' ,
4949 'ui:widget' : 'tagger' ,
50+ allowOther : {
51+ type : 'string'
52+ } ,
5053 enum : [
5154 [ 'Apache-2.0' , 'Apache License 2.0' ] ,
5255 [ 'MIT' , 'MIT License' ] ,
@@ -136,7 +139,7 @@ export class PluginCore extends Plugin {
136139 minItems : 1 ,
137140 items : {
138141 type : 'object' ,
139- required : [ 'rel' , 'href' ] ,
142+ required : [ 'rel' , 'href' , 'type' ] ,
140143 properties : {
141144 href : {
142145 label : 'URL' ,
Original file line number Diff line number Diff line change 1- import { Plugin , SchemaFieldObject } from '@stac-manager/data-core' ;
1+ import { Plugin , PluginEditSchema } from '@stac-manager/data-core' ;
22
33export class PluginKitchenSink extends Plugin {
44 name = 'Kitchen Sink' ;
55
6- editSchema ( ) : SchemaFieldObject {
6+ editSchema ( ) : PluginEditSchema {
77 return {
88 type : 'root' ,
99 properties : {
Original file line number Diff line number Diff line change 1- import { Plugin , SchemaFieldObject } from '@stac-manager/data-core' ;
1+ import { Plugin , PluginEditSchema } from '@stac-manager/data-core' ;
22
33export class PluginMeta extends Plugin {
44 name = 'CollectionsMeta' ;
@@ -7,7 +7,7 @@ export class PluginMeta extends Plugin {
77 // await new Promise((resolve) => setTimeout(resolve, 100));
88 // }
99
10- editSchema ( ) : SchemaFieldObject {
10+ editSchema ( ) : PluginEditSchema {
1111 return {
1212 type : 'root' ,
1313 properties : {
You can’t perform that action at this time.
0 commit comments