@withstudiocms/sdk 0.1.0-beta.1 → 0.1.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/dist/consts.d.ts +10 -1
- package/dist/consts.js +12 -3
- package/dist/context.d.ts +36 -16
- package/dist/context.js +8 -1
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +6 -0
- package/dist/index.d.ts +341 -453
- package/dist/lib/pluginUtils.d.ts +4 -3
- package/dist/lib/pluginUtils.js +17 -10
- package/dist/lib/storage-manager.d.ts +10 -0
- package/dist/lib/storage-manager.js +17 -0
- package/dist/migrations/20251025T040912_init.d.ts +17 -0
- package/dist/migrations/20251025T040912_init.js +260 -0
- package/dist/migrations/20251130T150847_drop_deprecated.d.ts +13 -0
- package/dist/migrations/20251130T150847_drop_deprecated.js +262 -0
- package/dist/migrations/20251221T002125_url-mapping.d.ts +13 -0
- package/dist/migrations/20251221T002125_url-mapping.js +228 -0
- package/dist/migrator.d.ts +25 -0
- package/dist/migrator.js +21 -0
- package/dist/modules/auth/index.d.ts +60 -104
- package/dist/modules/auth/index.js +33 -9
- package/dist/modules/config/index.d.ts +5 -5
- package/dist/modules/config/index.js +26 -7
- package/dist/modules/delete/index.d.ts +2 -1
- package/dist/modules/delete/index.js +7 -2
- package/dist/modules/diffTracking/index.d.ts +8 -8
- package/dist/modules/diffTracking/index.js +7 -6
- package/dist/modules/get/index.d.ts +116 -16
- package/dist/modules/get/index.js +135 -22
- package/dist/modules/index.d.ts +326 -446
- package/dist/modules/init/index.d.ts +9 -9
- package/dist/modules/middleware/index.d.ts +2 -2
- package/dist/modules/notificationSettings/index.d.ts +3 -3
- package/dist/modules/plugins/index.d.ts +9 -8
- package/dist/modules/plugins/index.js +17 -6
- package/dist/modules/post/index.d.ts +29 -28
- package/dist/modules/post/index.js +47 -15
- package/dist/modules/resetTokenBucket/index.d.ts +1 -1
- package/dist/modules/resetTokenBucket/index.js +5 -2
- package/dist/modules/rest_api/index.d.ts +8 -8
- package/dist/modules/rest_api/index.js +7 -3
- package/dist/modules/update/index.d.ts +25 -25
- package/dist/modules/update/index.js +28 -10
- package/dist/modules/util/collectors.d.ts +14 -150
- package/dist/modules/util/collectors.js +41 -14
- package/dist/modules/util/folderTree.d.ts +4 -4
- package/dist/modules/util/folderTree.js +1 -1
- package/dist/modules/util/getFromNPM.d.ts +13 -5
- package/dist/modules/util/getFromNPM.js +8 -2
- package/dist/modules/util/index.d.ts +30 -166
- package/dist/modules/util/users.d.ts +7 -7
- package/dist/tables.d.ts +433 -0
- package/dist/tables.js +169 -0
- package/dist/types.d.ts +6 -7
- package/package.json +17 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect, Schema } from '@withstudiocms/effect';
|
|
2
|
-
import type { StudioCMSPluginData } from '@withstudiocms/kysely/tables';
|
|
3
2
|
import type { z } from 'zod';
|
|
3
|
+
import { StudioCMSSDKError } from '../errors.js';
|
|
4
|
+
import type { StudioCMSPluginData } from '../tables.js';
|
|
4
5
|
/**
|
|
5
6
|
* Represents a plugin data entry with a strongly-typed `data` property.
|
|
6
7
|
*
|
|
@@ -168,7 +169,7 @@ export declare const isJsonValid: <T extends object>(data: unknown) => (isValid:
|
|
|
168
169
|
* @returns A function that takes unknown data and returns an Effect that resolves to type `T` if validation succeeds, or fails with an error if validation fails.
|
|
169
170
|
* @throws Error if none of the expected validator options are provided.
|
|
170
171
|
*/
|
|
171
|
-
export declare const getValidatorFn: <T extends Schema.Struct<Schema.Struct.Fields> | object>(validator: ValidatorOptions<T>) => Effect.Effect<(data: unknown) => Effect.Effect<T,
|
|
172
|
+
export declare const getValidatorFn: <T extends Schema.Struct<Schema.Struct.Fields> | object>(validator: ValidatorOptions<T>) => Effect.Effect<(data: unknown) => Effect.Effect<T, StudioCMSSDKError, never>, StudioCMSSDKError, never>;
|
|
172
173
|
/**
|
|
173
174
|
* Parses and validates plugin data from a raw input, supporting multiple validation strategies.
|
|
174
175
|
*
|
|
@@ -188,7 +189,7 @@ export declare const getValidatorFn: <T extends Schema.Struct<Schema.Struct.Fiel
|
|
|
188
189
|
*
|
|
189
190
|
* @throws {Error} If the input is neither a string nor an object, or if parsing/validation fails.
|
|
190
191
|
*/
|
|
191
|
-
export declare const parseData: <T extends Schema.Struct<Schema.Struct.Fields> | object>(rawData: unknown, validator?: ValidatorOptions<T> | undefined) => Effect.Effect<T,
|
|
192
|
+
export declare const parseData: <T extends Schema.Struct<Schema.Struct.Fields> | object>(rawData: unknown, validator?: ValidatorOptions<T> | undefined) => Effect.Effect<T, StudioCMSSDKError, never>;
|
|
192
193
|
/**
|
|
193
194
|
* Base options for using plugin data.
|
|
194
195
|
*
|
package/dist/lib/pluginUtils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect, pipe, Schema } from "@withstudiocms/effect";
|
|
2
|
+
import { StudioCMSSDKError } from "../errors.js";
|
|
2
3
|
var SelectPluginDataRespondOrFail = /* @__PURE__ */ ((SelectPluginDataRespondOrFail2) => {
|
|
3
4
|
SelectPluginDataRespondOrFail2["ExistsNoFail"] = "existsNoFail";
|
|
4
5
|
SelectPluginDataRespondOrFail2["ExistsShouldFail"] = "existsShouldFail";
|
|
@@ -21,13 +22,19 @@ const getValidatorFn = Effect.fn("studiocms/sdk/effect/pluginUtils/getValidatorF
|
|
|
21
22
|
if ("jsonFn" in validator) {
|
|
22
23
|
return (data) => Effect.try({
|
|
23
24
|
try: () => pipe(validator.jsonFn(data), isJsonValid(data)),
|
|
24
|
-
catch: (
|
|
25
|
+
catch: (cause) => new StudioCMSSDKError({
|
|
26
|
+
message: `JSON validation failed: ${cause.message}`,
|
|
27
|
+
cause
|
|
28
|
+
})
|
|
25
29
|
});
|
|
26
30
|
}
|
|
27
31
|
if ("effectSchema" in validator) {
|
|
28
32
|
return (data) => Schema.decodeUnknown(validator.effectSchema)(data).pipe(
|
|
29
33
|
Effect.mapError(
|
|
30
|
-
(
|
|
34
|
+
(cause) => new StudioCMSSDKError({
|
|
35
|
+
message: `Schema validation failed: ${cause.message}`,
|
|
36
|
+
cause
|
|
37
|
+
})
|
|
31
38
|
)
|
|
32
39
|
);
|
|
33
40
|
}
|
|
@@ -42,14 +49,12 @@ const getValidatorFn = Effect.fn("studiocms/sdk/effect/pluginUtils/getValidatorF
|
|
|
42
49
|
cause: result.error.cause
|
|
43
50
|
});
|
|
44
51
|
},
|
|
45
|
-
catch: (
|
|
52
|
+
catch: (cause) => new StudioCMSSDKError({ message: cause.message, cause })
|
|
46
53
|
});
|
|
47
54
|
}
|
|
48
|
-
return yield*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
);
|
|
55
|
+
return yield* new StudioCMSSDKError({
|
|
56
|
+
message: "Invalid validator options provided, expected one of: jsonFn, effectSchema, or zodSchema"
|
|
57
|
+
});
|
|
53
58
|
}
|
|
54
59
|
);
|
|
55
60
|
const parseData = Effect.fn("studiocms/sdk/effect/pluginUtils/parseData")(function* (rawData, validator) {
|
|
@@ -57,12 +62,14 @@ const parseData = Effect.fn("studiocms/sdk/effect/pluginUtils/parseData")(functi
|
|
|
57
62
|
if (typeof rawData === "string") {
|
|
58
63
|
parsedInput = yield* Effect.try({
|
|
59
64
|
try: () => JSON.parse(rawData),
|
|
60
|
-
catch: (
|
|
65
|
+
catch: (cause) => new StudioCMSSDKError({ message: `JSON parsing failed: ${cause}`, cause })
|
|
61
66
|
});
|
|
62
67
|
} else if (rawData !== null && typeof rawData === "object") {
|
|
63
68
|
parsedInput = rawData;
|
|
64
69
|
} else {
|
|
65
|
-
return yield*
|
|
70
|
+
return yield* new StudioCMSSDKError({
|
|
71
|
+
message: `Invalid plugin data format: ${typeof rawData}`
|
|
72
|
+
});
|
|
66
73
|
}
|
|
67
74
|
if (!validator || validator === void 0) {
|
|
68
75
|
return parsedInput;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Effect } from '@withstudiocms/effect';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves Storage Manager URLs for the specified attributes of the given object.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam F - The type of the object containing the attributes to resolve.
|
|
6
|
+
* @param obj - The object containing the attributes with Storage Manager URLs.
|
|
7
|
+
* @param attributes - A single attribute key or an array of attribute keys to resolve.
|
|
8
|
+
* @returns An Effect that resolves the specified attributes and returns the updated object.
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveStorageManagerUrls: (smResolver: (identifier: string) => Promise<string>) => <F>(obj: F, attributes: keyof F | (keyof F)[]) => Effect.Effect<F | undefined, import("effect/Cause").UnknownException, never>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Effect } from "@withstudiocms/effect";
|
|
2
|
+
const resolveStorageManagerUrls = (smResolver) => (obj, attributes) => Effect.gen(function* () {
|
|
3
|
+
if (!obj) return;
|
|
4
|
+
const initialObject = obj;
|
|
5
|
+
const attrs = Array.isArray(attributes) ? attributes : [attributes];
|
|
6
|
+
for (const attr of attrs) {
|
|
7
|
+
const entryData = initialObject[attr];
|
|
8
|
+
if (typeof entryData !== "string") continue;
|
|
9
|
+
if (!entryData.startsWith("storage-file://")) continue;
|
|
10
|
+
const newData = yield* Effect.tryPromise(() => smResolver(entryData));
|
|
11
|
+
initialObject[attr] = newData;
|
|
12
|
+
}
|
|
13
|
+
return initialObject;
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
resolveStorageManagerUrls
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* - Title: Initial setup of StudioCMS database schema
|
|
3
|
+
* - Created: Oct. 25, 2025
|
|
4
|
+
* - Author: Adam Matthiesen (@Adammatthiesen)
|
|
5
|
+
* - GitHub PR: #963
|
|
6
|
+
* - Description: This migration initializes the database schema for StudioCMS,
|
|
7
|
+
* creating all necessary tables for users, sessions, permissions, pages, and more.
|
|
8
|
+
*
|
|
9
|
+
* This re-creates the original AstroDB schema within Kysely to ensure compatibility
|
|
10
|
+
* with existing installations while transitioning to Kysely as the database layer.
|
|
11
|
+
*/
|
|
12
|
+
/** biome-ignore-all lint/suspicious/noExplicitAny: Requirement from Kysely */
|
|
13
|
+
import type { Kysely } from '@withstudiocms/kysely/kysely';
|
|
14
|
+
import { type TableDefinition } from '@withstudiocms/kysely/utils/migrator';
|
|
15
|
+
export declare const schemaDefinition: TableDefinition[];
|
|
16
|
+
export declare function up(db: Kysely<any>): Promise<void>;
|
|
17
|
+
export declare function down(db: Kysely<any>): Promise<void>;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rollbackMigration,
|
|
3
|
+
syncDatabaseSchema
|
|
4
|
+
} from "@withstudiocms/kysely/utils/migrator";
|
|
5
|
+
const previousSchema = [];
|
|
6
|
+
const schemaDefinition = [
|
|
7
|
+
{
|
|
8
|
+
name: "StudioCMSUsersTable",
|
|
9
|
+
columns: [
|
|
10
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
11
|
+
{ name: "url", type: "text" },
|
|
12
|
+
{ name: "name", type: "text", notNull: true },
|
|
13
|
+
{ name: "email", type: "text" },
|
|
14
|
+
{ name: "avatar", type: "text" },
|
|
15
|
+
{ name: "username", type: "text", notNull: true },
|
|
16
|
+
{ name: "password", type: "text" },
|
|
17
|
+
{ name: "updatedAt", type: "text", notNull: true },
|
|
18
|
+
{ name: "createdAt", type: "text", notNull: true, defaultSQL: "CURRENT_TIMESTAMP" },
|
|
19
|
+
{ name: "emailVerified", type: "integer", notNull: true, default: 0 },
|
|
20
|
+
{ name: "notifications", type: "text" }
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "StudioCMSOAuthAccounts",
|
|
25
|
+
columns: [
|
|
26
|
+
{ name: "providerUserId", type: "text", notNull: true },
|
|
27
|
+
{ name: "provider", type: "text", notNull: true },
|
|
28
|
+
{
|
|
29
|
+
name: "userId",
|
|
30
|
+
type: "text",
|
|
31
|
+
notNull: true,
|
|
32
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "StudioCMSSessionTable",
|
|
38
|
+
columns: [
|
|
39
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
40
|
+
{
|
|
41
|
+
name: "userId",
|
|
42
|
+
type: "text",
|
|
43
|
+
notNull: true,
|
|
44
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
45
|
+
},
|
|
46
|
+
{ name: "expiresAt", type: "text", notNull: true }
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "StudioCMSPermissions",
|
|
51
|
+
columns: [
|
|
52
|
+
{
|
|
53
|
+
name: "user",
|
|
54
|
+
type: "text",
|
|
55
|
+
notNull: true,
|
|
56
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
57
|
+
},
|
|
58
|
+
{ name: "rank", type: "text", notNull: true }
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "StudioCMSAPIKeys",
|
|
63
|
+
columns: [
|
|
64
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
65
|
+
{
|
|
66
|
+
name: "userId",
|
|
67
|
+
type: "text",
|
|
68
|
+
notNull: true,
|
|
69
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
70
|
+
},
|
|
71
|
+
{ name: "key", type: "text", notNull: true },
|
|
72
|
+
{ name: "creationDate", type: "text", notNull: true },
|
|
73
|
+
{ name: "description", type: "text" }
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "StudioCMSUserResetTokens",
|
|
78
|
+
columns: [
|
|
79
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
80
|
+
{
|
|
81
|
+
name: "userId",
|
|
82
|
+
type: "text",
|
|
83
|
+
notNull: true,
|
|
84
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
85
|
+
},
|
|
86
|
+
{ name: "token", type: "text", notNull: true }
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "StudioCMSPageFolderStructure",
|
|
91
|
+
columns: [
|
|
92
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
93
|
+
{ name: "name", type: "text", notNull: true },
|
|
94
|
+
{ name: "parent", type: "text" }
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "StudioCMSPageData",
|
|
99
|
+
columns: [
|
|
100
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
101
|
+
{ name: "package", type: "text", notNull: true },
|
|
102
|
+
{ name: "title", type: "text", notNull: true },
|
|
103
|
+
{ name: "description", type: "text", notNull: true },
|
|
104
|
+
{ name: "showOnNav", type: "integer", notNull: true, default: 0 },
|
|
105
|
+
{ name: "publishedAt", type: "text" },
|
|
106
|
+
{ name: "updatedAt", type: "text", notNull: true },
|
|
107
|
+
{ name: "slug", type: "text", notNull: true },
|
|
108
|
+
{ name: "contentLang", type: "text", notNull: true },
|
|
109
|
+
{ name: "heroImage", type: "text" },
|
|
110
|
+
{ name: "categories", type: "text", notNull: true, default: JSON.stringify([]) },
|
|
111
|
+
{ name: "tags", type: "text", notNull: true, default: JSON.stringify([]) },
|
|
112
|
+
{ name: "authorId", type: "text", notNull: true },
|
|
113
|
+
{ name: "contributorIds", type: "text", notNull: true, default: JSON.stringify([]) },
|
|
114
|
+
{ name: "showAuthor", type: "integer", notNull: true, default: 0 },
|
|
115
|
+
{ name: "showContributors", type: "integer", notNull: true, default: 0 },
|
|
116
|
+
{ name: "parentFolder", type: "text" },
|
|
117
|
+
{ name: "draft", type: "integer", notNull: true, default: 0 },
|
|
118
|
+
{ name: "augments", type: "text", notNull: true, default: JSON.stringify([]) }
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "StudioCMSDiffTracking",
|
|
123
|
+
columns: [
|
|
124
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
125
|
+
{
|
|
126
|
+
name: "pageId",
|
|
127
|
+
type: "text",
|
|
128
|
+
notNull: true,
|
|
129
|
+
references: { table: "StudioCMSPageData", column: "id" }
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "userId",
|
|
133
|
+
type: "text",
|
|
134
|
+
notNull: true,
|
|
135
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
136
|
+
},
|
|
137
|
+
{ name: "timestamp", type: "text", notNull: true },
|
|
138
|
+
{ name: "pageMetaData", type: "text", notNull: true },
|
|
139
|
+
{ name: "pageContentStart", type: "text", notNull: true },
|
|
140
|
+
{ name: "diff", type: "text" }
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "StudioCMSPageDataTags",
|
|
145
|
+
columns: [
|
|
146
|
+
{ name: "id", type: "integer", primaryKey: true },
|
|
147
|
+
{ name: "description", type: "text", notNull: true },
|
|
148
|
+
{ name: "name", type: "text", notNull: true },
|
|
149
|
+
{ name: "slug", type: "text", notNull: true },
|
|
150
|
+
{ name: "meta", type: "text", notNull: true }
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "StudioCMSPageDataCategories",
|
|
155
|
+
columns: [
|
|
156
|
+
{ name: "id", type: "integer", primaryKey: true },
|
|
157
|
+
{ name: "parent", type: "integer" },
|
|
158
|
+
{ name: "description", type: "text", notNull: true },
|
|
159
|
+
{ name: "name", type: "text", notNull: true },
|
|
160
|
+
{ name: "slug", type: "text", notNull: true },
|
|
161
|
+
{ name: "meta", type: "text", notNull: true }
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "StudioCMSPageContent",
|
|
166
|
+
columns: [
|
|
167
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
168
|
+
{
|
|
169
|
+
name: "contentId",
|
|
170
|
+
type: "text",
|
|
171
|
+
notNull: true,
|
|
172
|
+
references: { table: "StudioCMSPageData", column: "id" }
|
|
173
|
+
},
|
|
174
|
+
{ name: "contentLang", type: "text", notNull: true },
|
|
175
|
+
{ name: "content", type: "text", notNull: true }
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "StudioCMSEmailVerificationTokens",
|
|
180
|
+
columns: [
|
|
181
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
182
|
+
{
|
|
183
|
+
name: "userId",
|
|
184
|
+
type: "text",
|
|
185
|
+
notNull: true,
|
|
186
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
187
|
+
},
|
|
188
|
+
{ name: "token", type: "text", notNull: true },
|
|
189
|
+
{ name: "expiresAt", type: "text", notNull: true }
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "StudioCMSPluginData",
|
|
194
|
+
columns: [
|
|
195
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
196
|
+
{ name: "data", type: "text", notNull: true }
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "StudioCMSDynamicConfigSettings",
|
|
201
|
+
columns: [
|
|
202
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
203
|
+
{ name: "data", type: "text", notNull: true }
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
// DEPRECATED TABLES - to be removed in future migrations
|
|
207
|
+
{
|
|
208
|
+
name: "StudioCMSSiteConfig",
|
|
209
|
+
columns: [
|
|
210
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
211
|
+
{ name: "title", type: "text", notNull: true },
|
|
212
|
+
{ name: "description", type: "text", notNull: true },
|
|
213
|
+
{ name: "defaultOgImage", type: "text" },
|
|
214
|
+
{ name: "siteIcon", type: "text" },
|
|
215
|
+
{ name: "loginPageBackground", type: "text", notNull: true, default: "studiocms-curves" },
|
|
216
|
+
{ name: "loginPageCustomImage", type: "text" },
|
|
217
|
+
{ name: "enableDiffs", type: "integer", notNull: true, default: 0 },
|
|
218
|
+
{ name: "diffPerPage", type: "integer", notNull: true, default: 10 },
|
|
219
|
+
{ name: "gridItems", type: "text", notNull: true, default: JSON.stringify([]) },
|
|
220
|
+
{ name: "enableMailer", type: "integer", notNull: true, default: 0 },
|
|
221
|
+
{ name: "hideDefaultIndex", type: "integer", notNull: true, default: 0 }
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "StudioCMSMailerConfig",
|
|
226
|
+
columns: [
|
|
227
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
228
|
+
{ name: "host", type: "text", notNull: true },
|
|
229
|
+
{ name: "port", type: "integer", notNull: true },
|
|
230
|
+
{ name: "secure", type: "integer", notNull: true, default: 0 },
|
|
231
|
+
{ name: "proxy", type: "text" },
|
|
232
|
+
{ name: "auth_user", type: "text" },
|
|
233
|
+
{ name: "auth_password", type: "text" },
|
|
234
|
+
{ name: "tls_rejectUnauthorized", type: "integer" },
|
|
235
|
+
{ name: "tls_servername", type: "text" },
|
|
236
|
+
{ name: "default_sender", type: "text", notNull: true }
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "StudioCMSNotificationSettings",
|
|
241
|
+
columns: [
|
|
242
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
243
|
+
{ name: "emailVerification", type: "integer", notNull: true, default: 0 },
|
|
244
|
+
{ name: "requireAdminVerification", type: "integer", notNull: true, default: 0 },
|
|
245
|
+
{ name: "requireEditorVerification", type: "integer", notNull: true, default: 0 },
|
|
246
|
+
{ name: "oAuthBypassVerification", type: "integer", notNull: true, default: 0 }
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
];
|
|
250
|
+
async function up(db) {
|
|
251
|
+
await syncDatabaseSchema(db, schemaDefinition, previousSchema);
|
|
252
|
+
}
|
|
253
|
+
async function down(db) {
|
|
254
|
+
await rollbackMigration(db, schemaDefinition, previousSchema);
|
|
255
|
+
}
|
|
256
|
+
export {
|
|
257
|
+
down,
|
|
258
|
+
schemaDefinition,
|
|
259
|
+
up
|
|
260
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* - Title: Drop Deprecated Tables
|
|
3
|
+
* - Created: 2025-11-30
|
|
4
|
+
* - Author: Adam Matthiesen
|
|
5
|
+
* - GitHub PR: #1033
|
|
6
|
+
* - Description: Drop previously deprecated tables from the database schema. (re-deprecate here to be fully removed in the next migration safely)
|
|
7
|
+
*/
|
|
8
|
+
/** biome-ignore-all lint/suspicious/noExplicitAny: Requirement from Kysely */
|
|
9
|
+
import type { Kysely } from '@withstudiocms/kysely/kysely';
|
|
10
|
+
import { type TableDefinition } from '@withstudiocms/kysely/utils/migrator';
|
|
11
|
+
export declare const schemaDefinition: TableDefinition[];
|
|
12
|
+
export declare function up(db: Kysely<any>): Promise<void>;
|
|
13
|
+
export declare function down(db: Kysely<any>): Promise<void>;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rollbackMigration,
|
|
3
|
+
syncDatabaseSchema
|
|
4
|
+
} from "@withstudiocms/kysely/utils/migrator";
|
|
5
|
+
import { schemaDefinition as previousSchema } from "./20251025T040912_init.js";
|
|
6
|
+
const schemaDefinition = [
|
|
7
|
+
{
|
|
8
|
+
name: "StudioCMSUsersTable",
|
|
9
|
+
columns: [
|
|
10
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
11
|
+
{ name: "url", type: "text" },
|
|
12
|
+
{ name: "name", type: "text", notNull: true },
|
|
13
|
+
{ name: "email", type: "text" },
|
|
14
|
+
{ name: "avatar", type: "text" },
|
|
15
|
+
{ name: "username", type: "text", notNull: true },
|
|
16
|
+
{ name: "password", type: "text" },
|
|
17
|
+
{ name: "updatedAt", type: "text", notNull: true },
|
|
18
|
+
{ name: "createdAt", type: "text", notNull: true, defaultSQL: "CURRENT_TIMESTAMP" },
|
|
19
|
+
{ name: "emailVerified", type: "integer", notNull: true, default: 0 },
|
|
20
|
+
{ name: "notifications", type: "text" }
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "StudioCMSOAuthAccounts",
|
|
25
|
+
columns: [
|
|
26
|
+
{ name: "providerUserId", type: "text", notNull: true },
|
|
27
|
+
{ name: "provider", type: "text", notNull: true },
|
|
28
|
+
{
|
|
29
|
+
name: "userId",
|
|
30
|
+
type: "text",
|
|
31
|
+
notNull: true,
|
|
32
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "StudioCMSSessionTable",
|
|
38
|
+
columns: [
|
|
39
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
40
|
+
{
|
|
41
|
+
name: "userId",
|
|
42
|
+
type: "text",
|
|
43
|
+
notNull: true,
|
|
44
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
45
|
+
},
|
|
46
|
+
{ name: "expiresAt", type: "text", notNull: true }
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "StudioCMSPermissions",
|
|
51
|
+
columns: [
|
|
52
|
+
{
|
|
53
|
+
name: "user",
|
|
54
|
+
type: "text",
|
|
55
|
+
notNull: true,
|
|
56
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
57
|
+
},
|
|
58
|
+
{ name: "rank", type: "text", notNull: true }
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "StudioCMSAPIKeys",
|
|
63
|
+
columns: [
|
|
64
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
65
|
+
{
|
|
66
|
+
name: "userId",
|
|
67
|
+
type: "text",
|
|
68
|
+
notNull: true,
|
|
69
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
70
|
+
},
|
|
71
|
+
{ name: "key", type: "text", notNull: true },
|
|
72
|
+
{ name: "creationDate", type: "text", notNull: true },
|
|
73
|
+
{ name: "description", type: "text" }
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "StudioCMSUserResetTokens",
|
|
78
|
+
columns: [
|
|
79
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
80
|
+
{
|
|
81
|
+
name: "userId",
|
|
82
|
+
type: "text",
|
|
83
|
+
notNull: true,
|
|
84
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
85
|
+
},
|
|
86
|
+
{ name: "token", type: "text", notNull: true }
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "StudioCMSPageFolderStructure",
|
|
91
|
+
columns: [
|
|
92
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
93
|
+
{ name: "name", type: "text", notNull: true },
|
|
94
|
+
{ name: "parent", type: "text" }
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "StudioCMSPageData",
|
|
99
|
+
columns: [
|
|
100
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
101
|
+
{ name: "package", type: "text", notNull: true },
|
|
102
|
+
{ name: "title", type: "text", notNull: true },
|
|
103
|
+
{ name: "description", type: "text", notNull: true },
|
|
104
|
+
{ name: "showOnNav", type: "integer", notNull: true, default: 0 },
|
|
105
|
+
{ name: "publishedAt", type: "text" },
|
|
106
|
+
{ name: "updatedAt", type: "text", notNull: true },
|
|
107
|
+
{ name: "slug", type: "text", notNull: true },
|
|
108
|
+
{ name: "contentLang", type: "text", notNull: true },
|
|
109
|
+
{ name: "heroImage", type: "text" },
|
|
110
|
+
{ name: "categories", type: "text", notNull: true, default: JSON.stringify([]) },
|
|
111
|
+
{ name: "tags", type: "text", notNull: true, default: JSON.stringify([]) },
|
|
112
|
+
{ name: "authorId", type: "text", notNull: true },
|
|
113
|
+
{ name: "contributorIds", type: "text", notNull: true, default: JSON.stringify([]) },
|
|
114
|
+
{ name: "showAuthor", type: "integer", notNull: true, default: 0 },
|
|
115
|
+
{ name: "showContributors", type: "integer", notNull: true, default: 0 },
|
|
116
|
+
{ name: "parentFolder", type: "text" },
|
|
117
|
+
{ name: "draft", type: "integer", notNull: true, default: 0 },
|
|
118
|
+
{ name: "augments", type: "text", notNull: true, default: JSON.stringify([]) }
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "StudioCMSDiffTracking",
|
|
123
|
+
columns: [
|
|
124
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
125
|
+
{
|
|
126
|
+
name: "pageId",
|
|
127
|
+
type: "text",
|
|
128
|
+
notNull: true,
|
|
129
|
+
references: { table: "StudioCMSPageData", column: "id" }
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "userId",
|
|
133
|
+
type: "text",
|
|
134
|
+
notNull: true,
|
|
135
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
136
|
+
},
|
|
137
|
+
{ name: "timestamp", type: "text", notNull: true },
|
|
138
|
+
{ name: "pageMetaData", type: "text", notNull: true },
|
|
139
|
+
{ name: "pageContentStart", type: "text", notNull: true },
|
|
140
|
+
{ name: "diff", type: "text" }
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "StudioCMSPageDataTags",
|
|
145
|
+
columns: [
|
|
146
|
+
{ name: "id", type: "integer", primaryKey: true },
|
|
147
|
+
{ name: "description", type: "text", notNull: true },
|
|
148
|
+
{ name: "name", type: "text", notNull: true },
|
|
149
|
+
{ name: "slug", type: "text", notNull: true },
|
|
150
|
+
{ name: "meta", type: "text", notNull: true }
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "StudioCMSPageDataCategories",
|
|
155
|
+
columns: [
|
|
156
|
+
{ name: "id", type: "integer", primaryKey: true },
|
|
157
|
+
{ name: "parent", type: "integer" },
|
|
158
|
+
{ name: "description", type: "text", notNull: true },
|
|
159
|
+
{ name: "name", type: "text", notNull: true },
|
|
160
|
+
{ name: "slug", type: "text", notNull: true },
|
|
161
|
+
{ name: "meta", type: "text", notNull: true }
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "StudioCMSPageContent",
|
|
166
|
+
columns: [
|
|
167
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
168
|
+
{
|
|
169
|
+
name: "contentId",
|
|
170
|
+
type: "text",
|
|
171
|
+
notNull: true,
|
|
172
|
+
references: { table: "StudioCMSPageData", column: "id" }
|
|
173
|
+
},
|
|
174
|
+
{ name: "contentLang", type: "text", notNull: true },
|
|
175
|
+
{ name: "content", type: "text", notNull: true }
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "StudioCMSEmailVerificationTokens",
|
|
180
|
+
columns: [
|
|
181
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
182
|
+
{
|
|
183
|
+
name: "userId",
|
|
184
|
+
type: "text",
|
|
185
|
+
notNull: true,
|
|
186
|
+
references: { table: "StudioCMSUsersTable", column: "id" }
|
|
187
|
+
},
|
|
188
|
+
{ name: "token", type: "text", notNull: true },
|
|
189
|
+
{ name: "expiresAt", type: "text", notNull: true }
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "StudioCMSPluginData",
|
|
194
|
+
columns: [
|
|
195
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
196
|
+
{ name: "data", type: "text", notNull: true }
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "StudioCMSDynamicConfigSettings",
|
|
201
|
+
columns: [
|
|
202
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
203
|
+
{ name: "data", type: "text", notNull: true }
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "StudioCMSSiteConfig",
|
|
208
|
+
deprecated: true,
|
|
209
|
+
columns: [
|
|
210
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
211
|
+
{ name: "title", type: "text", notNull: true },
|
|
212
|
+
{ name: "description", type: "text", notNull: true },
|
|
213
|
+
{ name: "defaultOgImage", type: "text" },
|
|
214
|
+
{ name: "siteIcon", type: "text" },
|
|
215
|
+
{ name: "loginPageBackground", type: "text", notNull: true, default: "studiocms-curves" },
|
|
216
|
+
{ name: "loginPageCustomImage", type: "text" },
|
|
217
|
+
{ name: "enableDiffs", type: "integer", notNull: true, default: 0 },
|
|
218
|
+
{ name: "diffPerPage", type: "integer", notNull: true, default: 10 },
|
|
219
|
+
{ name: "gridItems", type: "text", notNull: true, default: JSON.stringify([]) },
|
|
220
|
+
{ name: "enableMailer", type: "integer", notNull: true, default: 0 },
|
|
221
|
+
{ name: "hideDefaultIndex", type: "integer", notNull: true, default: 0 }
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "StudioCMSMailerConfig",
|
|
226
|
+
deprecated: true,
|
|
227
|
+
columns: [
|
|
228
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
229
|
+
{ name: "host", type: "text", notNull: true },
|
|
230
|
+
{ name: "port", type: "integer", notNull: true },
|
|
231
|
+
{ name: "secure", type: "integer", notNull: true, default: 0 },
|
|
232
|
+
{ name: "proxy", type: "text" },
|
|
233
|
+
{ name: "auth_user", type: "text" },
|
|
234
|
+
{ name: "auth_password", type: "text" },
|
|
235
|
+
{ name: "tls_rejectUnauthorized", type: "integer" },
|
|
236
|
+
{ name: "tls_servername", type: "text" },
|
|
237
|
+
{ name: "default_sender", type: "text", notNull: true }
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "StudioCMSNotificationSettings",
|
|
242
|
+
deprecated: true,
|
|
243
|
+
columns: [
|
|
244
|
+
{ name: "id", type: "text", primaryKey: true },
|
|
245
|
+
{ name: "emailVerification", type: "integer", notNull: true, default: 0 },
|
|
246
|
+
{ name: "requireAdminVerification", type: "integer", notNull: true, default: 0 },
|
|
247
|
+
{ name: "requireEditorVerification", type: "integer", notNull: true, default: 0 },
|
|
248
|
+
{ name: "oAuthBypassVerification", type: "integer", notNull: true, default: 0 }
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
];
|
|
252
|
+
async function up(db) {
|
|
253
|
+
await syncDatabaseSchema(db, schemaDefinition, previousSchema);
|
|
254
|
+
}
|
|
255
|
+
async function down(db) {
|
|
256
|
+
await rollbackMigration(db, schemaDefinition, previousSchema);
|
|
257
|
+
}
|
|
258
|
+
export {
|
|
259
|
+
down,
|
|
260
|
+
schemaDefinition,
|
|
261
|
+
up
|
|
262
|
+
};
|