@webiny/api-headless-cms 5.25.0 → 5.26.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/content/graphQLHandlerFactory.js +3 -1
  2. package/content/graphQLHandlerFactory.js.map +1 -1
  3. package/content/plugins/crud/contentEntry/afterDelete.js +1 -2
  4. package/content/plugins/crud/contentEntry/afterDelete.js.map +1 -1
  5. package/content/plugins/crud/contentEntry.crud.d.ts +2 -0
  6. package/content/plugins/crud/contentEntry.crud.js +71 -72
  7. package/content/plugins/crud/contentEntry.crud.js.map +1 -1
  8. package/content/plugins/crud/contentModel/beforeDelete.js +0 -2
  9. package/content/plugins/crud/contentModel/beforeDelete.js.map +1 -1
  10. package/content/plugins/crud/contentModel.crud.js +21 -12
  11. package/content/plugins/crud/contentModel.crud.js.map +1 -1
  12. package/content/plugins/crud/contentModelGroup.crud.js +38 -45
  13. package/content/plugins/crud/contentModelGroup.crud.js.map +1 -1
  14. package/content/plugins/crud/index.js +5 -3
  15. package/content/plugins/crud/index.js.map +1 -1
  16. package/content/plugins/graphqlFields/longText.js +1 -0
  17. package/content/plugins/graphqlFields/longText.js.map +1 -1
  18. package/content/plugins/graphqlFields/text.js +1 -0
  19. package/content/plugins/graphqlFields/text.js.map +1 -1
  20. package/content/plugins/schema/contentEntries.js +6 -9
  21. package/content/plugins/schema/contentEntries.js.map +1 -1
  22. package/content/plugins/validators/unique.js +0 -1
  23. package/content/plugins/validators/unique.js.map +1 -1
  24. package/package.json +24 -25
  25. package/plugins/context.js +9 -3
  26. package/plugins/context.js.map +1 -1
  27. package/plugins/crud/index.js +7 -4
  28. package/plugins/crud/index.js.map +1 -1
  29. package/plugins/crud/settings.crud.js +0 -1
  30. package/plugins/crud/settings.crud.js.map +1 -1
  31. package/plugins/crud/system.crud.d.ts +2 -0
  32. package/plugins/crud/system.crud.js +5 -4
  33. package/plugins/crud/system.crud.js.map +1 -1
  34. package/types.d.ts +59 -107
  35. package/types.js.map +1 -1
package/types.d.ts CHANGED
@@ -3,7 +3,6 @@ import { I18NContext, I18NLocale } from "@webiny/api-i18n/types";
3
3
  import { Context } from "@webiny/handler/types";
4
4
  import { TenancyContext } from "@webiny/api-tenancy/types";
5
5
  import { GraphQLFieldResolver, GraphQLSchemaDefinition, Resolvers } from "@webiny/handler-graphql/types";
6
- import { I18NContentContext } from "@webiny/api-i18n-content/types";
7
6
  import { SecurityPermission } from "@webiny/api-security/types";
8
7
  import { HttpContext } from "@webiny/handler-http/types";
9
8
  import { DbContext } from "@webiny/handler-db/types";
@@ -46,7 +45,7 @@ export interface HeadlessCms extends CmsSettingsContext, CmsSystemContext, CmsGr
46
45
  *
47
46
  * @category Context
48
47
  */
