@airnauts/comments-adapter-memory 0.1.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/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/in-memory.d.ts +16 -0
- package/dist/in-memory.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +178 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Airnauts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @airnauts/comments-adapter-memory
|
|
2
|
+
|
|
3
|
+
In-memory `Repository` adapter for the Airnauts commenting tool — ephemeral,
|
|
4
|
+
process-local storage for local development and tests.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { memoryRepository } from '@airnauts/comments-adapter-memory'
|
|
8
|
+
|
|
9
|
+
const repository = memoryRepository()
|
|
10
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Attachment, AttachmentId, Thread, ThreadId, ThreadListItem, ThreadStatus } from '@airnauts/comments-core';
|
|
2
|
+
import { type AnchorPatch, type ListQuery, type ListResult, type NewComment, type NewThread, type Repository, type Scope } from '@airnauts/comments-server';
|
|
3
|
+
export declare class InMemoryRepository implements Repository {
|
|
4
|
+
private threads;
|
|
5
|
+
private attachments;
|
|
6
|
+
createThread(input: NewThread): Promise<Thread>;
|
|
7
|
+
getThread(scope: Scope, id: ThreadId): Promise<Thread | null>;
|
|
8
|
+
listThreads(query: ListQuery): Promise<ListResult>;
|
|
9
|
+
addComment(scope: Scope, threadId: ThreadId, comment: NewComment): Promise<NewComment>;
|
|
10
|
+
setStatus(scope: Scope, threadId: ThreadId, status: ThreadStatus, now: string): Promise<Thread>;
|
|
11
|
+
updateAnchor(scope: Scope, threadId: ThreadId, patch: AnchorPatch, now: string): Promise<ThreadListItem>;
|
|
12
|
+
putAttachment(scope: Scope, attachment: Attachment): Promise<void>;
|
|
13
|
+
getAttachments(scope: Scope, ids: AttachmentId[]): Promise<Attachment[]>;
|
|
14
|
+
reset(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=in-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../src/in-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,cAAc,EACd,YAAY,EACb,MAAM,yBAAyB,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ryRepository } from './in-memory';
|
|
3
|
+
export { InMemoryRepository };
|
|
4
|
+
/** Fresh, process-local in-memory `Repository`. No connection, no config. */
|
|
5
|
+
export declare function memoryRepository(): Repository;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAE7B,6EAA6E;AAC7E,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// src/in-memory.ts
|
|
2
|
+
import {
|
|
3
|
+
decodeCursor,
|
|
4
|
+
encodeCursor
|
|
5
|
+
} from "@airnauts/comments-server";
|
|
6
|
+
function attachmentKey(scope, id) {
|
|
7
|
+
return `${scope.projectId}\0${scope.env ?? ""}\0${id}`;
|
|
8
|
+
}
|
|
9
|
+
function clone(value) {
|
|
10
|
+
return structuredClone(value);
|
|
11
|
+
}
|
|
12
|
+
function toListItem(t) {
|
|
13
|
+
const {
|
|
14
|
+
comments: _c,
|
|
15
|
+
captureContext: _cc,
|
|
16
|
+
provenance: _p,
|
|
17
|
+
projectId: _pid,
|
|
18
|
+
env: _env,
|
|
19
|
+
...rest
|
|
20
|
+
} = t;
|
|
21
|
+
return rest;
|
|
22
|
+
}
|
|
23
|
+
function toThread(t) {
|
|
24
|
+
const { projectId: _pid, env: _env, ...wire } = t;
|
|
25
|
+
return wire;
|
|
26
|
+
}
|
|
27
|
+
function matchesScope(t, scope) {
|
|
28
|
+
if (t.projectId !== scope.projectId) return false;
|
|
29
|
+
return (t.env ?? void 0) === (scope.env ?? void 0);
|
|
30
|
+
}
|
|
31
|
+
function unresolvedCountOf(thread) {
|
|
32
|
+
return thread.status === "open" ? 1 : 0;
|
|
33
|
+
}
|
|
34
|
+
function recomputeCounts(thread) {
|
|
35
|
+
return {
|
|
36
|
+
...thread,
|
|
37
|
+
commentCount: thread.comments.length,
|
|
38
|
+
unresolvedCount: unresolvedCountOf(thread)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
var InMemoryRepository = class {
|
|
42
|
+
threads = /* @__PURE__ */ new Map();
|
|
43
|
+
attachments = /* @__PURE__ */ new Map();
|
|
44
|
+
async createThread(input) {
|
|
45
|
+
const stored = recomputeCounts({
|
|
46
|
+
projectId: input.projectId,
|
|
47
|
+
env: input.env,
|
|
48
|
+
id: input.id,
|
|
49
|
+
scope: input.scope,
|
|
50
|
+
pageKey: input.pageKey,
|
|
51
|
+
pageUrl: input.pageUrl,
|
|
52
|
+
pageTitle: input.pageTitle,
|
|
53
|
+
anchor: clone(input.anchor),
|
|
54
|
+
status: input.status,
|
|
55
|
+
anchorState: input.anchorState,
|
|
56
|
+
selectionLost: input.selectionLost,
|
|
57
|
+
captureContext: clone(input.captureContext),
|
|
58
|
+
provenance: input.provenance ? clone(input.provenance) : void 0,
|
|
59
|
+
createdBy: clone(input.createdBy),
|
|
60
|
+
createdAt: input.createdAt,
|
|
61
|
+
updatedAt: input.updatedAt,
|
|
62
|
+
lastActivityAt: input.lastActivityAt,
|
|
63
|
+
schemaVersion: input.schemaVersion,
|
|
64
|
+
commentCount: 0,
|
|
65
|
+
// placeholder, overwritten by recomputeCounts
|
|
66
|
+
unresolvedCount: 0,
|
|
67
|
+
// placeholder, overwritten by recomputeCounts
|
|
68
|
+
comments: [clone(input.firstComment)]
|
|
69
|
+
});
|
|
70
|
+
this.threads.set(input.id, stored);
|
|
71
|
+
return toThread(clone(stored));
|
|
72
|
+
}
|
|
73
|
+
async getThread(scope, id) {
|
|
74
|
+
const t = this.threads.get(id);
|
|
75
|
+
if (!t || !matchesScope(t, scope)) return null;
|
|
76
|
+
return toThread(clone(t));
|
|
77
|
+
}
|
|
78
|
+
async listThreads(query) {
|
|
79
|
+
const limit = Math.max(1, Math.min(query.limit, 200));
|
|
80
|
+
const filtered = [];
|
|
81
|
+
for (const t of this.threads.values()) {
|
|
82
|
+
if (!matchesScope(t, query)) continue;
|
|
83
|
+
if (query.pageKey !== void 0 && t.pageKey !== query.pageKey) continue;
|
|
84
|
+
if (query.status !== void 0 && t.status !== query.status) continue;
|
|
85
|
+
filtered.push(t);
|
|
86
|
+
}
|
|
87
|
+
filtered.sort((a, b) => {
|
|
88
|
+
if (a.updatedAt !== b.updatedAt) return a.updatedAt < b.updatedAt ? 1 : -1;
|
|
89
|
+
return a.id < b.id ? 1 : a.id > b.id ? -1 : 0;
|
|
90
|
+
});
|
|
91
|
+
let start = 0;
|
|
92
|
+
if (query.cursor) {
|
|
93
|
+
const decoded = decodeCursor(query.cursor);
|
|
94
|
+
if (decoded) {
|
|
95
|
+
start = filtered.findIndex(
|
|
96
|
+
(t) => t.updatedAt < decoded.updatedAt || t.updatedAt === decoded.updatedAt && t.id < decoded.id
|
|
97
|
+
);
|
|
98
|
+
if (start === -1) start = filtered.length;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const page = filtered.slice(start, start + limit);
|
|
102
|
+
const last = page[page.length - 1];
|
|
103
|
+
const more = start + limit < filtered.length;
|
|
104
|
+
const nextCursor = more && last ? encodeCursor({ updatedAt: last.updatedAt, id: last.id }) : null;
|
|
105
|
+
return {
|
|
106
|
+
threads: page.map((t) => toListItem(clone(t))),
|
|
107
|
+
nextCursor
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async addComment(scope, threadId, comment) {
|
|
111
|
+
const t = this.threads.get(threadId);
|
|
112
|
+
if (!t || !matchesScope(t, scope)) throw new Error("thread not found");
|
|
113
|
+
const next = recomputeCounts({
|
|
114
|
+
...t,
|
|
115
|
+
comments: [...t.comments, clone(comment)],
|
|
116
|
+
updatedAt: comment.createdAt,
|
|
117
|
+
lastActivityAt: comment.createdAt
|
|
118
|
+
});
|
|
119
|
+
this.threads.set(threadId, next);
|
|
120
|
+
return clone(comment);
|
|
121
|
+
}
|
|
122
|
+
async setStatus(scope, threadId, status, now) {
|
|
123
|
+
const t = this.threads.get(threadId);
|
|
124
|
+
if (!t || !matchesScope(t, scope)) throw new Error("thread not found");
|
|
125
|
+
const next = recomputeCounts({
|
|
126
|
+
...t,
|
|
127
|
+
status,
|
|
128
|
+
updatedAt: now,
|
|
129
|
+
lastActivityAt: now
|
|
130
|
+
});
|
|
131
|
+
this.threads.set(threadId, next);
|
|
132
|
+
return toThread(clone(next));
|
|
133
|
+
}
|
|
134
|
+
async updateAnchor(scope, threadId, patch, now) {
|
|
135
|
+
const t = this.threads.get(threadId);
|
|
136
|
+
if (!t || !matchesScope(t, scope)) throw new Error("thread not found");
|
|
137
|
+
const nextAnchor = {
|
|
138
|
+
...t.anchor,
|
|
139
|
+
selectors: patch.selectors ?? t.anchor.selectors,
|
|
140
|
+
signals: patch.signals ?? t.anchor.signals
|
|
141
|
+
};
|
|
142
|
+
const next = recomputeCounts({
|
|
143
|
+
...t,
|
|
144
|
+
anchor: nextAnchor,
|
|
145
|
+
anchorState: patch.anchorState,
|
|
146
|
+
selectionLost: patch.selectionLost ?? t.selectionLost,
|
|
147
|
+
updatedAt: now,
|
|
148
|
+
lastActivityAt: now
|
|
149
|
+
});
|
|
150
|
+
this.threads.set(threadId, next);
|
|
151
|
+
return toListItem(clone(next));
|
|
152
|
+
}
|
|
153
|
+
async putAttachment(scope, attachment) {
|
|
154
|
+
this.attachments.set(attachmentKey(scope, attachment.id), clone(attachment));
|
|
155
|
+
}
|
|
156
|
+
async getAttachments(scope, ids) {
|
|
157
|
+
const out = [];
|
|
158
|
+
for (const id of ids) {
|
|
159
|
+
const found = this.attachments.get(attachmentKey(scope, id));
|
|
160
|
+
if (found) out.push(clone(found));
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
reset() {
|
|
165
|
+
this.threads.clear();
|
|
166
|
+
this.attachments.clear();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/index.ts
|
|
171
|
+
function memoryRepository() {
|
|
172
|
+
return new InMemoryRepository();
|
|
173
|
+
}
|
|
174
|
+
export {
|
|
175
|
+
InMemoryRepository,
|
|
176
|
+
memoryRepository
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/in-memory.ts","../src/index.ts"],"sourcesContent":["import type {\n Attachment,\n AttachmentId,\n Thread,\n ThreadId,\n ThreadListItem,\n ThreadStatus,\n} from '@airnauts/comments-core'\nimport {\n type AnchorPatch,\n decodeCursor,\n encodeCursor,\n type ListQuery,\n type ListResult,\n type NewComment,\n type NewThread,\n type Repository,\n type Scope,\n} from '@airnauts/comments-server'\n\ntype StoredThread = Thread & { projectId: string; env?: string }\n\n// Attachments are keyed by scope + id; the separators keep the three parts unambiguous.\nfunction attachmentKey(scope: Scope, id: AttachmentId): string {\n return `${scope.projectId}\u0000${scope.env ?? ''}\u0000${id}`\n}\n\nfunction clone<T>(value: T): T {\n return structuredClone(value)\n}\n\nfunction toListItem(t: StoredThread): ThreadListItem {\n // Strip server-only scope + thread-only payload (comments/captureContext/provenance).\n const {\n comments: _c,\n captureContext: _cc,\n provenance: _p,\n projectId: _pid,\n env: _env,\n ...rest\n } = t as StoredThread & Record<string, unknown>\n return rest as ThreadListItem\n}\n\nfunction toThread(t: StoredThread): Thread {\n const { projectId: _pid, env: _env, ...wire } = t as StoredThread & Record<string, unknown>\n return wire as Thread\n}\n\nfunction matchesScope(t: StoredThread, scope: Scope): boolean {\n if (t.projectId !== scope.projectId) return false\n return (t.env ?? undefined) === (scope.env ?? undefined)\n}\n\nfunction unresolvedCountOf(thread: StoredThread): number {\n return thread.status === 'open' ? 1 : 0\n}\n\nfunction recomputeCounts(thread: StoredThread): StoredThread {\n return {\n ...thread,\n commentCount: thread.comments.length,\n unresolvedCount: unresolvedCountOf(thread),\n }\n}\n\nexport class InMemoryRepository implements Repository {\n private threads = new Map<string, StoredThread>()\n private attachments = new Map<string, Attachment>()\n\n async createThread(input: NewThread): Promise<Thread> {\n const stored: StoredThread = recomputeCounts({\n projectId: input.projectId,\n env: input.env,\n id: input.id,\n scope: input.scope,\n pageKey: input.pageKey,\n pageUrl: input.pageUrl,\n pageTitle: input.pageTitle,\n anchor: clone(input.anchor),\n status: input.status,\n anchorState: input.anchorState,\n selectionLost: input.selectionLost,\n captureContext: clone(input.captureContext),\n provenance: input.provenance ? clone(input.provenance) : undefined,\n createdBy: clone(input.createdBy),\n createdAt: input.createdAt,\n updatedAt: input.updatedAt,\n lastActivityAt: input.lastActivityAt,\n schemaVersion: input.schemaVersion,\n commentCount: 0, // placeholder, overwritten by recomputeCounts\n unresolvedCount: 0, // placeholder, overwritten by recomputeCounts\n comments: [clone(input.firstComment)],\n })\n this.threads.set(input.id, stored)\n return toThread(clone(stored))\n }\n\n async getThread(scope: Scope, id: ThreadId): Promise<Thread | null> {\n const t = this.threads.get(id)\n if (!t || !matchesScope(t, scope)) return null\n return toThread(clone(t))\n }\n\n async listThreads(query: ListQuery): Promise<ListResult> {\n const limit = Math.max(1, Math.min(query.limit, 200))\n const filtered: StoredThread[] = []\n for (const t of this.threads.values()) {\n if (!matchesScope(t, query)) continue\n if (query.pageKey !== undefined && t.pageKey !== query.pageKey) continue\n if (query.status !== undefined && t.status !== query.status) continue\n filtered.push(t)\n }\n filtered.sort((a, b) => {\n if (a.updatedAt !== b.updatedAt) return a.updatedAt < b.updatedAt ? 1 : -1\n return a.id < b.id ? 1 : a.id > b.id ? -1 : 0\n })\n\n let start = 0\n if (query.cursor) {\n const decoded = decodeCursor(query.cursor)\n if (decoded) {\n start = filtered.findIndex(\n (t) =>\n t.updatedAt < decoded.updatedAt ||\n (t.updatedAt === decoded.updatedAt && t.id < decoded.id),\n )\n if (start === -1) start = filtered.length\n }\n }\n const page = filtered.slice(start, start + limit)\n const last = page[page.length - 1]\n const more = start + limit < filtered.length\n const nextCursor =\n more && last ? encodeCursor({ updatedAt: last.updatedAt, id: last.id }) : null\n return {\n threads: page.map((t) => toListItem(clone(t))),\n nextCursor,\n }\n }\n\n async addComment(scope: Scope, threadId: ThreadId, comment: NewComment): Promise<NewComment> {\n const t = this.threads.get(threadId)\n if (!t || !matchesScope(t, scope)) throw new Error('thread not found')\n const next: StoredThread = recomputeCounts({\n ...t,\n comments: [...t.comments, clone(comment)],\n updatedAt: comment.createdAt,\n lastActivityAt: comment.createdAt,\n })\n this.threads.set(threadId, next)\n return clone(comment)\n }\n\n async setStatus(\n scope: Scope,\n threadId: ThreadId,\n status: ThreadStatus,\n now: string,\n ): Promise<Thread> {\n const t = this.threads.get(threadId)\n if (!t || !matchesScope(t, scope)) throw new Error('thread not found')\n const next: StoredThread = recomputeCounts({\n ...t,\n status,\n updatedAt: now,\n lastActivityAt: now,\n })\n this.threads.set(threadId, next)\n return toThread(clone(next))\n }\n\n async updateAnchor(\n scope: Scope,\n threadId: ThreadId,\n patch: AnchorPatch,\n now: string,\n ): Promise<ThreadListItem> {\n const t = this.threads.get(threadId)\n if (!t || !matchesScope(t, scope)) throw new Error('thread not found')\n const nextAnchor = {\n ...t.anchor,\n selectors: patch.selectors ?? t.anchor.selectors,\n signals: patch.signals ?? t.anchor.signals,\n }\n const next: StoredThread = recomputeCounts({\n ...t,\n anchor: nextAnchor,\n anchorState: patch.anchorState,\n selectionLost: patch.selectionLost ?? t.selectionLost,\n updatedAt: now,\n lastActivityAt: now,\n })\n this.threads.set(threadId, next)\n return toListItem(clone(next))\n }\n\n async putAttachment(scope: Scope, attachment: Attachment): Promise<void> {\n this.attachments.set(attachmentKey(scope, attachment.id), clone(attachment))\n }\n\n async getAttachments(scope: Scope, ids: AttachmentId[]): Promise<Attachment[]> {\n const out: Attachment[] = []\n for (const id of ids) {\n const found = this.attachments.get(attachmentKey(scope, id))\n if (found) out.push(clone(found))\n }\n return out\n }\n\n reset(): void {\n this.threads.clear()\n this.attachments.clear()\n }\n}\n","import type { Repository } from '@airnauts/comments-server'\nimport { InMemoryRepository } from './in-memory'\n\nexport { InMemoryRepository }\n\n/** Fresh, process-local in-memory `Repository`. No connection, no config. */\nexport function memoryRepository(): Repository {\n return new InMemoryRepository()\n}\n"],"mappings":";AAQA;AAAA,EAEE;AAAA,EACA;AAAA,OAOK;AAKP,SAAS,cAAc,OAAc,IAA0B;AAC7D,SAAO,GAAG,MAAM,SAAS,KAAI,MAAM,OAAO,EAAE,KAAI,EAAE;AACpD;AAEA,SAAS,MAAS,OAAa;AAC7B,SAAO,gBAAgB,KAAK;AAC9B;AAEA,SAAS,WAAW,GAAiC;AAEnD,QAAM;AAAA,IACJ,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,KAAK;AAAA,IACL,GAAG;AAAA,EACL,IAAI;AACJ,SAAO;AACT;AAEA,SAAS,SAAS,GAAyB;AACzC,QAAM,EAAE,WAAW,MAAM,KAAK,MAAM,GAAG,KAAK,IAAI;AAChD,SAAO;AACT;AAEA,SAAS,aAAa,GAAiB,OAAuB;AAC5D,MAAI,EAAE,cAAc,MAAM,UAAW,QAAO;AAC5C,UAAQ,EAAE,OAAO,aAAgB,MAAM,OAAO;AAChD;AAEA,SAAS,kBAAkB,QAA8B;AACvD,SAAO,OAAO,WAAW,SAAS,IAAI;AACxC;AAEA,SAAS,gBAAgB,QAAoC;AAC3D,SAAO;AAAA,IACL,GAAG;AAAA,IACH,cAAc,OAAO,SAAS;AAAA,IAC9B,iBAAiB,kBAAkB,MAAM;AAAA,EAC3C;AACF;AAEO,IAAM,qBAAN,MAA+C;AAAA,EAC5C,UAAU,oBAAI,IAA0B;AAAA,EACxC,cAAc,oBAAI,IAAwB;AAAA,EAElD,MAAM,aAAa,OAAmC;AACpD,UAAM,SAAuB,gBAAgB;AAAA,MAC3C,WAAW,MAAM;AAAA,M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,MAAO,KAAI,KAAK,MAAM,KAAK,CAAC;AAAA,IAClC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,QAAc;AACZ,SAAK,QAAQ,MAAM;AACnB,SAAK,YAAY,MAAM;AAAA,EACzB;AACF;;;AChNO,SAAS,mBAA+B;AAC7C,SAAO,IAAI,mBAAmB;AAChC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@airnauts/comments-adapter-memory",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "In-memory repository adapter for the Airnauts commenting tool server.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"comments",
|
|
7
|
+
"commenting",
|
|
8
|
+
"annotations",
|
|
9
|
+
"feedback",
|
|
10
|
+
"airnauts",
|
|
11
|
+
"in-memory",
|
|
12
|
+
"adapter"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Airnauts",
|
|
16
|
+
"homepage": "https://github.com/Airnauts/commenting-tool#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/Airnauts/commenting-tool.git",
|
|
20
|
+
"directory": "packages/adapter-memory"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/Airnauts/commenting-tool/issues"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"!dist/.tsbuildinfo",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@airnauts/comments-core": "^0.1.0",
|
|
43
|
+
"@airnauts/comments-server": "^0.1.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@airnauts/comments-test-support": "0.0.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup && tsc --build --force",
|
|
50
|
+
"typecheck": "tsc --build",
|
|
51
|
+
"test": "vitest run"
|
|
52
|
+
}
|
|
53
|
+
}
|