UNPKG

macoolka-type-model

Version:

`macoolka-type-model` is a library for define model in TypeScript. It easily build a type contain field and method to your Application. It provide a generation model for type and validition

473 lines 12 kB
"use strict"; /** * Code generated by github.com/macoolka/macoolka-gen-model, DO NOT EDIT. * @since 0.2.0 */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Element = exports.Entity = exports.FieldElement = exports.Action = exports.Card = exports.QueryForm = exports.MutationForm = exports.Formable = exports.Iconable = exports.Pageable = exports.Elements = void 0; var t = __importStar(require("../io")); var Field = t.MField; var MInfoable = t.MInfoable; var MNameable = t.MNameable; /** * The element collection * @desczh * 渲染要素集合 * @since 0.2.0 */ exports.Elements = t.recursion('Elements', function () { return t.intersection([ /** * @since 0.2.0 */ t.type({ /** * @since 0.2.0 */ order: t.number, }) /** * @since 0.2.0 */ , t.partial({ /** * @since 0.2.0 */ item: exports.Element, /** * @since 0.2.0 */ items: t.withDefault(t.array(exports.Elements), []), }), ]); }); /** * Type have a page information * @desczh * 单独页面 * @since 0.2.0 */ exports.Pageable = /** * @since 0.2.0 */ t.partial({ /** * The page url * @desczh * 页面url * @since 0.2.0 */ href: t.string, }); /** * Type have a icon field * @desczh * 有一个图标字段 * @since 0.2.0 */ exports.Iconable = /** * @since 0.2.0 */ t.partial({ /** * Icon name * @desczh * 图标名称 * @since 0.2.0 */ icon: t.string, }); /** * @since 0.2.0 */ exports.Formable = t.intersection([ MInfoable, MNameable, exports.Pageable, exports.Iconable /** * @since 0.2.0 */ , t.partial({ /** * Contain query condition element * @desczh * 输入容器 * @since 0.2.0 */ input: t.withDefault(t.array(exports.Elements), []), /** * @since 0.2.0 */ style: t.keyof({ Add: '', Edit: '', Setting: '', Display: '' }), /** * Execute submit action after change event * @desczh * 当数据改变事件触发后执行submit动作 * @since 0.2.0 */ changeSubmit: t.withDefault(t.boolean, false), /** * Execute submit action after init action execute when the render is ready * @desczh * 当渲染完毕后以及初始化动作完成后执行submit动作 * @since 0.2.0 */ autoSubmit: t.withDefault(t.boolean, false), /** * @since 0.2.0 */ actions: t.withDefault(t.array(exports.Elements), []), /** * Get data from input element and execute submit action * @desczh * 提交动作表示从input中得到对应数据并执行预定义方法 * @since 0.2.0 */ submitAction: t.string, /** * The action mean init input element.Excute when the render is ready * @desczh * 初始化数据,渲染完成后自动执行 * @since 0.2.0 */ initAction: t.string, /** * The action mean init data.Excute on server render * @desczh * 初始化查询条件,服务器端自动执行 * @since 0.2.0 */ initActionOnServer: t.string, /** * Show the info when submit success * @desczh * 显示这个信息在提交成功后 * @since 0.2.0 */ success: t.withDefault(t.array(t.string), []), /** * i18n success * @desczh * 国际化成功消息 * @since 0.2.0 */ successes: t.record(t.string, t.any), }), ], 'Formable'); /** * @since 0.2.0 */ exports.MutationForm = t.intersection([ exports.Formable /** * @since 0.2.0 */ , t.type({ /** * The _kind is a tag that check which Type be used. * @desczh * 标签判断哪一个Type被使用 * @since 0.2.0 */ _kind: t.withDefault(t.literal('mutation'), 'mutation'), }), ], 'MutationForm'); /** * @since 0.2.0 */ exports.QueryForm = t.intersection([ exports.Formable, t.intersection([ /** * @since 0.2.0 */ t.type({ /** * The _kind is a tag that check which Type be used. * @desczh * 标签判断哪一个Type被使用 * @since 0.2.0 */ _kind: t.withDefault(t.literal('query'), 'query'), }) /** * @since 0.2.0 */ , t.partial({ /** * Contain query condition element * @desczh * 查询结果 * @since 0.2.0 */ result: t.withDefault(t.array(exports.Elements), []), }), ]), ], 'QueryForm'); /** * The card * @desczh * * @since 0.2.0 */ exports.Card = t.intersection([ MInfoable, MNameable, exports.Pageable, t.intersection([ /** * @since 0.2.0 */ t.type({ /** * The _kind is a tag that check which Type be used. * @desczh * 标签判断哪一个Type被使用 * @since 0.2.0 */ _kind: t.withDefault(t.literal('card'), 'card'), }) /** * @since 0.2.0 */ , t.partial({ /** * @since 0.2.0 */ type: t.keyof({ Add: '', Edit: '', Setting: '', Display: '', Manager: '', Home: '', Form: '', App: '', Grid: '', Group: '', }), /** * @since 0.2.0 */ image: t.string, /** * @since 0.2.0 */ elements: t.withDefault(t.array(exports.Elements), []), /** * @since 0.2.0 */ actions: t.withDefault(t.array(exports.Elements), []), /** * @since 0.2.0 */ links: t.withDefault(t.array(exports.Elements), []), /** * @since 0.2.0 */ mainActions: t.withDefault(t.array(exports.Elements), []), /** * @since 0.2.0 */ moreActions: t.withDefault(t.array(exports.Elements), []), }), ]), ], 'Card'); /** * @since 0.2.0 */ exports.Action = t.intersection([ MInfoable, MNameable, exports.Iconable, t.intersection([ /** * @since 0.2.0 */ t.type({ /** * The _kind is a tag that check which Type be used. * @desczh * 标签判断哪一个Type被使用 * @since 0.2.0 */ _kind: t.withDefault(t.literal('action'), 'action'), }) /** * @since 0.2.0 */ , t.partial({ /** * action type * @desczh * 动作类型 * @since 0.2.0 */ actionType: t.keyof({ Load: '', Loads: '', Query: '', QueryReset: '', Reset: '', QueryMore: '', LoadWithID: '', OpenWithID: '', DeleteWithID: '', UploadImage: '', UploadFile: '', Search: '', Submit: '', Link: '', }), /** * link url * @desczh * 链接url * @since 0.2.0 */ link: t.string, /** * action target * @desczh * 动作目标 * @since 0.2.0 */ target: t.withDefault(t.keyof({ Main: '', NewPage: '', Dialog: '' }), 'Main'), }), ]), ], 'Action'); /** * The used with field when render * @desczh * 字段渲染时对应的组件 * @since 0.2.0 */ exports.FieldElement = t.intersection([ MInfoable, MNameable, exports.Iconable, t.intersection([ /** * @since 0.2.0 */ t.type({ /** * The _kind is a tag that check which Type be used. * @desczh * 标签判断哪一个Type被使用 * @since 0.2.0 */ _kind: t.withDefault(t.literal('fieldElement'), 'fieldElement'), }) /** * @since 0.2.0 */ , t.partial({ /** * The Field used on render * @desczh * 对应字段 * @since 0.2.0 */ field: Field, /** * The Element type * @desczh * 类型 * @since 0.2.0 */ type: t.keyof({ H1: '', H2: '', H3: '', P: '', P1: '', P2: '', P3: '', Header: '', Subtitle: '', Overline: '', Caption: '', TextField: '', Display: '', }), /** * max rows count on render with non-TextField * @desczh * 在渲染中最大行数,用在类型非TextField时 * @since 0.2.0 */ maxRows: t.number, }), ]), ], 'FieldElement'); /** * @since 0.2.0 */ exports.Entity = t.intersection([ MInfoable, MNameable /** * @since 0.2.0 */ , t.type({ /** * @since 0.2.0 */ fields: t.withDefault(t.array(Field), []), /** * @since 0.2.0 */ mutations: t.withDefault(t.array(exports.MutationForm), []), /** * @since 0.2.0 */ forms: t.withDefault(t.array(exports.QueryForm), []), /** * @since 0.2.0 */ cards: t.withDefault(t.array(exports.Card), []), /** * @since 0.2.0 */ actions: t.withDefault(t.array(exports.Action), []), /** * @since 0.2.0 */ elements: t.withDefault(t.array(exports.FieldElement), []), }), ], 'Entity'); /** * The Element when render * @desczh * 渲染要素 * @since 0.2.0 */ exports.Element = t.union([Field, exports.FieldElement, exports.Card, exports.MutationForm, exports.QueryForm, exports.Action]); //# sourceMappingURL=io.js.map