@withstudiocms/sdk 0.0.0-beta.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/cache.d.ts +109 -0
- package/dist/cache.js +94 -0
- package/dist/consts.d.ts +37 -0
- package/dist/consts.js +35 -0
- package/dist/context.d.ts +208 -0
- package/dist/context.js +40 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +6 -0
- package/dist/index.d.ts +1024 -0
- package/dist/index.js +24 -0
- package/dist/lib/diff.d.ts +39 -0
- package/dist/lib/diff.js +29 -0
- package/dist/lib/logger.d.ts +31 -0
- package/dist/lib/logger.js +131 -0
- package/dist/lib/pluginUtils.d.ts +222 -0
- package/dist/lib/pluginUtils.js +87 -0
- 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 +419 -0
- package/dist/modules/auth/index.js +436 -0
- package/dist/modules/clear/index.d.ts +72 -0
- package/dist/modules/clear/index.js +52 -0
- package/dist/modules/config/consts.d.ts +32 -0
- package/dist/modules/config/consts.js +18 -0
- package/dist/modules/config/index.d.ts +100 -0
- package/dist/modules/config/index.js +224 -0
- package/dist/modules/config/templates/mailer.d.ts +36 -0
- package/dist/modules/config/templates/mailer.js +218 -0
- package/dist/modules/config/type-utils.d.ts +13 -0
- package/dist/modules/config/type-utils.js +11 -0
- package/dist/modules/delete/index.d.ts +141 -0
- package/dist/modules/delete/index.js +279 -0
- package/dist/modules/diffTracking/index.d.ts +188 -0
- package/dist/modules/diffTracking/index.js +277 -0
- package/dist/modules/get/index.d.ts +372 -0
- package/dist/modules/get/index.js +579 -0
- package/dist/modules/index.d.ts +883 -0
- package/dist/modules/index.js +37 -0
- package/dist/modules/init/index.d.ts +60 -0
- package/dist/modules/init/index.js +38 -0
- package/dist/modules/middleware/index.d.ts +56 -0
- package/dist/modules/middleware/index.js +50 -0
- package/dist/modules/notificationSettings/index.d.ts +57 -0
- package/dist/modules/notificationSettings/index.js +39 -0
- package/dist/modules/plugins/index.d.ts +167 -0
- package/dist/modules/plugins/index.js +272 -0
- package/dist/modules/post/index.d.ts +306 -0
- package/dist/modules/post/index.js +337 -0
- package/dist/modules/resetTokenBucket/index.d.ts +91 -0
- package/dist/modules/resetTokenBucket/index.js +96 -0
- package/dist/modules/rest_api/index.d.ts +92 -0
- package/dist/modules/rest_api/index.js +117 -0
- package/dist/modules/update/index.d.ts +184 -0
- package/dist/modules/update/index.js +192 -0
- package/dist/modules/util/collectors.d.ts +125 -0
- package/dist/modules/util/collectors.js +168 -0
- package/dist/modules/util/folderTree.d.ts +100 -0
- package/dist/modules/util/folderTree.js +176 -0
- package/dist/modules/util/generators.d.ts +83 -0
- package/dist/modules/util/generators.js +106 -0
- package/dist/modules/util/getFromNPM.d.ts +199 -0
- package/dist/modules/util/getFromNPM.js +106 -0
- package/dist/modules/util/index.d.ts +100 -0
- package/dist/modules/util/index.js +20 -0
- package/dist/modules/util/parsers.d.ts +60 -0
- package/dist/modules/util/parsers.js +43 -0
- package/dist/modules/util/slugify.d.ts +22 -0
- package/dist/modules/util/slugify.js +19 -0
- package/dist/modules/util/users.d.ts +99 -0
- package/dist/modules/util/users.js +78 -0
- package/dist/tables.d.ts +433 -0
- package/dist/tables.js +169 -0
- package/dist/types.d.ts +359 -0
- package/dist/types.js +10 -0
- package/package.json +67 -7
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rollbackMigration,
|
|
3
|
+
syncDatabaseSchema
|
|
4
|
+
} from "@withstudiocms/kysely/utils/migrator";
|
|
5
|
+
import { schemaDefinition as previousSchema } from "./20251130T150847_drop_deprecated.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: "StudioCMSStorageManagerUrlMappings",
|
|
208
|
+
columns: [
|
|
209
|
+
{ name: "identifier", type: "text", primaryKey: true },
|
|
210
|
+
{ name: "url", type: "text", notNull: true },
|
|
211
|
+
{ name: "isPermanent", type: "integer", notNull: true, default: 0 },
|
|
212
|
+
{ name: "expiresAt", type: "integer" },
|
|
213
|
+
{ name: "createdAt", type: "integer", notNull: true },
|
|
214
|
+
{ name: "updatedAt", type: "integer", notNull: true }
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
async function up(db) {
|
|
219
|
+
await syncDatabaseSchema(db, schemaDefinition, previousSchema);
|
|
220
|
+
}
|
|
221
|
+
async function down(db) {
|
|
222
|
+
await rollbackMigration(db, schemaDefinition, previousSchema);
|
|
223
|
+
}
|
|
224
|
+
export {
|
|
225
|
+
down,
|
|
226
|
+
schemaDefinition,
|
|
227
|
+
up
|
|
228
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** biome-ignore-all lint/suspicious/noExplicitAny: Kysely Requirement */
|
|
2
|
+
import type { Effect } from '@withstudiocms/effect';
|
|
3
|
+
import type { MigratorError } from '@withstudiocms/kysely/core/errors';
|
|
4
|
+
import type { Dialect, MigrationInfo, MigrationResultSet } from '@withstudiocms/kysely/kysely';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a live migrator instance bound to the package's migration folder.
|
|
7
|
+
*
|
|
8
|
+
* This convenience factory forwards the provided dialect to `makeMigratorLive`
|
|
9
|
+
* and binds the module's default `migrationFolder`, producing a migrator that
|
|
10
|
+
* runs migrations from the package's built-in migration directory.
|
|
11
|
+
*
|
|
12
|
+
* @template Schema - The database schema type; defaults to `StudioCMSDatabaseSchema`.
|
|
13
|
+
* @param dialect - The SQL dialect implementation to use (e.g. Postgres, MySQL, SQLite).
|
|
14
|
+
* @returns A migrator instance configured for the given dialect and the package migration folder.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const migrator = getMigratorLive<MySchema>(yourDriver);
|
|
18
|
+
* await migrator.migrateToLatest();
|
|
19
|
+
*/
|
|
20
|
+
export declare const getMigratorLive: <Schema>(dialect: Dialect) => Effect.Effect<{
|
|
21
|
+
readonly toLatest: Effect.Effect<MigrationResultSet, MigratorError, never>;
|
|
22
|
+
readonly down: Effect.Effect<MigrationResultSet, MigratorError, never>;
|
|
23
|
+
readonly up: Effect.Effect<MigrationResultSet, MigratorError, never>;
|
|
24
|
+
readonly status: Effect.Effect<readonly MigrationInfo[], MigratorError, never>;
|
|
25
|
+
}, MigratorError, never>;
|
package/dist/migrator.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { makeMigratorLive } from "@withstudiocms/kysely/core/migrator";
|
|
2
|
+
const importMigration = async (name) => {
|
|
3
|
+
if (import.meta.env?.VITEST) {
|
|
4
|
+
const migrations = import.meta.glob("../dist/migrations/*.js");
|
|
5
|
+
const migrationPath = `../dist/migrations/${name}.js`;
|
|
6
|
+
if (!migrations[migrationPath]) {
|
|
7
|
+
throw new Error(`Migration not found: ${name}`);
|
|
8
|
+
}
|
|
9
|
+
return await migrations[migrationPath]();
|
|
10
|
+
}
|
|
11
|
+
return await import(`./migrations/${name}.js`).then(({ up, down }) => ({ up, down }));
|
|
12
|
+
};
|
|
13
|
+
const migrationIndex = {
|
|
14
|
+
"20251025T040912_init": await importMigration("20251025T040912_init"),
|
|
15
|
+
"20251130T150847_drop_deprecated": await importMigration("20251130T150847_drop_deprecated"),
|
|
16
|
+
"20251221T002125_url-mapping": await importMigration("20251221T002125_url-mapping")
|
|
17
|
+
};
|
|
18
|
+
const getMigratorLive = (dialect) => makeMigratorLive(dialect, migrationIndex);
|
|
19
|
+
export {
|
|
20
|
+
getMigratorLive
|
|
21
|
+
};
|