mirror of
https://github.com/strapi/strapi.git
synced 2025-09-08 08:08:18 +00:00
Add custom fields to TS generators
This commit is contained in:
parent
baad89e678
commit
cb10c9a81a
@ -29,6 +29,9 @@ export type NonUniqueAttribute = { unique: false };
|
|||||||
export type ConfigurableAttribute = { configurable: true };
|
export type ConfigurableAttribute = { configurable: true };
|
||||||
export type NonConfigurableAttribute = { configurable: false };
|
export type NonConfigurableAttribute = { configurable: false };
|
||||||
|
|
||||||
|
// custom field
|
||||||
|
export type CustomField<T extends string, P extends object = undefined> = { customField: T, options?: P };
|
||||||
|
|
||||||
// min/max
|
// min/max
|
||||||
export type SetMinMax<T extends MinMaxOption<U>, U = number> = T;
|
export type SetMinMax<T extends MinMaxOption<U>, U = number> = T;
|
||||||
|
|
||||||
|
@ -438,6 +438,8 @@ describe('Attributes', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO custom field
|
||||||
|
|
||||||
describe('Plugin Options', () => {
|
describe('Plugin Options', () => {
|
||||||
test('No plugin options', () => {
|
test('No plugin options', () => {
|
||||||
const attribute = {};
|
const attribute = {};
|
||||||
|
@ -70,6 +70,22 @@ const getAttributeModifiers = (attribute) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom field
|
||||||
|
if (attribute.customField) {
|
||||||
|
addImport('CustomField');
|
||||||
|
|
||||||
|
const customFieldUid = factory.createStringLiteral(attribute.customField);
|
||||||
|
const typeParams = [customFieldUid];
|
||||||
|
|
||||||
|
if (attribute.options) {
|
||||||
|
typeParams.push(toTypeLiteral(attribute.options));
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiers.push(
|
||||||
|
factory.createTypeReferenceNode(factory.createIdentifier('CustomField'), typeParams)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Plugin Options
|
// Plugin Options
|
||||||
if (!_.isEmpty(attribute.pluginOptions)) {
|
if (!_.isEmpty(attribute.pluginOptions)) {
|
||||||
addImport('SetPluginOptions');
|
addImport('SetPluginOptions');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user