@estiva-app/interop 0.101.1 → 0.102.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.
- package/CHANGELOG.md +10 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/projection.d.ts +45 -7
- package/dist/projection.d.ts.map +1 -1
- package/dist/projection.js +120 -70
- package/dist/projection.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/projection.ts +157 -80
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estiva-app/interop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.102.0",
|
|
4
4
|
"description": "Render and act on another app's objects from its published NIP-89 manifest. The owner defines the projection; the consumer decides how it looks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/index.ts
CHANGED
package/src/projection.ts
CHANGED
|
@@ -2336,6 +2336,12 @@ export const BODY_SLOT = 'body'
|
|
|
2336
2336
|
/** The slot that is a file's summary, one line of plain text (SPEC §7.2). */
|
|
2337
2337
|
const SUBTITLE_SLOT = 'subtitle'
|
|
2338
2338
|
|
|
2339
|
+
/** The slot progress is counted from: it carries the stage (SPEC §6.2). */
|
|
2340
|
+
const STATUS_SLOT = 'status'
|
|
2341
|
+
|
|
2342
|
+
/** One field as folded: its value, the format and stage its winning change carried. */
|
|
2343
|
+
type FoldedField = { value: string; format?: ContentFormat; stage?: Stage }
|
|
2344
|
+
|
|
2339
2345
|
|
|
2340
2346
|
/**
|
|
2341
2347
|
* Does this change sit in the Folder its target is filed in — SPEC §6.2.
|
|
@@ -2392,7 +2398,7 @@ function inTargetFolder(change: SignedEvent, folders: ReadonlySet<string> | unde
|
|
|
2392
2398
|
* version where several are.
|
|
2393
2399
|
*/
|
|
2394
2400
|
function foldChanges(changes: SignedEvent[], rule: RecordsRule, root: SignedEvent | undefined) {
|
|
2395
|
-
const fields: Record<string, { value: string; by: string; at: number; format: ContentFormat; id: string }> = {}
|
|
2401
|
+
const fields: Record<string, { value: string; by: string; at: number; format: ContentFormat; id: string; stage?: Stage }> = {}
|
|
2396
2402
|
const folders = targetFolders(root)
|
|
2397
2403
|
const id = root && tagValue(root, 'd')
|
|
2398
2404
|
for (const change of [...changes].filter((c) => inTargetFolder(c, folders)).sort(byOrder)) {
|
|
@@ -2410,18 +2416,28 @@ function foldChanges(changes: SignedEvent[], rule: RecordsRule, root: SignedEven
|
|
|
2410
2416
|
// §13.4: "an app MUST read the tag from the event it took the value from,
|
|
2411
2417
|
// never from the object's root" — a description created as marker text and
|
|
2412
2418
|
// later edited into blocks is a root with no tag and a change with one.
|
|
2419
|
+
// The stage travels with the winning change too (SPEC §6.2): the one
|
|
2420
|
+
// naming this field, on a value that is not cleared. A later change with
|
|
2421
|
+
// none leaves none, never the older change's.
|
|
2422
|
+
const stage = value === '' ? undefined : stageTagOf(change, field)
|
|
2413
2423
|
fields[field] = {
|
|
2414
2424
|
value,
|
|
2415
2425
|
by: change.pubkey,
|
|
2416
2426
|
at: change.created_at,
|
|
2417
2427
|
format: contentFormatOf(change),
|
|
2418
2428
|
id: change.id,
|
|
2429
|
+
...(stage ? { stage } : {}),
|
|
2419
2430
|
}
|
|
2420
2431
|
}
|
|
2421
2432
|
}
|
|
2422
2433
|
return fields
|
|
2423
2434
|
}
|
|
2424
2435
|
|
|
2436
|
+
/** The stage an event (a change or a root) gives `field`: `["stage", <field>, <stage>]`, one of the four. */
|
|
2437
|
+
function stageTagOf(event: SignedEvent, field: string): Stage | undefined {
|
|
2438
|
+
return asStage(event.tags.find((t) => t[0] === 'stage' && t[1] === field)?.[2])
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2425
2441
|
/**
|
|
2426
2442
|
* The fields one change sets under `rule`: one per `set` when it carries any
|
|
2427
2443
|
* (SPEC §6.2, applied at the change's time as that many one-field changes),
|
|
@@ -2861,6 +2877,14 @@ export interface ResolvedSlot {
|
|
|
2861
2877
|
* event body, which no action can set.
|
|
2862
2878
|
*/
|
|
2863
2879
|
field?: string
|
|
2880
|
+
/**
|
|
2881
|
+
* What the status means, on the `status` slot only: the stage on the change
|
|
2882
|
+
* that set it, else its base type's directory stage, else its words (SPEC
|
|
2883
|
+
* §6.2). Undefined when none says, which counts as underway, not as done.
|
|
2884
|
+
* Every app counts by this ({@link progressOf}, {@link isClosedStatus}), so
|
|
2885
|
+
* a status a reader cannot look up still counts as its writer meant.
|
|
2886
|
+
*/
|
|
2887
|
+
stage?: Stage
|
|
2864
2888
|
}
|
|
2865
2889
|
|
|
2866
2890
|
/**
|
|
@@ -2915,12 +2939,14 @@ function firstTag(root: SignedEvent, tag: string | string[] | undefined): string
|
|
|
2915
2939
|
interface RawSlotValue {
|
|
2916
2940
|
value: string
|
|
2917
2941
|
format?: ContentFormat
|
|
2942
|
+
/** The stage the event the value came from gives its field (SPEC §6.2), a change's or a root's. */
|
|
2943
|
+
stage?: Stage
|
|
2918
2944
|
}
|
|
2919
2945
|
|
|
2920
2946
|
function rawSlotValue(
|
|
2921
2947
|
spec: SlotSpec,
|
|
2922
2948
|
root: SignedEvent,
|
|
2923
|
-
folded: Record<string,
|
|
2949
|
+
folded: Record<string, FoldedField>,
|
|
2924
2950
|
isBody: boolean,
|
|
2925
2951
|
): RawSlotValue | undefined {
|
|
2926
2952
|
// `fold` first, and a spec may carry both: a field that starts as a tag on
|
|
@@ -2930,7 +2956,7 @@ function rawSlotValue(
|
|
|
2930
2956
|
// reassigning it from here.
|
|
2931
2957
|
if (spec.fold) {
|
|
2932
2958
|
const change = folded[spec.fold]
|
|
2933
|
-
if (change) return { value: change.value, format: isBody ? (change.format ?? 'marker') : undefined }
|
|
2959
|
+
if (change) return { value: change.value, format: isBody ? (change.format ?? 'marker') : undefined, ...(change.stage ? { stage: change.stage } : {}) }
|
|
2934
2960
|
/*
|
|
2935
2961
|
Nobody has changed this field, so the object's own creation value stands.
|
|
2936
2962
|
§7.2 rule 2 covers seeding from a tag; `field: "content"` seeds from the
|
|
@@ -2953,7 +2979,9 @@ function rawSlotValue(
|
|
|
2953
2979
|
truncation guard reachable.
|
|
2954
2980
|
*/
|
|
2955
2981
|
const seedTag = firstTag(root, spec.tag)
|
|
2956
|
-
|
|
2982
|
+
// A root that sets a staged property carries its stage, as a change does (SPEC §6.2).
|
|
2983
|
+
const rootStage = stageTagOf(root, spec.fold)
|
|
2984
|
+
if (seedTag !== undefined) return { value: seedTag, format: isBody ? contentFormatOf(root) : undefined, ...(rootStage ? { stage: rootStage } : {}) }
|
|
2957
2985
|
if (spec.field === 'content' && root.content !== '') {
|
|
2958
2986
|
return { value: root.content, format: contentFormatOf(root) }
|
|
2959
2987
|
}
|
|
@@ -2966,7 +2994,10 @@ function rawSlotValue(
|
|
|
2966
2994
|
if (spec.tag) {
|
|
2967
2995
|
const value = firstTag(root, spec.tag)
|
|
2968
2996
|
if (value === undefined) return undefined
|
|
2969
|
-
|
|
2997
|
+
// The stage names the tag the value was read from, the first one the root carries.
|
|
2998
|
+
const read = (Array.isArray(spec.tag) ? spec.tag : [spec.tag]).find((name) => firstTag(root, name) !== undefined)
|
|
2999
|
+
const rootStage = read ? stageTagOf(root, read) : undefined
|
|
3000
|
+
return { value, format: isBody ? contentFormatOf(root) : undefined, ...(rootStage ? { stage: rootStage } : {}) }
|
|
2970
3001
|
}
|
|
2971
3002
|
if (spec.field === 'content') return { value: root.content, format: contentFormatOf(root) }
|
|
2972
3003
|
/*
|
|
@@ -2990,7 +3021,7 @@ function rawSlotValue(
|
|
|
2990
3021
|
function resolveSlot(
|
|
2991
3022
|
spec: SlotSpec,
|
|
2992
3023
|
root: SignedEvent,
|
|
2993
|
-
folded: Record<string,
|
|
3024
|
+
folded: Record<string, FoldedField>,
|
|
2994
3025
|
manifest: Manifest,
|
|
2995
3026
|
name?: string,
|
|
2996
3027
|
): ResolvedSlot | null {
|
|
@@ -3031,16 +3062,21 @@ function resolveSlot(
|
|
|
3031
3062
|
const entry = manifest.vocabularies?.[spec.map]?.find((v) => v.value === raw)
|
|
3032
3063
|
// A value outside the declared vocabulary is shown as-is rather than
|
|
3033
3064
|
// dropped. Another app may have written it, and silently rendering nothing
|
|
3034
|
-
// would hide exactly the corruption the honour system permits.
|
|
3065
|
+
// would hide exactly the corruption the honour system permits. By its id,
|
|
3066
|
+
// in the neutral grey of a status with no colour (Katerina, 30 Oct, EAC-2):
|
|
3067
|
+
// not `muted`, which draws as cancelled.
|
|
3035
3068
|
value = entry?.label ?? raw
|
|
3036
|
-
colour = entry?.colour ?? '
|
|
3069
|
+
colour = entry?.colour ?? 'neutral'
|
|
3037
3070
|
}
|
|
3071
|
+
const field = spec.fold ?? (Array.isArray(spec.tag) ? spec.tag[0] : spec.tag)
|
|
3072
|
+
const stage = name === STATUS_SLOT ? stageOf(root.kind, field, spec, manifest, raw, value, source.stage) : undefined
|
|
3038
3073
|
return {
|
|
3039
3074
|
label: spec.label,
|
|
3040
3075
|
value,
|
|
3041
3076
|
colour,
|
|
3042
3077
|
isPubkey: spec.as === 'pubkey',
|
|
3043
|
-
field
|
|
3078
|
+
field,
|
|
3079
|
+
...(stage ? { stage } : {}),
|
|
3044
3080
|
// Present only on a slot that can carry a body. Absent is the honest shape
|
|
3045
3081
|
// for a title read from a tag — and it keeps the key out of every existing
|
|
3046
3082
|
// consumer's deep comparisons, which is not the reason but is a real cost
|
|
@@ -3122,7 +3158,7 @@ function withDefaultSubtitle(
|
|
|
3122
3158
|
function resolveSlots(
|
|
3123
3159
|
projection: { slots: Record<string, SlotSpec | SlotSpec[]> },
|
|
3124
3160
|
root: SignedEvent,
|
|
3125
|
-
folded: Record<string,
|
|
3161
|
+
folded: Record<string, FoldedField>,
|
|
3126
3162
|
manifest: Manifest,
|
|
3127
3163
|
): { slots: Record<string, ResolvedSlot>; meta: ResolvedSlot[] } {
|
|
3128
3164
|
const slots: Record<string, ResolvedSlot> = {}
|
|
@@ -3188,6 +3224,13 @@ export interface ForeignObject {
|
|
|
3188
3224
|
* a renderer can tell "this holds nothing" from "this holds no list".
|
|
3189
3225
|
*/
|
|
3190
3226
|
children?: ForeignObject[]
|
|
3227
|
+
/**
|
|
3228
|
+
* How far along it is, from `children`: done over every child not dropped,
|
|
3229
|
+
* by each one's stage ({@link progressOf}). Absent when it has no children,
|
|
3230
|
+
* or one has no status. A renderer draws this rather than counting itself,
|
|
3231
|
+
* so every app counts a project the same way.
|
|
3232
|
+
*/
|
|
3233
|
+
progress?: { done: number; total: number }
|
|
3191
3234
|
/**
|
|
3192
3235
|
* Whether the owning app declares a child list **and** says how to draw it.
|
|
3193
3236
|
*
|
|
@@ -3997,7 +4040,11 @@ export async function resolveForeignRoots(
|
|
|
3997
4040
|
viaRecommendation: resolved.viaRecommendation,
|
|
3998
4041
|
childChanges: childEvents,
|
|
3999
4042
|
})
|
|
4000
|
-
if (children)
|
|
4043
|
+
if (children) {
|
|
4044
|
+
parent.children = textUnread(children)
|
|
4045
|
+
const progress = progressOf(children)
|
|
4046
|
+
if (progress) parent.progress = progress
|
|
4047
|
+
}
|
|
4001
4048
|
}
|
|
4002
4049
|
const objects = options.listRead ? textUnread(projected) : projected
|
|
4003
4050
|
if (options.archivedWith) {
|
|
@@ -4934,7 +4981,8 @@ function peopleOf({ object, children }: AssembledObject): string[] {
|
|
|
4934
4981
|
}
|
|
4935
4982
|
|
|
4936
4983
|
function withPeople({ object, children }: AssembledObject, people: People): ForeignObject {
|
|
4937
|
-
|
|
4984
|
+
const progress = children && progressOf(children)
|
|
4985
|
+
return { ...object, people, ...(children ? { children: children.map((c) => ({ ...c, people })) } : {}), ...(progress ? { progress } : {}) }
|
|
4938
4986
|
}
|
|
4939
4987
|
|
|
4940
4988
|
/**
|
|
@@ -5496,9 +5544,9 @@ export interface FolderProject {
|
|
|
5496
5544
|
* record from its own lists is saying it is no longer part of the project.
|
|
5497
5545
|
*/
|
|
5498
5546
|
tickets: ForeignObject[]
|
|
5499
|
-
/** Tickets still to do. With `doneCount`, the total the panel counts against. */
|
|
5547
|
+
/** Tickets still to do, every one not done or dropped. With `doneCount`, the total the panel counts against ({@link progressOf}). */
|
|
5500
5548
|
openCount: number
|
|
5501
|
-
/**
|
|
5549
|
+
/** Done tickets — the numerator in the panel's "1/3". A dropped one is in neither count. */
|
|
5502
5550
|
doneCount: number
|
|
5503
5551
|
}
|
|
5504
5552
|
|
|
@@ -5524,13 +5572,11 @@ export interface FolderProject {
|
|
|
5524
5572
|
* ships, its words are not in the set, and its panel renders blank, which is
|
|
5525
5573
|
* PEE-10's failure exactly. A declared stage is what removes the guess.
|
|
5526
5574
|
*
|
|
5527
|
-
*
|
|
5528
|
-
*
|
|
5529
|
-
*
|
|
5530
|
-
* nobody is doing and it would inflate the total into meaninglessness; an
|
|
5531
|
-
* unrecognised status some other app invented is not evidence of anything.
|
|
5575
|
+
* *EAC-2 (17 Nov):* the words are now the last of three readings (`stageOf`):
|
|
5576
|
+
* the change's own stage comes first, and a status none of them reads counts as
|
|
5577
|
+
* underway, in the total and not done, as Ship counts it (Miky, 17 Nov).
|
|
5532
5578
|
*
|
|
5533
|
-
*
|
|
5579
|
+
* A dropped status is left out of both numbers, which is what keeps "3/3" reachable. A cancelled ticket is
|
|
5534
5580
|
* not outstanding and never becomes done, so counting it in the total would
|
|
5535
5581
|
* leave a finished project stuck at 3/4 for good.
|
|
5536
5582
|
*
|
|
@@ -5577,75 +5623,109 @@ const inSet = (set: Set<string>) => (raw: string | undefined, label: string | un
|
|
|
5577
5623
|
const isOpenStatusByLabel = inSet(OPEN_STATUSES)
|
|
5578
5624
|
const isDoneStatusByLabel = inSet(DONE_STATUSES)
|
|
5579
5625
|
|
|
5580
|
-
/**
|
|
5581
|
-
|
|
5626
|
+
/**
|
|
5627
|
+
* What a status means: `open`, `started`, `done` or `dropped` (SPEC §7.4).
|
|
5628
|
+
* Anything else is not a stage, and counts as absent rather than as a fifth.
|
|
5629
|
+
*/
|
|
5630
|
+
export type Stage = 'open' | 'started' | 'done' | 'dropped'
|
|
5582
5631
|
const STAGES = new Set<Stage>(['open', 'started', 'done', 'dropped'])
|
|
5632
|
+
const asStage = (value: string | undefined): Stage | undefined =>
|
|
5633
|
+
value !== undefined && STAGES.has(value as Stage) ? (value as Stage) : undefined
|
|
5583
5634
|
|
|
5584
5635
|
/**
|
|
5585
|
-
*
|
|
5586
|
-
*
|
|
5587
|
-
* `undefined` means "this manifest does not say", which is a different fact
|
|
5588
|
-
* from "this status is not progress" and must not be collapsed into one — the
|
|
5589
|
-
* caller falls back to the word lists only in the first case.
|
|
5636
|
+
* A base type's default options and their stages, from its directory entry
|
|
5637
|
+
* (TYPES.md: `osnova.project`, `osnova.issue`), by kind and then by field.
|
|
5590
5638
|
*
|
|
5591
|
-
*
|
|
5592
|
-
*
|
|
5593
|
-
*
|
|
5594
|
-
*
|
|
5639
|
+
* SPEC §7.4: until a relay knows which apps a workspace added, a reader takes a
|
|
5640
|
+
* base type's default stages from here, **never from a manifest it resolved**
|
|
5641
|
+
* — a manifest is one app's self-description, and anyone can publish one.
|
|
5642
|
+
* The company's own statuses never count either (§6.2): a guest who cannot
|
|
5643
|
+
* read them would count the same file differently.
|
|
5595
5644
|
*/
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
raw: string | undefined,
|
|
5600
|
-
): Stage | undefined {
|
|
5601
|
-
if (!spec?.map || raw === undefined) return undefined
|
|
5602
|
-
const stage = manifest.vocabularies?.[spec.map]?.find((v) => v.value === raw)?.stage
|
|
5603
|
-
return stage && STAGES.has(stage as Stage) ? (stage as Stage) : undefined
|
|
5645
|
+
const DIRECTORY_STAGES: Record<number, Record<string, Record<string, Stage>>> = {
|
|
5646
|
+
30850: { status: { planned: 'open', in_progress: 'started', completed: 'done', cancelled: 'dropped' } },
|
|
5647
|
+
30851: { status: { todo: 'open', in_progress: 'started', done: 'done', cancelled: 'dropped' } },
|
|
5604
5648
|
}
|
|
5605
5649
|
|
|
5650
|
+
/** `cancelled` and its kin: finished, but not done. Split out of DONE_STATUSES so the words give a stage. */
|
|
5651
|
+
const DROPPED_STATUSES = new Set(['cancelled', 'canceled', 'duplicate'])
|
|
5606
5652
|
/**
|
|
5607
|
-
*
|
|
5653
|
+
* Started work sits above the queue.
|
|
5608
5654
|
*
|
|
5609
|
-
*
|
|
5610
|
-
*
|
|
5611
|
-
*
|
|
5612
|
-
* *progress* either, and an app that wanted to draw that distinction now can —
|
|
5613
|
-
* the stage is on the wire and this fold is the consumer's, not the protocol's.
|
|
5655
|
+
* Both halves are open, but "in progress" is what somebody opened the panel to
|
|
5656
|
+
* find; ordering by activity alone would bury it under whatever was filed most
|
|
5657
|
+
* recently.
|
|
5614
5658
|
*/
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5659
|
+
const STARTED = new Set(['in progress', 'started', 'doing', 'in review', 'review'])
|
|
5660
|
+
const isDroppedByLabel = inSet(DROPPED_STATUSES)
|
|
5661
|
+
const isStartedByLabel = inSet(STARTED)
|
|
5662
|
+
|
|
5663
|
+
/** The reader's own reading of the words, the last resort (SPEC §6.2): a stage, or nothing. */
|
|
5664
|
+
function stageByWords(raw: string | undefined, label: string | undefined): Stage | undefined {
|
|
5665
|
+
if (isDroppedByLabel(raw, label)) return 'dropped'
|
|
5666
|
+
if (isDoneStatusByLabel(raw, label)) return 'done'
|
|
5667
|
+
if (isStartedByLabel(raw, label)) return 'started'
|
|
5668
|
+
if (isOpenStatusByLabel(raw, label)) return 'open'
|
|
5669
|
+
return undefined
|
|
5618
5670
|
}
|
|
5619
5671
|
|
|
5620
5672
|
/**
|
|
5621
|
-
*
|
|
5673
|
+
* The stage a status counts by — the one read every app shares (SPEC §6.2,
|
|
5674
|
+
* record a-companys-statuses-are-its-own-layer-of-a-types-properties):
|
|
5675
|
+
*
|
|
5676
|
+
* 1. the stage on the change (or root) that set the field's current value,
|
|
5677
|
+
* when the field is staged;
|
|
5678
|
+
* 2. else, for a base type, its directory entry's stage for that id;
|
|
5679
|
+
* 3. else the words.
|
|
5622
5680
|
*
|
|
5623
|
-
*
|
|
5624
|
-
*
|
|
5625
|
-
*
|
|
5681
|
+
* A field is staged when the base type's directory gives its options stages,
|
|
5682
|
+
* or, for any other kind, when the vocabulary its slot maps to does. A stage on
|
|
5683
|
+
* an unstaged field is ignored, as is one outside the four.
|
|
5684
|
+
*
|
|
5685
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-companys-statuses-are-its-own-layer-of-a-types-properties.md
|
|
5626
5686
|
*/
|
|
5627
|
-
|
|
5628
|
-
|
|
5687
|
+
function stageOf(
|
|
5688
|
+
kind: number,
|
|
5689
|
+
field: string | undefined,
|
|
5690
|
+
spec: SlotSpec,
|
|
5691
|
+
manifest: Manifest,
|
|
5692
|
+
raw: string,
|
|
5693
|
+
label: string,
|
|
5694
|
+
written: Stage | undefined,
|
|
5695
|
+
): Stage | undefined {
|
|
5696
|
+
const directory = field !== undefined ? DIRECTORY_STAGES[kind]?.[field] : undefined
|
|
5697
|
+
const staged = directory !== undefined || (spec.map !== undefined && (manifest.vocabularies?.[spec.map] ?? []).some((v) => asStage(v.stage)))
|
|
5698
|
+
if (staged && written) return written
|
|
5699
|
+
if (directory?.[raw]) return directory[raw]
|
|
5700
|
+
return stageByWords(raw, label)
|
|
5629
5701
|
}
|
|
5630
5702
|
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
return isOpenStatusByLabel(raw, label)
|
|
5634
|
-
}
|
|
5703
|
+
/** Finished work, done or dropped: `[` puts a closed issue after an open one (PEE-21). */
|
|
5704
|
+
const isClosed = (stage: Stage | undefined) => stage === 'done' || stage === 'dropped'
|
|
5635
5705
|
|
|
5636
5706
|
/**
|
|
5637
|
-
*
|
|
5638
|
-
*
|
|
5639
|
-
*
|
|
5640
|
-
*
|
|
5641
|
-
* recently.
|
|
5707
|
+
* Is a resolved `status` slot finished work, done or dropped? By the stage it
|
|
5708
|
+
* counts by ({@link ResolvedSlot.stage}), else by its words for a slot built
|
|
5709
|
+
* before the stage was on it. `[` uses it to put a closed issue after an open
|
|
5710
|
+
* one (PEE-21).
|
|
5642
5711
|
*/
|
|
5643
|
-
|
|
5644
|
-
|
|
5712
|
+
export function isClosedStatus(slot: ResolvedSlot | undefined): boolean {
|
|
5713
|
+
if (slot === undefined) return false
|
|
5714
|
+
return isClosed(slot.stage ?? stageByWords(slot.value, slot.label))
|
|
5715
|
+
}
|
|
5645
5716
|
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5717
|
+
/**
|
|
5718
|
+
* How far along a project is: its done children over every child not dropped,
|
|
5719
|
+
* by the stage each counts by. A cancelled issue is out of both numbers, so a
|
|
5720
|
+
* finished project reads full (Miky, 3 Nov for Ship, 17 Nov for every app).
|
|
5721
|
+
* A child whose status has no stage (an unknown word) is in the total and not
|
|
5722
|
+
* done. `undefined` when there is nothing to count or a child has no status:
|
|
5723
|
+
* a list of things that are not work has no progress.
|
|
5724
|
+
*/
|
|
5725
|
+
export function progressOf(children: readonly { slots: { status?: ResolvedSlot } }[]): { done: number; total: number } | undefined {
|
|
5726
|
+
if (!children.length || children.some((child) => !child.slots.status)) return undefined
|
|
5727
|
+
const stages = children.map((child) => child.slots.status?.stage)
|
|
5728
|
+
return { done: stages.filter((stage) => stage === 'done').length, total: stages.filter((stage) => stage !== 'dropped').length }
|
|
5649
5729
|
}
|
|
5650
5730
|
|
|
5651
5731
|
/**
|
|
@@ -6045,17 +6125,14 @@ export async function resolveFolderProject(
|
|
|
6045
6125
|
}
|
|
6046
6126
|
const ticketChanges = changesFor(pointerToAddress(ticketPointer))
|
|
6047
6127
|
const folded = foldChanges(ticketChanges, records, event)
|
|
6048
|
-
const status = statusSpec ? resolveSlot(statusSpec, event, folded, manifest) : null
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
//
|
|
6052
|
-
|
|
6053
|
-
const
|
|
6054
|
-
if (done) doneCount += 1
|
|
6055
|
-
else if (
|
|
6056
|
-
// A status in neither set — parked, or one this consumer has never seen —
|
|
6057
|
-
// is still a ticket and still listed. It just cannot claim to be progress
|
|
6058
|
-
// in either direction, so it stays out of both counts.
|
|
6128
|
+
const status = statusSpec ? resolveSlot(statusSpec, event, folded, manifest, STATUS_SLOT) : null
|
|
6129
|
+
|
|
6130
|
+
// The stage the change says, then the directory's, then the words: as
|
|
6131
|
+
// `progressOf` counts, done over everything not dropped.
|
|
6132
|
+
// A ticket with no status at all is listed and counted in neither, as before.
|
|
6133
|
+
const stage = status?.stage
|
|
6134
|
+
if (status && stage === 'done') doneCount += 1
|
|
6135
|
+
else if (status && stage !== 'dropped') openCount += 1
|
|
6059
6136
|
|
|
6060
6137
|
rows.push({
|
|
6061
6138
|
ticket: buildObject({
|
|
@@ -6067,7 +6144,7 @@ export async function resolveFolderProject(
|
|
|
6067
6144
|
viaRecommendation,
|
|
6068
6145
|
webTemplate: resolved.webTemplate,
|
|
6069
6146
|
}),
|
|
6070
|
-
rank:
|
|
6147
|
+
rank: stage === 'started' ? 0 : isClosed(stage) ? 2 : 1,
|
|
6071
6148
|
activityMs: Math.max(event.created_at * 1000, ...ticketChanges.map(orderingMs)),
|
|
6072
6149
|
})
|
|
6073
6150
|
}
|