lighten types in arg inputs

This commit is contained in:
Ruben Fiszel
2023-06-29 13:44:26 +02:00
parent ec0b91c2c3
commit ebca2574d7
5 changed files with 9 additions and 296 deletions
+1 -1
View File
@@ -139,7 +139,7 @@
function validateInput(pattern: string | undefined, v: any): void {
if (required && (v == undefined || v == null || v === '')) {
error = 'This field is required'
error = 'Required'
valid = false
} else {
if (pattern && !testRegex(pattern, v)) {
@@ -134,293 +134,6 @@
return rec(schema.properties, true)
}
$: console.log(
compile({
type: 'object',
required: [],
properties: {
id: {
type: 'integer'
},
meta: {
type: 'object',
properties: {
team: {
type: 'null'
},
sender: {
type: 'object',
properties: {
id: {
type: 'integer'
},
name: {
type: 'string'
},
type: {
type: 'string'
},
email: {
type: 'null'
},
thumbnail: {
type: 'string'
},
identifier: {
type: 'null'
},
phone_number: {
type: 'null'
},
custom_attributes: {
type: 'object'
},
additional_attributes: {
type: 'object'
}
},
additionalProperties: false
},
assignee: {
type: 'null'
},
hmac_verified: {
type: 'boolean'
}
},
additionalProperties: false
},
event: {
type: 'string'
},
labels: {
type: 'array'
},
status: {
type: 'string'
},
channel: {
type: 'string'
},
inbox_id: {
type: 'integer'
},
messages: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'integer'
},
sender: {
type: 'object',
properties: {
id: {
type: 'integer'
},
name: {
type: 'string'
},
type: {
type: 'string'
},
email: {
type: ['null']
},
thumbnail: {
type: 'string'
},
identifier: {
type: ['null']
},
phone_number: {
type: ['null']
},
custom_attributes: {
type: 'object'
},
additional_attributes: {
type: 'object'
}
},
additionalProperties: false
},
status: {
type: 'string'
},
content: {
type: 'string'
},
private: {
type: 'boolean'
},
inbox_id: {
type: 'integer'
},
sender_id: {
type: 'integer'
},
source_id: {
type: ['null']
},
account_id: {
type: 'integer'
},
created_at: {
type: 'integer'
},
label_list: {
type: ['null']
},
updated_at: {
type: 'string',
format: 'date-time'
},
sender_type: {
type: 'string'
},
content_type: {
type: 'string'
},
conversation: {
type: 'object',
properties: {
assignee_id: {
type: ['null']
},
unread_count: {
type: 'integer'
}
},
additionalProperties: false
},
message_type: {
type: 'integer'
},
conversation_id: {
type: 'integer'
},
content_attributes: {
type: 'object'
},
external_source_ids: {
type: 'object'
},
additional_attributes: {
type: 'object'
}
},
additionalProperties: false
}
},
can_reply: {
type: 'boolean'
},
timestamp: {
type: 'integer'
},
created_at: {
type: 'integer'
},
unread_count: {
type: 'integer'
},
contact_inbox: {
type: 'object',
properties: {
id: {
type: 'integer'
},
inbox_id: {
type: 'integer'
},
source_id: {
type: 'string',
format: 'uuid'
},
contact_id: {
type: 'integer'
},
created_at: {
type: 'string',
format: 'date-time'
},
updated_at: {
type: 'string',
format: 'date-time'
},
pubsub_token: {
type: 'string'
},
hmac_verified: {
type: 'boolean'
}
},
additionalProperties: false
},
snoozed_until: {
type: 'null'
},
custom_attributes: {
type: 'object'
},
agent_last_seen_at: {
type: 'integer'
},
contact_last_seen_at: {
type: 'integer'
},
additional_attributes: {
type: 'object',
properties: {
browser: {
type: 'object',
properties: {
device_name: {
type: 'string'
},
browser_name: {
type: 'string'
},
platform_name: {
type: 'string'
},
browser_version: {
type: 'string'
},
platform_version: {
type: 'string'
}
},
additionalProperties: false
},
referer: {
type: 'string',
format: 'url'
},
initiated_at: {
type: 'object',
properties: {
timestamp: {
type: 'string'
}
},
additionalProperties: false
},
browser_language: {
type: 'string'
}
},
additionalProperties: false
},
first_reply_created_at: {
type: 'null'
}
},
additionalProperties: false
})
)
let historyBrowserDrawerOpen = false
</script>
@@ -24,15 +24,15 @@
<Required {required} class="!ml-0" />
{#if displayType}
{#if format && format != ''}
<span class="text-sm italic ml-1 text-indigo-800 dark:text-indigo-400">
({format})
{#if format && !format.startsWith('resource')}
<span class="text-xs italic ml-2 text-gray-500 dark:text-indigo-400">
{format}
</span>
{:else}
<span class="text-sm italic ml-1 text-indigo-800 dark:text-indigo-400">
({type ?? 'any'}{contentEncoding && contentEncoding != ''
<span class="text-xs italic ml-2 text-gray-500 dark:text-indigo-400">
{type ?? 'any'}{contentEncoding && contentEncoding != ''
? `, encoding: ${contentEncoding}`
: ''})
: ''}
</span>
{/if}
{/if}
@@ -105,7 +105,7 @@
function validateInput(pattern: string | undefined, v: any): void {
if (required && (v == undefined || v == null || v === '')) {
error = 'This field is required'
error = 'Required'
valid = false
} else {
if (pattern && !testRegex(pattern, v)) {
+1 -1
View File
@@ -4,7 +4,7 @@
</script>
{#if required}
<span class="text-red-700 dark:text-red-400 font-normal {$$props.class}">*</span>
<span class="text-red-500 dark:text-red-400 text-sm font-normal {$$props.class}">*</span>
{:else if detail || detail != ''}
<span class="text-sm text-gray-500 ml-2 font-normal {$$props.class}"
>({detail != '' ? `${detail}` : ''})</span