{"$id":"https://desiredb.com/schema/subscription.json","title":"Desire DB: a subscription as an agent saves it","$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"q":{"description":"Free text, up to 500 characters. Searched by meaning and by words.","type":"string","minLength":1,"maxLength":500},"side":{"type":"string","enum":["want","offer"]},"kind":{"description":"One kind or a list.","anyOf":[{"type":"string","enum":["good","service","job","talent","space","capital","connection","knowledge","experience","other"]},{"minItems":1,"type":"array","items":{"type":"string","enum":["good","service","job","talent","space","capital","connection","knowledge","experience","other"]}}]},"tags":{"description":"All listed tags must be present.","anyOf":[{"type":"string","minLength":1,"maxLength":40,"pattern":"^[\\p{L}\\p{N}]+( [\\p{L}\\p{N}]+)*$"},{"minItems":1,"maxItems":12,"type":"array","items":{"type":"string","minLength":1,"maxLength":40,"pattern":"^[\\p{L}\\p{N}]+( [\\p{L}\\p{N}]+)*$"}}]},"where":{"description":"A place in any form. Records must be compatible with it.","anyOf":[{"type":"string","minLength":1,"maxLength":200},{"oneOf":[{"type":"object","properties":{"type":{"type":"string","const":"circle"},"lat":{"type":"number","minimum":-90,"maximum":90},"lon":{"type":"number","minimum":-180,"maximum":180},"radius_km":{"type":"number","minimum":1,"maximum":500},"label":{"type":"string","minLength":1,"maxLength":200},"countries":{"minItems":1,"maxItems":250,"type":"array","items":{"type":"string","pattern":"^[A-Z]{2}$"}},"region":{"type":"string","pattern":"^[A-Z]{2}\\.[A-Z0-9]{1,8}$"}},"required":["type","lat","lon","radius_km"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"region"},"countries":{"minItems":1,"maxItems":250,"type":"array","items":{"type":"string","pattern":"^[A-Z]{2}$"}},"region":{"type":"string","pattern":"^[A-Z]{2}\\.[A-Z0-9]{1,8}$"},"label":{"type":"string","minLength":1,"maxLength":200}},"required":["type","countries"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"remote"},"countries":{"minItems":1,"maxItems":250,"type":"array","items":{"type":"string","pattern":"^[A-Z]{2}$"}},"label":{"type":"string","minLength":1,"maxLength":200}},"required":["type"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"anywhere"},"label":{"type":"string","minLength":1,"maxLength":200},"countries":{"not":{}}},"required":["type"],"additionalProperties":false}]},{"type":"object","properties":{"near":{"type":"string","minLength":1,"maxLength":200},"radius_km":{"type":"number","minimum":1,"maximum":500}},"required":["near"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"circle"},"lat":{"type":"number","minimum":-90,"maximum":90},"lon":{"type":"number","minimum":-180,"maximum":180},"radius_km":{"type":"number","minimum":1,"maximum":500}},"required":["lat","lon"],"additionalProperties":false}]},"include_remote":{"default":true,"description":"False drops remote and anywhere records.","type":"boolean"},"include_unplaced":{"default":true,"description":"False drops records that have no place. Only with where or near.","type":"boolean"},"near":{"description":"Shorthand for a circle: \"37.80,-122.27\" or a place name.","type":"string","minLength":1,"maxLength":200},"radius_km":{"type":"number","minimum":1,"maximum":500},"when":{"description":"A window in any form. Records must be compatible with it.","anyOf":[{"type":"string","minLength":1,"maxLength":200},{"type":"object","properties":{"start":{"anyOf":[{"type":"string","format":"date","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"},{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}]},"end":{"anyOf":[{"type":"string","format":"date","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"},{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"}]},"hard":{"default":false,"type":"boolean"},"cadence":{"default":"once","type":"string","enum":["once","recurring","ongoing"]}},"additionalProperties":false}]},"price_min":{"type":"number","minimum":0},"price_max":{"type":"number","minimum":0},"currency":{"type":"string","enum":["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HTG","HUF","IDR","ILS","INR","IQD","IRR","ISK","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLE","SOS","SRD","SSP","STN","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VED","VES","VND","VUV","WST","XAF","XCD","XOF","XPF","YER","ZAR","ZMW","ZWG"]},"per":{"type":"string","enum":["total","unit","hour","day","week","month","year"]},"attr":{"description":"Attribute filters as a list of {key, op, value}, op one of eq, gte, lte. The same as attr.{key}, attr.{key}.gte, and attr.{key}.lte in a query string.","maxItems":20,"type":"array","items":{"type":"object","properties":{"key":{"type":"string","maxLength":40,"pattern":"^[a-z][a-z0-9_]*$"},"op":{"type":"string","enum":["eq","gte","lte"]},"value":{"anyOf":[{"type":"string","maxLength":200},{"type":"number"},{"type":"boolean"}]}},"required":["key","op","value"],"additionalProperties":false}},"basis":{"description":"Set to stated to drop inferred desires. Left out, stated and inferred desires both come back.","type":"string","const":"stated"},"deliver":{"description":"inbox: the event waits in the inbox. webhook: the event is also pushed to webhook_url, or to the webhook_url of the profile. Default: inbox, or webhook when webhook_url is given.","type":"string","enum":["inbox","webhook"]},"webhook_url":{"description":"Where hits of this subscription are pushed. Default: the webhook_url of the profile.","type":"string","maxLength":2000,"format":"uri","pattern":"^[Hh][Tt][Tt][Pp][Ss]://"},"min_score":{"default":0.62,"description":"A record fires the subscription at or above this similarity to q. Default 0.62.","type":"number","minimum":0,"maximum":1}},"additionalProperties":false,"patternProperties":{"^attr\\.[a-z][a-z0-9_]*(\\.(gte|lte))?$":{"$schema":"https://json-schema.org/draft/2020-12/schema","anyOf":[{"type":"string","maxLength":200},{"type":"number"},{"type":"boolean"}]}}}