datocms-plugin-sdk 0.7.15 → 0.8.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.
@@ -1217,6 +1217,30 @@ export declare type ItemFormAdditionalMethods = {
1217
1217
  * ```
1218
1218
  */
1219
1219
  setFieldValue: (path: string, value: unknown) => Promise<void>;
1220
+ /**
1221
+ * Takes the internal form state, and transforms it into an Item entity
1222
+ * compatible with DatoCMS API.
1223
+ *
1224
+ * If the required nested blocks are still not loaded, this method will return
1225
+ * `undefined`.
1226
+ *
1227
+ * @example
1228
+ *
1229
+ * ```js
1230
+ * await ctx.formValuesToItem(ctx.formValues);
1231
+ * ```
1232
+ */
1233
+ formValuesToItem: (formValues: Record<string, unknown>) => Promise<Omit<Item, 'id' | 'meta'> | undefined>;
1234
+ /**
1235
+ * Takes an Item entity, and converts it into the internal form state
1236
+ *
1237
+ * @example
1238
+ *
1239
+ * ```js
1240
+ * await ctx.itemToFormValues(ctx.item);
1241
+ * ```
1242
+ */
1243
+ itemToFormValues: (item: Omit<Item, 'id' | 'meta'>) => Promise<Record<string, unknown>>;
1220
1244
  /**
1221
1245
  * Triggers a submit form for current record
1222
1246
  *
@@ -1217,6 +1217,30 @@ export declare type ItemFormAdditionalMethods = {
1217
1217
  * ```
1218
1218
  */
1219
1219
  setFieldValue: (path: string, value: unknown) => Promise<void>;
1220
+ /**
1221
+ * Takes the internal form state, and transforms it into an Item entity
1222
+ * compatible with DatoCMS API.
1223
+ *
1224
+ * If the required nested blocks are still not loaded, this method will return
1225
+ * `undefined`.
1226
+ *
1227
+ * @example
1228
+ *
1229
+ * ```js
1230
+ * await ctx.formValuesToItem(ctx.formValues);
1231
+ * ```
1232
+ */
1233
+ formValuesToItem: (formValues: Record<string, unknown>) => Promise<Omit<Item, 'id' | 'meta'> | undefined>;
1234
+ /**
1235
+ * Takes an Item entity, and converts it into the internal form state
1236
+ *
1237
+ * @example
1238
+ *
1239
+ * ```js
1240
+ * await ctx.itemToFormValues(ctx.item);
1241
+ * ```
1242
+ */
1243
+ itemToFormValues: (item: Omit<Item, 'id' | 'meta'>) => Promise<Record<string, unknown>>;
1220
1244
  /**
1221
1245
  * Triggers a submit form for current record
1222
1246
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datocms-plugin-sdk",
3
- "version": "0.7.15",
3
+ "version": "0.8.0",
4
4
  "description": "DatoCMS Plugin SDK",
5
5
  "keywords": [
6
6
  "datocms",
@@ -44,5 +44,5 @@
44
44
  "devDependencies": {
45
45
  "typedoc": "^0.23.20"
46
46
  },
47
- "gitHead": "5d21c006626fb71e79cbf29a3b7398b9e896ce10"
47
+ "gitHead": "9110cbf584ae4ac4ace170d25899ec90e32db588"
48
48
  }
package/src/types.ts CHANGED
@@ -1309,6 +1309,34 @@ export type ItemFormAdditionalMethods = {
1309
1309
  * ```
1310
1310
  */
1311
1311
  setFieldValue: (path: string, value: unknown) => Promise<void>;
1312
+ /**
1313
+ * Takes the internal form state, and transforms it into an Item entity
1314
+ * compatible with DatoCMS API.
1315
+ *
1316
+ * If the required nested blocks are still not loaded, this method will return
1317
+ * `undefined`.
1318
+ *
1319
+ * @example
1320
+ *
1321
+ * ```js
1322
+ * await ctx.formValuesToItem(ctx.formValues);
1323
+ * ```
1324
+ */
1325
+ formValuesToItem: (
1326
+ formValues: Record<string, unknown>,
1327
+ ) => Promise<Omit<Item, 'id' | 'meta'> | undefined>;
1328
+ /**
1329
+ * Takes an Item entity, and converts it into the internal form state
1330
+ *
1331
+ * @example
1332
+ *
1333
+ * ```js
1334
+ * await ctx.itemToFormValues(ctx.item);
1335
+ * ```
1336
+ */
1337
+ itemToFormValues: (
1338
+ item: Omit<Item, 'id' | 'meta'>,
1339
+ ) => Promise<Record<string, unknown>>;
1312
1340
  /**
1313
1341
  * Triggers a submit form for current record
1314
1342
  *