@graview/core 0.2.3 → 0.2.5
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/across-copies.d.ts +3 -0
- package/dist/across-copies.d.ts.map +1 -0
- package/dist/across-copies.js +39 -0
- package/dist/across-copies.js.map +1 -0
- package/dist/binding-served.d.ts +11 -2
- package/dist/binding-served.d.ts.map +1 -1
- package/dist/binding-served.js +19 -0
- package/dist/binding-served.js.map +1 -1
- package/dist/binding.d.ts +25 -0
- package/dist/binding.d.ts.map +1 -1
- package/dist/binding.js +128 -19
- package/dist/binding.js.map +1 -1
- package/dist/capabilities.js +1 -1
- package/dist/capabilities.js.map +1 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +37 -1
- package/dist/catalog.js.map +1 -1
- package/dist/check.d.ts +3 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +3 -0
- package/dist/check.js.map +1 -1
- package/dist/cited.d.ts +55 -0
- package/dist/cited.d.ts.map +1 -0
- package/dist/cited.js +48 -0
- package/dist/cited.js.map +1 -0
- package/dist/cli/check/cites.d.ts +4 -0
- package/dist/cli/check/cites.d.ts.map +1 -0
- package/dist/cli/check/cites.js +35 -0
- package/dist/cli/check/cites.js.map +1 -0
- package/dist/cli/check/context-of.d.ts +12 -0
- package/dist/cli/check/context-of.d.ts.map +1 -0
- package/dist/cli/check/context-of.js +25 -0
- package/dist/cli/check/context-of.js.map +1 -0
- package/dist/cli/check/index.d.ts +1 -0
- package/dist/cli/check/index.d.ts.map +1 -1
- package/dist/cli/check/index.js +1 -0
- package/dist/cli/check/index.js.map +1 -1
- package/dist/cli/check/policy.d.ts.map +1 -1
- package/dist/cli/check/policy.js +28 -3
- package/dist/cli/check/policy.js.map +1 -1
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +4 -12
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +42 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/compose-change.d.ts +33 -0
- package/dist/compose-change.d.ts.map +1 -0
- package/dist/compose-change.js +43 -0
- package/dist/compose-change.js.map +1 -0
- package/dist/compose-home.d.ts +46 -6
- package/dist/compose-home.d.ts.map +1 -1
- package/dist/compose-home.js +189 -47
- package/dist/compose-home.js.map +1 -1
- package/dist/compose.d.ts +6 -4
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js +18 -39
- package/dist/compose.js.map +1 -1
- package/dist/composer-check.d.ts +16 -0
- package/dist/composer-check.d.ts.map +1 -0
- package/dist/composer-check.js +48 -0
- package/dist/composer-check.js.map +1 -0
- package/dist/composer.d.ts +19 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +49 -0
- package/dist/composer.js.map +1 -0
- package/dist/css/faces-words.d.ts.map +1 -1
- package/dist/css/faces-words.js +2 -0
- package/dist/css/faces-words.js.map +1 -1
- package/dist/css/faces.d.ts +1 -1
- package/dist/css/faces.d.ts.map +1 -1
- package/dist/css/sanitize.d.ts +5 -1
- package/dist/css/sanitize.d.ts.map +1 -1
- package/dist/css/sanitize.js +16 -1
- package/dist/css/sanitize.js.map +1 -1
- package/dist/document/compile.d.ts.map +1 -1
- package/dist/document/compile.js +5 -2
- package/dist/document/compile.js.map +1 -1
- package/dist/document/compiled.d.ts.map +1 -1
- package/dist/document/compiled.js +6 -0
- package/dist/document/compiled.js.map +1 -1
- package/dist/document/design-findings.d.ts.map +1 -1
- package/dist/document/design-findings.js +2 -1
- package/dist/document/design-findings.js.map +1 -1
- package/dist/document/edit.d.ts +1 -1
- package/dist/document/edit.d.ts.map +1 -1
- package/dist/document/edit.js +184 -152
- package/dist/document/edit.js.map +1 -1
- package/dist/document/expr/evaluate.d.ts +3 -1
- package/dist/document/expr/evaluate.d.ts.map +1 -1
- package/dist/document/expr/evaluate.js +29 -1
- package/dist/document/expr/evaluate.js.map +1 -1
- package/dist/document/expr/typing.d.ts.map +1 -1
- package/dist/document/expr/typing.js +1 -0
- package/dist/document/expr/typing.js.map +1 -1
- package/dist/document/field-spec.d.ts.map +1 -1
- package/dist/document/field-spec.js +6 -1
- package/dist/document/field-spec.js.map +1 -1
- package/dist/document/format-findings.d.ts.map +1 -1
- package/dist/document/format-findings.js +8 -0
- package/dist/document/format-findings.js.map +1 -1
- package/dist/document/instantiate-template.d.ts.map +1 -1
- package/dist/document/instantiate-template.js +16 -1
- package/dist/document/instantiate-template.js.map +1 -1
- package/dist/document/rules.d.ts.map +1 -1
- package/dist/document/rules.js +4 -0
- package/dist/document/rules.js.map +1 -1
- package/dist/document/schema.d.ts +5 -0
- package/dist/document/schema.d.ts.map +1 -1
- package/dist/document/schema.js +7 -0
- package/dist/document/schema.js.map +1 -1
- package/dist/document/uncited-findings.d.ts +9 -0
- package/dist/document/uncited-findings.d.ts.map +1 -0
- package/dist/document/uncited-findings.js +10 -0
- package/dist/document/uncited-findings.js.map +1 -0
- package/dist/document.schema.json +12 -2
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +4 -0
- package/dist/graph/graph.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/mutations/define-mutation.d.ts +8 -0
- package/dist/mutations/define-mutation.d.ts.map +1 -1
- package/dist/mutations/define-mutation.js +23 -1
- package/dist/mutations/define-mutation.js.map +1 -1
- package/dist/mutations/invalid-arguments.d.ts.map +1 -1
- package/dist/mutations/invalid-arguments.js +3 -0
- package/dist/mutations/invalid-arguments.js.map +1 -1
- package/dist/ops/revisions.d.ts.map +1 -1
- package/dist/ops/revisions.js +10 -3
- package/dist/ops/revisions.js.map +1 -1
- package/dist/ops/undo.d.ts.map +1 -1
- package/dist/ops/undo.js +49 -1
- package/dist/ops/undo.js.map +1 -1
- package/dist/permissions/policy.d.ts +19 -18
- package/dist/permissions/policy.d.ts.map +1 -1
- package/dist/permissions/policy.js +27 -22
- package/dist/permissions/policy.js.map +1 -1
- package/dist/permissions/types.d.ts.map +1 -1
- package/dist/permissions/types.js +3 -0
- package/dist/permissions/types.js.map +1 -1
- package/dist/persistence/memory.d.ts.map +1 -1
- package/dist/persistence/memory.js +6 -0
- package/dist/persistence/memory.js.map +1 -1
- package/dist/persistence/sql.d.ts.map +1 -1
- package/dist/persistence/sql.js +18 -0
- package/dist/persistence/sql.js.map +1 -1
- package/dist/persistence/types.d.ts +10 -0
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/refused.d.ts.map +1 -1
- package/dist/refused.js +3 -0
- package/dist/refused.js.map +1 -1
- package/dist/schema/cites.d.ts +30 -0
- package/dist/schema/cites.d.ts.map +1 -0
- package/dist/schema/cites.js +70 -0
- package/dist/schema/cites.js.map +1 -0
- package/dist/schema/files.d.ts +28 -0
- package/dist/schema/files.d.ts.map +1 -1
- package/dist/schema/files.js +13 -1
- package/dist/schema/files.js.map +1 -1
- package/dist/schema/reading.d.ts.map +1 -1
- package/dist/schema/reading.js +3 -2
- package/dist/schema/reading.js.map +1 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +3 -0
- package/dist/schema/schema.js.map +1 -1
- package/dist/seen.d.ts +8 -0
- package/dist/seen.d.ts.map +1 -1
- package/dist/seen.js +6 -4
- package/dist/seen.js.map +1 -1
- package/dist/store.d.ts +12 -5
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +74 -35
- package/dist/store.js.map +1 -1
- package/dist/tidying.d.ts +2 -0
- package/dist/tidying.d.ts.map +1 -1
- package/dist/tidying.js +2 -0
- package/dist/tidying.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/views/types.d.ts +7 -0
- package/dist/views/types.d.ts.map +1 -1
- package/dist/views/types.js.map +1 -1
- package/dist/who.d.ts.map +1 -1
- package/dist/who.js +7 -3
- package/dist/who.js.map +1 -1
- package/package.json +5 -1
package/dist/store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hidesFrom, readingOf, seatLens, seenBy, seesEveryRecord, seesId } from "./seen.js";
|
|
1
|
+
import { everBound, hidesFrom, readingOf, seatLens, seenBy, seesEveryRecord, seesId } from "./seen.js";
|
|
2
2
|
import { isoToday } from "./days.js";
|
|
3
3
|
import { Graph, GraphError, MissingRecordError } from "./graph/graph.js";
|
|
4
4
|
import { resolveModules } from "./modules.js";
|
|
@@ -10,7 +10,7 @@ import { LabelIndex, refusalFor } from "./labels.js";
|
|
|
10
10
|
import { heldRefKinds, nodeRefArgs } from "./mutations/node-ref.js";
|
|
11
11
|
import { verifyFold } from "./integrity.js";
|
|
12
12
|
import { evaluate } from "./invariants/engine.js";
|
|
13
|
-
import { compileMutation } from "./mutations/define-mutation.js";
|
|
13
|
+
import { compileMutation, mintPersonId } from "./mutations/define-mutation.js";
|
|
14
14
|
import { wouldRun } from "./mutations/would-run.js";
|
|
15
15
|
import { actSpelledAs, nearestAct } from "./mutations/act-spelling.js";
|
|
16
16
|
import { InvalidArguments } from "./mutations/invalid-arguments.js";
|
|
@@ -27,7 +27,7 @@ import { advisoryVoterOf, signedOutSeat, SIGN_IN_TO_VOTE, VOTE_SUGGESTION, VOTIN
|
|
|
27
27
|
import { TYPE_TEXT, TYPING } from "./text/typing-hook.js";
|
|
28
28
|
import { DECLINES, isAutomated, isTidyingActor, tidyingRefusal } from "./ops/tidying.js";
|
|
29
29
|
import { nameOfAuthor } from "./who.js";
|
|
30
|
-
import { actingAs, boundPersonOf, grantsTo, isSystem, meIn, meOf, ownsId, permits, profileOf, rolesSaid, seatedIn, withValidProfile, permittedMutations, proposes, subjectKinds } from "./permissions/policy.js";
|
|
30
|
+
import { actingAs, asBoundTo, bindable, boundPersonOf, grantsTo, isSystem, meIn, meOf, ownsId, permits, profileOf, rolesSaid, seatedIn, seatPersonOf, withValidProfile, permittedMutations, proposes, subjectKinds } from "./permissions/policy.js";
|
|
31
31
|
import { MOST_PROPOSED, PROPOSE_CHANGES, proposeChangesMutation } from "./mutations/propose-changes.js";
|
|
32
32
|
import { namesUnseen, redact } from "./ops/withheld.js";
|
|
33
33
|
import { writersBehind } from "./ops/writers.js";
|
|
@@ -327,6 +327,9 @@ export class Store {
|
|
|
327
327
|
if (this.mutations.has(mutation.name)) {
|
|
328
328
|
throw new GraphError(`Duplicate mutation "${mutation.name}"`);
|
|
329
329
|
}
|
|
330
|
+
// A name the framework keeps for an act of its own is never an app's (`binding-act-taken`): the framework's answers it.
|
|
331
|
+
if (mutation.name === BIND_PERSON)
|
|
332
|
+
continue;
|
|
330
333
|
this.mutations.set(mutation.name, mutation);
|
|
331
334
|
}
|
|
332
335
|
/*
|
|
@@ -337,7 +340,7 @@ export class Store {
|
|
|
337
340
|
* invariants — and by the policy, through the acts that already write or
|
|
338
341
|
* create the kind (see `permits`). Nothing an app declares is replaced.
|
|
339
342
|
*/
|
|
340
|
-
for (const mutation of options.past ? [] : deriveMutations(options.schema, options.mutations ?? [])) {
|
|
343
|
+
for (const mutation of options.past ? [] : deriveMutations(options.schema, (options.mutations ?? []).filter((mutation) => mutation.name !== BIND_PERSON))) {
|
|
341
344
|
this.mutations.set(mutation.name, mutation);
|
|
342
345
|
}
|
|
343
346
|
// "Keep this link" (FR-172): answered by every store, offered by no list. An app's own `keep-link` keeps its name.
|
|
@@ -550,7 +553,7 @@ export class Store {
|
|
|
550
553
|
if (name === TYPE_TEXT && !this.typer && TYPING.typeText && !this.past && !this.mutations.has(name))
|
|
551
554
|
this.mutations.set(name, (this.typer = TYPING.typeText(this)));
|
|
552
555
|
// "Bind a person" (Roadmap f-invite-binds-existing-person): answered where a kind is the people once the host loads `@graview/core/binding`, and offered by no list.
|
|
553
|
-
if (name === BIND_PERSON && !this.binder && BINDING.act && !this.past
|
|
556
|
+
if (name === BIND_PERSON && !this.binder && BINDING.act && !this.past) {
|
|
554
557
|
const binder = BINDING.act(this);
|
|
555
558
|
if (binder)
|
|
556
559
|
this.mutations.set(name, (this.binder = binder));
|
|
@@ -646,7 +649,7 @@ export class Store {
|
|
|
646
649
|
if (mutation !== undefined && mutation === this.typer) {
|
|
647
650
|
// Through an act that could run on this record now: its module on, its own rule holding for the record as this principal is served it (`wouldRun`).
|
|
648
651
|
const served = principal === undefined || isSystem(principal) ? this.graph : seenBy(this, principal).graph;
|
|
649
|
-
const allows = (writer) => !this.mutationDisabled(writer) && wouldRun(writer, this.schema, served, call?.args["node"], call?.args["field"], principal && meIn(this.schema, principal));
|
|
652
|
+
const allows = (writer) => !this.mutationDisabled(writer) && wouldRun(writer, this.schema, served, call?.args["node"], call?.args["field"], principal && meIn(this.schema, this.seated(principal)));
|
|
650
653
|
return TYPING.via(this.schema, [...this.mutations.values()], this.subjectKindOf(call, principal), call?.args["field"], allows);
|
|
651
654
|
}
|
|
652
655
|
if (!mutation?.derived)
|
|
@@ -1469,15 +1472,15 @@ export class Store {
|
|
|
1469
1472
|
wouldDo(calls, author = this.by) {
|
|
1470
1473
|
const as = withValidProfile(author);
|
|
1471
1474
|
const person = this.personFor(as);
|
|
1472
|
-
return person ? this.withPersonMade(as
|
|
1475
|
+
return person ? this.withPersonMade(as).compiledEach(calls, as) : this.compiledEach(calls, as);
|
|
1473
1476
|
}
|
|
1474
1477
|
/**
|
|
1475
1478
|
* THE STORE AS IT WOULD BE WITH A PROFILE'S PERSON MADE: one copy, kept
|
|
1476
1479
|
* while this store's `version` stands, so every call a face asks of it in
|
|
1477
1480
|
* one look — each act over every chosen record — is judged on the same copy.
|
|
1478
1481
|
*/
|
|
1479
|
-
withPersonMade(author
|
|
1480
|
-
const key = JSON.stringify([this.version, this.log.length, actingAs(author).id,
|
|
1482
|
+
withPersonMade(author) {
|
|
1483
|
+
const key = JSON.stringify([this.version, this.log.length, actingAs(author).id, seatPersonOf(author), profileOf(author)?.name]);
|
|
1481
1484
|
if (this.personMade?.key === key)
|
|
1482
1485
|
return this.personMade.twin;
|
|
1483
1486
|
const twin = this.rehearsal();
|
|
@@ -1572,7 +1575,7 @@ export class Store {
|
|
|
1572
1575
|
wouldApply(call, author, land) {
|
|
1573
1576
|
const as = withValidProfile(author);
|
|
1574
1577
|
const person = this.personFor(as);
|
|
1575
|
-
const store = person ? this.withPersonMade(as
|
|
1578
|
+
const store = person ? this.withPersonMade(as) : this;
|
|
1576
1579
|
const was = store.rehearsing;
|
|
1577
1580
|
store.rehearsing = true;
|
|
1578
1581
|
try {
|
|
@@ -1633,7 +1636,7 @@ export class Store {
|
|
|
1633
1636
|
judgedAs(author) {
|
|
1634
1637
|
const as = withValidProfile(author);
|
|
1635
1638
|
const person = this.personFor(as);
|
|
1636
|
-
return person ? this.withPersonMade(as
|
|
1639
|
+
return person ? this.withPersonMade(as) : this;
|
|
1637
1640
|
}
|
|
1638
1641
|
/**
|
|
1639
1642
|
* HOW MANY TIMES THIS STORE HAS TOLD ITS SUBSCRIBERS SOMETHING, or would
|
|
@@ -2264,6 +2267,10 @@ export class Store {
|
|
|
2264
2267
|
throw new UndoBlockedError(seen);
|
|
2265
2268
|
}
|
|
2266
2269
|
const check = this.canUndo(ids);
|
|
2270
|
+
// A binding its seat has acted as says so first to the host, which alone takes one back, whatever else stands in the way (Roadmap f-unbind-person).
|
|
2271
|
+
const keptBinding = check.ok || !isSystem(author) ? undefined : this.bindingKept(check.ops);
|
|
2272
|
+
if (keptBinding)
|
|
2273
|
+
this.refuse(keptBinding, author.id, true);
|
|
2267
2274
|
if (!check.ok) {
|
|
2268
2275
|
throw new UndoBlockedError(sighted
|
|
2269
2276
|
? { ok: false, ops: [], blockedBy: [], includeBatches: [], message: "Cannot undo on its own — a later change you cannot see depends on it, which only somebody who can see it can take back." }
|
|
@@ -2343,11 +2350,35 @@ export class Store {
|
|
|
2343
2350
|
if (kept)
|
|
2344
2351
|
return kept.refusal ? { ok: false, refusal: kept.refusal } : { ok: true };
|
|
2345
2352
|
const check = this.canUndo(batchIds);
|
|
2353
|
+
const keptBinding = check.ok || !isSystem(principal) ? undefined : this.bindingKept(check.ops);
|
|
2354
|
+
if (keptBinding)
|
|
2355
|
+
return { ok: false, refusal: keptBinding };
|
|
2356
|
+
// What stands in the way, as this seat may be told it: in words, judged over what it sees, as `undo` says it.
|
|
2346
2357
|
if (!check.ok)
|
|
2347
|
-
return { ok: false, check };
|
|
2358
|
+
return { ok: false, check: isSystem(principal) ? check : this.toldCheck(check, typeof batchIds === "string" ? [batchIds] : batchIds, principal) };
|
|
2348
2359
|
const refusal = this.undoRefusal(check.ops, principal);
|
|
2349
2360
|
return refusal ? { ok: false, refusal } : { ok: true };
|
|
2350
2361
|
}
|
|
2362
|
+
/** An undo check as a seat other than the host is told it: its sentence, over the log as that seat sees it, and no op. */
|
|
2363
|
+
toldCheck(check, ids, principal) {
|
|
2364
|
+
const sighted = (this.policy?.sees?.length ?? 0) > 0;
|
|
2365
|
+
const seen = sighted ? checkUndo(readingOf(redact(this.log.all(), seatLens(this, principal)), () => this.log.epochs()), ids) : check;
|
|
2366
|
+
const message = seen.ok ? "Cannot undo on its own — a later change you cannot see depends on it, which only somebody who can see it can take back." : seen.message;
|
|
2367
|
+
return { ok: false, ops: [], blockedBy: [], includeBatches: [], message, ...(check.reason ? { reason: check.reason } : {}) };
|
|
2368
|
+
}
|
|
2369
|
+
/** Why a binding among these ops stays (`BINDING.undo`), or nothing. */
|
|
2370
|
+
bindingKept(ops) {
|
|
2371
|
+
for (const target of ops) {
|
|
2372
|
+
// Judged as the change its undo chain begins with, however often it was taken back and put back.
|
|
2373
|
+
const root = this.rootOf(target);
|
|
2374
|
+
if (root.mutation?.name !== BIND_PERSON)
|
|
2375
|
+
continue;
|
|
2376
|
+
const kept = BINDING.undo ? BINDING.undo(this, target, root) : "This binding cannot be taken back here.";
|
|
2377
|
+
if (kept)
|
|
2378
|
+
return { mutation: "undo", wouldNeed: [], message: kept };
|
|
2379
|
+
}
|
|
2380
|
+
return undefined;
|
|
2381
|
+
}
|
|
2351
2382
|
/** What refuses `author` taking these ops back, or nothing: what you may undo is what you may have done. */
|
|
2352
2383
|
undoRefusal(ops, author) {
|
|
2353
2384
|
// Asked of `@graview/core/tidying`; a store that has not loaded it offers no way back it cannot judge.
|
|
@@ -2360,13 +2391,9 @@ export class Store {
|
|
|
2360
2391
|
* did to whoever is bound there next. Judged by `@graview/core/binding`;
|
|
2361
2392
|
* a store that has not loaded it takes no binding back.
|
|
2362
2393
|
*/
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
const kept = BINDING.undo ? BINDING.undo(this, target) : "This binding cannot be taken back here.";
|
|
2367
|
-
if (kept)
|
|
2368
|
-
return { mutation: "undo", wouldNeed: [], message: kept };
|
|
2369
|
-
}
|
|
2394
|
+
const kept = this.bindingKept(ops);
|
|
2395
|
+
if (kept)
|
|
2396
|
+
return kept;
|
|
2370
2397
|
if (this.policy || this.publisher) {
|
|
2371
2398
|
for (const target of ops) {
|
|
2372
2399
|
/*
|
|
@@ -2423,7 +2450,10 @@ export class Store {
|
|
|
2423
2450
|
* it" is everybody's to run, and undoing Ann's was taking back her vote.
|
|
2424
2451
|
*/
|
|
2425
2452
|
/* What the act wrote as them: the profile's person, where they were one. */
|
|
2426
|
-
|
|
2453
|
+
// Or the record the seat was bound to last, where it is bound to none now: what it did is still theirs.
|
|
2454
|
+
const seatOfAuthor = seatPersonOf(judged.author);
|
|
2455
|
+
const doneAs = meOf(this.seated(judged.author)) ?? (seatOfAuthor === undefined ? undefined : everBound(this).get(seatOfAuthor));
|
|
2456
|
+
const names = (value) => doneAs !== undefined && (JSON.stringify(value) ?? "").includes(JSON.stringify(doneAs));
|
|
2427
2457
|
const verdict = by !== undefined && by !== actingAs(author).id && !isSystem(author) && !names(judged.mutation.args) && names(judged.primitives)
|
|
2428
2458
|
? { ok: false, refusal: { mutation: judged.mutation.name, wouldNeed: [], message: "it was done as somebody else." } }
|
|
2429
2459
|
: this.judged(judged.mutation, author, true);
|
|
@@ -2450,27 +2480,35 @@ export class Store {
|
|
|
2450
2480
|
return at;
|
|
2451
2481
|
}
|
|
2452
2482
|
/**
|
|
2453
|
-
* THE RECORD A PROFILE'S PERSON WOULD BE, where one can be made
|
|
2454
|
-
*
|
|
2455
|
-
*
|
|
2456
|
-
*
|
|
2457
|
-
*
|
|
2483
|
+
* THE RECORD A PROFILE'S PERSON WOULD BE, where one can be made: of the
|
|
2484
|
+
* people kind, its name in the kind's name field, and the seat as its mark
|
|
2485
|
+
* (`PERSON_SEAT`), which is what ties it to the profile and is served to
|
|
2486
|
+
* that seat and the host alone. Its id is its own (`mintPersonId`, from
|
|
2487
|
+
* the batch it is made in). As Graview Cloud makes a
|
|
2488
|
+
* member's: the id and the name, and where the kind asks for more, none,
|
|
2489
|
+
* since nobody is there to answer. And none where the seat was ever bound
|
|
2490
|
+
* to a record: one removed stays removed, one unbound stays unbound.
|
|
2458
2491
|
*/
|
|
2459
|
-
personFor(author) {
|
|
2492
|
+
personFor(author, batch = PREVIEW_BATCH) {
|
|
2460
2493
|
author = this.seated(author);
|
|
2461
2494
|
const profile = profileOf(author);
|
|
2462
|
-
const
|
|
2463
|
-
if (!profile ||
|
|
2495
|
+
const seat = bindable(author) ? seatPersonOf(author) : undefined;
|
|
2496
|
+
if (!profile || seat === undefined || meOf(author) !== undefined)
|
|
2464
2497
|
return undefined;
|
|
2465
2498
|
const people = this.schema.definitions.find((definition) => definition.people);
|
|
2466
|
-
if (!people || this.graph.
|
|
2499
|
+
if (!people || this.graph.personBoundTo(seat) !== undefined || everBound(this).has(seat))
|
|
2467
2500
|
return undefined;
|
|
2501
|
+
// A record an earlier version made, not yet migrated (`@graview/ship`'s `migrateProfilePeople`): never a second one beside it.
|
|
2502
|
+
const records = recordsOf(this.log);
|
|
2503
|
+
if (this.graph.has(seat) || records.kindOf(seat) !== undefined)
|
|
2504
|
+
return undefined;
|
|
2505
|
+
const id = mintPersonId(people.kind, batch, profile.id, (one) => this.graph.has(one) || records.kindOf(one) !== undefined);
|
|
2468
2506
|
const fields = people.fields;
|
|
2469
2507
|
const shape = fields.shape ?? {};
|
|
2470
2508
|
const words = Object.keys(shape).filter((field) => shape[field].safeParse("x").success && !shape[field].safeParse(1).success);
|
|
2471
2509
|
const named = words.includes("name") ? "name" : (words.find((field) => !shape[field].safeParse(undefined).success) ?? words[0]);
|
|
2472
2510
|
const node = { ...people.defaults, id, kind: people.kind, ...(named ? { [named]: profile.name } : {}) };
|
|
2473
|
-
return fields.safeParse(node).success ? { id, name: profile.name, node } : undefined;
|
|
2511
|
+
return fields.safeParse(node).success ? { id, name: profile.name, node: { ...node, [PERSON_SEAT]: seat } } : undefined;
|
|
2474
2512
|
}
|
|
2475
2513
|
/**
|
|
2476
2514
|
* A SEAT THAT CAN BE NOBODY HERE, where a kind is the people: a profile with
|
|
@@ -2493,10 +2531,10 @@ export class Store {
|
|
|
2493
2531
|
if (actingAs(author).id === undefined)
|
|
2494
2532
|
return kept({ id: "", kind: people.kind });
|
|
2495
2533
|
const id = meOf(author);
|
|
2496
|
-
if (id === undefined)
|
|
2534
|
+
if (id === undefined && !profileOf(author))
|
|
2497
2535
|
return true;
|
|
2498
|
-
const kind = this.graph.getNode(id)?.kind;
|
|
2499
|
-
if (kind !== undefined && this.schema.tryDefinition(kind)?.people)
|
|
2536
|
+
const kind = id === undefined ? undefined : this.graph.getNode(id)?.kind;
|
|
2537
|
+
if (id !== undefined && kind !== undefined && this.schema.tryDefinition(kind)?.people)
|
|
2500
2538
|
return kept({ id, kind });
|
|
2501
2539
|
if (!profileOf(author))
|
|
2502
2540
|
return false;
|
|
@@ -2509,7 +2547,8 @@ export class Store {
|
|
|
2509
2547
|
return true;
|
|
2510
2548
|
if (this.modules.disabledKinds.has(person.kind) && !isSystem(author))
|
|
2511
2549
|
return false;
|
|
2512
|
-
|
|
2550
|
+
// A person not made yet is judged as the seat's own: the seat bound to it, as it will be.
|
|
2551
|
+
return this.graph.has(person.id) ? seesId(this, author)(person.id) : sees(this.policy, asBoundTo(author, person.id), person, { out: () => [], in: () => [] }, recordsOf(this.log), fieldsJudged(this));
|
|
2513
2552
|
}
|
|
2514
2553
|
/**
|
|
2515
2554
|
* WHY AN ACT DONE AS `$me` IS NOT THIS SEAT'S: its profile has no person
|
|
@@ -2523,7 +2562,7 @@ export class Store {
|
|
|
2523
2562
|
}
|
|
2524
2563
|
/** The op that makes a profile's person on first use: by the account's own hand, so it is what the account made (`own`), and no other's. */
|
|
2525
2564
|
personToMake(author, batch, options) {
|
|
2526
|
-
const person = this.personFor(author);
|
|
2565
|
+
const person = this.personFor(author, batch);
|
|
2527
2566
|
if (!person)
|
|
2528
2567
|
return undefined;
|
|
2529
2568
|
return {
|