farmOS / farmOS.js

A JavaScript library for working with farmOS data structures and interacting with farmOS servers.
MIT License
15 stars 13 forks source link

Parse types to make `getSchemata` polymorphic. #80

Closed jgaehring closed 1 year ago

jgaehring commented 1 year ago

This is already the case with setSchemata, where anywhere from 1 - 3 parameters are allowed:

https://github.com/farmOS/farmOS.js/blob/99816e6cacdf4cf05dcfd9575896283c0c6d819c/src/model/index.js#L130-L138

Basically, these should all be equivalent:

/**
 * @typedef {Function} getSchemataByEntityBundle
 * @param {String} entity
 * @param {String} bundle
 * @returns {JsonSchema}
 */
const activitySchema1 = farm.schema.get('log', 'activity');

/**
 * @typedef {Function} getSchemataByEntityType
 * @param {String} entity
 * @param {String} type
 * @returns {JsonSchema}
 */
const activitySchema2 = farm.schema.get('log', 'log--activity');

/**
 * @typedef {Function} getSchemataByType
 * @param {String} type
 * @returns {JsonSchema}
 */
const activitySchema3 = farm.schema.get('log---activity');