datocms-plugin-sdk 0.7.15 → 0.8.2

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,33 @@ 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
+ * When `skipUnchangedFields`, only the fields that changed value will be
1225
+ * serialized.
1226
+ *
1227
+ * If the required nested blocks are still not loaded, this method will return
1228
+ * `undefined`.
1229
+ *
1230
+ * @example
1231
+ *
1232
+ * ```js
1233
+ * await ctx.formValuesToItem(ctx.formValues, false);
1234
+ * ```
1235
+ */
1236
+ formValuesToItem: (formValues: Record<string, unknown>, skipUnchangedFields?: boolean) => Promise<Omit<Item, 'id' | 'meta'> | undefined>;
1237
+ /**
1238
+ * Takes an Item entity, and converts it into the internal form state
1239
+ *
1240
+ * @example
1241
+ *
1242
+ * ```js
1243
+ * await ctx.itemToFormValues(ctx.item);
1244
+ * ```
1245
+ */
1246
+ itemToFormValues: (item: Omit<Item, 'id' | 'meta'>) => Promise<Record<string, unknown>>;
1220
1247
  /**
1221
1248
  * Triggers a submit form for current record
1222
1249
  *
@@ -1217,6 +1217,33 @@ 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
+ * When `skipUnchangedFields`, only the fields that changed value will be
1225
+ * serialized.
1226
+ *
1227
+ * If the required nested blocks are still not loaded, this method will return
1228
+ * `undefined`.
1229
+ *
1230
+ * @example
1231
+ *
1232
+ * ```js
1233
+ * await ctx.formValuesToItem(ctx.formValues, false);
1234
+ * ```
1235
+ */
1236
+ formValuesToItem: (formValues: Record<string, unknown>, skipUnchangedFields?: boolean) => Promise<Omit<Item, 'id' | 'meta'> | undefined>;
1237
+ /**
1238
+ * Takes an Item entity, and converts it into the internal form state
1239
+ *
1240
+ * @example
1241
+ *
1242
+ * ```js
1243
+ * await ctx.itemToFormValues(ctx.item);
1244
+ * ```
1245
+ */
1246
+ itemToFormValues: (item: Omit<Item, 'id' | 'meta'>) => Promise<Record<string, unknown>>;
1220
1247
  /**
1221
1248
  * Triggers a submit form for current record
1222
1249
  *
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.2",
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": "cd9036995eefda50300a5226e7511ee7f3377cd0"
48
48
  }
package/src/types.ts CHANGED
@@ -1309,6 +1309,38 @@ 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
+ * When `skipUnchangedFields`, only the fields that changed value will be
1317
+ * serialized.
1318
+ *
1319
+ * If the required nested blocks are still not loaded, this method will return
1320
+ * `undefined`.
1321
+ *
1322
+ * @example
1323
+ *
1324
+ * ```js
1325
+ * await ctx.formValuesToItem(ctx.formValues, false);
1326
+ * ```
1327
+ */
1328
+ formValuesToItem: (
1329
+ formValues: Record<string, unknown>,
1330
+ skipUnchangedFields?: boolean,
1331
+ ) => Promise<Omit<Item, 'id' | 'meta'> | undefined>;
1332
+ /**
1333
+ * Takes an Item entity, and converts it into the internal form state
1334
+ *
1335
+ * @example
1336
+ *
1337
+ * ```js
1338
+ * await ctx.itemToFormValues(ctx.item);
1339
+ * ```
1340
+ */
1341
+ itemToFormValues: (
1342
+ item: Omit<Item, 'id' | 'meta'>,
1343
+ ) => Promise<Record<string, unknown>>;
1312
1344
  /**
1313
1345
  * Triggers a submit form for current record
1314
1346
  *