49
- export interface CmsContext extends Context, DbContext, HttpContext, I18NContext, FileManagerContext, I18NContentContext, TenancyContext {
48
+ export interface CmsContext extends Context, DbContext, HttpContext, I18NContext, FileManagerContext, TenancyContext {
50
49
  cms: HeadlessCms;
51
50
  }
52
51
  interface CmsModelFieldPredefinedValuesValue {
@@ -320,6 +319,10 @@ export interface CmsModel {
320
319
  * Unique ID for the content model. Created from name if not defined by user.
321
320
  */
322
321
  modelId: string;
322
+ /**
323
+ * Model tenant.
324
+ */
325
+ tenant: string;
323
326
  /**
324
327
  * Locale this model belongs to.
325
328
  */
@@ -340,7 +343,7 @@ export interface CmsModel {
340
343
  /**
341
344
  * Description for the content model.
342
345
  */
343
- description?: string | null;
346
+ description: string;
344
347
  /**
345
348
  * Date created
346
349
  */
@@ -381,10 +384,6 @@ export interface CmsModel {
381
384
  * The version of Webiny which this record was stored with.
382
385
  */
383
386
  webinyVersion: string;
384
- /**
385
- * Model tenant.
386
- */
387
- tenant: string;
388
387
  }
389
388
  /**
390
389
  * @category ModelField
@@ -432,6 +431,15 @@ export interface CmsModelFieldToGraphQLPlugin extends Plugin {
432
431
  * ```
433
432
  */
434
433
  isSearchable: boolean;
434
+ /**
435
+ * Is the field searchable via full text search?
436
+ *
437
+ * Field is not full text searchable by default.
438
+ * ```ts
439
+ * fullTextSearch: false
440
+ * ```
441
+ */
442
+ fullTextSearch?: boolean;
435
443
  /**
436
444
  * Is the field sortable via the GraphQL?
437
445
  *
@@ -730,9 +738,11 @@ export interface CmsSettingsContext {
730
738
  }
731
739
  export interface BeforeInstallTopicParams {
732
740
  tenant: string;
741
+ locale: string;
733
742
  }
734
743
  export interface AfterInstallTopicParams {
735
744
  tenant: string;
745
+ locale: string;
736
746
  }
737
747
  export declare type CmsSystemContext = {
738
748
  getSystemVersion: () => Promise<string | null>;
@@ -789,6 +799,10 @@ export interface CmsGroup {
789
799
  * Slug for the group. Must be unique.
790
800
  */
791
801
  slug: string;
802
+ /**
803
+ * Group tenant.
804
+ */
805
+ tenant: string;
792
806
  /**
793
807
  * Locale this group belongs to.
794
808
  */
@@ -796,11 +810,11 @@ export interface CmsGroup {
796
810
  /**
797
811
  * Description for the group.
798
812
  */
799
- description?: string;
813
+ description: string;
800
814
  /**
801
815
  * Icon for the group. In a form of "ico/ico".
802
816
  */
803
- icon?: string;
817
+ icon: string;
804
818
  /**
805
819
  * CreatedBy reference object.
806
820
  */
@@ -817,10 +831,6 @@ export interface CmsGroup {
817
831
  * Which Webiny version was this record stored with.
818
832
  */
819
833
  webinyVersion: string;
820
- /**
821
- * Group tenant.
822
- */
823
- tenant: string;
824
834
  }
825
835
  /**
826
836
  * A data.where parameter received when listing content model groups.
@@ -906,6 +916,10 @@ export interface CmsGroupContext {
906
916
  * Delete content model group by given id.
907
917
  */
908
918
  deleteGroup: (id: string) => Promise<boolean>;
919
+ /**
920
+ * Clear the cached groups.
921
+ */
922
+ clearGroupsCache: () => void;
909
923
  /**
910
924
  * Events.
911
925
  */
@@ -1296,13 +1310,22 @@ export interface CmsModelContext {
1296
1310
  * Get a instance of CmsModelManager for given content modelId.
1297
1311
  *
1298
1312
  * @see CmsModelManager
1313
+ *
1314
+ * @deprecated use the getEntryManager() method instead
1299
1315
  */
1300
1316
  getModelManager: (model: CmsModel | string) => Promise<CmsModelManager>;
1317
+ getEntryManager: (model: CmsModel | string) => Promise<CmsModelManager>;
1301
1318
  /**
1302
1319
  * Get all content model managers mapped by modelId.
1303
1320
  * @see CmsModelManager
1321
+ * @deprecated use getEntryManagers instead
1304
1322
  */
1305
1323
  getManagers: () => Map<string, CmsModelManager>;
1324
+ getEntryManagers: () => Map<string, CmsModelManager>;
1325
+ /**
1326
+ * Clear all the model caches.
1327
+ */
1328
+ clearModelsCache: () => void;
1306
1329
  /**
1307
1330
  * Events.
1308
1331
  */
@@ -1320,7 +1343,7 @@ export interface CmsModelContext {
1320
1343
  *
1321
1344
  * @category CmsEntry
1322
1345
  */
1323
- declare type CmsEntryStatus = "published" | "unpublished" | "reviewRequested" | "changesRequested" | "draft";
1346
+ export declare type CmsEntryStatus = "published" | "unpublished" | "reviewRequested" | "changesRequested" | "draft";
1324
1347
  export interface CmsEntryListWhereRef {
1325
1348
  id?: string;
1326
1349
  id_in?: string[];
@@ -1353,7 +1376,9 @@ export interface CmsEntryListWhere {
1353
1376
  entryId_in?: string[];
1354
1377
  entryId_not_in?: string[];
1355
1378
  /**
1356
- * Entry is owned by whom?
1379
+ * Contains the owner of the entry. An "owner" is the identity who originally created the entry.
1380
+ * Subsequent revisions can be created by other identities, and those will be stored in `createdBy`,
1381
+ * but the `owner` is always the original author of the entry.
1357
1382
  *
1358
1383
  * Can be sent via the API or set internal if user can see only their own entries.
1359
1384
  */
@@ -1378,32 +1403,23 @@ export interface CmsEntryListWhere {
1378
1403
  version_lt?: number;
1379
1404
  version_gt?: number;
1380
1405
  /**
1381
- * Each operations implementation MUST determine how to use this field.
1382
- * In SQL it can be published field and in DynamoDB can be a secondary key.
1406
+ * Each storage operations implementation MUST determine how to use this field.
1407
+ * In SQL, it can be a `published` field, and in DynamoDB it can be an SK.
1383
1408
  *
1384
1409
  * It is not meant to be used via the API.
1385
1410
  * @internal
1386
1411
  */
1387
1412
  published?: boolean;
1388
1413
  /**
1389
- * Each operations implementation MUST determine how to use this field.
1390
- * In SQL it can be published field and in DynamoDB can be a secondary key.
1414
+ * Each storage operations implementation MUST determine how to use this field.
1415
+ * In SQL, it can be a `latest` field, and in DynamoDB it can be an SK.
1391
1416
  *
1392
1417
  * It is not meant to be used via the API.
1393
1418
  * @internal
1394
1419
  */
1395
1420
  latest?: boolean;
1396
1421
  /**
1397
- * Search for exact locale.
1398
- * This will most likely be populated, but leave it as optional.
1399
- */
1400
- locale?: string;
1401
- /**
1402
- * Exact tenant. No multi-tenancy search.
1403
- */
1404
- tenant: string;
1405
- /**
1406
- * Can be reference field or, actually, anything else.
1422
+ * This is to allow querying by any content model field defined by the user.
1407
1423
  */
1408
1424
  [key: string]: any | CmsEntryListWhereRef;
1409
1425
  }
@@ -1431,8 +1447,10 @@ export interface CmsEntryGetParams {
1431
1447
  * @category GraphQL params
1432
1448
  */
1433
1449
  export interface CmsEntryListParams {
1434
- where: CmsEntryListWhere;
1450
+ where?: CmsEntryListWhere;
1435
1451
  sort?: CmsEntryListSort;
1452
+ search?: string;
1453
+ fields?: string[];
1436
1454
  limit?: number;
1437
1455
  after?: string | null;
1438
1456
  }
@@ -1786,13 +1804,10 @@ export interface CmsGroupStorageOperationsListParams {
1786
1804
  sort?: string[];
1787
1805
  }
1788
1806
  export interface CmsGroupStorageOperationsCreateParams {
1789
- input: CmsGroupCreateInput;
1790
1807
  group: CmsGroup;
1791
1808
  }
1792
1809
  export interface CmsGroupStorageOperationsUpdateParams {
1793
- original: CmsGroup;
1794
1810
  group: CmsGroup;
1795
- input: CmsGroupUpdateInput;
1796
1811
  }
1797
1812
  export interface CmsGroupStorageOperationsDeleteParams {
1798
1813
  group: CmsGroup;
@@ -1838,13 +1853,10 @@ export interface CmsModelStorageOperationsListParams {
1838
1853
  where: CmsModelStorageOperationsListWhereParams;
1839
1854
  }
1840
1855
  export interface CmsModelStorageOperationsCreateParams {
1841
- input: CmsModelCreateInput;
1842
1856
  model: CmsModel;
1843
1857
  }
1844
1858
  export interface CmsModelStorageOperationsUpdateParams {
1845
- original: CmsModel;
1846
1859
  model: CmsModel;
1847
- input: CmsModelUpdateInput;
1848
1860
  }
1849
1861
  export interface CmsModelStorageOperationsDeleteParams {
1850
1862
  model: CmsModel;
@@ -1884,14 +1896,12 @@ export interface CmsEntryStorageOperationsGetParams {
1884
1896
  export interface CmsEntryStorageOperationsListParams {
1885
1897
  where: CmsEntryListWhere;
1886
1898
  sort?: CmsEntryListSort;
1899
+ search?: string;
1900
+ fields?: string[];
1887
1901
  limit?: number;
1888
1902
  after?: string | null;
1889
1903
  }
1890
1904
  export interface CmsEntryStorageOperationsCreateParams<T extends CmsStorageEntry = CmsStorageEntry> {
1891
- /**
1892
- * Input received from the user.
1893
- */
1894
- input: Record<string, any>;
1895
1905
  /**
1896
1906
  * Real entry, with no transformations on it.
1897
1907
  */
@@ -1902,14 +1912,6 @@ export interface CmsEntryStorageOperationsCreateParams<T extends CmsStorageEntry
1902
1912
  storageEntry: T;
1903
1913
  }
1904
1914
  export interface CmsEntryStorageOperationsCreateRevisionFromParams<T extends CmsStorageEntry = CmsStorageEntry> {
1905
- /**
1906
- * The entry we are creating new one from.
1907
- */
1908
- originalEntry: CmsEntry;
1909
- /**
1910
- * The entry we are creating new one from, directly from storage, with transformations on it.
1911
- */
1912
- originalStorageEntry: T;
1913
1915
  /**
1914
1916
  * Latest entry, used to calculate the new version.
1915
1917
  */
@@ -1928,18 +1930,6 @@ export interface CmsEntryStorageOperationsCreateRevisionFromParams<T extends Cms
1928
1930
  storageEntry: T;
1929
1931
  }
1930
1932
  export interface CmsEntryStorageOperationsUpdateParams<T extends CmsStorageEntry = CmsStorageEntry> {
1931
- /**
1932
- * Input received from the user.
1933
- */
1934
- input: Record<string, any>;
1935
- /**
1936
- * Used to compare IDs, versions and passed into storage operations to be used if required.
1937
- */
1938
- originalEntry: CmsEntry;
1939
- /**
1940
- * Directly from storage, with transformations on it.
1941
- */
1942
- originalStorageEntry: T;
1943
1933
  /**
1944
1934
  * Real entry, with no transformations on it.
1945
1935
  */
@@ -1953,39 +1943,27 @@ export interface CmsEntryStorageOperationsDeleteRevisionParams<T extends CmsStor
1953
1943
  /**
1954
1944
  * Entry that was deleted.
1955
1945
  */
1956
- entryToDelete: CmsEntry;
1946
+ entry: CmsEntry;
1957
1947
  /**
1958
1948
  * Entry that was deleted, directly from storage, with transformations.
1959
1949
  */
1960
- storageEntryToDelete: T;
1950
+ storageEntry: T;
1961
1951
  /**
1962
1952
  * Entry that was set as latest.
1963
1953
  */
1964
- entryToSetAsLatest: CmsEntry | null;
1954
+ latestEntry: CmsEntry | null;
1965
1955
  /**
1966
1956
  * Entry that was set as latest, directly from storage, with transformations.
1967
1957
  */
1968
- storageEntryToSetAsLatest: T | null;
1958
+ latestStorageEntry: T | null;
1969
1959
  }
1970
- export interface CmsEntryStorageOperationsDeleteParams<T extends CmsStorageEntry = CmsStorageEntry> {
1960
+ export interface CmsEntryStorageOperationsDeleteParams {
1971
1961
  /**
1972
1962
  * Entry that is going to be deleted.
1973
1963
  */
1974
1964
  entry: CmsEntry;
1975
- /**
1976
- * Entry that is going to be deleted, directly from storage.
1977
- */
1978
- storageEntry: T;
1979
1965
  }
1980
1966
  export interface CmsEntryStorageOperationsPublishParams<T extends CmsStorageEntry = CmsStorageEntry> {
1981
- /**
1982
- * The entry record before it was published.
1983
- */
1984
- originalEntry: CmsEntry;
1985
- /**
1986
- * Directly from storage, with transformations on it.
1987
- */
1988
- originalStorageEntry: T;
1989
1967
  /**
1990
1968
  * The modified entry that is going to be saved as published.
1991
1969
  * Entry is in its original form.
@@ -1997,14 +1975,6 @@ export interface CmsEntryStorageOperationsPublishParams<T extends CmsStorageEntr
1997
1975
  storageEntry: T;
1998
1976
  }
1999
1977
  export interface CmsEntryStorageOperationsUnpublishParams<T extends CmsStorageEntry = CmsStorageEntry> {
2000
- /**
2001
- * The entry record before it was unpublished.
2002
- */
2003
- originalEntry: CmsEntry;
2004
- /**
2005
- * The entry record before it was unpublished, with transformations on it.
2006
- */
2007
- originalStorageEntry: T;
2008
1978
  /**
2009
1979
  * The modified entry that is going to be saved as unpublished.
2010
1980
  */
@@ -2023,14 +1993,6 @@ export interface CmsEntryStorageOperationsRequestChangesParams<T extends CmsStor
2023
1993
  * Entry that is prepared for the storageOperations, with the transformations.
2024
1994
  */
2025
1995
  storageEntry: T;
2026
- /**
2027
- * Original entry from the storage.
2028
- */
2029
- originalEntry: CmsEntry;
2030
- /**
2031
- * Original entry to be updated, directly from storage, with the transformations.
2032
- */
2033
- originalStorageEntry: T;
2034
1996
  }
2035
1997
  export interface CmsEntryStorageOperationsRequestReviewParams<T extends CmsStorageEntry = CmsStorageEntry> {
2036
1998
  /**
@@ -2041,14 +2003,6 @@ export interface CmsEntryStorageOperationsRequestReviewParams<T extends CmsStora
2041
2003
  * Entry that is prepared for the storageOperations, with the transformations.
2042
2004
  */
2043
2005
  storageEntry: T;
2044
- /**
2045
- * Original entry from the storage.
2046
- */
2047
- originalEntry: CmsEntry;
2048
- /**
2049
- * Original entry to be updated, directly from storage, with the transformations.
2050
- */
2051
- originalStorageEntry: T;
2052
2006
  }
2053
2007
  export interface CmsEntryStorageOperationsGetByIdsParams {
2054
2008
  ids: readonly string[];
@@ -2165,7 +2119,7 @@ export interface CmsEntryStorageOperations<T extends CmsStorageEntry = CmsStorag
2165
2119
  /**
2166
2120
  * Delete the entry.
2167
2121
  */
2168
- delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams<T>) => Promise<void>;
2122
+ delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;
2169
2123
  /**
2170
2124
  * Publish the entry.
2171
2125
  */
@@ -2198,7 +2152,6 @@ export interface CmsSettingsStorageOperationsCreateParams {
2198
2152
  settings: CmsSettings;
2199
2153
  }
2200
2154
  export interface CmsSettingsStorageOperationsUpdateParams {
2201
- original: CmsSettings;
2202
2155
  settings: CmsSettings;
2203
2156
  }
2204
2157
  export interface CmsSettingsStorageOperations {
@@ -2231,7 +2184,6 @@ export interface CmsSystemStorageOperationsCreateParams {
2231
2184
  }
2232
2185
  export interface CmsSystemStorageOperationsUpdateParams {
2233
2186
  system: CmsSystem;
2234
- original: CmsSystem;
2235
2187
  }
2236
2188
  export interface CmsSystemStorageOperations {
2237
2189
  /**
@@ -2253,11 +2205,11 @@ export interface HeadlessCmsStorageOperations {
2253
2205
  groups: CmsGroupStorageOperations;
2254
2206
  models: CmsModelStorageOperations;
2255
2207
  entries: CmsEntryStorageOperations;
2256
- init?: (cms: HeadlessCms) => Promise<void>;
2257
2208
  /**
2258
- * Plugins to be attached to the main context.
2209
+ * Either attach something from the storage operations or run something in it.
2259
2210
  */
2260
- plugins?: Plugin[] | Plugin[][];
2211
+ beforeInit?: (context: CmsContext) => Promise<void>;
2212
+ init?: (context: CmsContext) => Promise<void>;
2261
2213
  /**
2262
2214
  * An upgrade to run if necessary.
2263
2215
  */