@webiny/api-headless-cms 5.20.0 → 5.22.0-beta.1
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.
- package/content/contextSetup.d.ts +1 -1
- package/content/contextSetup.js +2 -2
- package/content/graphQLHandlerFactory.js +13 -7
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +1 -1
- package/content/plugins/crud/contentEntry/afterDelete.js +2 -2
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +1 -1
- package/content/plugins/crud/contentEntry/beforeCreate.js +2 -2
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +1 -1
- package/content/plugins/crud/contentEntry/beforeUpdate.js +2 -2
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +8 -2
- package/content/plugins/crud/contentEntry/entryDataValidation.js +16 -6
- package/content/plugins/crud/contentEntry/markLockedFields.js +2 -2
- package/content/plugins/crud/contentEntry/referenceFieldsMapping.js +2 -2
- package/content/plugins/crud/contentEntry.crud.js +163 -77
- package/content/plugins/crud/contentModel/afterCreate.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterCreate.js +2 -2
- package/content/plugins/crud/contentModel/afterDelete.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterDelete.js +2 -2
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterUpdate.js +2 -2
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +2 -2
- package/content/plugins/crud/contentModel/beforeCreate.js +4 -4
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +1 -1
- package/content/plugins/crud/contentModel/beforeDelete.js +2 -2
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +1 -1
- package/content/plugins/crud/contentModel/beforeUpdate.js +2 -2
- package/content/plugins/crud/contentModel/models.js +2 -1
- package/content/plugins/crud/contentModel.crud.js +52 -67
- package/content/plugins/crud/contentModelGroup.crud.js +2 -2
- package/content/plugins/crud/index.d.ts +1 -1
- package/content/plugins/crud/index.js +4 -4
- package/content/plugins/graphqlFields/boolean.js +4 -2
- package/content/plugins/graphqlFields/datetime.js +4 -1
- package/content/plugins/graphqlFields/file.js +5 -2
- package/content/plugins/graphqlFields/longText.js +4 -2
- package/content/plugins/graphqlFields/number.js +4 -2
- package/content/plugins/graphqlFields/object.js +3 -1
- package/content/plugins/graphqlFields/ref.js +6 -4
- package/content/plugins/graphqlFields/requiredField.d.ts +2 -0
- package/content/plugins/graphqlFields/requiredField.js +24 -0
- package/content/plugins/graphqlFields/richText.js +5 -2
- package/content/plugins/graphqlFields/text.js +4 -2
- package/content/plugins/schema/baseSchema.js +2 -2
- package/content/plugins/schema/contentModelGroups.js +6 -2
- package/content/plugins/schema/contentModels.js +2 -0
- package/content/plugins/schema/createFieldResolvers.js +2 -2
- package/content/plugins/schema/createManageResolvers.js +2 -2
- package/content/plugins/schema/createPreviewResolvers.js +2 -2
- package/content/plugins/schema/createReadResolvers.js +2 -2
- package/content/plugins/schema/resolvers/preview/resolveGet.js +2 -2
- package/content/plugins/schema/resolvers/read/resolveGet.js +2 -2
- package/content/plugins/storage/object.js +7 -2
- package/content/plugins/utils/entryStorage.js +2 -2
- package/content/plugins/validators/index.js +3 -1
- package/content/plugins/validators/unique.d.ts +7 -0
- package/content/plugins/validators/unique.js +62 -0
- package/index.d.ts +3 -3
- package/package.json +31 -31
- package/plugins/context.d.ts +1 -1
- package/plugins/context.js +4 -4
- package/plugins/crud/index.d.ts +1 -1
- package/plugins/crud/index.js +4 -4
- package/plugins/crud/settings.crud.js +2 -2
- package/plugins/crud/system.crud.js +13 -5
- package/types.d.ts +66 -31
- package/types.js +15 -0
package/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins/types";
|
|
2
2
|
import { I18NContext, I18NLocale } from "@webiny/api-i18n/types";
|
|
3
|
-
import {
|
|
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 {
|
|
6
|
+
import { I18NContentContext } from "@webiny/api-i18n-content/types";
|
|
7
7
|
import { SecurityPermission } from "@webiny/api-security/types";
|
|
8
8
|
import { HttpContext } from "@webiny/handler-http/types";
|
|
9
9
|
import { DbContext } from "@webiny/handler-db/types";
|
|
@@ -45,12 +45,16 @@ export interface HeadlessCms extends CmsSettingsContext, CmsSystemContext, CmsGr
|
|
|
45
45
|
*
|
|
46
46
|
* @category Context
|
|
47
47
|
*/
|
|
48
|
-
export interface CmsContext extends
|
|
48
|
+
export interface CmsContext extends Context, DbContext, HttpContext, I18NContext, FileManagerContext, I18NContentContext, TenancyContext {
|
|
49
49
|
cms: HeadlessCms;
|
|
50
50
|
}
|
|
51
51
|
interface CmsModelFieldPredefinedValuesValue {
|
|
52
52
|
value: string;
|
|
53
53
|
label: string;
|
|
54
|
+
/**
|
|
55
|
+
* Default selected predefined value.
|
|
56
|
+
*/
|
|
57
|
+
selected?: boolean;
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
56
60
|
* Object containing content model field predefined options and values.
|
|
@@ -143,6 +147,13 @@ export interface CmsModelField {
|
|
|
143
147
|
* @default {}
|
|
144
148
|
*/
|
|
145
149
|
settings?: {
|
|
150
|
+
/**
|
|
151
|
+
* The default value for the field in case it is not predefined values field.
|
|
152
|
+
*/
|
|
153
|
+
defaultValue?: string | number | null | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* There are a lot of other settings that are possible to add so we keep the type opened.
|
|
156
|
+
*/
|
|
146
157
|
[key: string]: any;
|
|
147
158
|
};
|
|
148
159
|
}
|
|
@@ -186,7 +197,12 @@ export interface CmsModelFieldValidatorValidateParams<T = any> {
|
|
|
186
197
|
/**
|
|
187
198
|
* An instance of the content model being validated.
|
|
188
199
|
*/
|
|
189
|
-
|
|
200
|
+
model: CmsModel;
|
|
201
|
+
/**
|
|
202
|
+
* If entry is sent it means it is an update operation.
|
|
203
|
+
* First usage is for the unique field value.
|
|
204
|
+
*/
|
|
205
|
+
entry?: CmsEntry;
|
|
190
206
|
}
|
|
191
207
|
/**
|
|
192
208
|
* Definition for the field validator.
|
|
@@ -400,6 +416,9 @@ export interface CmsModelFieldToGraphQLPlugin extends Plugin {
|
|
|
400
416
|
* ```
|
|
401
417
|
*/
|
|
402
418
|
isSortable: boolean;
|
|
419
|
+
/**
|
|
420
|
+
* Read API methods.
|
|
421
|
+
*/
|
|
403
422
|
read: {
|
|
404
423
|
/**
|
|
405
424
|
* Definition for get filtering for GraphQL.
|
|
@@ -1180,12 +1199,12 @@ export interface AfterModelCreateTopicParams {
|
|
|
1180
1199
|
model: CmsModel;
|
|
1181
1200
|
}
|
|
1182
1201
|
export interface BeforeModelCreateFromTopicParams {
|
|
1183
|
-
input:
|
|
1202
|
+
input: CmsModelCreateInput;
|
|
1184
1203
|
original: CmsModel;
|
|
1185
1204
|
model: CmsModel;
|
|
1186
1205
|
}
|
|
1187
1206
|
export interface AfterModelCreateFromTopicParams {
|
|
1188
|
-
input:
|
|
1207
|
+
input: CmsModelCreateInput;
|
|
1189
1208
|
original: CmsModel;
|
|
1190
1209
|
model: CmsModel;
|
|
1191
1210
|
}
|
|
@@ -1216,15 +1235,6 @@ export interface CmsModelUpdateDirectParams {
|
|
|
1216
1235
|
* @category CmsModel
|
|
1217
1236
|
*/
|
|
1218
1237
|
export interface CmsModelContext {
|
|
1219
|
-
/**
|
|
1220
|
-
* A function defining usage of a method with authenticating the user but not throwing an error.
|
|
1221
|
-
*/
|
|
1222
|
-
silentAuthModel: () => {
|
|
1223
|
-
/**
|
|
1224
|
-
* Get all content models.
|
|
1225
|
-
*/
|
|
1226
|
-
list: () => Promise<CmsModel[]>;
|
|
1227
|
-
};
|
|
1228
1238
|
/**
|
|
1229
1239
|
* Get a single content model.
|
|
1230
1240
|
*/
|
|
@@ -1259,7 +1269,7 @@ export interface CmsModelContext {
|
|
|
1259
1269
|
*
|
|
1260
1270
|
* @see CmsModelManager
|
|
1261
1271
|
*/
|
|
1262
|
-
getModelManager: (
|
|
1272
|
+
getModelManager: (model: CmsModel | string) => Promise<CmsModelManager>;
|
|
1263
1273
|
/**
|
|
1264
1274
|
* Get all content model managers mapped by modelId.
|
|
1265
1275
|
* @see CmsModelManager
|
|
@@ -1410,33 +1420,37 @@ export interface CmsEntryMeta {
|
|
|
1410
1420
|
totalCount: number;
|
|
1411
1421
|
}
|
|
1412
1422
|
export interface BeforeEntryCreateTopicParams {
|
|
1413
|
-
input:
|
|
1423
|
+
input: CreateCmsEntryInput;
|
|
1414
1424
|
entry: CmsEntry;
|
|
1415
1425
|
model: CmsModel;
|
|
1416
1426
|
}
|
|
1417
1427
|
export interface AfterEntryCreateTopicParams {
|
|
1418
|
-
input:
|
|
1428
|
+
input: CreateCmsEntryInput;
|
|
1419
1429
|
entry: CmsEntry;
|
|
1420
1430
|
model: CmsModel;
|
|
1421
1431
|
storageEntry: CmsEntry;
|
|
1422
1432
|
}
|
|
1423
|
-
export interface
|
|
1433
|
+
export interface BeforeEntryCreateRevisionTopicParams {
|
|
1434
|
+
input: CreateFromCmsEntryInput;
|
|
1424
1435
|
entry: CmsEntry;
|
|
1436
|
+
original: CmsEntry;
|
|
1425
1437
|
model: CmsModel;
|
|
1426
1438
|
}
|
|
1427
|
-
export interface
|
|
1439
|
+
export interface AfterEntryCreateRevisionTopicParams {
|
|
1440
|
+
input: CreateFromCmsEntryInput;
|
|
1428
1441
|
entry: CmsEntry;
|
|
1442
|
+
original: CmsEntry;
|
|
1429
1443
|
model: CmsModel;
|
|
1430
1444
|
storageEntry: CmsEntry;
|
|
1431
1445
|
}
|
|
1432
1446
|
export interface BeforeEntryUpdateTopicParams {
|
|
1433
|
-
input:
|
|
1447
|
+
input: UpdateCmsEntryInput;
|
|
1434
1448
|
original: CmsEntry;
|
|
1435
1449
|
entry: CmsEntry;
|
|
1436
1450
|
model: CmsModel;
|
|
1437
1451
|
}
|
|
1438
1452
|
export interface AfterEntryUpdateTopicParams {
|
|
1439
|
-
input:
|
|
1453
|
+
input: UpdateCmsEntryInput;
|
|
1440
1454
|
original: CmsEntry;
|
|
1441
1455
|
entry: CmsEntry;
|
|
1442
1456
|
model: CmsModel;
|
|
@@ -1486,11 +1500,11 @@ export interface AfterEntryDeleteTopicParams {
|
|
|
1486
1500
|
entry: CmsEntry;
|
|
1487
1501
|
model: CmsModel;
|
|
1488
1502
|
}
|
|
1489
|
-
export interface
|
|
1503
|
+
export interface BeforeEntryDeleteRevisionTopicParams {
|
|
1490
1504
|
entry: CmsEntry;
|
|
1491
1505
|
model: CmsModel;
|
|
1492
1506
|
}
|
|
1493
|
-
export interface
|
|
1507
|
+
export interface AfterEntryDeleteRevisionTopicParams {
|
|
1494
1508
|
entry: CmsEntry;
|
|
1495
1509
|
model: CmsModel;
|
|
1496
1510
|
}
|
|
@@ -1502,6 +1516,27 @@ export interface BeforeEntryListTopicParams {
|
|
|
1502
1516
|
where: CmsEntryListWhere;
|
|
1503
1517
|
model: CmsModel;
|
|
1504
1518
|
}
|
|
1519
|
+
/**
|
|
1520
|
+
* @category Context
|
|
1521
|
+
* @category CmsEntry
|
|
1522
|
+
*/
|
|
1523
|
+
export interface CreateCmsEntryInput {
|
|
1524
|
+
[key: string]: any;
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* @category Context
|
|
1528
|
+
* @category CmsEntry
|
|
1529
|
+
*/
|
|
1530
|
+
export interface CreateFromCmsEntryInput {
|
|
1531
|
+
[key: string]: any;
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* @category Context
|
|
1535
|
+
* @category CmsEntry
|
|
1536
|
+
*/
|
|
1537
|
+
export interface UpdateCmsEntryInput {
|
|
1538
|
+
[key: string]: any;
|
|
1539
|
+
}
|
|
1505
1540
|
/**
|
|
1506
1541
|
* Cms Entry CRUD methods in the context.
|
|
1507
1542
|
*
|
|
@@ -1544,15 +1579,15 @@ export interface CmsEntryContext {
|
|
|
1544
1579
|
/**
|
|
1545
1580
|
* Create a new content entry.
|
|
1546
1581
|
*/
|
|
1547
|
-
createEntry: (model: CmsModel,
|
|
1582
|
+
createEntry: (model: CmsModel, input: CreateCmsEntryInput) => Promise<CmsEntry>;
|
|
1548
1583
|
/**
|
|
1549
1584
|
* Create a new entry from already existing entry.
|
|
1550
1585
|
*/
|
|
1551
|
-
createEntryRevisionFrom: (model: CmsModel, id: string,
|
|
1586
|
+
createEntryRevisionFrom: (model: CmsModel, id: string, input: CreateFromCmsEntryInput) => Promise<CmsEntry>;
|
|
1552
1587
|
/**
|
|
1553
1588
|
* Update existing entry.
|
|
1554
1589
|
*/
|
|
1555
|
-
updateEntry: (model: CmsModel, id: string,
|
|
1590
|
+
updateEntry: (model: CmsModel, id: string, input?: UpdateCmsEntryInput) => Promise<CmsEntry>;
|
|
1556
1591
|
/**
|
|
1557
1592
|
* Method that republishes entry with given identifier.
|
|
1558
1593
|
* @internal
|
|
@@ -1591,14 +1626,14 @@ export interface CmsEntryContext {
|
|
|
1591
1626
|
*/
|
|
1592
1627
|
onBeforeEntryCreate: Topic<BeforeEntryCreateTopicParams>;
|
|
1593
1628
|
onAfterEntryCreate: Topic<AfterEntryCreateTopicParams>;
|
|
1594
|
-
|
|
1595
|
-
|
|
1629
|
+
onBeforeEntryCreateRevision: Topic<BeforeEntryCreateRevisionTopicParams>;
|
|
1630
|
+
onAfterEntryCreateRevision: Topic<AfterEntryCreateRevisionTopicParams>;
|
|
1596
1631
|
onBeforeEntryUpdate: Topic<BeforeEntryUpdateTopicParams>;
|
|
1597
1632
|
onAfterEntryUpdate: Topic<AfterEntryUpdateTopicParams>;
|
|
1598
1633
|
onBeforeEntryDelete: Topic<BeforeEntryDeleteTopicParams>;
|
|
1599
1634
|
onAfterEntryDelete: Topic<AfterEntryDeleteTopicParams>;
|
|
1600
|
-
|
|
1601
|
-
|
|
1635
|
+
onBeforeEntryDeleteRevision: Topic<BeforeEntryDeleteRevisionTopicParams>;
|
|
1636
|
+
onAfterEntryDeleteRevision: Topic<AfterEntryDeleteRevisionTopicParams>;
|
|
1602
1637
|
onBeforeEntryPublish: Topic<BeforeEntryPublishTopicParams>;
|
|
1603
1638
|
onAfterEntryPublish: Topic<AfterEntryPublishTopicParams>;
|
|
1604
1639
|
onBeforeEntryUnpublish: Topic<BeforeEntryUnpublishTopicParams>;
|
package/types.js
CHANGED
|
@@ -291,6 +291,21 @@ exports.CONTENT_ENTRY_STATUS = void 0;
|
|
|
291
291
|
* @category GraphQL output
|
|
292
292
|
*/
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* @category Context
|
|
296
|
+
* @category CmsEntry
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @category Context
|
|
301
|
+
* @category CmsEntry
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @category Context
|
|
306
|
+
* @category CmsEntry
|
|
307
|
+
*/
|
|
308
|
+
|
|
294
309
|
/**
|
|
295
310
|
* Cms Entry CRUD methods in the context.
|
|
296
311
|
*
|