@mainsoft/agent-cms 0.7.0 → 0.10.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/CHANGELOG.md +64 -0
- package/README.md +291 -32
- package/TODO.md +72 -26
- package/UPGRADE-0.10.md +36 -0
- package/UPGRADE-0.8.md +118 -0
- package/dist/agent.cjs +39 -17
- package/dist/agent.d.cts +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +9 -7
- package/dist/bin.js +4528 -355
- package/dist/{chunk-OQ55GEF3.js → chunk-3OPKTBEI.js} +1 -1
- package/dist/chunk-6PB4ZCHH.js +328 -0
- package/dist/chunk-7SCYDG2G.js +2943 -0
- package/dist/chunk-7WJIIJCI.js +544 -0
- package/dist/chunk-7Y6TU2UA.js +150 -0
- package/dist/{chunk-QC2M4NZY.js → chunk-BFVBHIHV.js} +72 -1
- package/dist/chunk-DSJETZT4.js +493 -0
- package/dist/{chunk-IW3D4I7Q.js → chunk-IU2SMWAM.js} +246 -4
- package/dist/{chunk-VICZ76TR.js → chunk-KAO3Z3CF.js} +43 -2
- package/dist/{chunk-CRDW6Q72.js → chunk-MA6VKJ3F.js} +87 -25
- package/dist/{chunk-6K5ZTGHQ.js → chunk-PEQY4N73.js} +16 -0
- package/dist/{chunk-DOADAH4L.js → chunk-PGV2QPIL.js} +40 -0
- package/dist/{chunk-Y63XQS2J.js → chunk-QMPSOLLH.js} +1 -1
- package/dist/{chunk-EXV6JNLY.js → chunk-ZCUJ4MPT.js} +15 -22
- package/dist/cli.cjs +4528 -355
- package/dist/cli.d.cts +19 -3
- package/dist/cli.d.ts +19 -3
- package/dist/cli.js +206 -16
- package/dist/client.cjs +72 -1
- package/dist/client.d.cts +308 -6
- package/dist/client.d.ts +308 -6
- package/dist/client.js +1 -1
- package/dist/cms-C_vkAxYV.d.cts +1537 -0
- package/dist/cms-pqJyowu1.d.ts +1537 -0
- package/dist/config.d.cts +7 -1
- package/dist/config.d.ts +7 -1
- package/dist/drizzle-repo-CviH3EX7.d.cts +146 -0
- package/dist/drizzle-repo-DWLD0rWe.d.ts +146 -0
- package/dist/errors.cjs +82 -1
- package/dist/errors.d.cts +43 -3
- package/dist/errors.d.ts +43 -3
- package/dist/errors.js +2 -2
- package/dist/frontmatter.d.cts +5 -4
- package/dist/frontmatter.d.ts +5 -4
- package/dist/http.cjs +640 -94
- package/dist/http.d.cts +51 -2
- package/dist/http.d.ts +51 -2
- package/dist/http.js +203 -13
- package/dist/index.cjs +3759 -575
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +226 -30
- package/dist/markdown.cjs +89 -25
- package/dist/markdown.d.cts +57 -3
- package/dist/markdown.d.ts +57 -3
- package/dist/markdown.js +5 -1
- package/dist/mcp.cjs +314 -37
- package/dist/mcp.d.cts +3 -2
- package/dist/mcp.d.ts +3 -2
- package/dist/mcp.js +12 -9
- package/dist/messages/en.cjs +40 -0
- package/dist/messages/en.js +1 -1
- package/dist/messages/ko.cjs +40 -0
- package/dist/messages/ko.js +40 -0
- package/dist/registry/cms-audit.json +1 -1
- package/dist/registry/cms-doc-editor.json +15 -4
- package/dist/registry/cms-doc-list.json +2 -1
- package/dist/registry/cms-files.json +29 -0
- package/dist/registry/cms-lib.json +3 -3
- package/dist/registry/cms-media-picker.json +29 -0
- package/dist/registry/cms-media.json +28 -0
- package/dist/registry/cms-preview-comments.json +24 -0
- package/dist/registry/cms-releases.json +28 -0
- package/dist/registry/cms-shell.json +2 -2
- package/dist/registry/cms-trash.json +24 -0
- package/dist/registry/cms-versions.json +2 -1
- package/dist/registry/registry.json +163 -3
- package/dist/storage-s3.cjs +168 -0
- package/dist/storage-s3.d.cts +53 -0
- package/dist/storage-s3.d.ts +53 -0
- package/dist/storage-s3.js +143 -0
- package/dist/storage.cjs +373 -0
- package/dist/storage.d.cts +183 -0
- package/dist/storage.d.ts +183 -0
- package/dist/storage.js +49 -0
- package/dist/tables.cjs +251 -3
- package/dist/tables.d.cts +4965 -681
- package/dist/tables.d.ts +4965 -681
- package/dist/tables.js +14 -2
- package/dist/tools.cjs +331 -20
- package/dist/tools.d.cts +54 -7
- package/dist/tools.d.ts +54 -7
- package/dist/tools.js +16 -7
- package/dist/types.cjs +99 -1
- package/dist/types.d.cts +205 -5
- package/dist/types.d.ts +205 -5
- package/dist/types.js +5 -3
- package/package.json +32 -22
- package/dist/ai.cjs +0 -555
- package/dist/ai.d.cts +0 -48
- package/dist/ai.d.ts +0 -48
- package/dist/ai.js +0 -73
- package/dist/chunk-52NUUZC7.js +0 -1446
- package/dist/chunk-IGL2V6US.js +0 -324
- package/dist/chunk-QQV6VLYJ.js +0 -204
- package/dist/cms-BPp01z-8.d.ts +0 -411
- package/dist/cms-D6D89-qZ.d.cts +0 -411
- package/dist/drizzle-repo-B1rt7r4j.d.ts +0 -90
- package/dist/drizzle-repo-Cn-kL2FK.d.cts +0 -90
- package/dist/repo-BWI2Pkrv.d.ts +0 -162
- package/dist/repo-CeDxUxO6.d.cts +0 -162
package/dist/index.d.cts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { A as AgentChange, a as AnyCollection, B as BULK_ACTIONS,
|
|
2
|
-
export { D as DoctorReport, a as DrizzleRepo, b as DrizzleRepoOptions } from './drizzle-repo-
|
|
3
|
-
export {
|
|
4
|
-
export { CmsTables, CmsTablesOptions, SCHEMA_VERSION, cmsApiKeys, cmsAudit, cmsDdl, cmsDocuments, cmsHits, cmsMeta, cmsTables, cmsVersions, defaultTables, schemaVersionSql, splitSql, upgradeSteps } from './tables.cjs';
|
|
1
|
+
export { A as AgentChange, a as AnyCollection, b as AssetInfo, c as AssetListOptions, d as AssetPatch, e as AssetQuery, f as AssetUsage, g as AssetView, h as AuditQuery, B as BULK_ACTIONS, i as BulkAction, j as BulkResult, k as ChangeInfo, l as Cms, m as CmsAssets, n as CmsCore, C as CmsLike, o as CmsRepo, p as CollectionName, q as CreateCmsOptions, D as DocDiff, r as DocInput, s as DocPatch, F as FieldsOf, t as FieldsPatch, K as KeyRow, L as LIMITS, u as ListOptions, M as MediaOptions, v as MediaStoreConfig, w as MemoryRepo, N as NewAsset, x as NewAudit, y as NewDoc, z as NewVersion, P as PREVIEW_TTLS, E as PatchOp, G as PreviewLink, H as PreviewRead, I as PreviewTtl, S as SLUG_RE, J as ScanFile, O as SearchOptions, Q as SearchResult, R as SectionRange, T as StoredVersion, U as TypedDoc, V as UploadInstructions, W as UploadRequest, X as WriteOptions, Y as applyPatch, Z as assetFields, _ as assetId, $ as coreOf, a0 as createCms, a1 as createCmsCore, a2 as dayIn, a3 as defineCollection, a4 as humanSize, a5 as mergePatch, a6 as normalizeQuery, a7 as sectionRanges } from './cms-C_vkAxYV.cjs';
|
|
2
|
+
export { D as DoctorReport, a as DrizzleRepo, b as DrizzleRepoOptions } from './drizzle-repo-CviH3EX7.cjs';
|
|
3
|
+
export { CmsTables, CmsTablesOptions, SCHEMA_VERSION, cmsApiKeys, cmsAssetRefs, cmsAssets, cmsAudit, cmsComments, cmsDdl, cmsDocuments, cmsHits, cmsMeta, cmsPresence, cmsReleases, cmsSavedFilters, cmsTables, cmsVersions, defaultTables, schemaVersionSql, splitSql, upgradeSteps } from './tables.cjs';
|
|
5
4
|
export { AgentLink, AgentLookup, AgentSection, Citation, ENVELOPE_PREAMBLE, LookupOptions, citationId, envelope, lookupForAgent, verifyCitations } from './agent.cjs';
|
|
6
|
-
export { CMS_TOOLS, CMS_TOOL_NAMES, CmsToolDef, toolsFor } from './tools.cjs';
|
|
5
|
+
export { CMS_TOOLS, CMS_TOOL_NAMES, CallToolOptions, CmsToolDef, ToolErrorResult, ToolOutcome, callTool, runTool, toolErrorResult, toolsFor } from './tools.cjs';
|
|
6
|
+
export { DEFAULT_ACCEPT, MemoryStorage, StorageAdapter } from './storage.cjs';
|
|
7
7
|
export { CmsClient, CmsClientOptions, CmsRemoteError, RestClient, RestClientOptions, createCmsClient, createRestClient, isCmsRemoteError } from './client.cjs';
|
|
8
8
|
export { docFromMarkdown, parseFrontmatter } from './frontmatter.cjs';
|
|
9
|
-
export { AUDIT_ACTIONS, AccessArgs, Actor, AuditAction, AuditEntry, AutosaveState, CmsDoc, CmsKey, CmsVersion, CollectionConfig, DOC_STATUSES, DocContent, DocCounts, DocState, DocStatus, DocSummary, FieldAdmin, KEY_SCOPES, KeyScope, ReviewMark, SearchMissEvent, VIAS, VersionChange, VersionSummary, Via, docState } from './types.cjs';
|
|
9
|
+
export { ASSET_KINDS, AUDIT_ACTIONS, AccessArgs, Actor, ActorKind, AssetKind, AssetRef, AuditAction, AuditEntry, AutosaveState, CmsAsset, CmsComment, CmsDoc, CmsKey, CmsRelease, CmsVersion, CollectionConfig, DOC_STATUSES, DocContent, DocCounts, DocState, DocStatus, DocSummary, FieldAdmin, KEY_SCOPES, KeyScope, Presence, ReleaseItem, ReviewMark, ReviewRequest, SavedFilter, Schedule, SearchMissEvent, VIAS, VersionChange, VersionSummary, Via, docState } from './types.cjs';
|
|
10
10
|
export { CmsError, CmsErrorCode, CmsErrorKind, CmsErrorOptions, Diagnostic, ERROR_CODES, ERROR_KINDS, ErrorParams, MessageTemplate, Messages, formatMessage, isCmsError } from './errors.cjs';
|
|
11
11
|
import 'zod';
|
|
12
|
+
import './markdown.cjs';
|
|
12
13
|
import './diff.cjs';
|
|
13
14
|
import 'drizzle-orm/pg-core';
|
|
14
|
-
import './markdown.cjs';
|
|
15
15
|
|
|
16
16
|
/** Package version (kept in step with package.json by `src/parts.test.ts`). */
|
|
17
|
-
declare const VERSION = "0.
|
|
17
|
+
declare const VERSION = "0.10.1";
|
|
18
18
|
|
|
19
19
|
export { VERSION };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { A as AgentChange, a as AnyCollection, B as BULK_ACTIONS,
|
|
2
|
-
export { D as DoctorReport, a as DrizzleRepo, b as DrizzleRepoOptions } from './drizzle-repo-
|
|
3
|
-
export {
|
|
4
|
-
export { CmsTables, CmsTablesOptions, SCHEMA_VERSION, cmsApiKeys, cmsAudit, cmsDdl, cmsDocuments, cmsHits, cmsMeta, cmsTables, cmsVersions, defaultTables, schemaVersionSql, splitSql, upgradeSteps } from './tables.js';
|
|
1
|
+
export { A as AgentChange, a as AnyCollection, b as AssetInfo, c as AssetListOptions, d as AssetPatch, e as AssetQuery, f as AssetUsage, g as AssetView, h as AuditQuery, B as BULK_ACTIONS, i as BulkAction, j as BulkResult, k as ChangeInfo, l as Cms, m as CmsAssets, n as CmsCore, C as CmsLike, o as CmsRepo, p as CollectionName, q as CreateCmsOptions, D as DocDiff, r as DocInput, s as DocPatch, F as FieldsOf, t as FieldsPatch, K as KeyRow, L as LIMITS, u as ListOptions, M as MediaOptions, v as MediaStoreConfig, w as MemoryRepo, N as NewAsset, x as NewAudit, y as NewDoc, z as NewVersion, P as PREVIEW_TTLS, E as PatchOp, G as PreviewLink, H as PreviewRead, I as PreviewTtl, S as SLUG_RE, J as ScanFile, O as SearchOptions, Q as SearchResult, R as SectionRange, T as StoredVersion, U as TypedDoc, V as UploadInstructions, W as UploadRequest, X as WriteOptions, Y as applyPatch, Z as assetFields, _ as assetId, $ as coreOf, a0 as createCms, a1 as createCmsCore, a2 as dayIn, a3 as defineCollection, a4 as humanSize, a5 as mergePatch, a6 as normalizeQuery, a7 as sectionRanges } from './cms-pqJyowu1.js';
|
|
2
|
+
export { D as DoctorReport, a as DrizzleRepo, b as DrizzleRepoOptions } from './drizzle-repo-DWLD0rWe.js';
|
|
3
|
+
export { CmsTables, CmsTablesOptions, SCHEMA_VERSION, cmsApiKeys, cmsAssetRefs, cmsAssets, cmsAudit, cmsComments, cmsDdl, cmsDocuments, cmsHits, cmsMeta, cmsPresence, cmsReleases, cmsSavedFilters, cmsTables, cmsVersions, defaultTables, schemaVersionSql, splitSql, upgradeSteps } from './tables.js';
|
|
5
4
|
export { AgentLink, AgentLookup, AgentSection, Citation, ENVELOPE_PREAMBLE, LookupOptions, citationId, envelope, lookupForAgent, verifyCitations } from './agent.js';
|
|
6
|
-
export { CMS_TOOLS, CMS_TOOL_NAMES, CmsToolDef, toolsFor } from './tools.js';
|
|
5
|
+
export { CMS_TOOLS, CMS_TOOL_NAMES, CallToolOptions, CmsToolDef, ToolErrorResult, ToolOutcome, callTool, runTool, toolErrorResult, toolsFor } from './tools.js';
|
|
6
|
+
export { DEFAULT_ACCEPT, MemoryStorage, StorageAdapter } from './storage.js';
|
|
7
7
|
export { CmsClient, CmsClientOptions, CmsRemoteError, RestClient, RestClientOptions, createCmsClient, createRestClient, isCmsRemoteError } from './client.js';
|
|
8
8
|
export { docFromMarkdown, parseFrontmatter } from './frontmatter.js';
|
|
9
|
-
export { AUDIT_ACTIONS, AccessArgs, Actor, AuditAction, AuditEntry, AutosaveState, CmsDoc, CmsKey, CmsVersion, CollectionConfig, DOC_STATUSES, DocContent, DocCounts, DocState, DocStatus, DocSummary, FieldAdmin, KEY_SCOPES, KeyScope, ReviewMark, SearchMissEvent, VIAS, VersionChange, VersionSummary, Via, docState } from './types.js';
|
|
9
|
+
export { ASSET_KINDS, AUDIT_ACTIONS, AccessArgs, Actor, ActorKind, AssetKind, AssetRef, AuditAction, AuditEntry, AutosaveState, CmsAsset, CmsComment, CmsDoc, CmsKey, CmsRelease, CmsVersion, CollectionConfig, DOC_STATUSES, DocContent, DocCounts, DocState, DocStatus, DocSummary, FieldAdmin, KEY_SCOPES, KeyScope, Presence, ReleaseItem, ReviewMark, ReviewRequest, SavedFilter, Schedule, SearchMissEvent, VIAS, VersionChange, VersionSummary, Via, docState } from './types.js';
|
|
10
10
|
export { CmsError, CmsErrorCode, CmsErrorKind, CmsErrorOptions, Diagnostic, ERROR_CODES, ERROR_KINDS, ErrorParams, MessageTemplate, Messages, formatMessage, isCmsError } from './errors.js';
|
|
11
11
|
import 'zod';
|
|
12
|
+
import './markdown.js';
|
|
12
13
|
import './diff.js';
|
|
13
14
|
import 'drizzle-orm/pg-core';
|
|
14
|
-
import './markdown.js';
|
|
15
15
|
|
|
16
16
|
/** Package version (kept in step with package.json by `src/parts.test.ts`). */
|
|
17
|
-
declare const VERSION = "0.
|
|
17
|
+
declare const VERSION = "0.10.1";
|
|
18
18
|
|
|
19
19
|
export { VERSION };
|
package/dist/index.js
CHANGED
|
@@ -1,68 +1,84 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DrizzleRepo
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7WJIIJCI.js";
|
|
4
4
|
import {
|
|
5
5
|
docFromMarkdown,
|
|
6
6
|
parseFrontmatter
|
|
7
7
|
} from "./chunk-DD56PTZ4.js";
|
|
8
8
|
import {
|
|
9
9
|
cmsApiKeys,
|
|
10
|
+
cmsAssetRefs,
|
|
11
|
+
cmsAssets,
|
|
10
12
|
cmsAudit,
|
|
13
|
+
cmsComments,
|
|
11
14
|
cmsDdl,
|
|
12
15
|
cmsDocuments,
|
|
13
16
|
cmsHits,
|
|
14
17
|
cmsMeta,
|
|
18
|
+
cmsPresence,
|
|
19
|
+
cmsReleases,
|
|
20
|
+
cmsSavedFilters,
|
|
15
21
|
cmsTables,
|
|
16
22
|
cmsVersions,
|
|
17
23
|
defaultTables,
|
|
18
24
|
schemaVersionSql,
|
|
19
25
|
splitSql,
|
|
20
26
|
upgradeSteps
|
|
21
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-IU2SMWAM.js";
|
|
22
28
|
import {
|
|
23
29
|
VERSION
|
|
24
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-QMPSOLLH.js";
|
|
31
|
+
import {
|
|
32
|
+
CMS_TOOLS,
|
|
33
|
+
CMS_TOOL_NAMES,
|
|
34
|
+
callTool,
|
|
35
|
+
runTool,
|
|
36
|
+
toolErrorResult,
|
|
37
|
+
toolsFor
|
|
38
|
+
} from "./chunk-DSJETZT4.js";
|
|
25
39
|
import {
|
|
26
40
|
CmsRemoteError,
|
|
27
41
|
createCmsClient,
|
|
28
42
|
createRestClient,
|
|
29
43
|
isCmsRemoteError
|
|
30
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-BFVBHIHV.js";
|
|
31
45
|
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
ENVELOPE_PREAMBLE,
|
|
47
|
+
citationId,
|
|
48
|
+
envelope,
|
|
49
|
+
lookupForAgent,
|
|
50
|
+
verifyCitations
|
|
51
|
+
} from "./chunk-7Y6TU2UA.js";
|
|
36
52
|
import {
|
|
37
53
|
BULK_ACTIONS,
|
|
38
|
-
ENVELOPE_PREAMBLE,
|
|
39
54
|
LIMITS,
|
|
40
55
|
PREVIEW_TTLS,
|
|
41
56
|
SLUG_RE,
|
|
42
57
|
applyPatch,
|
|
43
|
-
|
|
58
|
+
assetFields,
|
|
59
|
+
assetId,
|
|
44
60
|
coreOf,
|
|
45
61
|
createCms,
|
|
46
62
|
createCmsCore,
|
|
47
63
|
dayIn,
|
|
48
64
|
defineCollection,
|
|
49
|
-
|
|
50
|
-
lookupForAgent,
|
|
65
|
+
humanSize,
|
|
51
66
|
mergePatch,
|
|
52
67
|
normalizeQuery,
|
|
53
|
-
sectionRanges
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
sectionRanges
|
|
69
|
+
} from "./chunk-7SCYDG2G.js";
|
|
70
|
+
import "./chunk-MA6VKJ3F.js";
|
|
56
71
|
import {
|
|
72
|
+
ASSET_KINDS,
|
|
57
73
|
AUDIT_ACTIONS,
|
|
58
74
|
DOC_STATUSES,
|
|
59
75
|
KEY_SCOPES,
|
|
60
76
|
VIAS,
|
|
61
77
|
docState
|
|
62
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-PEQY4N73.js";
|
|
63
79
|
import {
|
|
64
80
|
SCHEMA_VERSION
|
|
65
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-3OPKTBEI.js";
|
|
66
82
|
import "./chunk-AKN7SUXU.js";
|
|
67
83
|
import {
|
|
68
84
|
CmsError,
|
|
@@ -70,48 +86,69 @@ import {
|
|
|
70
86
|
ERROR_KINDS,
|
|
71
87
|
formatMessage,
|
|
72
88
|
isCmsError
|
|
73
|
-
} from "./chunk-
|
|
74
|
-
import "./chunk-
|
|
75
|
-
import
|
|
89
|
+
} from "./chunk-KAO3Z3CF.js";
|
|
90
|
+
import "./chunk-PGV2QPIL.js";
|
|
91
|
+
import {
|
|
92
|
+
DEFAULT_ACCEPT,
|
|
93
|
+
MemoryStorage
|
|
94
|
+
} from "./chunk-6PB4ZCHH.js";
|
|
76
95
|
import "./chunk-2NTK7H4W.js";
|
|
77
96
|
|
|
78
97
|
// src/repo.ts
|
|
98
|
+
var inFolder = (folder, under) => under === "" || folder === under || folder.startsWith(`${under}/`);
|
|
79
99
|
var MemoryRepo = class {
|
|
80
100
|
docs = /* @__PURE__ */ new Map();
|
|
81
101
|
versions = [];
|
|
82
102
|
keys = [];
|
|
83
103
|
hits = /* @__PURE__ */ new Map();
|
|
84
104
|
audit = [];
|
|
105
|
+
assets = /* @__PURE__ */ new Map();
|
|
106
|
+
assetRefs = [];
|
|
107
|
+
comments = [];
|
|
108
|
+
releases = [];
|
|
109
|
+
filters = [];
|
|
110
|
+
presence = [];
|
|
85
111
|
meta = /* @__PURE__ */ new Map([["schema_version", SCHEMA_VERSION]]);
|
|
86
112
|
seq = 0;
|
|
87
113
|
id = () => `00000000-0000-4000-8000-${String(++this.seq).padStart(12, "0")}`;
|
|
88
114
|
async tx(fn) {
|
|
89
|
-
const snap = {
|
|
115
|
+
const snap = {
|
|
116
|
+
docs: new Map([...this.docs].map(([k, v]) => [k, structuredClone(v)])),
|
|
117
|
+
versions: this.versions.map((v) => structuredClone(v)),
|
|
118
|
+
assets: new Map([...this.assets].map(([k, v]) => [k, structuredClone(v)])),
|
|
119
|
+
assetRefs: this.assetRefs.map((r) => ({ ...r })),
|
|
120
|
+
releases: structuredClone(this.releases),
|
|
121
|
+
comments: structuredClone(this.comments)
|
|
122
|
+
};
|
|
90
123
|
try {
|
|
91
124
|
return await fn(this);
|
|
92
125
|
} catch (e) {
|
|
93
126
|
this.docs = snap.docs;
|
|
94
127
|
this.versions = snap.versions;
|
|
128
|
+
this.assets = snap.assets;
|
|
129
|
+
this.assetRefs = snap.assetRefs;
|
|
130
|
+
this.releases = snap.releases;
|
|
131
|
+
this.comments = snap.comments;
|
|
95
132
|
throw e;
|
|
96
133
|
}
|
|
97
134
|
}
|
|
98
|
-
async findDoc(collection, slug) {
|
|
99
|
-
for (const d of this.docs.values()) if (d.collection === collection && d.slug === slug) return structuredClone(d);
|
|
135
|
+
async findDoc(collection, slug, o = {}) {
|
|
136
|
+
for (const d of this.docs.values()) if (d.collection === collection && d.slug === slug) return d.deletedAt && !o.trashed ? null : structuredClone(d);
|
|
100
137
|
return null;
|
|
101
138
|
}
|
|
102
|
-
async findDocById(id) {
|
|
139
|
+
async findDocById(id, o = {}) {
|
|
103
140
|
const d = this.docs.get(id);
|
|
104
|
-
return d ? structuredClone(d) : null;
|
|
141
|
+
return d && (!d.deletedAt || o.trashed) ? structuredClone(d) : null;
|
|
105
142
|
}
|
|
106
143
|
async listDocs(f) {
|
|
107
144
|
return [...this.docs.values()].filter(
|
|
108
|
-
(d) => (!f.collection || d.collection === f.collection) && (!f.statuses || f.statuses.includes(d.status)) && (f.published === void 0 || (d.publishedVersion !== null && d.status !== "archived") === f.published)
|
|
145
|
+
(d) => !!d.deletedAt === !!f.trashed && (!f.dueBefore || d.dueAt !== null && d.dueAt <= f.dueBefore) && (!f.collection || d.collection === f.collection) && (!f.statuses || f.statuses.includes(d.status)) && (f.published === void 0 || (d.publishedVersion !== null && d.status !== "archived") === f.published)
|
|
109
146
|
).map((d) => structuredClone(d));
|
|
110
147
|
}
|
|
111
148
|
async insertDoc(doc) {
|
|
112
149
|
for (const d of this.docs.values()) if (d.collection === doc.collection && d.slug === doc.slug) throw new Error("duplicate slug");
|
|
113
150
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
114
|
-
const row = { republishedAt: null, autosave: null, ...doc, id: doc.id ?? this.id(), createdAt: doc.createdAt ?? now, updatedAt: doc.updatedAt ?? now };
|
|
151
|
+
const row = { republishedAt: null, autosave: null, updatedByAgent: null, deletedAt: null, deletedBy: null, schedule: null, dueAt: null, review: null, ...doc, id: doc.id ?? this.id(), createdAt: doc.createdAt ?? now, updatedAt: doc.updatedAt ?? now };
|
|
115
152
|
this.docs.set(row.id, structuredClone(row));
|
|
116
153
|
return structuredClone(row);
|
|
117
154
|
}
|
|
@@ -130,10 +167,13 @@ var MemoryRepo = class {
|
|
|
130
167
|
this.docs.delete(id);
|
|
131
168
|
this.versions = this.versions.filter((v) => v.documentId !== id);
|
|
132
169
|
for (const k of [...this.hits.keys()]) if (k.startsWith(`${id}|`)) this.hits.delete(k);
|
|
170
|
+
this.assetRefs = this.assetRefs.filter((r) => r.documentId !== id);
|
|
171
|
+
this.comments = this.comments.filter((c) => c.documentId !== id);
|
|
172
|
+
this.presence = this.presence.filter((p) => p.documentId !== id);
|
|
133
173
|
}
|
|
134
174
|
async insertVersion(v) {
|
|
135
175
|
if (this.versions.some((x) => x.documentId === v.documentId && x.version === v.version)) throw new Error("duplicate version");
|
|
136
|
-
this.versions.push({ changed: null, ...structuredClone(v), reviewed: [], id: this.id(), createdAt: v.createdAt ?? (/* @__PURE__ */ new Date()).toISOString() });
|
|
176
|
+
this.versions.push({ changed: null, authorAgent: null, label: null, pinned: false, approvedBy: null, approvedAt: null, ...structuredClone(v), reviewed: [], id: this.id(), createdAt: v.createdAt ?? (/* @__PURE__ */ new Date()).toISOString() });
|
|
137
177
|
}
|
|
138
178
|
async listVersions(documentId) {
|
|
139
179
|
return this.versions.filter((v) => v.documentId === documentId).sort((a, b) => b.version - a.version).map((v) => structuredClone(v));
|
|
@@ -146,9 +186,13 @@ var MemoryRepo = class {
|
|
|
146
186
|
const v = this.versions.find((x) => x.documentId === documentId && x.version === version);
|
|
147
187
|
if (v) v.reviewed = structuredClone(reviewed);
|
|
148
188
|
}
|
|
189
|
+
async updateVersion(documentId, version, patch) {
|
|
190
|
+
const v = this.versions.find((x) => x.documentId === documentId && x.version === version);
|
|
191
|
+
if (v) Object.assign(v, Object.fromEntries(Object.entries(patch).filter(([, x]) => x !== void 0)));
|
|
192
|
+
}
|
|
149
193
|
async pruneVersions(documentId, keep, protect) {
|
|
150
194
|
const mine = this.versions.filter((v) => v.documentId === documentId).sort((a, b) => b.version - a.version);
|
|
151
|
-
const drop = new Set(mine.slice(keep).filter((v) => !protect.includes(v.version)).map((v) => v.id));
|
|
195
|
+
const drop = new Set(mine.slice(keep).filter((v) => !protect.includes(v.version) && !v.pinned).map((v) => v.id));
|
|
152
196
|
this.versions = this.versions.filter((v) => !drop.has(v.id));
|
|
153
197
|
}
|
|
154
198
|
async insertKey(k) {
|
|
@@ -189,11 +233,148 @@ var MemoryRepo = class {
|
|
|
189
233
|
return out;
|
|
190
234
|
}
|
|
191
235
|
async insertAudit(e) {
|
|
192
|
-
this.audit.push({ ...structuredClone(e), id: this.id() });
|
|
236
|
+
this.audit.push({ actorAgent: null, ...structuredClone(e), id: this.id() });
|
|
193
237
|
}
|
|
194
238
|
async listAudit(q) {
|
|
195
239
|
return this.audit.filter((e) => (!q.before || `${e.at}|${e.id}` < q.before) && (!q.action || e.action === q.action) && (!q.outcome || e.outcome === q.outcome) && (!q.actorKind || e.actorKind === q.actorKind)).sort((a, b) => `${b.at}|${b.id}`.localeCompare(`${a.at}|${a.id}`)).slice(0, q.limit).map((e) => structuredClone(e));
|
|
196
240
|
}
|
|
241
|
+
async insertAsset(a) {
|
|
242
|
+
if (this.assets.has(a.id)) throw new Error("duplicate asset id");
|
|
243
|
+
for (const o of this.assets.values()) if (o.store === a.store && o.key === a.key) throw new Error("duplicate asset key");
|
|
244
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
245
|
+
const row = { deletedAt: null, deletedBy: null, ...structuredClone(a), createdAt: a.createdAt ?? now, updatedAt: a.updatedAt ?? now };
|
|
246
|
+
this.assets.set(row.id, row);
|
|
247
|
+
return structuredClone(row);
|
|
248
|
+
}
|
|
249
|
+
async findAsset(id, o = {}) {
|
|
250
|
+
const a = this.assets.get(id);
|
|
251
|
+
return a && (!a.deletedAt || o.trashed) ? structuredClone(a) : null;
|
|
252
|
+
}
|
|
253
|
+
async findAssets(ids) {
|
|
254
|
+
return ids.map((id) => this.assets.get(id)).filter((a) => !!a && !a.deletedAt).map((a) => structuredClone(a));
|
|
255
|
+
}
|
|
256
|
+
async findAssetByKey(store, key) {
|
|
257
|
+
for (const a of this.assets.values()) if (a.store === store && a.key === key) return structuredClone(a);
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
async findAssetsByKeys(store, keys) {
|
|
261
|
+
const want = new Set(keys);
|
|
262
|
+
return [...this.assets.values()].filter((a) => a.store === store && want.has(a.key)).map((a) => structuredClone(a));
|
|
263
|
+
}
|
|
264
|
+
async listAssets(q) {
|
|
265
|
+
const needle = q.q?.trim().toLowerCase();
|
|
266
|
+
return [...this.assets.values()].filter(
|
|
267
|
+
(a) => !!a.deletedAt === !!q.trashed && (!q.store || a.store === q.store) && (q.folder === void 0 || a.folder === q.folder) && (q.under === void 0 || inFolder(a.folder, q.under)) && (!q.kinds || q.kinds.includes(a.kind)) && (!q.notKinds || !q.notKinds.includes(a.kind)) && (!q.status || a.status === q.status) && (!q.tag || a.tags.includes(q.tag)) && (!q.createdBefore || a.createdAt < q.createdBefore) && (!needle || a.name.toLowerCase().includes(needle) || a.alt.toLowerCase().includes(needle) || a.tags.some((t) => t.toLowerCase().includes(needle))) && (!q.before || `${a.createdAt}|${a.id}` < q.before)
|
|
268
|
+
).sort((x, y) => `${y.createdAt}|${y.id}`.localeCompare(`${x.createdAt}|${x.id}`)).slice(0, q.limit ?? 1e3).map((a) => structuredClone(a));
|
|
269
|
+
}
|
|
270
|
+
async countAssets(store) {
|
|
271
|
+
const out = /* @__PURE__ */ new Map();
|
|
272
|
+
for (const a of this.assets.values()) {
|
|
273
|
+
if (a.status !== "ready" || a.deletedAt || store && a.store !== store) continue;
|
|
274
|
+
const k = `${a.store}|${a.folder}|${a.kind}`;
|
|
275
|
+
const cur = out.get(k) ?? { store: a.store, folder: a.folder, kind: a.kind, n: 0 };
|
|
276
|
+
cur.n++;
|
|
277
|
+
out.set(k, cur);
|
|
278
|
+
}
|
|
279
|
+
return [...out.values()];
|
|
280
|
+
}
|
|
281
|
+
async updateAsset(id, patch) {
|
|
282
|
+
const a = this.assets.get(id);
|
|
283
|
+
if (!a) return null;
|
|
284
|
+
if (patch.key !== void 0 && patch.key !== a.key) {
|
|
285
|
+
for (const o of this.assets.values()) if (o.id !== id && o.store === a.store && o.key === patch.key) throw new Error("duplicate asset key");
|
|
286
|
+
}
|
|
287
|
+
const clean = Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== void 0));
|
|
288
|
+
Object.assign(a, structuredClone(clean), { updatedAt: patch.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString() });
|
|
289
|
+
return structuredClone(a);
|
|
290
|
+
}
|
|
291
|
+
async deleteAsset(id) {
|
|
292
|
+
this.assets.delete(id);
|
|
293
|
+
this.assetRefs = this.assetRefs.filter((r) => r.assetId !== id);
|
|
294
|
+
}
|
|
295
|
+
async setAssetRefs(documentId, refs) {
|
|
296
|
+
this.assetRefs = this.assetRefs.filter((r) => r.documentId !== documentId);
|
|
297
|
+
const seen = /* @__PURE__ */ new Set();
|
|
298
|
+
for (const r of refs) {
|
|
299
|
+
if (seen.has(r.assetId) || !this.assets.has(r.assetId) || !r.inDraft && !r.inPublished) continue;
|
|
300
|
+
seen.add(r.assetId);
|
|
301
|
+
this.assetRefs.push({ assetId: r.assetId, documentId, inDraft: r.inDraft, inPublished: r.inPublished });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
async listAssetRefs(assetId2) {
|
|
305
|
+
return this.assetRefs.filter((r) => r.assetId === assetId2).map((r) => ({ ...r }));
|
|
306
|
+
}
|
|
307
|
+
async insertComment(c) {
|
|
308
|
+
const row = { ...structuredClone(c), id: this.id(), resolvedAt: null, resolvedBy: null };
|
|
309
|
+
this.comments.push(row);
|
|
310
|
+
return structuredClone(row);
|
|
311
|
+
}
|
|
312
|
+
async findComment(id) {
|
|
313
|
+
const c = this.comments.find((x) => x.id === id);
|
|
314
|
+
return c ? structuredClone(c) : null;
|
|
315
|
+
}
|
|
316
|
+
async listComments(documentId) {
|
|
317
|
+
return this.comments.filter((c) => c.documentId === documentId).sort((a, b) => a.createdAt.localeCompare(b.createdAt)).map((c) => structuredClone(c));
|
|
318
|
+
}
|
|
319
|
+
async updateComment(id, patch) {
|
|
320
|
+
const c = this.comments.find((x) => x.id === id);
|
|
321
|
+
if (!c) return null;
|
|
322
|
+
Object.assign(c, patch);
|
|
323
|
+
return structuredClone(c);
|
|
324
|
+
}
|
|
325
|
+
async countComments(documentIds) {
|
|
326
|
+
const out = /* @__PURE__ */ new Map();
|
|
327
|
+
for (const c of this.comments) if (!c.threadId && !c.resolvedAt && documentIds.includes(c.documentId)) out.set(c.documentId, (out.get(c.documentId) ?? 0) + 1);
|
|
328
|
+
return out;
|
|
329
|
+
}
|
|
330
|
+
async insertRelease(r) {
|
|
331
|
+
const row = { ...r, id: this.id(), state: "open", publishAt: null, items: [], updatedAt: r.createdAt, publishedAt: null, publishedBy: null, lastError: null };
|
|
332
|
+
this.releases.push(row);
|
|
333
|
+
return structuredClone(row);
|
|
334
|
+
}
|
|
335
|
+
async findRelease(id) {
|
|
336
|
+
const r = this.releases.find((x) => x.id === id);
|
|
337
|
+
return r ? structuredClone(r) : null;
|
|
338
|
+
}
|
|
339
|
+
async listReleases() {
|
|
340
|
+
return this.releases.map((r) => structuredClone(r)).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
341
|
+
}
|
|
342
|
+
async updateRelease(id, patch, expectedState) {
|
|
343
|
+
const r = this.releases.find((x) => x.id === id);
|
|
344
|
+
if (!r || expectedState && r.state !== expectedState) return null;
|
|
345
|
+
Object.assign(r, structuredClone(Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== void 0))));
|
|
346
|
+
return structuredClone(r);
|
|
347
|
+
}
|
|
348
|
+
async deleteRelease(id) {
|
|
349
|
+
this.releases = this.releases.filter((r) => r.id !== id);
|
|
350
|
+
}
|
|
351
|
+
async insertFilter(f) {
|
|
352
|
+
const row = { ...structuredClone(f), id: this.id() };
|
|
353
|
+
this.filters.push(row);
|
|
354
|
+
return structuredClone(row);
|
|
355
|
+
}
|
|
356
|
+
async findFilter(id) {
|
|
357
|
+
const f = this.filters.find((x) => x.id === id);
|
|
358
|
+
return f ? structuredClone(f) : null;
|
|
359
|
+
}
|
|
360
|
+
async listFilters(collection) {
|
|
361
|
+
return this.filters.filter((f) => f.collection === collection).sort((a, b) => a.name.localeCompare(b.name)).map((f) => structuredClone(f));
|
|
362
|
+
}
|
|
363
|
+
async deleteFilter(id) {
|
|
364
|
+
this.filters = this.filters.filter((f) => f.id !== id);
|
|
365
|
+
}
|
|
366
|
+
async touchPresence(p) {
|
|
367
|
+
this.presence = [...this.presence.filter((x) => !(x.documentId === p.documentId && x.actorId === p.actorId)), structuredClone(p)];
|
|
368
|
+
}
|
|
369
|
+
async listPresence(since, documentIds) {
|
|
370
|
+
return this.presence.filter((p) => p.seenAt >= since && (!documentIds || documentIds.includes(p.documentId))).map((p) => structuredClone(p));
|
|
371
|
+
}
|
|
372
|
+
async dropPresence(documentId, actorId) {
|
|
373
|
+
this.presence = this.presence.filter((x) => !(x.documentId === documentId && x.actorId === actorId));
|
|
374
|
+
}
|
|
375
|
+
async prunePresence(before) {
|
|
376
|
+
this.presence = this.presence.filter((p) => p.seenAt >= before);
|
|
377
|
+
}
|
|
197
378
|
async changeStamp() {
|
|
198
379
|
let max = "";
|
|
199
380
|
for (const d of this.docs.values()) if (d.updatedAt > max) max = d.updatedAt;
|
|
@@ -207,12 +388,14 @@ var MemoryRepo = class {
|
|
|
207
388
|
}
|
|
208
389
|
};
|
|
209
390
|
export {
|
|
391
|
+
ASSET_KINDS,
|
|
210
392
|
AUDIT_ACTIONS,
|
|
211
393
|
BULK_ACTIONS,
|
|
212
394
|
CMS_TOOLS,
|
|
213
395
|
CMS_TOOL_NAMES,
|
|
214
396
|
CmsError,
|
|
215
397
|
CmsRemoteError,
|
|
398
|
+
DEFAULT_ACCEPT,
|
|
216
399
|
DOC_STATUSES,
|
|
217
400
|
DrizzleRepo,
|
|
218
401
|
ENVELOPE_PREAMBLE,
|
|
@@ -221,19 +404,29 @@ export {
|
|
|
221
404
|
KEY_SCOPES,
|
|
222
405
|
LIMITS,
|
|
223
406
|
MemoryRepo,
|
|
407
|
+
MemoryStorage,
|
|
224
408
|
PREVIEW_TTLS,
|
|
225
409
|
SCHEMA_VERSION,
|
|
226
410
|
SLUG_RE,
|
|
227
411
|
VERSION,
|
|
228
412
|
VIAS,
|
|
229
413
|
applyPatch,
|
|
414
|
+
assetFields,
|
|
415
|
+
assetId,
|
|
416
|
+
callTool,
|
|
230
417
|
citationId,
|
|
231
418
|
cmsApiKeys,
|
|
419
|
+
cmsAssetRefs,
|
|
420
|
+
cmsAssets,
|
|
232
421
|
cmsAudit,
|
|
422
|
+
cmsComments,
|
|
233
423
|
cmsDdl,
|
|
234
424
|
cmsDocuments,
|
|
235
425
|
cmsHits,
|
|
236
426
|
cmsMeta,
|
|
427
|
+
cmsPresence,
|
|
428
|
+
cmsReleases,
|
|
429
|
+
cmsSavedFilters,
|
|
237
430
|
cmsTables,
|
|
238
431
|
cmsVersions,
|
|
239
432
|
coreOf,
|
|
@@ -248,15 +441,18 @@ export {
|
|
|
248
441
|
docState,
|
|
249
442
|
envelope,
|
|
250
443
|
formatMessage,
|
|
444
|
+
humanSize,
|
|
251
445
|
isCmsError,
|
|
252
446
|
isCmsRemoteError,
|
|
253
447
|
lookupForAgent,
|
|
254
448
|
mergePatch,
|
|
255
449
|
normalizeQuery,
|
|
256
450
|
parseFrontmatter,
|
|
451
|
+
runTool,
|
|
257
452
|
schemaVersionSql,
|
|
258
453
|
sectionRanges,
|
|
259
454
|
splitSql,
|
|
455
|
+
toolErrorResult,
|
|
260
456
|
toolsFor,
|
|
261
457
|
upgradeSteps,
|
|
262
458
|
verifyCitations
|