*/ public static function admin(): array { return [ 'label' => 'Products', 'key' => [ 'type' => 'integer', ], 'pagination' => 'offset', 'query' => FilteredProducts::class, 'schema' => [ 'type' => 'object', 'required' => [ 'id', 'category_id', 'name', 'slug', 'sku', 'status', 'price', 'compare_at_price', 'cost_price', 'photos', 'video_url', 'description', 'size_chart', 'is_featured', 'published_at', 'published_by', 'specs', 'created_at', 'updated_at', ], 'properties' => [ 'id' => [ 'type' => 'integer', 'readOnly' => true, ], 'category_id' => [ 'type' => 'integer', 'description' => 'Id of the related category.', ], 'name' => [ 'type' => 'string', 'maxLength' => 120, ], 'slug' => [ 'type' => 'string', 'maxLength' => 140, ], 'sku' => [ 'type' => 'string', 'maxLength' => 32, 'title' => 'SKU', ], 'status' => [ 'type' => 'string', 'enum' => [ 'draft', 'active', 'archived', ], ], 'price' => [ 'type' => 'string', 'format' => 'decimal', 'pattern' => '^-?\\d+(\\.\\d+)?$', 'examples' => [ '1234.55', ], ], 'compare_at_price' => [ 'type' => [ 'string', 'null', ], 'format' => 'decimal', 'pattern' => '^-?\\d+(\\.\\d+)?$', 'examples' => [ '1234.55', ], 'title' => 'Compare-at price', ], 'cost_price' => [ 'type' => [ 'string', 'null', ], 'format' => 'decimal', 'pattern' => '^-?\\d+(\\.\\d+)?$', 'examples' => [ '1234.55', ], ], 'photos' => [ 'type' => [ 'array', 'null', ], 'items' => [ 'type' => 'object', 'required' => [ 'path', 'url', ], 'properties' => [ 'path' => [ 'type' => 'string', 'description' => 'Send it in photos_existing to keep the file.', ], 'url' => [ 'type' => 'string', 'format' => 'uri', ], ], ], ], 'photos_variants' => [ 'type' => 'array', 'items' => [ 'type' => 'object', 'description' => 'The file route with `?size=`: each size once built, the original until then.', 'properties' => [ 'original' => [ 'type' => 'string', 'format' => 'uri', ], 'thumb' => [ 'type' => 'string', 'format' => 'uri', ], 'medium' => [ 'type' => 'string', 'format' => 'uri', ], 'large' => [ 'type' => 'string', 'format' => 'uri', ], ], ], ], 'video_url' => [ 'type' => [ 'string', 'null', ], 'format' => 'uri', 'title' => 'Video', ], 'description' => [ 'type' => [ 'string', 'null', ], 'contentMediaType' => 'text/html', 'description' => 'HTML limited to p, br, strong, b, em, i, u, ul, ol, li, h2, h3, div, span, a (http, https, mailto, tel or relative href) and table, thead, tbody, tr, th and td (colspan and rowspan as whole numbers). Anything else is removed when it is written and when it is read.', ], 'size_chart' => [ 'type' => [ 'string', 'null', ], 'format' => 'uri', 'description' => 'Where the file is served from.', 'title' => 'Size chart', ], 'is_featured' => [ 'type' => 'boolean', ], 'published_at' => [ 'type' => [ 'string', 'null', ], 'format' => 'date-time', 'title' => 'Published', 'readOnly' => true, ], 'published_by' => [ 'type' => [ 'integer', 'null', ], 'description' => 'Id of the related published by ref.', 'title' => 'Published by', 'readOnly' => true, ], 'specs' => [ 'type' => [ 'object', 'null', ], 'additionalProperties' => [ 'type' => 'string', ], 'title' => 'Specifications', ], 'created_at' => [ 'type' => [ 'string', 'null', ], 'format' => 'date-time', 'readOnly' => true, ], 'updated_at' => [ 'type' => [ 'string', 'null', ], 'format' => 'date-time', 'readOnly' => true, ], 'category' => [ 'type' => [ 'object', 'null', ], 'description' => 'Present with ?include=category.', 'properties' => [ 'id' => [ 'type' => 'integer', ], 'label' => [ 'type' => [ 'string', 'null', ], ], ], ], 'publishedByRef' => [ 'type' => [ 'object', 'null', ], 'description' => 'Present with ?include=publishedByRef.', 'properties' => [ 'id' => [ 'type' => 'integer', ], 'label' => [ 'type' => [ 'string', 'null', ], ], ], ], 'productVariants' => [ 'type' => 'array', 'description' => 'Present with ?include=productVariants.', 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'type' => 'integer', ], ], ], ], 'reviews' => [ 'type' => 'array', 'description' => 'Present with ?include=reviews.', 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'type' => 'integer', ], ], ], ], 'coupons' => [ 'type' => 'array', 'description' => 'Present with ?include=coupons.', 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'type' => 'integer', ], ], ], ], 'tags' => [ 'type' => 'array', 'description' => 'Present with ?include=tags.', 'items' => [ 'type' => 'object', 'properties' => [ 'id' => [ 'type' => 'integer', ], 'label' => [ 'type' => 'string', ], ], ], ], 'product_variants_count' => [ 'type' => 'integer', 'readOnly' => true, 'description' => 'Present on a list with ?include=productVariantsCount.', ], 'product_variants_exists' => [ 'type' => 'boolean', 'readOnly' => true, 'description' => 'Present on a list with ?include=productVariantsExists.', ], 'reviews_count' => [ 'type' => 'integer', 'readOnly' => true, 'description' => 'Present on a list with ?include=reviewsCount.', ], 'reviews_exists' => [ 'type' => 'boolean', 'readOnly' => true, 'description' => 'Present on a list with ?include=reviewsExists.', ], 'coupons_count' => [ 'type' => 'integer', 'readOnly' => true, 'description' => 'Present on a list with ?include=couponsCount.', ], 'coupons_exists' => [ 'type' => 'boolean', 'readOnly' => true, 'description' => 'Present on a list with ?include=couponsExists.', ], 'tags_count' => [ 'type' => 'integer', 'readOnly' => true, 'description' => 'Present on a list with ?include=tagsCount.', ], 'tags_exists' => [ 'type' => 'boolean', 'readOnly' => true, 'description' => 'Present on a list with ?include=tagsExists.', ], ], ], 'filters' => [ 'search' => [ 'type' => 'string', 'description' => 'Matches name, sku.', ], 'category' => [ 'type' => 'integer', 'description' => 'Id of the related category.', ], 'status' => [ 'type' => 'string', 'enum' => [ 'draft', 'active', 'archived', ], 'description' => 'One value, or several separated by commas.', ], 'is_featured' => [ 'type' => 'string', 'enum' => [ '1', '0', ], 'description' => '1 for true, 0 for false.', ], 'publishedByRef' => [ 'type' => 'integer', 'description' => 'Id of the related published by ref.', ], 'price_min' => [ 'type' => 'number', 'description' => 'At least this.', ], 'price_max' => [ 'type' => 'number', 'description' => 'At most this.', ], 'tags' => [ 'type' => 'integer', 'description' => 'Rows related to this id.', ], ], 'includes' => [ 'category', 'publishedByRef', 'productVariants', 'reviews', 'coupons', 'tags', ], 'countable' => [ 'productVariants', 'reviews', 'coupons', 'tags', ], 'input' => [ 'type' => 'object', 'properties' => [ 'category_id' => [ 'type' => 'integer', 'description' => 'Id of the related category.', ], 'name' => [ 'type' => 'string', 'maxLength' => 120, ], 'slug' => [ 'type' => 'string', 'maxLength' => 140, ], 'sku' => [ 'type' => 'string', 'maxLength' => 32, 'title' => 'SKU', ], 'status' => [ 'type' => 'string', 'enum' => [ 'draft', 'active', 'archived', ], ], 'price' => [ 'type' => 'number', 'minimum' => 0, 'description' => 'Up to 2 decimal places.', 'maximum' => 99999999.99, ], 'compare_at_price' => [ 'type' => [ 'number', 'null', ], 'title' => 'Compare-at price', 'minimum' => 0, 'description' => 'Up to 2 decimal places.', 'maximum' => 99999999.99, ], 'cost_price' => [ 'type' => [ 'number', 'null', ], 'minimum' => 0, 'description' => 'Up to 2 decimal places.', 'maximum' => 99999999.99, ], 'photos_new' => [ 'type' => 'array', 'maxItems' => 20, 'items' => [ 'type' => 'string', 'format' => 'binary', 'contentMediaType' => 'application/octet-stream', ], 'description' => 'Files to add, at most 20 a save, each at most 8000×8000 px.', ], 'photos_existing' => [ 'type' => 'array', 'items' => [ 'type' => 'string', ], 'description' => 'On update, the `path` of each stored file to keep, as `photos` lists them: left out, every stored file stays; an empty list removes them all.', ], 'video_url' => [ 'type' => [ 'string', 'null', ], 'format' => 'uri', 'title' => 'Video', 'maxLength' => 500, ], 'description' => [ 'type' => [ 'string', 'null', ], 'contentMediaType' => 'text/html', 'description' => 'HTML limited to p, br, strong, b, em, i, u, ul, ol, li, h2, h3, div, span, a (http, https, mailto, tel or relative href) and table, thead, tbody, tr, th and td (colspan and rowspan as whole numbers). Anything else is removed when it is written and when it is read.', 'maxLength' => 2000, ], 'size_chart' => [ 'type' => [ 'string', 'null', ], 'format' => 'binary', 'contentMediaType' => 'application/octet-stream', 'title' => 'Size chart', 'description' => 'At most 5120 KB.', ], 'is_featured' => [ 'type' => 'boolean', ], 'specs' => [ 'type' => [ 'object', 'null', ], 'propertyNames' => [ 'minLength' => 1, 'maxLength' => 100, 'pattern' => '\\S', ], 'additionalProperties' => [ 'type' => [ 'string', 'null', ], 'maxLength' => 1000, ], 'title' => 'Specifications', 'maxProperties' => 100, ], 'tag_ids' => [ 'type' => 'array', 'items' => [ 'type' => 'integer', ], 'description' => 'Ids of the related tags. On update, left out, the links stay as they are; an empty list removes them all.', ], 'tag_new' => [ 'type' => 'array', 'items' => [ 'type' => 'string', 'maxLength' => 255, ], 'description' => 'Names of tags to create and link.', ], ], 'required' => [ 'category_id', 'name', 'sku', 'status', 'price', 'is_featured', ], ], 'updateInput' => [ 'type' => 'object', 'properties' => [ 'category_id' => [ 'type' => 'integer', 'description' => 'Id of the related category.', ], 'name' => [ 'type' => 'string', 'maxLength' => 120, ], 'slug' => [ 'type' => 'string', 'maxLength' => 140, ], 'status' => [ 'type' => 'string', 'enum' => [ 'draft', 'active', 'archived', ], ], 'price' => [ 'type' => 'number', 'minimum' => 0, 'description' => 'Up to 2 decimal places.', 'maximum' => 99999999.99, ], 'compare_at_price' => [ 'type' => [ 'number', 'null', ], 'title' => 'Compare-at price', 'minimum' => 0, 'description' => 'Up to 2 decimal places.', 'maximum' => 99999999.99, ], 'cost_price' => [ 'type' => [ 'number', 'null', ], 'minimum' => 0, 'description' => 'Up to 2 decimal places.', 'maximum' => 99999999.99, ], 'photos_new' => [ 'type' => 'array', 'maxItems' => 20, 'items' => [ 'type' => 'string', 'format' => 'binary', 'contentMediaType' => 'application/octet-stream', ], 'description' => 'Files to add, at most 20 a save, each at most 8000×8000 px.', ], 'photos_existing' => [ 'type' => 'array', 'items' => [ 'type' => 'string', ], 'description' => 'On update, the `path` of each stored file to keep, as `photos` lists them: left out, every stored file stays; an empty list removes them all.', ], 'video_url' => [ 'type' => [ 'string', 'null', ], 'format' => 'uri', 'title' => 'Video', 'maxLength' => 500, ], 'description' => [ 'type' => [ 'string', 'null', ], 'contentMediaType' => 'text/html', 'description' => 'HTML limited to p, br, strong, b, em, i, u, ul, ol, li, h2, h3, div, span, a (http, https, mailto, tel or relative href) and table, thead, tbody, tr, th and td (colspan and rowspan as whole numbers). Anything else is removed when it is written and when it is read.', 'maxLength' => 2000, ], 'size_chart' => [ 'type' => [ 'string', 'null', ], 'format' => 'binary', 'contentMediaType' => 'application/octet-stream', 'title' => 'Size chart', 'description' => 'At most 5120 KB.', ], 'is_featured' => [ 'type' => 'boolean', ], 'specs' => [ 'type' => [ 'object', 'null', ], 'propertyNames' => [ 'minLength' => 1, 'maxLength' => 100, 'pattern' => '\\S', ], 'additionalProperties' => [ 'type' => [ 'string', 'null', ], 'maxLength' => 1000, ], 'title' => 'Specifications', 'maxProperties' => 100, ], 'tag_ids' => [ 'type' => 'array', 'items' => [ 'type' => 'integer', ], 'description' => 'Ids of the related tags. On update, left out, the links stay as they are; an empty list removes them all.', ], 'tag_new' => [ 'type' => 'array', 'items' => [ 'type' => 'string', 'maxLength' => 255, ], 'description' => 'Names of tags to create and link.', ], ], 'required' => [ 'category_id', 'name', 'status', 'price', 'is_featured', ], ], 'variants' => [ 'photos' => [ 'thumb', 'medium', 'large', ], ], ]; } /** * The public API; `includes` is cut to the public modules when the document is built. * * @return array */ public static function publicApi(): array { return [ 'label' => 'Products', 'key' => [ 'type' => 'string', 'description' => 'The record\'s `slug`.', ], 'pagination' => 'offset', 'query' => FilteredProducts::class, 'set' => 'publicSet', 'schema' => [ 'type' => 'object', 'required' => [ 'id', 'category_id', 'name', 'sku', 'status', 'price', 'compare_at_price', 'photos', 'video_url', 'description', 'size_chart', 'is_featured', 'published_at', 'specs', ], 'properties' => [ 'id' => [ 'type' => 'string', 'readOnly' => true, 'description' => 'The record\'s public id (its `slug`).', ], 'category_id' => [ 'type' => 'string', 'description' => 'The related category\'s public id (its `slug`).', ], 'name' => [ 'type' => 'string', 'maxLength' => 120, ], 'sku' => [ 'type' => 'string', 'maxLength' => 32, 'title' => 'SKU', ], 'status' => [ 'type' => 'string', 'enum' => [ 'draft', 'active', 'archived', ], ], 'price' => [ 'type' => 'string', 'format' => 'decimal', 'pattern' => '^-?\\d+(\\.\\d+)?$', 'examples' => [ '1234.55', ], ], 'compare_at_price' => [ 'type' => [ 'string', 'null', ], 'format' => 'decimal', 'pattern' => '^-?\\d+(\\.\\d+)?$', 'examples' => [ '1234.55', ], 'title' => 'Compare-at price', ], 'photos' => [ 'type' => [ 'array', 'null', ], 'items' => [ 'type' => 'string', 'format' => 'uri', ], ], 'photos_variants' => [ 'type' => 'array', 'items' => [ 'type' => 'object', 'description' => 'The file route with `?size=`: each size once built, the original until then.', 'properties' => [ 'original' => [ 'type' => 'string', 'format' => 'uri', ], 'thumb' => [ 'type' => 'string', 'format' => 'uri', ], 'medium' => [ 'type' => 'string', 'format' => 'uri', ], 'large' => [ 'type' => 'string', 'format' => 'uri', ], ], ], ], 'video_url' => [ 'type' => [ 'string', 'null', ], 'format' => 'uri', 'title' => 'Video', ], 'description' => [ 'type' => [ 'string', 'null', ], 'contentMediaType' => 'text/html', 'description' => 'HTML limited to p, br, strong, b, em, i, u, ul, ol, li, h2, h3, div, span, a (http, https, mailto, tel or relative href) and table, thead, tbody, tr, th and td (colspan and rowspan as whole numbers). Anything else is removed when it is written and when it is read.', ], 'size_chart' => [ 'type' => [ 'string', 'null', ], 'format' => 'uri', 'description' => 'Where the file is served from.', 'title' => 'Size chart', ], 'is_featured' => [ 'type' => 'boolean', ], 'published_at' => [ 'type' => [ 'string', 'null', ], 'format' => 'date-time', 'title' => 'Published', 'readOnly' => true, ], 'specs' => [ 'type' => [ 'object', 'null', ], 'additionalProperties' => [ 'type' => 'string', ], 'title' => 'Specifications', ], 'category' => [ 'type' => [ 'object', 'null', ], 'description' => 'Present with ?include=category, when that module is public: its public fields.', ], 'productVariants' => [ 'type' => 'array', 'description' => 'Present with ?include=productVariants, when that module is public: their public fields.', 'items' => [ 'type' => 'object', ], ], 'reviews' => [ 'type' => 'array', 'description' => 'Present with ?include=reviews, when that module is public: their public fields.', 'items' => [ 'type' => 'object', ], ], 'coupons' => [ 'type' => 'array', 'description' => 'Present with ?include=coupons, when that module is public: their public fields.', 'items' => [ 'type' => 'object', ], ], 'tags' => [ 'type' => 'array', 'description' => 'Present with ?include=tags, when that module is public: their public fields.', 'items' => [ 'type' => 'object', ], ], ], ], 'filters' => [ 'search' => [ 'type' => 'string', 'description' => 'Matches name, sku.', ], 'category' => [ 'type' => 'string', 'description' => 'The related category\'s public id (its `slug`).', ], 'status' => [ 'type' => 'string', 'enum' => [ 'draft', 'active', 'archived', ], 'description' => 'One value, or several separated by commas.', ], 'is_featured' => [ 'type' => 'string', 'enum' => [ '1', '0', ], 'description' => '1 for true, 0 for false.', ], 'price_min' => [ 'type' => 'number', 'description' => 'At least this.', ], 'price_max' => [ 'type' => 'number', 'description' => 'At most this.', ], 'tags' => [ 'type' => 'integer', 'description' => 'Rows related to this id.', ], ], 'includes' => [ 'category', 'productVariants', 'reviews', 'coupons', 'tags', ], 'variants' => [ 'photos' => [ 'thumb', 'medium', 'large', ], ], ]; } }