@luminocity/lemonate-gateway 8.2.10 → 8.2.12

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/dist/index.d.ts CHANGED
@@ -796,6 +796,7 @@ declare class Block extends Snapshotable {
796
796
  posY: number;
797
797
  constructor(id?: string | Snapshot | undefined, parent?: Block | undefined, type?: string | undefined, name?: string | undefined, displayName?: string | undefined, item?: PreparedItem | undefined);
798
798
  getId(): string;
799
+ getPositionInParent(): number;
799
800
  refreshFieldDependencies(): void;
800
801
  resetFieldValues(withChildren?: boolean): void;
801
802
  makeIdsUnique(map?: Map<string, string>, force?: boolean): Map<string, string>;
@@ -1163,6 +1164,29 @@ declare class AssetCreator {
1163
1164
  createAssetFromFiles(processedFiles: any[], assetBaseFolderId: string, itemData: any, forceReplace?: boolean, returnFolderInfo?: boolean): Promise<any>;
1164
1165
  }
1165
1166
 
1167
+ type PutOptions = {
1168
+ dontCopyScripts?: boolean;
1169
+ fieldOverrides?: any;
1170
+ parentPosition?: number;
1171
+ };
1172
+ type SerializedBlock = {
1173
+ type: "block";
1174
+ item: string;
1175
+ field: string;
1176
+ path: string;
1177
+ block: {
1178
+ id: string;
1179
+ type: string;
1180
+ fields: any[];
1181
+ scripts: any[];
1182
+ children: GrabResult;
1183
+ };
1184
+ };
1185
+ type SerializedBlocks = {
1186
+ type: "serializedBlocks";
1187
+ data: SerializedBlock[];
1188
+ };
1189
+ type GrabResult = string | SerializedBlocks | any[];
1166
1190
  declare class Serializer {
1167
1191
  apiClient: ApiClient;
1168
1192
  itemRepo: ItemRepo;
@@ -1178,7 +1202,7 @@ declare class Serializer {
1178
1202
  * @param {boolean} [options.omitPath] don't return path
1179
1203
  * @return {string|*[]}
1180
1204
  */
1181
- grab(item: PreparedItem, field: Field, blocks: Block[], options: any): string | any[] | any;
1205
+ grab(item: PreparedItem, field: Field, blocks: Block[], options: any): GrabResult;
1182
1206
  /**
1183
1207
  * Put elements in the project
1184
1208
  * @param msg the data to use to create new elements in the project
@@ -1186,15 +1210,16 @@ declare class Serializer {
1186
1210
  * @param targetBlock the target block to put the elements in case the data contains blocks
1187
1211
  * @param {object} options
1188
1212
  * @param {boolean} [options.dontCopyScripts] if true, scripts will not be copied
1189
- * @param {boolean} [putOptions.fieldOverrides] if true, field overrides will be applied to new blocks
1213
+ * @param {any} [options.fieldOverrides] object with override values for fields
1214
+ * @param {number} [options.parentPosition] if set, specified the position index in the parent
1190
1215
  */
1191
- put(msg: any, field: Field, targetBlock: Block, options?: any): Promise<any[]>;
1216
+ put(msg: any, field: Field, targetBlock: Block, options?: PutOptions): Promise<Block[]>;
1192
1217
  /**
1193
1218
  * Validate the clipboard message and parse it if necessary.
1194
1219
  * @param msg the message to be validated
1195
1220
  * @return {object}
1196
1221
  */
1197
- validateMessage(msg: any): any;
1222
+ validateMessage(msg: any): SerializedBlocks;
1198
1223
  /**
1199
1224
  * Clone a block from the source block to the new parent block.
1200
1225
  * @param {object} srcBlock source block to grab from
@@ -1203,14 +1228,28 @@ declare class Serializer {
1203
1228
  * @param {PreparedItem} grabFromItem item to grab from.
1204
1229
  * @param {object} putOptions
1205
1230
  * @param {boolean} [putOptions.dontCopyScripts] if true, scripts will not be copied
1206
- * @param {boolean} [putOptions.fieldOverrides] if true, field overrides will be applied to new blocks
1231
+ * @param {any} [putOptions.fieldOverrides] object with override values for fields
1232
+ * @param {number} [putOptions.parentPosition] if set, specified the position index in the parent
1207
1233
  * @return {object}
1208
1234
  */
1209
- clone(srcBlock: Block, field: Field, newParentBlock: Block, grabFromItem: PreparedItem, putOptions?: any): Promise<any[]>;
1235
+ clone(srcBlock: Block, field: Field, newParentBlock: Block, grabFromItem: PreparedItem, putOptions?: PutOptions): Promise<Block[]>;
1210
1236
  _updateScriptFieldReferences(oldBlockSerialized: any, newBlock: Block): void;
1211
- _putBlock(entry: any, field: Field, targetBlock: Block, options?: any, attachToParent?: boolean): Promise<any>;
1237
+ /**
1238
+ * Build unproxified subtree and only attach/proxify at the top level.
1239
+ * We create an unproxified tree because we cannot rely on objects having been created
1240
+ * before their block is being added to the parent. By then, the children might be created multiple times.
1241
+ * @param entry the data to construct the new block from
1242
+ * @param field what's the field that owns the block
1243
+ * @param targetBlock parent block to add the new block to
1244
+ * @param {any} options
1245
+ * @param {boolean} [putOptions.dontCopyScripts] if true, scripts will not be copied
1246
+ * @param {any} [putOptions.fieldOverrides] object with override values for fields
1247
+ * @param {number} [putOptions.parentPosition] if set, specified the position index in the parent
1248
+ * @param attachToParent
1249
+ */
1250
+ _putBlock(entry: SerializedBlock, field: Field, targetBlock: Block, options?: PutOptions, attachToParent?: boolean): Promise<Block | null>;
1212
1251
  _createUnproxifiedBlock(type: string, fieldOverrides: any, scriptsData: any[], field: Field, ownerItem: PreparedItem): Promise<Block | null>;
1213
- _proxifyAndAttachTree(root: Block, parent: Block, ownerItem: PreparedItem): any;
1252
+ _proxifyAndAttachTree(root: Block, parent: Block, ownerItem: PreparedItem, parentPosition?: number): Block;
1214
1253
  _findItemById(id: string): PreparedItem | undefined;
1215
1254
  _findItemField(item: PreparedItem, fieldName: string): Field | null;
1216
1255
  _findParentBlock(item: PreparedItem, fieldName: string, path: string): Block | null;