@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
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { AssetKind } from './types.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import './errors.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Where files live. The CMS keeps a row per file (`cms_assets`) and talks to
|
|
7
|
+
* the bucket through a `StorageAdapter`; `./storage-s3` is the adapter for
|
|
8
|
+
* S3-compatible storage. Files go from the browser straight to the storage
|
|
9
|
+
* with signed URLs, so the app server never carries their bytes.
|
|
10
|
+
*
|
|
11
|
+
* This file also holds the rules about names and file types, which are the
|
|
12
|
+
* same for every adapter.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface StoredObject {
|
|
16
|
+
key: string;
|
|
17
|
+
size: number;
|
|
18
|
+
mime: string | null;
|
|
19
|
+
etag: string | null;
|
|
20
|
+
lastModified: string | null;
|
|
21
|
+
}
|
|
22
|
+
interface PutOptions {
|
|
23
|
+
mime: string;
|
|
24
|
+
/** `Content-Disposition` to store with the object (e.g. `attachment; filename="a.zip"`). */
|
|
25
|
+
disposition?: string | null;
|
|
26
|
+
cacheControl?: string | null;
|
|
27
|
+
}
|
|
28
|
+
interface SignedRequest {
|
|
29
|
+
url: string;
|
|
30
|
+
/** Headers the uploader must send with the request, exactly. */
|
|
31
|
+
headers: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
interface StoragePart {
|
|
34
|
+
partNumber: number;
|
|
35
|
+
etag: string;
|
|
36
|
+
size: number;
|
|
37
|
+
}
|
|
38
|
+
interface StorageList {
|
|
39
|
+
objects: StoredObject[];
|
|
40
|
+
/** Sub-folders (with a trailing slash) when a delimiter was given. */
|
|
41
|
+
prefixes: string[];
|
|
42
|
+
cursor: string | null;
|
|
43
|
+
}
|
|
44
|
+
interface StorageAdapter {
|
|
45
|
+
/** A URL the browser can PUT the whole file to. */
|
|
46
|
+
presignPut(key: string, o: PutOptions & {
|
|
47
|
+
expires: number;
|
|
48
|
+
}): Promise<SignedRequest>;
|
|
49
|
+
/** Server-side upload (small files: thumbnails, imports, folder markers). */
|
|
50
|
+
put(key: string, body: Uint8Array, o: PutOptions): Promise<void>;
|
|
51
|
+
createMultipart(key: string, o: PutOptions): Promise<string>;
|
|
52
|
+
presignPart(key: string, uploadId: string, partNumber: number, expires: number): Promise<string>;
|
|
53
|
+
listParts(key: string, uploadId: string): Promise<StoragePart[]>;
|
|
54
|
+
completeMultipart(key: string, uploadId: string, parts: readonly Pick<StoragePart, "partNumber" | "etag">[]): Promise<void>;
|
|
55
|
+
abortMultipart(key: string, uploadId: string): Promise<void>;
|
|
56
|
+
head(key: string): Promise<StoredObject | null>;
|
|
57
|
+
/** The first `bytes` bytes of the object (to check what it really is). */
|
|
58
|
+
readStart(key: string, bytes: number): Promise<Uint8Array | null>;
|
|
59
|
+
/** A short-lived URL to read the object. `download`: file name to save as. */
|
|
60
|
+
presignGet(key: string, o: {
|
|
61
|
+
expires: number;
|
|
62
|
+
download?: string | null;
|
|
63
|
+
}): Promise<string>;
|
|
64
|
+
/** The object's public address, when the bucket is public. */
|
|
65
|
+
publicUrl(key: string): string | null;
|
|
66
|
+
copy(from: string, to: string): Promise<void>;
|
|
67
|
+
delete(key: string): Promise<void>;
|
|
68
|
+
list(o: {
|
|
69
|
+
prefix?: string;
|
|
70
|
+
delimiter?: string;
|
|
71
|
+
cursor?: string | null;
|
|
72
|
+
limit?: number;
|
|
73
|
+
}): Promise<StorageList>;
|
|
74
|
+
}
|
|
75
|
+
/** Extension → MIME type for the types the CMS knows. */
|
|
76
|
+
declare const MIME_BY_EXT: Readonly<Record<string, string>>;
|
|
77
|
+
/**
|
|
78
|
+
* What a store takes when nothing is configured: images, video, sound, PDF,
|
|
79
|
+
* office documents, plain text and ZIP. HTML and programs are not in it; a
|
|
80
|
+
* developer who wants them lists them in `media.accept`.
|
|
81
|
+
*/
|
|
82
|
+
declare const DEFAULT_ACCEPT: readonly string[];
|
|
83
|
+
declare const DEFAULT_MAX_FILE_SIZE: number;
|
|
84
|
+
/** Files up to this size go up in one request; larger ones in parts of this size. */
|
|
85
|
+
declare const PART_SIZE: number;
|
|
86
|
+
declare const THUMB_PREFIX = "_cms/thumbs/";
|
|
87
|
+
declare const RESERVED_FOLDER = "_cms";
|
|
88
|
+
declare const extOf: (name: string) => string;
|
|
89
|
+
/** The MIME type to store: the extension decides when it is a known one. */
|
|
90
|
+
declare function mimeOf(name: string, declared?: string | null): string;
|
|
91
|
+
/** False when the browser's declared type is a different kind of file than the extension says. */
|
|
92
|
+
declare function declaredMatches(name: string, declared?: string | null): boolean;
|
|
93
|
+
/** Does `rules` (MIME types, groups such as `image/*`, extensions such as `.pdf`, or the wildcard) take this file? */
|
|
94
|
+
declare function acceptsFile(rules: readonly string[], file: {
|
|
95
|
+
name: string;
|
|
96
|
+
mime: string;
|
|
97
|
+
}): boolean;
|
|
98
|
+
declare function kindOf(mime: string): Exclude<AssetKind, "folder">;
|
|
99
|
+
/** Shown in the page (image, video, sound, PDF) or saved as a download (everything else). */
|
|
100
|
+
declare const servedInline: (mime: string) => boolean;
|
|
101
|
+
declare function dispositionFor(name: string, mime: string, forceDownload?: boolean): string | null;
|
|
102
|
+
type Family = "jpeg" | "png" | "gif" | "webp" | "iso" | "webm" | "pdf" | "zip" | "mp3" | "wav" | "ogg" | "program" | "html" | "svg" | "text";
|
|
103
|
+
/** What the first bytes of a file say it is (`null`: an unknown binary format). */
|
|
104
|
+
declare function sniff(b: Uint8Array): Family | null;
|
|
105
|
+
/** True when the file's first bytes fit the type it was stored as. */
|
|
106
|
+
declare function contentMatches(mime: string, start: Uint8Array): boolean;
|
|
107
|
+
/** A safe file name: keeps Korean and spaces, drops control characters, slashes and leading dots; 200 characters at most. */
|
|
108
|
+
declare function cleanName(name: string): string;
|
|
109
|
+
/** A safe folder path ("" = top level): no empty, `.` or `..` parts, nothing under `_cms`. `null` when it is not allowed. */
|
|
110
|
+
declare function cleanFolder(folder: string | null | undefined): string | null;
|
|
111
|
+
declare const joinKey: (folder: string, name: string) => string;
|
|
112
|
+
/** `name`, `name-2`, `name-3`… before the extension. */
|
|
113
|
+
declare function numberedName(name: string, n: number): string;
|
|
114
|
+
/** 12 lowercase letters and digits. */
|
|
115
|
+
declare function newAssetId(): string;
|
|
116
|
+
declare const ASSET_ID_RE: RegExp;
|
|
117
|
+
interface MemObject {
|
|
118
|
+
body: Uint8Array;
|
|
119
|
+
mime: string;
|
|
120
|
+
disposition: string | null;
|
|
121
|
+
at: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A storage that lives in memory. Signed URLs look like
|
|
125
|
+
* `memory://<name>/<key>?…`; `send(url, body)` plays the browser's part.
|
|
126
|
+
*/
|
|
127
|
+
declare class MemoryStorage implements StorageAdapter {
|
|
128
|
+
private o;
|
|
129
|
+
objects: Map<string, MemObject>;
|
|
130
|
+
uploads: Map<string, {
|
|
131
|
+
key: string;
|
|
132
|
+
o: PutOptions;
|
|
133
|
+
parts: Map<number, Uint8Array>;
|
|
134
|
+
}>;
|
|
135
|
+
private pending;
|
|
136
|
+
private n;
|
|
137
|
+
constructor(o?: {
|
|
138
|
+
name?: string;
|
|
139
|
+
publicUrl?: string | null;
|
|
140
|
+
});
|
|
141
|
+
private base;
|
|
142
|
+
private store;
|
|
143
|
+
private meta;
|
|
144
|
+
/** What a browser does with a signed PUT URL. Returns the HTTP status. */
|
|
145
|
+
send(url: string, body: Uint8Array): Promise<number>;
|
|
146
|
+
presignPut(key: string, o: PutOptions & {
|
|
147
|
+
expires: number;
|
|
148
|
+
}): Promise<{
|
|
149
|
+
url: string;
|
|
150
|
+
headers: Record<string, string>;
|
|
151
|
+
}>;
|
|
152
|
+
put(key: string, body: Uint8Array, o: PutOptions): Promise<void>;
|
|
153
|
+
createMultipart(key: string, o: PutOptions): Promise<string>;
|
|
154
|
+
presignPart(key: string, uploadId: string, partNumber: number): Promise<string>;
|
|
155
|
+
listParts(_key: string, uploadId: string): Promise<{
|
|
156
|
+
partNumber: number;
|
|
157
|
+
etag: string;
|
|
158
|
+
size: number;
|
|
159
|
+
}[]>;
|
|
160
|
+
completeMultipart(key: string, uploadId: string, parts: readonly Pick<StoragePart, "partNumber">[]): Promise<void>;
|
|
161
|
+
abortMultipart(_key: string, uploadId: string): Promise<void>;
|
|
162
|
+
head(key: string): Promise<StoredObject | null>;
|
|
163
|
+
readStart(key: string, bytes: number): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
164
|
+
presignGet(key: string, o: {
|
|
165
|
+
expires: number;
|
|
166
|
+
download?: string | null;
|
|
167
|
+
}): Promise<string>;
|
|
168
|
+
publicUrl(key: string): string | null;
|
|
169
|
+
copy(from: string, to: string): Promise<void>;
|
|
170
|
+
delete(key: string): Promise<void>;
|
|
171
|
+
list(o?: {
|
|
172
|
+
prefix?: string;
|
|
173
|
+
delimiter?: string;
|
|
174
|
+
cursor?: string | null;
|
|
175
|
+
limit?: number;
|
|
176
|
+
}): Promise<{
|
|
177
|
+
objects: StoredObject[];
|
|
178
|
+
prefixes: string[];
|
|
179
|
+
cursor: string | null;
|
|
180
|
+
}>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { ASSET_ID_RE, DEFAULT_ACCEPT, DEFAULT_MAX_FILE_SIZE, MIME_BY_EXT, MemoryStorage, PART_SIZE, type PutOptions, RESERVED_FOLDER, type SignedRequest, type StorageAdapter, type StorageList, type StoragePart, type StoredObject, THUMB_PREFIX, acceptsFile, cleanFolder, cleanName, contentMatches, declaredMatches, dispositionFor, extOf, joinKey, kindOf, mimeOf, newAssetId, numberedName, servedInline, sniff };
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ASSET_ID_RE,
|
|
3
|
+
DEFAULT_ACCEPT,
|
|
4
|
+
DEFAULT_MAX_FILE_SIZE,
|
|
5
|
+
MIME_BY_EXT,
|
|
6
|
+
MemoryStorage,
|
|
7
|
+
PART_SIZE,
|
|
8
|
+
RESERVED_FOLDER,
|
|
9
|
+
THUMB_PREFIX,
|
|
10
|
+
acceptsFile,
|
|
11
|
+
cleanFolder,
|
|
12
|
+
cleanName,
|
|
13
|
+
contentMatches,
|
|
14
|
+
declaredMatches,
|
|
15
|
+
dispositionFor,
|
|
16
|
+
extOf,
|
|
17
|
+
joinKey,
|
|
18
|
+
kindOf,
|
|
19
|
+
mimeOf,
|
|
20
|
+
newAssetId,
|
|
21
|
+
numberedName,
|
|
22
|
+
servedInline,
|
|
23
|
+
sniff
|
|
24
|
+
} from "./chunk-6PB4ZCHH.js";
|
|
25
|
+
import "./chunk-2NTK7H4W.js";
|
|
26
|
+
export {
|
|
27
|
+
ASSET_ID_RE,
|
|
28
|
+
DEFAULT_ACCEPT,
|
|
29
|
+
DEFAULT_MAX_FILE_SIZE,
|
|
30
|
+
MIME_BY_EXT,
|
|
31
|
+
MemoryStorage,
|
|
32
|
+
PART_SIZE,
|
|
33
|
+
RESERVED_FOLDER,
|
|
34
|
+
THUMB_PREFIX,
|
|
35
|
+
acceptsFile,
|
|
36
|
+
cleanFolder,
|
|
37
|
+
cleanName,
|
|
38
|
+
contentMatches,
|
|
39
|
+
declaredMatches,
|
|
40
|
+
dispositionFor,
|
|
41
|
+
extOf,
|
|
42
|
+
joinKey,
|
|
43
|
+
kindOf,
|
|
44
|
+
mimeOf,
|
|
45
|
+
newAssetId,
|
|
46
|
+
numberedName,
|
|
47
|
+
servedInline,
|
|
48
|
+
sniff
|
|
49
|
+
};
|
package/dist/tables.cjs
CHANGED
|
@@ -23,11 +23,17 @@ __export(tables_exports, {
|
|
|
23
23
|
LEGACY_COLUMNS: () => LEGACY_COLUMNS,
|
|
24
24
|
SCHEMA_VERSION: () => SCHEMA_VERSION,
|
|
25
25
|
cmsApiKeys: () => cmsApiKeys,
|
|
26
|
+
cmsAssetRefs: () => cmsAssetRefs,
|
|
27
|
+
cmsAssets: () => cmsAssets,
|
|
26
28
|
cmsAudit: () => cmsAudit,
|
|
29
|
+
cmsComments: () => cmsComments,
|
|
27
30
|
cmsDdl: () => cmsDdl,
|
|
28
31
|
cmsDocuments: () => cmsDocuments,
|
|
29
32
|
cmsHits: () => cmsHits,
|
|
30
33
|
cmsMeta: () => cmsMeta,
|
|
34
|
+
cmsPresence: () => cmsPresence,
|
|
35
|
+
cmsReleases: () => cmsReleases,
|
|
36
|
+
cmsSavedFilters: () => cmsSavedFilters,
|
|
31
37
|
cmsTables: () => cmsTables,
|
|
32
38
|
cmsVersions: () => cmsVersions,
|
|
33
39
|
defaultTables: () => defaultTables,
|
|
@@ -39,7 +45,7 @@ module.exports = __toCommonJS(tables_exports);
|
|
|
39
45
|
var import_pg_core = require("drizzle-orm/pg-core");
|
|
40
46
|
|
|
41
47
|
// src/schema-version.ts
|
|
42
|
-
var SCHEMA_VERSION =
|
|
48
|
+
var SCHEMA_VERSION = 4;
|
|
43
49
|
|
|
44
50
|
// src/tables.ts
|
|
45
51
|
var NAME_RE = /^[a-z_][a-z0-9_]*$/;
|
|
@@ -67,18 +73,26 @@ function cmsTables(o = {}) {
|
|
|
67
73
|
published: (0, import_pg_core.jsonb)("published").$type(),
|
|
68
74
|
updatedBy: (0, import_pg_core.text)("updated_by"),
|
|
69
75
|
updatedByKind: (0, import_pg_core.text)("updated_by_kind"),
|
|
76
|
+
/** Name of the agent that acted for `updatedBy` (a person), when one did. */
|
|
77
|
+
updatedByAgent: (0, import_pg_core.text)("updated_by_agent"),
|
|
70
78
|
publishedAt: (0, import_pg_core.timestamp)("published_at", { withTimezone: true }),
|
|
71
79
|
republishedAt: (0, import_pg_core.timestamp)("republished_at", { withTimezone: true }),
|
|
72
80
|
autosave: (0, import_pg_core.jsonb)("autosave").$type(),
|
|
73
81
|
autosaveAt: (0, import_pg_core.timestamp)("autosave_at", { withTimezone: true }),
|
|
74
82
|
autosaveBy: (0, import_pg_core.text)("autosave_by"),
|
|
75
83
|
autosaveBaseVersion: (0, import_pg_core.integer)("autosave_base_version"),
|
|
84
|
+
deletedAt: (0, import_pg_core.timestamp)("deleted_at", { withTimezone: true }),
|
|
85
|
+
deletedBy: (0, import_pg_core.text)("deleted_by"),
|
|
86
|
+
schedule: (0, import_pg_core.jsonb)("schedule").$type(),
|
|
87
|
+
dueAt: (0, import_pg_core.timestamp)("due_at", { withTimezone: true }),
|
|
88
|
+
review: (0, import_pg_core.jsonb)("review").$type(),
|
|
76
89
|
createdAt: (0, import_pg_core.timestamp)("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
77
90
|
updatedAt: (0, import_pg_core.timestamp)("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
78
91
|
},
|
|
79
92
|
(t) => ({
|
|
80
93
|
slugIdx: (0, import_pg_core.uniqueIndex)(n("documents_collection_slug_idx")).on(t.collection, t.slug),
|
|
81
|
-
statusIdx: (0, import_pg_core.index)(n("documents_collection_status_idx")).on(t.collection, t.status)
|
|
94
|
+
statusIdx: (0, import_pg_core.index)(n("documents_collection_status_idx")).on(t.collection, t.status),
|
|
95
|
+
dueIdx: (0, import_pg_core.index)(n("documents_due_idx")).on(t.dueAt)
|
|
82
96
|
})
|
|
83
97
|
);
|
|
84
98
|
const versions = table(
|
|
@@ -91,9 +105,14 @@ function cmsTables(o = {}) {
|
|
|
91
105
|
authorKind: (0, import_pg_core.text)("author_kind").notNull(),
|
|
92
106
|
authorId: (0, import_pg_core.text)("author_id"),
|
|
93
107
|
authorLabel: (0, import_pg_core.text)("author_label").notNull(),
|
|
108
|
+
authorAgent: (0, import_pg_core.text)("author_agent"),
|
|
94
109
|
note: (0, import_pg_core.text)("note"),
|
|
95
110
|
changed: (0, import_pg_core.jsonb)("changed").$type(),
|
|
96
111
|
reviewed: (0, import_pg_core.jsonb)("reviewed").$type().notNull().default([]),
|
|
112
|
+
label: (0, import_pg_core.text)("label"),
|
|
113
|
+
pinned: (0, import_pg_core.boolean)("pinned").notNull().default(false),
|
|
114
|
+
approvedBy: (0, import_pg_core.text)("approved_by"),
|
|
115
|
+
approvedAt: (0, import_pg_core.timestamp)("approved_at", { withTimezone: true }),
|
|
97
116
|
createdAt: (0, import_pg_core.timestamp)("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
98
117
|
},
|
|
99
118
|
(t) => ({
|
|
@@ -136,6 +155,7 @@ function cmsTables(o = {}) {
|
|
|
136
155
|
actorKind: (0, import_pg_core.text)("actor_kind").notNull(),
|
|
137
156
|
actorId: (0, import_pg_core.text)("actor_id"),
|
|
138
157
|
actorLabel: (0, import_pg_core.text)("actor_label").notNull(),
|
|
158
|
+
actorAgent: (0, import_pg_core.text)("actor_agent"),
|
|
139
159
|
action: (0, import_pg_core.text)("action").notNull(),
|
|
140
160
|
collection: (0, import_pg_core.text)("collection"),
|
|
141
161
|
slug: (0, import_pg_core.text)("slug"),
|
|
@@ -146,7 +166,111 @@ function cmsTables(o = {}) {
|
|
|
146
166
|
},
|
|
147
167
|
(t) => ({ atIdx: (0, import_pg_core.index)(n("audit_at_idx")).on(t.at), actionIdx: (0, import_pg_core.index)(n("audit_action_idx")).on(t.action, t.at) })
|
|
148
168
|
);
|
|
149
|
-
|
|
169
|
+
const assets = table(
|
|
170
|
+
n("assets"),
|
|
171
|
+
{
|
|
172
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
173
|
+
store: (0, import_pg_core.text)("store").notNull(),
|
|
174
|
+
key: (0, import_pg_core.text)("key").notNull(),
|
|
175
|
+
folder: (0, import_pg_core.text)("folder").notNull().default(""),
|
|
176
|
+
name: (0, import_pg_core.text)("name").notNull(),
|
|
177
|
+
kind: (0, import_pg_core.text)("kind").notNull(),
|
|
178
|
+
mime: (0, import_pg_core.text)("mime").notNull().default("application/octet-stream"),
|
|
179
|
+
size: (0, import_pg_core.bigint)("size", { mode: "number" }).notNull().default(0),
|
|
180
|
+
width: (0, import_pg_core.integer)("width"),
|
|
181
|
+
height: (0, import_pg_core.integer)("height"),
|
|
182
|
+
duration: (0, import_pg_core.real)("duration"),
|
|
183
|
+
alt: (0, import_pg_core.text)("alt").notNull().default(""),
|
|
184
|
+
tags: (0, import_pg_core.jsonb)("tags").$type().notNull().default([]),
|
|
185
|
+
thumbKey: (0, import_pg_core.text)("thumb_key"),
|
|
186
|
+
status: (0, import_pg_core.text)("status").notNull().default("pending"),
|
|
187
|
+
uploadId: (0, import_pg_core.text)("upload_id"),
|
|
188
|
+
createdBy: (0, import_pg_core.text)("created_by"),
|
|
189
|
+
createdByKind: (0, import_pg_core.text)("created_by_kind"),
|
|
190
|
+
createdByAgent: (0, import_pg_core.text)("created_by_agent"),
|
|
191
|
+
createdAt: (0, import_pg_core.timestamp)("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
192
|
+
updatedAt: (0, import_pg_core.timestamp)("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
193
|
+
deletedAt: (0, import_pg_core.timestamp)("deleted_at", { withTimezone: true }),
|
|
194
|
+
deletedBy: (0, import_pg_core.text)("deleted_by")
|
|
195
|
+
},
|
|
196
|
+
(t) => ({
|
|
197
|
+
keyIdx: (0, import_pg_core.uniqueIndex)(n("assets_store_key_idx")).on(t.store, t.key),
|
|
198
|
+
folderIdx: (0, import_pg_core.index)(n("assets_store_folder_idx")).on(t.store, t.folder),
|
|
199
|
+
statusIdx: (0, import_pg_core.index)(n("assets_status_idx")).on(t.status, t.createdAt)
|
|
200
|
+
})
|
|
201
|
+
);
|
|
202
|
+
const assetRefs = table(
|
|
203
|
+
n("asset_refs"),
|
|
204
|
+
{
|
|
205
|
+
assetId: (0, import_pg_core.text)("asset_id").notNull().references(() => assets.id, { onDelete: "cascade" }),
|
|
206
|
+
documentId: (0, import_pg_core.uuid)("document_id").notNull().references(() => documents.id, { onDelete: "cascade" }),
|
|
207
|
+
inDraft: (0, import_pg_core.boolean)("in_draft").notNull().default(false),
|
|
208
|
+
inPublished: (0, import_pg_core.boolean)("in_published").notNull().default(false)
|
|
209
|
+
},
|
|
210
|
+
(t) => ({ pk: (0, import_pg_core.primaryKey)({ columns: [t.assetId, t.documentId] }), docIdx: (0, import_pg_core.index)(n("asset_refs_document_idx")).on(t.documentId) })
|
|
211
|
+
);
|
|
212
|
+
const comments = table(
|
|
213
|
+
n("comments"),
|
|
214
|
+
{
|
|
215
|
+
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
216
|
+
documentId: (0, import_pg_core.uuid)("document_id").notNull().references(() => documents.id, { onDelete: "cascade" }),
|
|
217
|
+
threadId: (0, import_pg_core.uuid)("thread_id"),
|
|
218
|
+
anchor: (0, import_pg_core.text)("anchor").notNull().default(""),
|
|
219
|
+
quote: (0, import_pg_core.text)("quote").notNull().default(""),
|
|
220
|
+
body: (0, import_pg_core.text)("body").notNull(),
|
|
221
|
+
authorKind: (0, import_pg_core.text)("author_kind").notNull(),
|
|
222
|
+
authorId: (0, import_pg_core.text)("author_id"),
|
|
223
|
+
authorLabel: (0, import_pg_core.text)("author_label").notNull(),
|
|
224
|
+
authorAgent: (0, import_pg_core.text)("author_agent"),
|
|
225
|
+
createdAt: (0, import_pg_core.timestamp)("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
226
|
+
resolvedAt: (0, import_pg_core.timestamp)("resolved_at", { withTimezone: true }),
|
|
227
|
+
resolvedBy: (0, import_pg_core.text)("resolved_by")
|
|
228
|
+
},
|
|
229
|
+
(t) => ({ docIdx: (0, import_pg_core.index)(n("comments_document_idx")).on(t.documentId, t.createdAt) })
|
|
230
|
+
);
|
|
231
|
+
const releases = table(n("releases"), {
|
|
232
|
+
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
233
|
+
name: (0, import_pg_core.text)("name").notNull(),
|
|
234
|
+
state: (0, import_pg_core.text)("state").notNull().default("open"),
|
|
235
|
+
publishAt: (0, import_pg_core.timestamp)("publish_at", { withTimezone: true }),
|
|
236
|
+
items: (0, import_pg_core.jsonb)("items").$type().notNull().default([]),
|
|
237
|
+
createdBy: (0, import_pg_core.text)("created_by").notNull(),
|
|
238
|
+
createdById: (0, import_pg_core.text)("created_by_id"),
|
|
239
|
+
createdAt: (0, import_pg_core.timestamp)("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
240
|
+
updatedAt: (0, import_pg_core.timestamp)("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
241
|
+
publishedAt: (0, import_pg_core.timestamp)("published_at", { withTimezone: true }),
|
|
242
|
+
publishedBy: (0, import_pg_core.text)("published_by"),
|
|
243
|
+
lastError: (0, import_pg_core.text)("last_error")
|
|
244
|
+
});
|
|
245
|
+
const savedFilters = table(
|
|
246
|
+
n("saved_filters"),
|
|
247
|
+
{
|
|
248
|
+
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
249
|
+
collection: (0, import_pg_core.text)("collection").notNull(),
|
|
250
|
+
name: (0, import_pg_core.text)("name").notNull(),
|
|
251
|
+
query: (0, import_pg_core.jsonb)("query").$type().notNull().default({}),
|
|
252
|
+
ownerId: (0, import_pg_core.text)("owner_id").notNull(),
|
|
253
|
+
ownerLabel: (0, import_pg_core.text)("owner_label").notNull().default(""),
|
|
254
|
+
shared: (0, import_pg_core.boolean)("shared").notNull().default(false),
|
|
255
|
+
createdAt: (0, import_pg_core.timestamp)("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
256
|
+
},
|
|
257
|
+
(t) => ({ colIdx: (0, import_pg_core.index)(n("saved_filters_collection_idx")).on(t.collection) })
|
|
258
|
+
);
|
|
259
|
+
const presence = table(
|
|
260
|
+
n("presence"),
|
|
261
|
+
{
|
|
262
|
+
documentId: (0, import_pg_core.uuid)("document_id").notNull().references(() => documents.id, { onDelete: "cascade" }),
|
|
263
|
+
actorId: (0, import_pg_core.text)("actor_id").notNull(),
|
|
264
|
+
label: (0, import_pg_core.text)("label").notNull(),
|
|
265
|
+
kind: (0, import_pg_core.text)("kind").notNull(),
|
|
266
|
+
agent: (0, import_pg_core.text)("agent"),
|
|
267
|
+
cursor: (0, import_pg_core.jsonb)("cursor").$type(),
|
|
268
|
+
selection: (0, import_pg_core.jsonb)("selection").$type(),
|
|
269
|
+
seenAt: (0, import_pg_core.timestamp)("seen_at", { withTimezone: true }).notNull().defaultNow()
|
|
270
|
+
},
|
|
271
|
+
(t) => ({ pk: (0, import_pg_core.primaryKey)({ columns: [t.documentId, t.actorId] }), seenIdx: (0, import_pg_core.index)(n("presence_seen_idx")).on(t.seenAt) })
|
|
272
|
+
);
|
|
273
|
+
return { documents, versions, apiKeys, hits, meta, audit, assets, assetRefs, comments, releases, savedFilters, presence, options: { prefix, schema: o.schema ?? null } };
|
|
150
274
|
}
|
|
151
275
|
var defaultTables = cmsTables();
|
|
152
276
|
var cmsDocuments = defaultTables.documents;
|
|
@@ -155,6 +279,12 @@ var cmsApiKeys = defaultTables.apiKeys;
|
|
|
155
279
|
var cmsHits = defaultTables.hits;
|
|
156
280
|
var cmsMeta = defaultTables.meta;
|
|
157
281
|
var cmsAudit = defaultTables.audit;
|
|
282
|
+
var cmsAssets = defaultTables.assets;
|
|
283
|
+
var cmsAssetRefs = defaultTables.assetRefs;
|
|
284
|
+
var cmsComments = defaultTables.comments;
|
|
285
|
+
var cmsReleases = defaultTables.releases;
|
|
286
|
+
var cmsSavedFilters = defaultTables.savedFilters;
|
|
287
|
+
var cmsPresence = defaultTables.presence;
|
|
158
288
|
function names(t) {
|
|
159
289
|
const o = t && "options" in t ? t.options : t ?? {};
|
|
160
290
|
const prefix = o.prefix ?? "cms_";
|
|
@@ -206,6 +336,118 @@ CREATE TABLE IF NOT EXISTS ${tbl("audit")} (
|
|
|
206
336
|
);
|
|
207
337
|
CREATE INDEX IF NOT EXISTS ${idx("audit_at_idx")} ON ${tbl("audit")} ("at");
|
|
208
338
|
CREATE INDEX IF NOT EXISTS ${idx("audit_action_idx")} ON ${tbl("audit")} ("action", "at");`.trim()
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
version: 3,
|
|
342
|
+
name: "agent-cms 0.8.0: media files and their uses, agents acting for a person",
|
|
343
|
+
sql: `
|
|
344
|
+
ALTER TABLE ${tbl("documents")} ADD COLUMN IF NOT EXISTS "updated_by_agent" text;
|
|
345
|
+
ALTER TABLE ${tbl("versions")} ADD COLUMN IF NOT EXISTS "author_agent" text;
|
|
346
|
+
ALTER TABLE ${tbl("audit")} ADD COLUMN IF NOT EXISTS "actor_agent" text;
|
|
347
|
+
CREATE TABLE IF NOT EXISTS ${tbl("assets")} (
|
|
348
|
+
"id" text PRIMARY KEY,
|
|
349
|
+
"store" text NOT NULL,
|
|
350
|
+
"key" text NOT NULL,
|
|
351
|
+
"folder" text NOT NULL DEFAULT '',
|
|
352
|
+
"name" text NOT NULL,
|
|
353
|
+
"kind" text NOT NULL,
|
|
354
|
+
"mime" text NOT NULL DEFAULT 'application/octet-stream',
|
|
355
|
+
"size" bigint NOT NULL DEFAULT 0,
|
|
356
|
+
"width" integer,
|
|
357
|
+
"height" integer,
|
|
358
|
+
"duration" real,
|
|
359
|
+
"alt" text NOT NULL DEFAULT '',
|
|
360
|
+
"tags" jsonb NOT NULL DEFAULT '[]'::jsonb,
|
|
361
|
+
"thumb_key" text,
|
|
362
|
+
"status" text NOT NULL DEFAULT 'pending',
|
|
363
|
+
"upload_id" text,
|
|
364
|
+
"created_by" text,
|
|
365
|
+
"created_by_kind" text,
|
|
366
|
+
"created_by_agent" text,
|
|
367
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
368
|
+
"updated_at" timestamptz NOT NULL DEFAULT now()
|
|
369
|
+
);
|
|
370
|
+
CREATE UNIQUE INDEX IF NOT EXISTS ${idx("assets_store_key_idx")} ON ${tbl("assets")} ("store", "key");
|
|
371
|
+
CREATE INDEX IF NOT EXISTS ${idx("assets_store_folder_idx")} ON ${tbl("assets")} ("store", "folder");
|
|
372
|
+
CREATE INDEX IF NOT EXISTS ${idx("assets_status_idx")} ON ${tbl("assets")} ("status", "created_at");
|
|
373
|
+
CREATE TABLE IF NOT EXISTS ${tbl("asset_refs")} (
|
|
374
|
+
"asset_id" text NOT NULL REFERENCES ${tbl("assets")}("id") ON DELETE CASCADE,
|
|
375
|
+
"document_id" uuid NOT NULL REFERENCES ${tbl("documents")}("id") ON DELETE CASCADE,
|
|
376
|
+
"in_draft" boolean NOT NULL DEFAULT false,
|
|
377
|
+
"in_published" boolean NOT NULL DEFAULT false,
|
|
378
|
+
PRIMARY KEY ("asset_id", "document_id")
|
|
379
|
+
);
|
|
380
|
+
CREATE INDEX IF NOT EXISTS ${idx("asset_refs_document_idx")} ON ${tbl("asset_refs")} ("document_id");`.trim()
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
version: 4,
|
|
384
|
+
name: "agent-cms 0.10.0: schedules, trash, reviews, version labels, comments, releases, saved filters, presence",
|
|
385
|
+
sql: `
|
|
386
|
+
ALTER TABLE ${tbl("documents")} ADD COLUMN IF NOT EXISTS "deleted_at" timestamptz;
|
|
387
|
+
ALTER TABLE ${tbl("documents")} ADD COLUMN IF NOT EXISTS "deleted_by" text;
|
|
388
|
+
ALTER TABLE ${tbl("documents")} ADD COLUMN IF NOT EXISTS "schedule" jsonb;
|
|
389
|
+
ALTER TABLE ${tbl("documents")} ADD COLUMN IF NOT EXISTS "due_at" timestamptz;
|
|
390
|
+
ALTER TABLE ${tbl("documents")} ADD COLUMN IF NOT EXISTS "review" jsonb;
|
|
391
|
+
CREATE INDEX IF NOT EXISTS ${idx("documents_due_idx")} ON ${tbl("documents")} ("due_at");
|
|
392
|
+
ALTER TABLE ${tbl("versions")} ADD COLUMN IF NOT EXISTS "label" text;
|
|
393
|
+
ALTER TABLE ${tbl("versions")} ADD COLUMN IF NOT EXISTS "pinned" boolean NOT NULL DEFAULT false;
|
|
394
|
+
ALTER TABLE ${tbl("versions")} ADD COLUMN IF NOT EXISTS "approved_by" text;
|
|
395
|
+
ALTER TABLE ${tbl("versions")} ADD COLUMN IF NOT EXISTS "approved_at" timestamptz;
|
|
396
|
+
ALTER TABLE ${tbl("assets")} ADD COLUMN IF NOT EXISTS "deleted_at" timestamptz;
|
|
397
|
+
ALTER TABLE ${tbl("assets")} ADD COLUMN IF NOT EXISTS "deleted_by" text;
|
|
398
|
+
CREATE TABLE IF NOT EXISTS ${tbl("comments")} (
|
|
399
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
400
|
+
"document_id" uuid NOT NULL REFERENCES ${tbl("documents")}("id") ON DELETE CASCADE,
|
|
401
|
+
"thread_id" uuid,
|
|
402
|
+
"anchor" text NOT NULL DEFAULT '',
|
|
403
|
+
"quote" text NOT NULL DEFAULT '',
|
|
404
|
+
"body" text NOT NULL,
|
|
405
|
+
"author_kind" text NOT NULL,
|
|
406
|
+
"author_id" text,
|
|
407
|
+
"author_label" text NOT NULL,
|
|
408
|
+
"author_agent" text,
|
|
409
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
410
|
+
"resolved_at" timestamptz,
|
|
411
|
+
"resolved_by" text
|
|
412
|
+
);
|
|
413
|
+
CREATE INDEX IF NOT EXISTS ${idx("comments_document_idx")} ON ${tbl("comments")} ("document_id", "created_at");
|
|
414
|
+
CREATE TABLE IF NOT EXISTS ${tbl("releases")} (
|
|
415
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
416
|
+
"name" text NOT NULL,
|
|
417
|
+
"state" text NOT NULL DEFAULT 'open',
|
|
418
|
+
"publish_at" timestamptz,
|
|
419
|
+
"items" jsonb NOT NULL DEFAULT '[]'::jsonb,
|
|
420
|
+
"created_by" text NOT NULL,
|
|
421
|
+
"created_by_id" text,
|
|
422
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
423
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
424
|
+
"published_at" timestamptz,
|
|
425
|
+
"published_by" text,
|
|
426
|
+
"last_error" text
|
|
427
|
+
);
|
|
428
|
+
CREATE TABLE IF NOT EXISTS ${tbl("saved_filters")} (
|
|
429
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
430
|
+
"collection" text NOT NULL,
|
|
431
|
+
"name" text NOT NULL,
|
|
432
|
+
"query" jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
433
|
+
"owner_id" text NOT NULL,
|
|
434
|
+
"owner_label" text NOT NULL DEFAULT '',
|
|
435
|
+
"shared" boolean NOT NULL DEFAULT false,
|
|
436
|
+
"created_at" timestamptz NOT NULL DEFAULT now()
|
|
437
|
+
);
|
|
438
|
+
CREATE INDEX IF NOT EXISTS ${idx("saved_filters_collection_idx")} ON ${tbl("saved_filters")} ("collection");
|
|
439
|
+
CREATE TABLE IF NOT EXISTS ${tbl("presence")} (
|
|
440
|
+
"document_id" uuid NOT NULL REFERENCES ${tbl("documents")}("id") ON DELETE CASCADE,
|
|
441
|
+
"actor_id" text NOT NULL,
|
|
442
|
+
"label" text NOT NULL,
|
|
443
|
+
"kind" text NOT NULL,
|
|
444
|
+
"agent" text,
|
|
445
|
+
"cursor" jsonb,
|
|
446
|
+
"selection" jsonb,
|
|
447
|
+
"seen_at" timestamptz NOT NULL DEFAULT now(),
|
|
448
|
+
PRIMARY KEY ("document_id", "actor_id")
|
|
449
|
+
);
|
|
450
|
+
CREATE INDEX IF NOT EXISTS ${idx("presence_seen_idx")} ON ${tbl("presence")} ("seen_at");`.trim()
|
|
209
451
|
}
|
|
210
452
|
];
|
|
211
453
|
}
|
|
@@ -342,11 +584,17 @@ var LEGACY_COLUMNS = [
|
|
|
342
584
|
LEGACY_COLUMNS,
|
|
343
585
|
SCHEMA_VERSION,
|
|
344
586
|
cmsApiKeys,
|
|
587
|
+
cmsAssetRefs,
|
|
588
|
+
cmsAssets,
|
|
345
589
|
cmsAudit,
|
|
590
|
+
cmsComments,
|
|
346
591
|
cmsDdl,
|
|
347
592
|
cmsDocuments,
|
|
348
593
|
cmsHits,
|
|
349
594
|
cmsMeta,
|
|
595
|
+
cmsPresence,
|
|
596
|
+
cmsReleases,
|
|
597
|
+
cmsSavedFilters,
|
|
350
598
|
cmsTables,
|
|
351
599
|
cmsVersions,
|
|
352
600
|
defaultTables,
|