From 5da434556840652f17cd76366d213f4645b5a8dc Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Fri, 8 Sep 2023 08:06:55 +0200 Subject: [PATCH] Fix type only pkg being required as js --- .../src/api/address/controllers/address.js | 3 +- .../types/generated/components.d.ts | 154 ++ .../types/generated/contentTypes.d.ts | 1311 +++++++++++++++++ packages/core/strapi/src/index.ts | 1 - packages/core/typings/.eslintignore | 1 + packages/core/typings/index.js | 2 + packages/core/typings/package.json | 5 +- 7 files changed, 1473 insertions(+), 4 deletions(-) create mode 100644 examples/getstarted/types/generated/components.d.ts create mode 100644 examples/getstarted/types/generated/contentTypes.d.ts create mode 100644 packages/core/typings/index.js diff --git a/examples/getstarted/src/api/address/controllers/address.js b/examples/getstarted/src/api/address/controllers/address.js index b942bce6ef..cc2e650912 100644 --- a/examples/getstarted/src/api/address/controllers/address.js +++ b/examples/getstarted/src/api/address/controllers/address.js @@ -1,9 +1,10 @@ const { createCoreController } = require('@strapi/strapi').factories; + module.exports = createCoreController('api::address.address', { async find(ctx) { const { results } = await strapi.service('api::address.address').find(); - ctx.body = await this.sanitizeOutput(results); + ctx.body = await this.sanitizeOutput(results, ctx); }, }); diff --git a/examples/getstarted/types/generated/components.d.ts b/examples/getstarted/types/generated/components.d.ts new file mode 100644 index 0000000000..0de23b3d8d --- /dev/null +++ b/examples/getstarted/types/generated/components.d.ts @@ -0,0 +1,154 @@ +import type { Schema, Attribute } from '@strapi/strapi'; + +export interface BasicRelation extends Schema.Component { + collectionName: 'components_basic_relations'; + info: { + displayName: 'Relation'; + }; + attributes: { + categories: Attribute.Relation<'basic.relation', 'oneToMany', 'api::category.category'>; + }; +} + +export interface BasicSimple extends Schema.Component { + collectionName: 'components_basic_simples'; + info: { + displayName: 'simple'; + icon: 'ambulance'; + description: ''; + }; + attributes: { + name: Attribute.String & Attribute.Required; + test: Attribute.String; + }; +} + +export interface BlogTestComo extends Schema.Component { + collectionName: 'components_blog_test_comos'; + info: { + displayName: 'test comp'; + icon: 'air-freshener'; + description: ''; + }; + attributes: { + name: Attribute.String & Attribute.DefaultTo<'toto'>; + }; +} + +export interface DefaultApple extends Schema.Component { + collectionName: 'components_default_apples'; + info: { + displayName: 'apple'; + icon: 'apple-alt'; + description: ''; + }; + attributes: { + name: Attribute.String & Attribute.Required; + }; +} + +export interface DefaultCar extends Schema.Component { + collectionName: 'components_default_cars'; + info: { + displayName: 'car'; + icon: 'align-right'; + }; + attributes: { + name: Attribute.String; + }; +} + +export interface DefaultClosingperiod extends Schema.Component { + collectionName: 'components_closingperiods'; + info: { + displayName: 'closingperiod'; + description: ''; + icon: 'angry'; + }; + attributes: { + label: Attribute.String & Attribute.DefaultTo<'toto'>; + start_date: Attribute.Date & Attribute.Required; + end_date: Attribute.Date & Attribute.Required; + media: Attribute.Media; + dish: Attribute.Component<'default.dish', true> & + Attribute.Required & + Attribute.SetMinMax<{ + min: 2; + }>; + }; +} + +export interface DefaultDish extends Schema.Component { + collectionName: 'components_dishes'; + info: { + displayName: 'dish'; + description: ''; + icon: 'address-book'; + }; + attributes: { + name: Attribute.String & Attribute.DefaultTo<'My super dish'>; + description: Attribute.Text; + price: Attribute.Float; + picture: Attribute.Media; + very_long_description: Attribute.RichText; + categories: Attribute.Relation<'default.dish', 'oneToOne', 'api::category.category'>; + }; +} + +export interface DefaultOpeningtimes extends Schema.Component { + collectionName: 'components_openingtimes'; + info: { + displayName: 'openingtimes'; + description: ''; + icon: 'calendar'; + }; + attributes: { + label: Attribute.String & Attribute.Required & Attribute.DefaultTo<'something'>; + time: Attribute.String; + dishrep: Attribute.Component<'default.dish', true>; + }; +} + +export interface DefaultRestaurantservice extends Schema.Component { + collectionName: 'components_restaurantservices'; + info: { + displayName: 'restaurantservice'; + description: ''; + icon: 'cannabis'; + }; + attributes: { + name: Attribute.String & Attribute.Required & Attribute.DefaultTo<'something'>; + media: Attribute.Media; + is_available: Attribute.Boolean & Attribute.Required & Attribute.DefaultTo; + }; +} + +export interface DefaultTemp extends Schema.Component { + collectionName: 'components_default_temps'; + info: { + displayName: 'temp'; + icon: 'adjust'; + description: ''; + }; + attributes: { + name: Attribute.String & Attribute.Required; + url: Attribute.String; + }; +} + +declare module '@strapi/strapi' { + export module Shared { + export interface Components { + 'basic.relation': BasicRelation; + 'basic.simple': BasicSimple; + 'blog.test-como': BlogTestComo; + 'default.apple': DefaultApple; + 'default.car': DefaultCar; + 'default.closingperiod': DefaultClosingperiod; + 'default.dish': DefaultDish; + 'default.openingtimes': DefaultOpeningtimes; + 'default.restaurantservice': DefaultRestaurantservice; + 'default.temp': DefaultTemp; + } + } +} diff --git a/examples/getstarted/types/generated/contentTypes.d.ts b/examples/getstarted/types/generated/contentTypes.d.ts new file mode 100644 index 0000000000..8122ae39de --- /dev/null +++ b/examples/getstarted/types/generated/contentTypes.d.ts @@ -0,0 +1,1311 @@ +import type { Schema, Attribute } from '@strapi/strapi'; + +export interface AdminPermission extends Schema.CollectionType { + collectionName: 'admin_permissions'; + info: { + name: 'Permission'; + description: ''; + singularName: 'permission'; + pluralName: 'permissions'; + displayName: 'Permission'; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + action: Attribute.String & + Attribute.Required & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + subject: Attribute.String & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + properties: Attribute.JSON & Attribute.DefaultTo<{}>; + conditions: Attribute.JSON & Attribute.DefaultTo<[]>; + role: Attribute.Relation<'admin::permission', 'manyToOne', 'admin::role'>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'admin::permission', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'admin::permission', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface AdminUser extends Schema.CollectionType { + collectionName: 'admin_users'; + info: { + name: 'User'; + description: ''; + singularName: 'user'; + pluralName: 'users'; + displayName: 'User'; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + firstname: Attribute.String & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + lastname: Attribute.String & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + username: Attribute.String; + email: Attribute.Email & + Attribute.Required & + Attribute.Private & + Attribute.Unique & + Attribute.SetMinMaxLength<{ + minLength: 6; + }>; + password: Attribute.Password & + Attribute.Private & + Attribute.SetMinMaxLength<{ + minLength: 6; + }>; + resetPasswordToken: Attribute.String & Attribute.Private; + registrationToken: Attribute.String & Attribute.Private; + isActive: Attribute.Boolean & Attribute.Private & Attribute.DefaultTo; + roles: Attribute.Relation<'admin::user', 'manyToMany', 'admin::role'> & Attribute.Private; + blocked: Attribute.Boolean & Attribute.Private & Attribute.DefaultTo; + preferedLanguage: Attribute.String; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'admin::user', 'oneToOne', 'admin::user'> & Attribute.Private; + updatedBy: Attribute.Relation<'admin::user', 'oneToOne', 'admin::user'> & Attribute.Private; + }; +} + +export interface AdminRole extends Schema.CollectionType { + collectionName: 'admin_roles'; + info: { + name: 'Role'; + description: ''; + singularName: 'role'; + pluralName: 'roles'; + displayName: 'Role'; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + name: Attribute.String & + Attribute.Required & + Attribute.Unique & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + code: Attribute.String & + Attribute.Required & + Attribute.Unique & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + description: Attribute.String; + users: Attribute.Relation<'admin::role', 'manyToMany', 'admin::user'>; + permissions: Attribute.Relation<'admin::role', 'oneToMany', 'admin::permission'>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'admin::role', 'oneToOne', 'admin::user'> & Attribute.Private; + updatedBy: Attribute.Relation<'admin::role', 'oneToOne', 'admin::user'> & Attribute.Private; + }; +} + +export interface AdminApiToken extends Schema.CollectionType { + collectionName: 'strapi_api_tokens'; + info: { + name: 'Api Token'; + singularName: 'api-token'; + pluralName: 'api-tokens'; + displayName: 'Api Token'; + description: ''; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + name: Attribute.String & + Attribute.Required & + Attribute.Unique & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + description: Attribute.String & + Attribute.SetMinMaxLength<{ + minLength: 1; + }> & + Attribute.DefaultTo<''>; + type: Attribute.Enumeration<['read-only', 'full-access', 'custom']> & + Attribute.Required & + Attribute.DefaultTo<'read-only'>; + accessKey: Attribute.String & + Attribute.Required & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + lastUsedAt: Attribute.DateTime; + permissions: Attribute.Relation<'admin::api-token', 'oneToMany', 'admin::api-token-permission'>; + expiresAt: Attribute.DateTime; + lifespan: Attribute.BigInteger; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'admin::api-token', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'admin::api-token', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface AdminApiTokenPermission extends Schema.CollectionType { + collectionName: 'strapi_api_token_permissions'; + info: { + name: 'API Token Permission'; + description: ''; + singularName: 'api-token-permission'; + pluralName: 'api-token-permissions'; + displayName: 'API Token Permission'; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + action: Attribute.String & + Attribute.Required & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + token: Attribute.Relation<'admin::api-token-permission', 'manyToOne', 'admin::api-token'>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'admin::api-token-permission', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'admin::api-token-permission', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface AdminTransferToken extends Schema.CollectionType { + collectionName: 'strapi_transfer_tokens'; + info: { + name: 'Transfer Token'; + singularName: 'transfer-token'; + pluralName: 'transfer-tokens'; + displayName: 'Transfer Token'; + description: ''; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + name: Attribute.String & + Attribute.Required & + Attribute.Unique & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + description: Attribute.String & + Attribute.SetMinMaxLength<{ + minLength: 1; + }> & + Attribute.DefaultTo<''>; + accessKey: Attribute.String & + Attribute.Required & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + lastUsedAt: Attribute.DateTime; + permissions: Attribute.Relation< + 'admin::transfer-token', + 'oneToMany', + 'admin::transfer-token-permission' + >; + expiresAt: Attribute.DateTime; + lifespan: Attribute.BigInteger; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'admin::transfer-token', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'admin::transfer-token', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface AdminTransferTokenPermission extends Schema.CollectionType { + collectionName: 'strapi_transfer_token_permissions'; + info: { + name: 'Transfer Token Permission'; + description: ''; + singularName: 'transfer-token-permission'; + pluralName: 'transfer-token-permissions'; + displayName: 'Transfer Token Permission'; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + action: Attribute.String & + Attribute.Required & + Attribute.SetMinMaxLength<{ + minLength: 1; + }>; + token: Attribute.Relation< + 'admin::transfer-token-permission', + 'manyToOne', + 'admin::transfer-token' + >; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'admin::transfer-token-permission', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'admin::transfer-token-permission', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface PluginUploadFile extends Schema.CollectionType { + collectionName: 'files'; + info: { + singularName: 'file'; + pluralName: 'files'; + displayName: 'File'; + description: ''; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + name: Attribute.String & Attribute.Required; + alternativeText: Attribute.String; + caption: Attribute.String; + width: Attribute.Integer; + height: Attribute.Integer; + formats: Attribute.JSON; + hash: Attribute.String & Attribute.Required; + ext: Attribute.String; + mime: Attribute.String & Attribute.Required; + size: Attribute.Decimal & Attribute.Required; + url: Attribute.String & Attribute.Required; + previewUrl: Attribute.String; + provider: Attribute.String & Attribute.Required; + provider_metadata: Attribute.JSON; + related: Attribute.Relation<'plugin::upload.file', 'morphToMany'>; + folder: Attribute.Relation<'plugin::upload.file', 'manyToOne', 'plugin::upload.folder'> & + Attribute.Private; + folderPath: Attribute.String & + Attribute.Required & + Attribute.Private & + Attribute.SetMinMax<{ + min: 1; + }>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'plugin::upload.file', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'plugin::upload.file', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface PluginUploadFolder extends Schema.CollectionType { + collectionName: 'upload_folders'; + info: { + singularName: 'folder'; + pluralName: 'folders'; + displayName: 'Folder'; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + name: Attribute.String & + Attribute.Required & + Attribute.SetMinMax<{ + min: 1; + }>; + pathId: Attribute.Integer & Attribute.Required & Attribute.Unique; + parent: Attribute.Relation<'plugin::upload.folder', 'manyToOne', 'plugin::upload.folder'>; + children: Attribute.Relation<'plugin::upload.folder', 'oneToMany', 'plugin::upload.folder'>; + files: Attribute.Relation<'plugin::upload.folder', 'oneToMany', 'plugin::upload.file'>; + path: Attribute.String & + Attribute.Required & + Attribute.SetMinMax<{ + min: 1; + }>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'plugin::upload.folder', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'plugin::upload.folder', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface PluginMypluginTest extends Schema.CollectionType { + collectionName: 'myplugin_test'; + info: { + displayName: 'Test'; + singularName: 'test'; + pluralName: 'tests'; + description: ''; + }; + options: { + draftAndPublish: false; + }; + pluginOptions: { + i18n: { + localized: true; + }; + }; + attributes: { + type: Attribute.String & + Attribute.Required & + Attribute.Unique & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'plugin::myplugin.test', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'plugin::myplugin.test', 'oneToOne', 'admin::user'> & + Attribute.Private; + localizations: Attribute.Relation< + 'plugin::myplugin.test', + 'oneToMany', + 'plugin::myplugin.test' + >; + locale: Attribute.String; + }; +} + +export interface PluginI18NLocale extends Schema.CollectionType { + collectionName: 'i18n_locale'; + info: { + singularName: 'locale'; + pluralName: 'locales'; + collectionName: 'locales'; + displayName: 'Locale'; + description: ''; + }; + options: { + draftAndPublish: false; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + name: Attribute.String & + Attribute.SetMinMax<{ + min: 1; + max: 50; + }>; + code: Attribute.String & Attribute.Unique; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'plugin::i18n.locale', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'plugin::i18n.locale', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface PluginUsersPermissionsPermission extends Schema.CollectionType { + collectionName: 'up_permissions'; + info: { + name: 'permission'; + description: ''; + singularName: 'permission'; + pluralName: 'permissions'; + displayName: 'Permission'; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + action: Attribute.String & Attribute.Required; + role: Attribute.Relation< + 'plugin::users-permissions.permission', + 'manyToOne', + 'plugin::users-permissions.role' + >; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation< + 'plugin::users-permissions.permission', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + updatedBy: Attribute.Relation< + 'plugin::users-permissions.permission', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + }; +} + +export interface PluginUsersPermissionsRole extends Schema.CollectionType { + collectionName: 'up_roles'; + info: { + name: 'role'; + description: ''; + singularName: 'role'; + pluralName: 'roles'; + displayName: 'Role'; + }; + pluginOptions: { + 'content-manager': { + visible: false; + }; + 'content-type-builder': { + visible: false; + }; + }; + attributes: { + name: Attribute.String & + Attribute.Required & + Attribute.SetMinMaxLength<{ + minLength: 3; + }>; + description: Attribute.String; + type: Attribute.String & Attribute.Unique; + permissions: Attribute.Relation< + 'plugin::users-permissions.role', + 'oneToMany', + 'plugin::users-permissions.permission' + >; + users: Attribute.Relation< + 'plugin::users-permissions.role', + 'oneToMany', + 'plugin::users-permissions.user' + >; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'plugin::users-permissions.role', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'plugin::users-permissions.role', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface PluginUsersPermissionsUser extends Schema.CollectionType { + collectionName: 'up_users'; + info: { + name: 'User'; + description: ''; + singularName: 'user'; + pluralName: 'users'; + displayName: 'User'; + }; + options: { + draftAndPublish: false; + }; + attributes: { + username: Attribute.String & + Attribute.Required & + Attribute.Unique & + Attribute.SetMinMaxLength<{ + minLength: 3; + }>; + email: Attribute.Email & + Attribute.Required & + Attribute.SetMinMaxLength<{ + minLength: 6; + }>; + provider: Attribute.String; + password: Attribute.Password & + Attribute.Private & + Attribute.SetMinMaxLength<{ + minLength: 6; + }>; + resetPasswordToken: Attribute.String & Attribute.Private; + confirmationToken: Attribute.String & Attribute.Private; + confirmed: Attribute.Boolean & Attribute.DefaultTo; + blocked: Attribute.Boolean & Attribute.DefaultTo; + role: Attribute.Relation< + 'plugin::users-permissions.user', + 'manyToOne', + 'plugin::users-permissions.role' + >; + picture: Attribute.Media; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'plugin::users-permissions.user', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'plugin::users-permissions.user', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface ApiAddressAddress extends Schema.CollectionType { + collectionName: 'addresses'; + info: { + displayName: 'Address'; + singularName: 'address'; + pluralName: 'addresses'; + description: ''; + name: 'Address'; + }; + options: { + reviewWorkflows: true; + draftAndPublish: false; + }; + attributes: { + postal_code: Attribute.String & + Attribute.SetMinMaxLength<{ + maxLength: 2; + }>; + categories: Attribute.Relation<'api::address.address', 'manyToMany', 'api::category.category'>; + cover: Attribute.Media; + images: Attribute.Media; + city: Attribute.String & + Attribute.Required & + Attribute.SetMinMaxLength<{ + maxLength: 200; + }>; + json: Attribute.JSON; + slug: Attribute.UID; + notrepeat_req: Attribute.Component<'blog.test-como'> & Attribute.Required; + repeat_req: Attribute.Component<'blog.test-como', true> & Attribute.Required; + repeat_req_min: Attribute.Component<'blog.test-como', true> & + Attribute.SetMinMax<{ + min: 2; + }>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::address.address', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'api::address.address', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface ApiCategoryCategory extends Schema.CollectionType { + collectionName: 'categories'; + info: { + displayName: 'Category'; + singularName: 'category'; + pluralName: 'categories'; + description: ''; + name: 'Category'; + }; + options: { + reviewWorkflows: true; + draftAndPublish: true; + }; + pluginOptions: { + i18n: { + localized: true; + }; + }; + attributes: { + name: Attribute.String & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + addresses: Attribute.Relation<'api::category.category', 'manyToMany', 'api::address.address'>; + temps: Attribute.Relation<'api::category.category', 'manyToMany', 'api::temp.temp'>; + datetime: Attribute.DateTime & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + date: Attribute.Date & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + relation_locales: Attribute.Relation< + 'api::category.category', + 'manyToMany', + 'api::relation-locale.relation-locale' + >; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::category.category', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'api::category.category', 'oneToOne', 'admin::user'> & + Attribute.Private; + localizations: Attribute.Relation< + 'api::category.category', + 'oneToMany', + 'api::category.category' + >; + locale: Attribute.String; + }; +} + +export interface ApiCountryCountry extends Schema.CollectionType { + collectionName: 'countries'; + info: { + displayName: 'Country'; + singularName: 'country'; + pluralName: 'countries'; + description: ''; + name: 'Country'; + }; + options: { + draftAndPublish: false; + comment: ''; + }; + pluginOptions: { + i18n: { + localized: true; + }; + }; + attributes: { + name: Attribute.String & + Attribute.Required & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }> & + Attribute.SetMinMaxLength<{ + minLength: 3; + }>; + code: Attribute.String & + Attribute.Unique & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }> & + Attribute.SetMinMaxLength<{ + minLength: 2; + maxLength: 3; + }>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::country.country', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'api::country.country', 'oneToOne', 'admin::user'> & + Attribute.Private; + localizations: Attribute.Relation<'api::country.country', 'oneToMany', 'api::country.country'>; + locale: Attribute.String; + }; +} + +export interface ApiHomepageHomepage extends Schema.SingleType { + collectionName: 'homepages'; + info: { + displayName: 'Homepage'; + singularName: 'homepage'; + pluralName: 'homepages'; + }; + options: { + draftAndPublish: true; + }; + pluginOptions: { + i18n: { + localized: true; + }; + }; + attributes: { + title: Attribute.String & + Attribute.Required & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + slug: Attribute.UID<'api::homepage.homepage', 'title'> & + Attribute.Required & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + single: Attribute.Media; + multiple: Attribute.Media; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::homepage.homepage', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'api::homepage.homepage', 'oneToOne', 'admin::user'> & + Attribute.Private; + localizations: Attribute.Relation< + 'api::homepage.homepage', + 'oneToMany', + 'api::homepage.homepage' + >; + locale: Attribute.String; + }; +} + +export interface ApiKitchensinkKitchensink extends Schema.CollectionType { + collectionName: 'kitchensinks'; + info: { + displayName: 'Kitchen Sink'; + singularName: 'kitchensink'; + pluralName: 'kitchensinks'; + description: ''; + name: 'Kitchen Sink'; + }; + options: { + draftAndPublish: true; + }; + attributes: { + short_text: Attribute.String; + long_text: Attribute.Text; + rich_text: Attribute.RichText; + integer: Attribute.Integer; + biginteger: Attribute.BigInteger; + decimal: Attribute.Decimal; + float: Attribute.Float; + date: Attribute.Date; + datetime: Attribute.DateTime; + time: Attribute.Time; + timestamp: Attribute.Timestamp; + boolean: Attribute.Boolean; + email: Attribute.Email; + password: Attribute.Password; + enumeration: Attribute.Enumeration<['A', 'B', 'C', 'D', 'E']>; + single_media: Attribute.Media; + multiple_media: Attribute.Media; + json: Attribute.JSON; + single_compo: Attribute.Component<'basic.simple'>; + repeatable_compo: Attribute.Component<'basic.simple', true>; + dynamiczone: Attribute.DynamicZone<['basic.simple', 'blog.test-como']>; + one_way_tag: Attribute.Relation<'api::kitchensink.kitchensink', 'oneToOne', 'api::tag.tag'>; + one_to_one_tag: Attribute.Relation<'api::kitchensink.kitchensink', 'oneToOne', 'api::tag.tag'> & + Attribute.Private; + one_to_many_tags: Attribute.Relation< + 'api::kitchensink.kitchensink', + 'oneToMany', + 'api::tag.tag' + >; + many_to_one_tag: Attribute.Relation< + 'api::kitchensink.kitchensink', + 'manyToOne', + 'api::tag.tag' + >; + many_to_many_tags: Attribute.Relation< + 'api::kitchensink.kitchensink', + 'manyToMany', + 'api::tag.tag' + >; + many_way_tags: Attribute.Relation<'api::kitchensink.kitchensink', 'oneToMany', 'api::tag.tag'>; + morph_to_one: Attribute.Relation<'api::kitchensink.kitchensink', 'morphToOne'>; + morph_to_many: Attribute.Relation<'api::kitchensink.kitchensink', 'morphToMany'>; + custom_field: Attribute.String & Attribute.CustomField<'plugin::color-picker.color'>; + custom_field_with_default_options: Attribute.String & + Attribute.CustomField<'plugin::color-picker.color'>; + cats: Attribute.DynamicZone<['basic.relation', 'basic.simple']>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::kitchensink.kitchensink', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'api::kitchensink.kitchensink', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface ApiLikeLike extends Schema.CollectionType { + collectionName: 'likes'; + info: { + displayName: 'Like'; + singularName: 'like'; + pluralName: 'likes'; + description: ''; + }; + options: { + draftAndPublish: false; + comment: ''; + }; + attributes: { + author: Attribute.Relation<'api::like.like', 'oneToOne', 'plugin::users-permissions.user'>; + review: Attribute.Relation<'api::like.like', 'manyToOne', 'api::review.review'>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::like.like', 'oneToOne', 'admin::user'> & Attribute.Private; + updatedBy: Attribute.Relation<'api::like.like', 'oneToOne', 'admin::user'> & Attribute.Private; + }; +} + +export interface ApiMenuMenu extends Schema.CollectionType { + collectionName: 'menus'; + info: { + description: ''; + displayName: 'Menu'; + singularName: 'menu'; + pluralName: 'menus'; + }; + options: { + draftAndPublish: false; + comment: ''; + }; + attributes: { + description: Attribute.Text; + menusections: Attribute.Relation<'api::menu.menu', 'oneToMany', 'api::menusection.menusection'>; + restaurant: Attribute.Relation<'api::menu.menu', 'oneToOne', 'api::restaurant.restaurant'>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::menu.menu', 'oneToOne', 'admin::user'> & Attribute.Private; + updatedBy: Attribute.Relation<'api::menu.menu', 'oneToOne', 'admin::user'> & Attribute.Private; + }; +} + +export interface ApiMenusectionMenusection extends Schema.CollectionType { + collectionName: 'menusections'; + info: { + displayName: 'Menu Section'; + singularName: 'menusection'; + pluralName: 'menusections'; + description: ''; + }; + options: { + draftAndPublish: false; + comment: ''; + }; + attributes: { + name: Attribute.String & + Attribute.Required & + Attribute.SetMinMaxLength<{ + minLength: 6; + }>; + dishes: Attribute.Component<'default.dish', true> & Attribute.Required; + menu: Attribute.Relation<'api::menusection.menusection', 'manyToOne', 'api::menu.menu'>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::menusection.menusection', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'api::menusection.menusection', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface ApiRelationLocaleRelationLocale extends Schema.CollectionType { + collectionName: 'relation_locales'; + info: { + singularName: 'relation-locale'; + pluralName: 'relation-locales'; + displayName: 'Relations'; + description: ''; + }; + options: { + draftAndPublish: true; + }; + pluginOptions: { + i18n: { + localized: true; + }; + }; + attributes: { + categories: Attribute.Relation< + 'api::relation-locale.relation-locale', + 'manyToMany', + 'api::category.category' + >; + title: Attribute.String & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + repeatable_relations: Attribute.Component<'basic.relation', true> & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + dynamic_relations: Attribute.DynamicZone<['basic.relation', 'basic.simple']> & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + single_relation: Attribute.Component<'basic.relation'> & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + require_single_relation: Attribute.Component<'basic.relation'> & + Attribute.Required & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation< + 'api::relation-locale.relation-locale', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + updatedBy: Attribute.Relation< + 'api::relation-locale.relation-locale', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + localizations: Attribute.Relation< + 'api::relation-locale.relation-locale', + 'oneToMany', + 'api::relation-locale.relation-locale' + >; + locale: Attribute.String; + }; +} + +export interface ApiRestaurantRestaurant extends Schema.CollectionType { + collectionName: 'restaurants'; + info: { + displayName: 'Restaurant'; + singularName: 'restaurant'; + pluralName: 'restaurants'; + description: ''; + name: 'Restaurant'; + }; + options: { + draftAndPublish: true; + populateCreatorFields: true; + comment: ''; + }; + pluginOptions: { + i18n: { + localized: true; + }; + }; + attributes: { + name: Attribute.String & + Attribute.Required & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }> & + Attribute.SetMinMaxLength<{ + minLength: 5; + maxLength: 50; + }>; + slug: Attribute.UID<'api::restaurant.restaurant', 'name'>; + priceRange: Attribute.Enumeration< + ['very_cheap', 'cheap', 'average', 'expensive', 'very_expensive'] + > & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + closingPeriod: Attribute.Component<'default.closingperiod'> & + Attribute.Required & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + contactEmail: Attribute.Email & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + stars: Attribute.Integer & + Attribute.Required & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }> & + Attribute.SetMinMax<{ + min: 0; + max: 3; + }>; + averagePrice: Attribute.Float & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }> & + Attribute.SetMinMax<{ + min: 0; + max: 35.12; + }>; + address: Attribute.Relation<'api::restaurant.restaurant', 'oneToOne', 'api::address.address'>; + cover: Attribute.Media & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + timestamp: Attribute.Timestamp; + images: Attribute.Media & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + shortDescription: Attribute.Text & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + since: Attribute.Date & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + categories: Attribute.Relation< + 'api::restaurant.restaurant', + 'oneToMany', + 'api::category.category' + >; + description: Attribute.RichText & + Attribute.Required & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }> & + Attribute.SetMinMaxLength<{ + minLength: 10; + }>; + services: Attribute.Component<'default.restaurantservice', true> & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }> & + Attribute.SetMinMax<{ + max: 1; + }>; + menu: Attribute.Relation<'api::restaurant.restaurant', 'oneToOne', 'api::menu.menu'>; + openingTimes: Attribute.Component<'default.openingtimes', true> & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }> & + Attribute.SetMinMax<{ + min: 1; + max: 10; + }>; + dz: Attribute.DynamicZone< + ['default.openingtimes', 'default.restaurantservice', 'default.closingperiod', 'default.dish'] + > & + Attribute.SetPluginOptions<{ + i18n: { + localized: true; + }; + }>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::restaurant.restaurant', 'oneToOne', 'admin::user'>; + updatedBy: Attribute.Relation<'api::restaurant.restaurant', 'oneToOne', 'admin::user'>; + localizations: Attribute.Relation< + 'api::restaurant.restaurant', + 'oneToMany', + 'api::restaurant.restaurant' + >; + locale: Attribute.String; + }; +} + +export interface ApiReviewReview extends Schema.CollectionType { + collectionName: 'reviews'; + info: { + displayName: 'Review'; + singularName: 'review'; + pluralName: 'reviews'; + description: ''; + }; + options: { + draftAndPublish: false; + comment: ''; + }; + attributes: { + comment: Attribute.Text & Attribute.Required; + rating: Attribute.Integer & + Attribute.Required & + Attribute.SetMinMax<{ + min: 1; + max: 5; + }>; + likes: Attribute.Relation<'api::review.review', 'oneToMany', 'api::like.like'>; + author: Attribute.Relation<'api::review.review', 'oneToOne', 'plugin::users-permissions.user'>; + restaurant: Attribute.Relation<'api::review.review', 'oneToOne', 'api::restaurant.restaurant'>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::review.review', 'oneToOne', 'admin::user'> & + Attribute.Private; + updatedBy: Attribute.Relation<'api::review.review', 'oneToOne', 'admin::user'> & + Attribute.Private; + }; +} + +export interface ApiTagTag extends Schema.CollectionType { + collectionName: 'tags'; + info: { + displayName: 'Tag'; + singularName: 'tag'; + pluralName: 'tags'; + description: ''; + }; + options: { + draftAndPublish: true; + }; + attributes: { + name: Attribute.String; + many_to_one_kitchensink: Attribute.Relation< + 'api::tag.tag', + 'manyToOne', + 'api::kitchensink.kitchensink' + >; + one_to_many_kitchensinks: Attribute.Relation< + 'api::tag.tag', + 'oneToMany', + 'api::kitchensink.kitchensink' + >; + many_to_many_kitchensinks: Attribute.Relation< + 'api::tag.tag', + 'manyToMany', + 'api::kitchensink.kitchensink' + >; + one_to_one_kitchensink: Attribute.Relation< + 'api::tag.tag', + 'oneToOne', + 'api::kitchensink.kitchensink' + >; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::tag.tag', 'oneToOne', 'admin::user'> & Attribute.Private; + updatedBy: Attribute.Relation<'api::tag.tag', 'oneToOne', 'admin::user'> & Attribute.Private; + }; +} + +export interface ApiTempTemp extends Schema.CollectionType { + collectionName: 'temps'; + info: { + singularName: 'temp'; + pluralName: 'temps'; + displayName: 'temp'; + name: 'temp'; + description: ''; + }; + options: { + draftAndPublish: true; + }; + attributes: { + name: Attribute.String; + category: Attribute.Relation<'api::temp.temp', 'oneToOne', 'api::category.category'>; + categories: Attribute.Relation<'api::temp.temp', 'manyToMany', 'api::category.category'>; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation<'api::temp.temp', 'oneToOne', 'admin::user'> & Attribute.Private; + updatedBy: Attribute.Relation<'api::temp.temp', 'oneToOne', 'admin::user'> & Attribute.Private; + }; +} + +declare module '@strapi/strapi' { + export module Shared { + export interface ContentTypes { + 'admin::permission': AdminPermission; + 'admin::user': AdminUser; + 'admin::role': AdminRole; + 'admin::api-token': AdminApiToken; + 'admin::api-token-permission': AdminApiTokenPermission; + 'admin::transfer-token': AdminTransferToken; + 'admin::transfer-token-permission': AdminTransferTokenPermission; + 'plugin::upload.file': PluginUploadFile; + 'plugin::upload.folder': PluginUploadFolder; + 'plugin::myplugin.test': PluginMypluginTest; + 'plugin::i18n.locale': PluginI18NLocale; + 'plugin::users-permissions.permission': PluginUsersPermissionsPermission; + 'plugin::users-permissions.role': PluginUsersPermissionsRole; + 'plugin::users-permissions.user': PluginUsersPermissionsUser; + 'api::address.address': ApiAddressAddress; + 'api::category.category': ApiCategoryCategory; + 'api::country.country': ApiCountryCountry; + 'api::homepage.homepage': ApiHomepageHomepage; + 'api::kitchensink.kitchensink': ApiKitchensinkKitchensink; + 'api::like.like': ApiLikeLike; + 'api::menu.menu': ApiMenuMenu; + 'api::menusection.menusection': ApiMenusectionMenusection; + 'api::relation-locale.relation-locale': ApiRelationLocaleRelationLocale; + 'api::restaurant.restaurant': ApiRestaurantRestaurant; + 'api::review.review': ApiReviewReview; + 'api::tag.tag': ApiTagTag; + 'api::temp.temp': ApiTempTemp; + } + } +} diff --git a/packages/core/strapi/src/index.ts b/packages/core/strapi/src/index.ts index 87fba06bab..a6e58fea0b 100644 --- a/packages/core/strapi/src/index.ts +++ b/packages/core/strapi/src/index.ts @@ -1,4 +1,3 @@ -import '@strapi/typings'; import strapiFactory from './Strapi'; export type * from '@strapi/typings'; diff --git a/packages/core/typings/.eslintignore b/packages/core/typings/.eslintignore index 1178bea959..55df64040b 100644 --- a/packages/core/typings/.eslintignore +++ b/packages/core/typings/.eslintignore @@ -2,3 +2,4 @@ node_modules/ .eslintrc.js dist/ jest.config.js +index.js diff --git a/packages/core/typings/index.js b/packages/core/typings/index.js new file mode 100644 index 0000000000..db1c359ae9 --- /dev/null +++ b/packages/core/typings/index.js @@ -0,0 +1,2 @@ +// this is a failsafe file in case the package gets required as code +module.exports = null; diff --git a/packages/core/typings/package.json b/packages/core/typings/package.json index 59f9a4a84f..10f51c027c 100644 --- a/packages/core/typings/package.json +++ b/packages/core/typings/package.json @@ -26,10 +26,11 @@ "url": "https://strapi.io" } ], - "main": "./dist/index.js", + "main": "index.js", "types": "./dist/index.d.ts", "files": [ - "./dist" + "./dist", + "index.js" ], "scripts": { "build": "run -T tsc -p tsconfig.build.json",