@milaboratories/pl-middle-layer 1.72.0 → 1.73.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/dist/middle_layer/build_stamp.cjs +1 -1
- package/dist/middle_layer/build_stamp.js +1 -1
- package/dist/middle_layer/folders.cjs +14 -9
- package/dist/middle_layer/folders.cjs.map +1 -1
- package/dist/middle_layer/folders.js +14 -10
- package/dist/middle_layer/folders.js.map +1 -1
- package/dist/middle_layer/middle_layer.cjs +17 -17
- package/dist/middle_layer/middle_layer.cjs.map +1 -1
- package/dist/middle_layer/middle_layer.d.ts +11 -11
- package/dist/middle_layer/middle_layer.d.ts.map +1 -1
- package/dist/middle_layer/middle_layer.js +18 -18
- package/dist/middle_layer/middle_layer.js.map +1 -1
- package/package.json +14 -14
- package/src/middle_layer/folders.test.ts +22 -14
- package/src/middle_layer/folders.ts +37 -27
- package/src/middle_layer/middle_layer.ts +18 -18
- package/src/middle_layer/templates.test.ts +1 -1
|
@@ -167,9 +167,9 @@ export declare class MiddleLayer {
|
|
|
167
167
|
* different places: a rename that carried a stale description alongside the new name would
|
|
168
168
|
* undo a description edit that happened in between, and the reverse.
|
|
169
169
|
*
|
|
170
|
-
* The label is stored trimmed, and
|
|
171
|
-
*
|
|
172
|
-
* human typed it, and a name that silently becomes a different name is worse than one that is
|
|
170
|
+
* The label is stored trimmed, and the folder rule governs it, so a label another project
|
|
171
|
+
* inside the same folder already carries is refused rather than written — a folder or a
|
|
172
|
+
* template of that name beside it is no obstacle. A human typed it, and a name that silently becomes a different name is worse than one that is
|
|
173
173
|
* turned down. The check and the write share one transaction, so two renames racing for the
|
|
174
174
|
* same name cannot both win. Duplicates an account already holds are tolerated and never
|
|
175
175
|
* rewritten; see the name check of {@link openFoldersTx}.
|
|
@@ -179,7 +179,7 @@ export declare class MiddleLayer {
|
|
|
179
179
|
/** Creates a folder inside `parent`, or at the top level, and returns its id. A name already
|
|
180
180
|
* used there is rejected. */
|
|
181
181
|
createFolder(name: string, parent?: FolderId): Promise<FolderId>;
|
|
182
|
-
/** Renames a folder. A name
|
|
182
|
+
/** Renames a folder. A name another folder beside it already carries is rejected. */
|
|
183
183
|
renameFolder(folder: FolderId, name: string): Promise<void>;
|
|
184
184
|
/** Sets what a folder says about itself; blank clears it. Descriptions are in no namespace, so
|
|
185
185
|
* nothing is refused here. */
|
|
@@ -213,7 +213,7 @@ export declare class MiddleLayer {
|
|
|
213
213
|
* in them, and a copy of every template.
|
|
214
214
|
*
|
|
215
215
|
* The copy lands beside the source, so only its root needs a name of its own — `X (Copy)`.
|
|
216
|
-
* Nothing inside is renamed: names are compared among siblings, and a copied folder's children
|
|
216
|
+
* Nothing inside is renamed: names are compared among siblings of one kind, and a copied folder's children
|
|
217
217
|
* are only ever compared with each other, where they came in distinct already.
|
|
218
218
|
*
|
|
219
219
|
* The subtree is read first and rebuilt in one write transaction, so the folders and everything
|
|
@@ -319,10 +319,10 @@ export declare class MiddleLayer {
|
|
|
319
319
|
* A block that cannot be expressed as a template entry stores nothing at all, and every
|
|
320
320
|
* such block is reported — fixing an unexportable project takes one pass, not one per block.
|
|
321
321
|
*
|
|
322
|
-
* The template lands beside its project, and is named by the rule
|
|
323
|
-
* by: a label the caller chose is stored trimmed and refused if
|
|
324
|
-
* without one the project's own label is taken — suffixed
|
|
325
|
-
* answers to it.
|
|
322
|
+
* The template lands beside its project, and is named by the rule templates there are named
|
|
323
|
+
* by: a label the caller chose is stored trimmed and refused if another template there already
|
|
324
|
+
* carries it, and without one the project's own label is taken — suffixed only when a template
|
|
325
|
+
* there already answers to it. The project is not a template, so its own name is no obstacle.
|
|
326
326
|
*
|
|
327
327
|
* The template's description is the one the caller gives, stored trimmed; blank means none.
|
|
328
328
|
* Without one the template is stored undescribed, whatever the project's own description says.
|
|
@@ -336,8 +336,8 @@ export declare class MiddleLayer {
|
|
|
336
336
|
* Changes a template's label. The stored document is immutable and stays untouched —
|
|
337
337
|
* improving a template means saving a new one.
|
|
338
338
|
*
|
|
339
|
-
* The label is stored trimmed.
|
|
340
|
-
*
|
|
339
|
+
* The label is stored trimmed. One another template beside it already carries is refused, in
|
|
340
|
+
* the transaction that writes it; a folder or a project of that name beside it is no obstacle.
|
|
341
341
|
*/
|
|
342
342
|
renameTemplate(id: TemplateId$1, label: string): Promise<void>;
|
|
343
343
|
/** Sets what a stored template says about itself; blank clears it. The stored document is not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middle_layer.d.ts","names":[],"sources":["../../src/middle_layer/middle_layer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"middle_layer.d.ts","names":[],"sources":["../../src/middle_layer/middle_layer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiLiB;EACf,WAAW;WACF,IAAI;WACJ,qBAAqB;WACrB,QAAQ;WACR,sBAAsB;WACtB,gBAAgB;WAChB,qBAAqB;WACrB,QAAQ;WACR,KAAK;WACL,YAAY;WACZ,wBAAwB;WACxB,oBAAoB;WACpB,SAAS;WACT,WAAW;WACX,iBAAiB;WACjB,eAAe;;;WAGf,gBAAgB;;;;;;;;;;;;;;qBAed;mBAIQ;WACD,WAAW;WACX,QAAQ;mBACP;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;WACD,uBAAuB;;WAEvB,aAAa,wBAAwB;;WAErC,cAAc,wBAAwB;;;WAGtC,SAAS,wBAAwB;;EAE1C,gBAAgB,WAAW;;;EAG3B,iBAAiB,WAAW;;;;mBAIlB;WAlCH,IAAI;UAEb;;;;;MA0CI,kBAAkB;;;;;;;MAUlB;;;;;MAQA;;;;;;;MAUA;;MAQA;;;;;MAQA,mBAAmB;;;;;;;MAUnB;;;;;;;;MAeA;;EAKJ,qBACL,aAAa,sBACb;;EAMK,wBAAwB,cAAc;;MAKlC,qBAAqB;;MAKrB,mBAAmB;mBAQb;;;UAIH;;;;;;;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;;;;;;;;EA6DE,uBACX,cAAc,aACd,qBACA,UAAU,uBAAuB,sCAChC;;;;;;;EAyCU,cACX,YAAY,eACZ,SAAS,uBACR,QAAQ;;;;;;;;;;;;;EAgCE,cAAc,IAAI,cAAY,SAAS,uBAAuB,QAAQ;;;;;;;;;;;;;;;EAmCtE,YAAY,QAAQ,UAAU,SAAS,qBAAqB,QAAQ;;;;;;;;;;UAgCnE;;;;;;;;UA2CA;;;;;;;;;;;;;UAoBA;;;;;;;EAkBD,YAAY,SAAS,UAAU;;;;;;;UAiB9B;;;;;;;;;;;UA0BA;;;;;;;;;;;;;;;;EAwBD,UACX,UAAU,WACV,cAAc,WACb;IACD,UAAU;IACV,WAAW;IACX;MAAU,SAAS;MAAS;;;;;;;;EA8JjB,UAAU,SAAS,UAAU;;EAW7B,YAAY,SAAS,UAAU;0BAapB;UAChB;;UAGA;;;UAWM;mBAsCG;;;mBAIA;UAET;;;;;;;UAWM;;EAgBD,YAAY,IAAI,cAAY;;EAQ5B,aAAa,IAAI,cAAY;;EAmBnC,iBAAiB,IAAI,cAAY;;EAOjC,gBAAgB,IAAI;;;;MAOhB,qBAAqB,SAAS;;;;;;EAS5B,SAAK;;EAkBL,4BAAwB;;;SAMvB;;MAKH,wBAAwB;;SAKf,KAClB,IAAI,UACJ,iBACA,MAAM,4BACL,QAAQ"}
|
|
@@ -5,7 +5,7 @@ import { ProjectsField, ProjectsResourceType, createProjectList, ensureProjectLi
|
|
|
5
5
|
import { TemplateDescriptionKey, TemplateLabelKey, TemplatesField, TemplatesResourceType, createTemplateList, decodeStoredTemplateData } from "./template_list.js";
|
|
6
6
|
import { listedById, notListedError } from "../mutator/list.js";
|
|
7
7
|
import { createTemplate, deleteTemplate, renameTemplate, setTemplateDescription } from "../mutator/template.js";
|
|
8
|
-
import { FoldersField, FoldersResourceType, createFolder, createFolderList, deleteFolder, foldersLocalSubtree, moveFolderItems, openFoldersTx, previewFolderDeletion, previewFoldersMove, renameFolder, resetFolders, setFolderDescription } from "./folders.js";
|
|
8
|
+
import { FoldersField, FoldersResourceType, createFolder, createFolderList, deleteFolder, foldersLocalSubtree, moveFolderItems, nameTakenMessage, openFoldersTx, previewFolderDeletion, previewFoldersMove, renameFolder, resetFolders, setFolderDescription } from "./folders.js";
|
|
9
9
|
import { SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, canGrantToEveryone, canImpersonate, decodeEnvelopeData, envelopeFolderRoot, newEnvelopeFolderId } from "../model/sharing_model.js";
|
|
10
10
|
import { resolveTemplateEntries } from "../model/template_resolve.js";
|
|
11
11
|
import { TemplateEntryRejected, kindMismatch } from "../model/template_apply.js";
|
|
@@ -224,9 +224,9 @@ var MiddleLayer = class MiddleLayer {
|
|
|
224
224
|
* different places: a rename that carried a stale description alongside the new name would
|
|
225
225
|
* undo a description edit that happened in between, and the reverse.
|
|
226
226
|
*
|
|
227
|
-
* The label is stored trimmed, and
|
|
228
|
-
*
|
|
229
|
-
* human typed it, and a name that silently becomes a different name is worse than one that is
|
|
227
|
+
* The label is stored trimmed, and the folder rule governs it, so a label another project
|
|
228
|
+
* inside the same folder already carries is refused rather than written — a folder or a
|
|
229
|
+
* template of that name beside it is no obstacle. A human typed it, and a name that silently becomes a different name is worse than one that is
|
|
230
230
|
* turned down. The check and the write share one transaction, so two renames racing for the
|
|
231
231
|
* same name cannot both win. Duplicates an account already holds are tolerated and never
|
|
232
232
|
* rewritten; see the name check of {@link openFoldersTx}.
|
|
@@ -264,7 +264,7 @@ var MiddleLayer = class MiddleLayer {
|
|
|
264
264
|
await this.foldersTree.refreshState();
|
|
265
265
|
return id;
|
|
266
266
|
}
|
|
267
|
-
/** Renames a folder. A name
|
|
267
|
+
/** Renames a folder. A name another folder beside it already carries is rejected. */
|
|
268
268
|
async renameFolder(folder, name) {
|
|
269
269
|
await renameFolder(this.pl, this.foldersRids, folder, name);
|
|
270
270
|
await this.foldersTree.refreshState();
|
|
@@ -331,7 +331,7 @@ var MiddleLayer = class MiddleLayer {
|
|
|
331
331
|
* in them, and a copy of every template.
|
|
332
332
|
*
|
|
333
333
|
* The copy lands beside the source, so only its root needs a name of its own — `X (Copy)`.
|
|
334
|
-
* Nothing inside is renamed: names are compared among siblings, and a copied folder's children
|
|
334
|
+
* Nothing inside is renamed: names are compared among siblings of one kind, and a copied folder's children
|
|
335
335
|
* are only ever compared with each other, where they came in distinct already.
|
|
336
336
|
*
|
|
337
337
|
* The subtree is read first and rebuilt in one write transaction, so the folders and everything
|
|
@@ -609,10 +609,10 @@ var MiddleLayer = class MiddleLayer {
|
|
|
609
609
|
* A block that cannot be expressed as a template entry stores nothing at all, and every
|
|
610
610
|
* such block is reported — fixing an unexportable project takes one pass, not one per block.
|
|
611
611
|
*
|
|
612
|
-
* The template lands beside its project, and is named by the rule
|
|
613
|
-
* by: a label the caller chose is stored trimmed and refused if
|
|
614
|
-
* without one the project's own label is taken — suffixed
|
|
615
|
-
* answers to it.
|
|
612
|
+
* The template lands beside its project, and is named by the rule templates there are named
|
|
613
|
+
* by: a label the caller chose is stored trimmed and refused if another template there already
|
|
614
|
+
* carries it, and without one the project's own label is taken — suffixed only when a template
|
|
615
|
+
* there already answers to it. The project is not a template, so its own name is no obstacle.
|
|
616
616
|
*
|
|
617
617
|
* The template's description is the one the caller gives, stored trimmed; blank means none.
|
|
618
618
|
* Without one the template is stored undescribed, whatever the project's own description says.
|
|
@@ -632,9 +632,9 @@ var MiddleLayer = class MiddleLayer {
|
|
|
632
632
|
const signedRid = await this.pl.withWriteTx("MLSaveProjectAsTemplate", async (tx) => {
|
|
633
633
|
const meta = await tx.getKValueJson(rid, ProjectMetaKey);
|
|
634
634
|
const tree = await openFoldersTx(tx, this.foldersRids);
|
|
635
|
-
const taken = tree.namesTakenBeside(projectId);
|
|
636
|
-
if (wanted !== void 0 && foldersNameTaken(wanted, taken)) throw new Error(
|
|
637
|
-
const name = wanted ?? foldersUniqueName(meta.label,
|
|
635
|
+
const taken = tree.namesTakenBeside(projectId, "template");
|
|
636
|
+
if (wanted !== void 0 && foldersNameTaken(wanted, taken)) throw new Error(nameTakenMessage("template", wanted));
|
|
637
|
+
const name = wanted ?? foldersUniqueName(meta.label, taken);
|
|
638
638
|
const created = await createTemplate(tx, this.templateListResourceId, {
|
|
639
639
|
label: name,
|
|
640
640
|
description
|
|
@@ -662,8 +662,8 @@ var MiddleLayer = class MiddleLayer {
|
|
|
662
662
|
* Changes a template's label. The stored document is immutable and stays untouched —
|
|
663
663
|
* improving a template means saving a new one.
|
|
664
664
|
*
|
|
665
|
-
* The label is stored trimmed.
|
|
666
|
-
*
|
|
665
|
+
* The label is stored trimmed. One another template beside it already carries is refused, in
|
|
666
|
+
* the transaction that writes it; a folder or a project of that name beside it is no obstacle.
|
|
667
667
|
*/
|
|
668
668
|
async renameTemplate(id, label) {
|
|
669
669
|
const rid = await this.resolveTemplateId(id);
|
|
@@ -793,7 +793,7 @@ var MiddleLayer = class MiddleLayer {
|
|
|
793
793
|
const newPrj = await this.pl.withWriteTx("MLDuplicateProject", async (tx) => {
|
|
794
794
|
const sourceMeta = await tx.getKValueJson(sourceRid, ProjectMetaKey);
|
|
795
795
|
const tree = await openFoldersTx(tx, this.foldersRids);
|
|
796
|
-
const label = rename === void 0 ? foldersUniqueName(sourceMeta.label, [sourceMeta.label, ...tree.namesTakenBeside(srcProjectId)]) : rename(sourceMeta.label, await existingProjectLabels(tx, this.projectListResourceId));
|
|
796
|
+
const label = rename === void 0 ? foldersUniqueName(sourceMeta.label, [sourceMeta.label, ...tree.namesTakenBeside(srcProjectId, "project")]) : rename(sourceMeta.label, await existingProjectLabels(tx, this.projectListResourceId));
|
|
797
797
|
const newPrj = await duplicateProject(tx, sourceRid, {
|
|
798
798
|
...sourceMeta,
|
|
799
799
|
label
|
|
@@ -1058,7 +1058,7 @@ var MiddleLayer = class MiddleLayer {
|
|
|
1058
1058
|
const rid = await this.pl.withWriteTx("MLCopyTemplateShare", async (tx) => {
|
|
1059
1059
|
const tree = await openFoldersTx(tx, this.foldersRids);
|
|
1060
1060
|
const created = await createTemplate(tx, this.templateListResourceId, {
|
|
1061
|
-
label: foldersUniqueName(payload.label, tree.namesTakenIn(destination)),
|
|
1061
|
+
label: foldersUniqueName(payload.label, tree.namesTakenIn(destination, "template")),
|
|
1062
1062
|
description: payload.description
|
|
1063
1063
|
}, {
|
|
1064
1064
|
schemaVersion: 1,
|
|
@@ -1130,7 +1130,7 @@ var MiddleLayer = class MiddleLayer {
|
|
|
1130
1130
|
}
|
|
1131
1131
|
const createdRids = await this.pl.withWriteTx("MLCopyShare", async (tx) => {
|
|
1132
1132
|
const tree = await openFoldersTx(tx, this.foldersRids);
|
|
1133
|
-
const taken = [...tree.namesTakenIn(destination)];
|
|
1133
|
+
const taken = [...tree.namesTakenIn(destination, "project")];
|
|
1134
1134
|
const created = await copyEnvelopeProjectsIntoList(tx, envelope.rid, this.projectListResourceId, (sourceLabel) => {
|
|
1135
1135
|
const name = foldersUniqueName(sourceLabel, taken);
|
|
1136
1136
|
taken.push(name);
|