@estiva-app/interop 0.72.0 → 0.74.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 +60 -0
- package/README.md +12 -12
- package/dist/fields.d.ts +205 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +250 -0
- package/dist/fields.js.map +1 -0
- package/dist/folders.d.ts +56 -36
- package/dist/folders.d.ts.map +1 -1
- package/dist/folders.js +66 -37
- package/dist/folders.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/projection.d.ts +17 -0
- package/dist/projection.d.ts.map +1 -1
- package/dist/projection.js +26 -1
- package/dist/projection.js.map +1 -1
- package/package.json +3 -3
- package/src/fields.ts +346 -0
- package/src/folders.ts +87 -46
- package/src/index.ts +22 -0
- package/src/projection.ts +41 -1
package/dist/projection.js
CHANGED
|
@@ -16,7 +16,7 @@ import { decodeNevent, encodeNaddr, encodeNevent, pointerToAddress, referenceToP
|
|
|
16
16
|
import { parseProfile } from '@estiva-app/protocol';
|
|
17
17
|
import { MAX_FILTERS_PER_QUERY, RELAY_PAGE_CEILING } from '@estiva-app/protocol';
|
|
18
18
|
import { attachmentsInDocument, BLOCK_DOCUMENT_FORMAT, CONTENT_FORMAT_TAG, imetaTag, parseBlockDocument, } from '@estiva-app/protocol';
|
|
19
|
-
import { planPlaceFile, planUnlistFile } from './folders.js';
|
|
19
|
+
import { identifierOf, planPlaceFile, planUnlistFile } from './folders.js';
|
|
20
20
|
/*
|
|
21
21
|
SPEC §6.4's comment strength and §6.3's ordering are the conversation
|
|
22
22
|
package's (CON-5): one copy of each rule, read here for a file's `comments`,
|
|
@@ -4439,6 +4439,8 @@ function buildCreationEvent(args) {
|
|
|
4439
4439
|
* is refused rather than converted: the person picking it saw something else.
|
|
4440
4440
|
*/
|
|
4441
4441
|
const PERSON_KEY = /^[0-9a-f]{64}$/;
|
|
4442
|
+
/** An event id as the relay reads a `prev`: lower-case hex. */
|
|
4443
|
+
const EVENT_ID = /^[0-9a-f]{64}$/;
|
|
4442
4444
|
/** Why `value` is neither `''` nor a person's key, or undefined when it is one. */
|
|
4443
4445
|
function personKeyProblem(label, value) {
|
|
4444
4446
|
if (value === '' || PERSON_KEY.test(value))
|
|
@@ -4540,6 +4542,13 @@ function buildOneActionEvent(args) {
|
|
|
4540
4542
|
if (args.note !== undefined && (isCreation || !declared.emits.field || declared.emits.kind === KIND_DELETION)) {
|
|
4541
4543
|
return `"${declared.label}" is not a change, so it takes no note.`;
|
|
4542
4544
|
}
|
|
4545
|
+
// Only a change follows another for its field (§6.2).
|
|
4546
|
+
if (args.prev !== undefined && (isCreation || !declared.emits.field || declared.emits.kind === KIND_DELETION)) {
|
|
4547
|
+
return `"${declared.label}" is not a change, so it follows no change.`;
|
|
4548
|
+
}
|
|
4549
|
+
if (args.prev !== undefined && !EVENT_ID.test(args.prev)) {
|
|
4550
|
+
return `"${declared.label}" follows ${JSON.stringify(args.prev)}, which is not an event id.`;
|
|
4551
|
+
}
|
|
4543
4552
|
// An object-creating action is a different event entirely — a new object
|
|
4544
4553
|
// rather than a change to one — so it branches before the scalar path.
|
|
4545
4554
|
if (isCreation) {
|
|
@@ -4619,9 +4628,13 @@ function buildOneActionEvent(args) {
|
|
|
4619
4628
|
if (typeof prose === 'string')
|
|
4620
4629
|
return prose;
|
|
4621
4630
|
const [formatTag, ...files] = prose;
|
|
4631
|
+
// The file the change is about, by its id, beside its address (§6.2): the
|
|
4632
|
+
// relay keeps each field in order by it.
|
|
4633
|
+
const fileId = records.targetTag === 'a' ? identifierOf(address) : undefined;
|
|
4622
4634
|
const tags = declared.emits.field
|
|
4623
4635
|
? [
|
|
4624
4636
|
[records.targetTag, address],
|
|
4637
|
+
...(fileId !== undefined ? [['O', fileId]] : []),
|
|
4625
4638
|
[records.fieldTag, declared.emits.field],
|
|
4626
4639
|
[records.valueTag, value],
|
|
4627
4640
|
['h', folder],
|
|
@@ -4661,6 +4674,8 @@ function buildOneActionEvent(args) {
|
|
|
4661
4674
|
// depending on which app you asked (FRICTION.md A6).
|
|
4662
4675
|
if (records.order?.includes('ts'))
|
|
4663
4676
|
tags.push(['ts', String(args.createdAtMs)]);
|
|
4677
|
+
if (args.prev !== undefined)
|
|
4678
|
+
tags.push(['prev', args.prev]);
|
|
4664
4679
|
tags.push(...files);
|
|
4665
4680
|
// The person, where the relay indexes them: `value` is not indexed, so
|
|
4666
4681
|
// without this `#p` never finds the change and §11.8 makes nobody a member.
|
|
@@ -4704,6 +4719,13 @@ function buildOneActionEvent(args) {
|
|
|
4704
4719
|
if (moved?.field === declared.emits.field && typeof value === 'string' && parentAddress.test(value)) {
|
|
4705
4720
|
tags.push([MOVED_TO_TAG, value]);
|
|
4706
4721
|
}
|
|
4722
|
+
// What the chosen option means, last (§6.2's `stage`): a status says
|
|
4723
|
+
// whether it is open, started, done or dropped, whichever app reads it.
|
|
4724
|
+
const stage = declared.emits.field && declared.input?.enum
|
|
4725
|
+
? manifest.vocabularies?.[declared.input.enum]?.find((entry) => entry.value === value)?.stage
|
|
4726
|
+
: undefined;
|
|
4727
|
+
if (declared.emits.field && stage && STAGES.has(stage))
|
|
4728
|
+
tags.push(['stage', declared.emits.field, stage]);
|
|
4707
4729
|
return {
|
|
4708
4730
|
pubkey: args.pubkey,
|
|
4709
4731
|
created_at: Math.floor(args.createdAtMs / 1000),
|
|
@@ -4917,6 +4939,8 @@ async function readFolderRecords(query) {
|
|
|
4917
4939
|
folder.name = name;
|
|
4918
4940
|
if (channel.tags.some((tag) => tag[0] === 'private'))
|
|
4919
4941
|
folder.private = true;
|
|
4942
|
+
if (channel.tags.some((tag) => tag[0] === 'company'))
|
|
4943
|
+
folder.company = true;
|
|
4920
4944
|
const admins = folderAdminsOf(adminsOf.get(id), channel);
|
|
4921
4945
|
if (admins.length)
|
|
4922
4946
|
folder.admins = admins;
|
|
@@ -5289,6 +5313,7 @@ cache, options = {}) {
|
|
|
5289
5313
|
name: nameOf(channel),
|
|
5290
5314
|
hasState: !!state,
|
|
5291
5315
|
...(channel?.tags.some((tag) => tag[0] === 'private') ? { private: true } : {}),
|
|
5316
|
+
...(channel?.tags.some((tag) => tag[0] === 'company') ? { company: true } : {}),
|
|
5292
5317
|
...(admins.length ? { admins } : {}),
|
|
5293
5318
|
...(channelAddress ? { channel: channelAddress } : {}),
|
|
5294
5319
|
...(state
|