@withstudiocms/sdk 0.0.0-beta.0 → 0.1.0-beta.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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -0
  3. package/dist/cache.d.ts +109 -0
  4. package/dist/cache.js +94 -0
  5. package/dist/consts.d.ts +28 -0
  6. package/dist/consts.js +26 -0
  7. package/dist/context.d.ts +188 -0
  8. package/dist/context.js +33 -0
  9. package/dist/index.d.ts +1136 -0
  10. package/dist/index.js +24 -0
  11. package/dist/lib/diff.d.ts +39 -0
  12. package/dist/lib/diff.js +29 -0
  13. package/dist/lib/logger.d.ts +31 -0
  14. package/dist/lib/logger.js +131 -0
  15. package/dist/lib/pluginUtils.d.ts +221 -0
  16. package/dist/lib/pluginUtils.js +80 -0
  17. package/dist/modules/auth/index.d.ts +463 -0
  18. package/dist/modules/auth/index.js +412 -0
  19. package/dist/modules/clear/index.d.ts +72 -0
  20. package/dist/modules/clear/index.js +52 -0
  21. package/dist/modules/config/consts.d.ts +32 -0
  22. package/dist/modules/config/consts.js +18 -0
  23. package/dist/modules/config/index.d.ts +100 -0
  24. package/dist/modules/config/index.js +205 -0
  25. package/dist/modules/config/templates/mailer.d.ts +36 -0
  26. package/dist/modules/config/templates/mailer.js +218 -0
  27. package/dist/modules/config/type-utils.d.ts +13 -0
  28. package/dist/modules/config/type-utils.js +11 -0
  29. package/dist/modules/delete/index.d.ts +140 -0
  30. package/dist/modules/delete/index.js +274 -0
  31. package/dist/modules/diffTracking/index.d.ts +188 -0
  32. package/dist/modules/diffTracking/index.js +276 -0
  33. package/dist/modules/get/index.d.ts +272 -0
  34. package/dist/modules/get/index.js +466 -0
  35. package/dist/modules/index.d.ts +1003 -0
  36. package/dist/modules/index.js +37 -0
  37. package/dist/modules/init/index.d.ts +60 -0
  38. package/dist/modules/init/index.js +38 -0
  39. package/dist/modules/middleware/index.d.ts +56 -0
  40. package/dist/modules/middleware/index.js +50 -0
  41. package/dist/modules/notificationSettings/index.d.ts +57 -0
  42. package/dist/modules/notificationSettings/index.js +39 -0
  43. package/dist/modules/plugins/index.d.ts +166 -0
  44. package/dist/modules/plugins/index.js +261 -0
  45. package/dist/modules/post/index.d.ts +305 -0
  46. package/dist/modules/post/index.js +305 -0
  47. package/dist/modules/resetTokenBucket/index.d.ts +91 -0
  48. package/dist/modules/resetTokenBucket/index.js +93 -0
  49. package/dist/modules/rest_api/index.d.ts +92 -0
  50. package/dist/modules/rest_api/index.js +113 -0
  51. package/dist/modules/update/index.d.ts +184 -0
  52. package/dist/modules/update/index.js +174 -0
  53. package/dist/modules/util/collectors.d.ts +261 -0
  54. package/dist/modules/util/collectors.js +141 -0
  55. package/dist/modules/util/folderTree.d.ts +100 -0
  56. package/dist/modules/util/folderTree.js +176 -0
  57. package/dist/modules/util/generators.d.ts +83 -0
  58. package/dist/modules/util/generators.js +106 -0
  59. package/dist/modules/util/getFromNPM.d.ts +191 -0
  60. package/dist/modules/util/getFromNPM.js +100 -0
  61. package/dist/modules/util/index.d.ts +236 -0
  62. package/dist/modules/util/index.js +20 -0
  63. package/dist/modules/util/parsers.d.ts +60 -0
  64. package/dist/modules/util/parsers.js +43 -0
  65. package/dist/modules/util/slugify.d.ts +22 -0
  66. package/dist/modules/util/slugify.js +19 -0
  67. package/dist/modules/util/users.d.ts +99 -0
  68. package/dist/modules/util/users.js +78 -0
  69. package/dist/types.d.ts +360 -0
  70. package/dist/types.js +10 -0
  71. package/package.json +55 -7
@@ -0,0 +1,205 @@
1
+ import { Deepmerge, Effect, Schema } from "@withstudiocms/effect";
2
+ import { StudioCMSDynamicConfigSettings } from "@withstudiocms/kysely/tables";
3
+ import { CacheMissError, CacheService } from "../../cache.js";
4
+ import { cacheKeyGetters, cacheTags } from "../../consts.js";
5
+ import { DBClientLive } from "../../context.js";
6
+ import {
7
+ MailerConfigId,
8
+ MailerConfigVersion,
9
+ NotificationSettingsId,
10
+ NotificationSettingsVersion,
11
+ SiteConfigId,
12
+ SiteConfigVersion,
13
+ TemplateConfigId,
14
+ TemplateConfigVersion
15
+ } from "./consts.js";
16
+ import defaultTemplates from "./templates/mailer.js";
17
+ import { castData } from "./type-utils.js";
18
+ const cacheKey = cacheKeyGetters.dynamicConfig;
19
+ const cacheOpts = { tags: cacheTags.dynamicConfig };
20
+ const SDKConfigModule = Effect.gen(function* () {
21
+ const [{ withCodec }, { merge }, cache] = yield* Effect.all([
22
+ DBClientLive,
23
+ Deepmerge,
24
+ CacheService
25
+ ]);
26
+ const _insert = withCodec({
27
+ decoder: StudioCMSDynamicConfigSettings.Select,
28
+ encoder: StudioCMSDynamicConfigSettings.Insert,
29
+ callbackFn: (db, data) => db(
30
+ (client) => client.insertInto("StudioCMSDynamicConfigSettings").values(data).returning(["id", "data"]).executeTakeFirstOrThrow()
31
+ )
32
+ });
33
+ const _select = withCodec({
34
+ decoder: Schema.UndefinedOr(StudioCMSDynamicConfigSettings.Select),
35
+ encoder: Schema.String,
36
+ callbackFn: (db, id) => db(
37
+ (client) => client.selectFrom("StudioCMSDynamicConfigSettings").selectAll().where("id", "=", id).executeTakeFirst()
38
+ )
39
+ });
40
+ const _update = withCodec({
41
+ decoder: StudioCMSDynamicConfigSettings.Select,
42
+ encoder: StudioCMSDynamicConfigSettings.Update,
43
+ callbackFn: (db, { id, data }) => db(
44
+ (client) => client.updateTable("StudioCMSDynamicConfigSettings").set({ data }).where("id", "=", id).returning(["id", "data"]).executeTakeFirstOrThrow()
45
+ )
46
+ });
47
+ const _tappedCacheUpdate = (fn) => Effect.fn(
48
+ (id, data) => fn({ id, data: JSON.stringify(data) }).pipe(
49
+ Effect.tap(() => cache.set(cacheKey(id), data, cacheOpts))
50
+ )
51
+ );
52
+ const setAndReturn = (id, data) => Effect.gen(function* () {
53
+ yield* cache.set(cacheKey(id), data, cacheOpts);
54
+ return yield* castData({ id, data });
55
+ });
56
+ const freshGet = Effect.fn(function* (id) {
57
+ const uncached = yield* _select(id);
58
+ if (!uncached) return void 0;
59
+ return yield* setAndReturn(id, uncached.data);
60
+ });
61
+ const create = _tappedCacheUpdate(_insert);
62
+ const update = _tappedCacheUpdate(_update);
63
+ const get = Effect.fn(
64
+ (id) => cache.get(cacheKey(id)).pipe(
65
+ Effect.flatMap(
66
+ (cached) => cached ? castData({ id, data: cached }) : Effect.fail(new CacheMissError())
67
+ ),
68
+ Effect.catchTag("CacheMissError", () => freshGet(id))
69
+ )
70
+ );
71
+ const siteConfig = {
72
+ /**
73
+ * Retrieves the site configuration.
74
+ *
75
+ * @returns An effect that yields the site configuration entry or undefined if not found, or a database error.
76
+ */
77
+ get: () => get(SiteConfigId),
78
+ /**
79
+ * Updates the site configuration.
80
+ *
81
+ * @param data - The new site configuration data to store.
82
+ * @returns An effect that yields the updated site configuration entry or a database error.
83
+ */
84
+ update: (data) => update(SiteConfigId, {
85
+ ...data,
86
+ _config_version: SiteConfigVersion
87
+ }),
88
+ /**
89
+ * Initializes the site configuration.
90
+ *
91
+ * @param data - The site configuration data to store.
92
+ * @returns An effect that yields the created site configuration entry or a database error.
93
+ */
94
+ init: (data) => create(SiteConfigId, {
95
+ ...data,
96
+ _config_version: SiteConfigVersion
97
+ })
98
+ };
99
+ const mailerConfig = {
100
+ /**
101
+ * Retrieves the mailer configuration.
102
+ *
103
+ * @returns An effect that yields the mailer configuration entry or undefined if not found, or a database error.
104
+ */
105
+ get: () => get(MailerConfigId),
106
+ /**
107
+ * Updates the mailer configuration.
108
+ *
109
+ * @param data - The new mailer configuration data to store.
110
+ * @returns An effect that yields the updated mailer configuration entry or a database error.
111
+ */
112
+ update: (data) => update(MailerConfigId, {
113
+ ...data,
114
+ _config_version: MailerConfigVersion
115
+ }),
116
+ /**
117
+ * Initializes the mailer configuration.
118
+ *
119
+ * @param data - The mailer configuration data to store.
120
+ * @returns An effect that yields the created mailer configuration entry or a database error.
121
+ */
122
+ init: (data) => create(MailerConfigId, {
123
+ ...data,
124
+ _config_version: MailerConfigVersion
125
+ })
126
+ };
127
+ const notificationConfig = {
128
+ /**
129
+ * Retrieves the notification settings configuration.
130
+ *
131
+ * @returns An effect that yields the notification settings configuration entry or undefined if not found, or a database error.
132
+ */
133
+ get: () => get(NotificationSettingsId),
134
+ /**
135
+ * Updates the notification settings configuration.
136
+ *
137
+ * @param data - The new notification settings configuration data to store.
138
+ * @returns An effect that yields the updated notification settings configuration entry or a database error.
139
+ */
140
+ update: (data) => update(NotificationSettingsId, {
141
+ ...data,
142
+ _config_version: NotificationSettingsVersion
143
+ }),
144
+ /**
145
+ * Initializes the notification settings configuration.
146
+ *
147
+ * @param data - The notification settings configuration data to store.
148
+ * @returns An effect that yields the created notification settings configuration entry or a database error.
149
+ */
150
+ init: (data) => create(NotificationSettingsId, {
151
+ ...data,
152
+ _config_version: NotificationSettingsVersion
153
+ })
154
+ };
155
+ const templateConfig = {
156
+ /**
157
+ * Retrieves the template configuration.
158
+ *
159
+ * @returns An effect that yields the template configuration entry or undefined if not found, or a database error.
160
+ */
161
+ get: () => get(TemplateConfigId),
162
+ /**
163
+ * Updates the template configuration by merging with existing data.
164
+ *
165
+ * @param data - The new template configuration data to merge and store.
166
+ * @returns An effect that yields the updated template configuration entry or a database error.
167
+ */
168
+ update: (data) => Effect.gen(function* () {
169
+ const currentData = yield* get(TemplateConfigId);
170
+ if (!currentData) {
171
+ const updatedData2 = yield* merge((m) => m(defaultTemplates, data));
172
+ return yield* create(TemplateConfigId, {
173
+ ...updatedData2,
174
+ _config_version: TemplateConfigVersion
175
+ });
176
+ }
177
+ const updatedData = yield* merge((m) => m(currentData.data, data));
178
+ return yield* update(TemplateConfigId, {
179
+ ...updatedData,
180
+ _config_version: TemplateConfigVersion
181
+ });
182
+ }),
183
+ /**
184
+ * Initializes the template configuration.
185
+ *
186
+ * @param data - The template configuration data to store.
187
+ * @returns An effect that yields the created template configuration entry or a database error.
188
+ */
189
+ init: (data) => create(TemplateConfigId, {
190
+ ...data,
191
+ _config_version: TemplateConfigVersion
192
+ })
193
+ };
194
+ return {
195
+ siteConfig,
196
+ mailerConfig,
197
+ notificationConfig,
198
+ templateConfig
199
+ };
200
+ });
201
+ var config_default = SDKConfigModule;
202
+ export {
203
+ SDKConfigModule,
204
+ config_default as default
205
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Default email templates for various mailer scenarios.
3
+ */
4
+ export declare const defaultTemplates: {
5
+ /**
6
+ * A simple HTML template for general notifications.
7
+ *
8
+ * Variables:
9
+ * - `data.title`: The title of the notification.
10
+ * - `data.message`: The message content of the notification.
11
+ */
12
+ readonly notifications: "<!doctype html>\n<html>\n <body>\n <div\n style='background-color:#F2F5F7;color:#242424;font-family:\"Helvetica Neue\", \"Arial Nova\", \"Nimbus Sans\", Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'\n >\n <table\n align=\"center\"\n width=\"100%\"\n style=\"margin:0 auto;max-width:600px;background-color:#FFFFFF\"\n role=\"presentation\"\n cellspacing=\"0\"\n cellpadding=\"0\"\n border=\"0\"\n >\n <tbody>\n <tr style=\"width:100%\">\n <td>\n <h3\n style=\"font-weight:bold;text-align:left;margin:0;font-size:20px;padding:32px 24px 0px 24px\"\n >\n {{data.title}}\n </h3>\n <div\n style=\"color:#474849;font-size:14px;font-weight:normal;text-align:left;padding:8px 24px 16px 24px\"\n >\n {{data.message}}\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </body>\n</html>";
13
+ /**
14
+ * A simple HTML template for password reset emails.
15
+ *
16
+ * Variables:
17
+ * - `data.link`: The password reset link.
18
+ */
19
+ readonly passwordReset: "<!doctype html>\n<html>\n <body>\n <div\n style='background-color:#F2F5F7;color:#242424;font-family:\"Helvetica Neue\", \"Arial Nova\", \"Nimbus Sans\", Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'\n >\n <table\n align=\"center\"\n width=\"100%\"\n style=\"margin:0 auto;max-width:600px;background-color:#FFFFFF\"\n role=\"presentation\"\n cellspacing=\"0\"\n cellpadding=\"0\"\n border=\"0\"\n >\n <tbody>\n <tr style=\"width:100%\">\n <td>\n <h3\n style=\"font-weight:bold;text-align:left;margin:0;font-size:20px;padding:32px 24px 0px 24px\"\n >\n Reset Your Password\n </h3>\n <div\n style=\"color:#474849;font-size:14px;font-weight:normal;text-align:left;padding:8px 24px 16px 24px\"\n >\n Click the button below, or copy-paste the link to reset your password!\n <br />\n <br />\n If you didn't request a password reset, you can ignore this email and\n your password will not be changed.\n </div>\n <div style=\"text-align:left;padding:12px 24px 32px 24px\">\n <a\n href=\"{{data.link}}\"\n style=\"color:#FFFFFF;font-size:14px;font-weight:bold;background-color:#0068FF;display:inline-block;padding:12px 20px;text-decoration:none\"\n target=\"_blank\"\n ><span>Reset Password</span></a\n >\n </div>\n <div\n style=\"font-size:12px;font-weight:normal;padding:16px 24px 16px 24px\"\n >\n Link: {{data.link}}\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </body>\n</html>";
20
+ /**
21
+ * A simple HTML template for user invite emails.
22
+ *
23
+ * Variables:
24
+ * - `site.title`: The title of the inviting organization or application.
25
+ * - `data.link`: The link for the user to set their password and get started.
26
+ */
27
+ readonly userInvite: "<!doctype html>\n<html>\n <body>\n <div\n style='background-color:#F2F5F7;color:#242424;font-family:\"Helvetica Neue\", \"Arial Nova\", \"Nimbus Sans\", Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'\n >\n <table\n align=\"center\"\n width=\"100%\"\n style=\"margin:0 auto;max-width:600px;background-color:#FFFFFF\"\n role=\"presentation\"\n cellspacing=\"0\"\n cellpadding=\"0\"\n border=\"0\"\n >\n <tbody>\n <tr style=\"width:100%\">\n <td>\n <h3\n style=\"font-weight:bold;text-align:left;margin:0;font-size:20px;padding:32px 24px 0px 24px\"\n >\n New User Invite from {{site.title}}\n </h3>\n <div\n style=\"color:#474849;font-size:14px;font-weight:normal;text-align:left;padding:8px 24px 16px 24px\"\n >\n You have been invited to join {{site.title}}! Click the button below to set your password and get started.\n </div>\n <div style=\"text-align:left;padding:12px 24px 32px 24px\">\n <a\n href=\"{{data.link}}\"\n style=\"color:#FFFFFF;font-size:14px;font-weight:bold;background-color:#0068FF;display:inline-block;padding:12px 20px;text-decoration:none\"\n target=\"_blank\"\n ><span>Set Password</span\n ></a\n >\n </div>\n <div\n style=\"font-size:12px;font-weight:normal;padding:16px 24px 16px 24px\"\n >\n Link: {{data.link}}\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </body>\n</html>";
28
+ /**
29
+ * A simple HTML template for email verification.
30
+ *
31
+ * Variables:
32
+ * - `data.link`: The email verification link.
33
+ */
34
+ readonly verifyEmail: "<!doctype html>\n<html>\n <body>\n <div\n style='background-color:#F2F5F7;color:#242424;font-family:\"Helvetica Neue\", \"Arial Nova\", \"Nimbus Sans\", Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'\n >\n <table\n align=\"center\"\n width=\"100%\"\n style=\"margin:0 auto;max-width:600px;background-color:#FFFFFF\"\n role=\"presentation\"\n cellspacing=\"0\"\n cellpadding=\"0\"\n border=\"0\"\n >\n <tbody>\n <tr style=\"width:100%\">\n <td>\n <h3\n style=\"font-weight:bold;text-align:left;margin:0;font-size:20px;padding:32px 24px 0px 24px\"\n >\n Verify your Email\n </h3>\n <div\n style=\"color:#474849;font-size:14px;font-weight:normal;text-align:left;padding:8px 24px 16px 24px\"\n >\n Click the button below, or copy-paste the link to verify your\n email!\n </div>\n <div style=\"text-align:left;padding:12px 24px 32px 24px\">\n <a\n href=\"{{data.link}}\"\n style=\"color:#FFFFFF;font-size:14px;font-weight:bold;background-color:#0068FF;display:inline-block;padding:12px 20px;text-decoration:none\"\n target=\"_blank\"\n ><span>Verify Email</span></a\n >\n </div>\n <div\n style=\"font-size:12px;font-weight:normal;padding:16px 24px 16px 24px\"\n >\n Link: {{data.link}}\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </body>\n</html>";
35
+ };
36
+ export default defaultTemplates;
@@ -0,0 +1,218 @@
1
+ const defaultTemplates = {
2
+ /**
3
+ * A simple HTML template for general notifications.
4
+ *
5
+ * Variables:
6
+ * - `data.title`: The title of the notification.
7
+ * - `data.message`: The message content of the notification.
8
+ */
9
+ notifications: `<!doctype html>
10
+ <html>
11
+ <body>
12
+ <div
13
+ style='background-color:#F2F5F7;color:#242424;font-family:"Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'
14
+ >
15
+ <table
16
+ align="center"
17
+ width="100%"
18
+ style="margin:0 auto;max-width:600px;background-color:#FFFFFF"
19
+ role="presentation"
20
+ cellspacing="0"
21
+ cellpadding="0"
22
+ border="0"
23
+ >
24
+ <tbody>
25
+ <tr style="width:100%">
26
+ <td>
27
+ <h3
28
+ style="font-weight:bold;text-align:left;margin:0;font-size:20px;padding:32px 24px 0px 24px"
29
+ >
30
+ {{data.title}}
31
+ </h3>
32
+ <div
33
+ style="color:#474849;font-size:14px;font-weight:normal;text-align:left;padding:8px 24px 16px 24px"
34
+ >
35
+ {{data.message}}
36
+ </div>
37
+ </td>
38
+ </tr>
39
+ </tbody>
40
+ </table>
41
+ </div>
42
+ </body>
43
+ </html>`,
44
+ /**
45
+ * A simple HTML template for password reset emails.
46
+ *
47
+ * Variables:
48
+ * - `data.link`: The password reset link.
49
+ */
50
+ passwordReset: `<!doctype html>
51
+ <html>
52
+ <body>
53
+ <div
54
+ style='background-color:#F2F5F7;color:#242424;font-family:"Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'
55
+ >
56
+ <table
57
+ align="center"
58
+ width="100%"
59
+ style="margin:0 auto;max-width:600px;background-color:#FFFFFF"
60
+ role="presentation"
61
+ cellspacing="0"
62
+ cellpadding="0"
63
+ border="0"
64
+ >
65
+ <tbody>
66
+ <tr style="width:100%">
67
+ <td>
68
+ <h3
69
+ style="font-weight:bold;text-align:left;margin:0;font-size:20px;padding:32px 24px 0px 24px"
70
+ >
71
+ Reset Your Password
72
+ </h3>
73
+ <div
74
+ style="color:#474849;font-size:14px;font-weight:normal;text-align:left;padding:8px 24px 16px 24px"
75
+ >
76
+ Click the button below, or copy-paste the link to reset your password!
77
+ <br />
78
+ <br />
79
+ If you didn't request a password reset, you can ignore this email and
80
+ your password will not be changed.
81
+ </div>
82
+ <div style="text-align:left;padding:12px 24px 32px 24px">
83
+ <a
84
+ href="{{data.link}}"
85
+ style="color:#FFFFFF;font-size:14px;font-weight:bold;background-color:#0068FF;display:inline-block;padding:12px 20px;text-decoration:none"
86
+ target="_blank"
87
+ ><span>Reset Password</span></a
88
+ >
89
+ </div>
90
+ <div
91
+ style="font-size:12px;font-weight:normal;padding:16px 24px 16px 24px"
92
+ >
93
+ Link: {{data.link}}
94
+ </div>
95
+ </td>
96
+ </tr>
97
+ </tbody>
98
+ </table>
99
+ </div>
100
+ </body>
101
+ </html>`,
102
+ /**
103
+ * A simple HTML template for user invite emails.
104
+ *
105
+ * Variables:
106
+ * - `site.title`: The title of the inviting organization or application.
107
+ * - `data.link`: The link for the user to set their password and get started.
108
+ */
109
+ userInvite: `<!doctype html>
110
+ <html>
111
+ <body>
112
+ <div
113
+ style='background-color:#F2F5F7;color:#242424;font-family:"Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'
114
+ >
115
+ <table
116
+ align="center"
117
+ width="100%"
118
+ style="margin:0 auto;max-width:600px;background-color:#FFFFFF"
119
+ role="presentation"
120
+ cellspacing="0"
121
+ cellpadding="0"
122
+ border="0"
123
+ >
124
+ <tbody>
125
+ <tr style="width:100%">
126
+ <td>
127
+ <h3
128
+ style="font-weight:bold;text-align:left;margin:0;font-size:20px;padding:32px 24px 0px 24px"
129
+ >
130
+ New User Invite from {{site.title}}
131
+ </h3>
132
+ <div
133
+ style="color:#474849;font-size:14px;font-weight:normal;text-align:left;padding:8px 24px 16px 24px"
134
+ >
135
+ You have been invited to join {{site.title}}! Click the button below to set your password and get started.
136
+ </div>
137
+ <div style="text-align:left;padding:12px 24px 32px 24px">
138
+ <a
139
+ href="{{data.link}}"
140
+ style="color:#FFFFFF;font-size:14px;font-weight:bold;background-color:#0068FF;display:inline-block;padding:12px 20px;text-decoration:none"
141
+ target="_blank"
142
+ ><span>Set Password</span
143
+ ></a
144
+ >
145
+ </div>
146
+ <div
147
+ style="font-size:12px;font-weight:normal;padding:16px 24px 16px 24px"
148
+ >
149
+ Link: {{data.link}}
150
+ </div>
151
+ </td>
152
+ </tr>
153
+ </tbody>
154
+ </table>
155
+ </div>
156
+ </body>
157
+ </html>`,
158
+ /**
159
+ * A simple HTML template for email verification.
160
+ *
161
+ * Variables:
162
+ * - `data.link`: The email verification link.
163
+ */
164
+ verifyEmail: `<!doctype html>
165
+ <html>
166
+ <body>
167
+ <div
168
+ style='background-color:#F2F5F7;color:#242424;font-family:"Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0.15008px;line-height:1.5;margin:0;padding:32px 0;min-height:100%;width:100%'
169
+ >
170
+ <table
171
+ align="center"
172
+ width="100%"
173
+ style="margin:0 auto;max-width:600px;background-color:#FFFFFF"
174
+ role="presentation"
175
+ cellspacing="0"
176
+ cellpadding="0"
177
+ border="0"
178
+ >
179
+ <tbody>
180
+ <tr style="width:100%">
181
+ <td>
182
+ <h3
183
+ style="font-weight:bold;text-align:left;margin:0;font-size:20px;padding:32px 24px 0px 24px"
184
+ >
185
+ Verify your Email
186
+ </h3>
187
+ <div
188
+ style="color:#474849;font-size:14px;font-weight:normal;text-align:left;padding:8px 24px 16px 24px"
189
+ >
190
+ Click the button below, or copy-paste the link to verify your
191
+ email!
192
+ </div>
193
+ <div style="text-align:left;padding:12px 24px 32px 24px">
194
+ <a
195
+ href="{{data.link}}"
196
+ style="color:#FFFFFF;font-size:14px;font-weight:bold;background-color:#0068FF;display:inline-block;padding:12px 20px;text-decoration:none"
197
+ target="_blank"
198
+ ><span>Verify Email</span></a
199
+ >
200
+ </div>
201
+ <div
202
+ style="font-size:12px;font-weight:normal;padding:16px 24px 16px 24px"
203
+ >
204
+ Link: {{data.link}}
205
+ </div>
206
+ </td>
207
+ </tr>
208
+ </tbody>
209
+ </table>
210
+ </div>
211
+ </body>
212
+ </html>`
213
+ };
214
+ var mailer_default = defaultTemplates;
215
+ export {
216
+ mailer_default as default,
217
+ defaultTemplates
218
+ };
@@ -0,0 +1,13 @@
1
+ import { Effect } from '@withstudiocms/effect';
2
+ import type { DynamicConfigEntry } from '../../types.js';
3
+ /**
4
+ * Casts the given id and data into a DynamicConfigEntry.
5
+ *
6
+ * @template T - The type of the data in the configuration entry.
7
+ * @param param0 - An object containing the id and data.
8
+ * @returns An effect that yields a DynamicConfigEntry with the given id and data.
9
+ */
10
+ export declare const castData: <T>({ id, data, }: {
11
+ id: string;
12
+ data: T;
13
+ }) => Effect.Effect<DynamicConfigEntry<T>>;
@@ -0,0 +1,11 @@
1
+ import { Effect } from "@withstudiocms/effect";
2
+ const castData = ({
3
+ id,
4
+ data
5
+ }) => Effect.succeed({
6
+ id,
7
+ data
8
+ });
9
+ export {
10
+ castData
11
+ };
@@ -0,0 +1,140 @@
1
+ import { Effect } from '@withstudiocms/effect';
2
+ import { DBClientLive, SDKDefaults } from '../../context.js';
3
+ /**
4
+ * SDKDeleteModule
5
+ *
6
+ * Effect generator that builds and returns the Delete API for the StudioCMS SDK.
7
+ *
8
+ * This module wires together low-level database delete operations, input validation
9
+ * (via encoders), cache clearing and higher-level helpers to provide a cohesive
10
+ * deletion surface for pages, page content, tags, categories, permissions, diff
11
+ * tracking, folders and users.
12
+ *
13
+ * Remarks
14
+ * - All low-level DB deletes are wrapped with a validation encoder (withEncoder)
15
+ * and execute the underlying query using executeTakeFirstOrThrow; absent rows
16
+ * will surface as errors which are handled by the module's error pipeline.
17
+ * - High-level helpers compose these low-level operations into meaningful flows:
18
+ * - Page deletion clears diff tracking, page content and page data, then clears relevant caches.
19
+ * - Folder deletion triggers subsequent updates to folder list and folder tree views.
20
+ * - User deletion clears user references and prevents deletion of the platform
21
+ * "ghost" (internal) user.
22
+ * - The module uses a shared error handler (_handleErrors) to normalize errors into
23
+ * DeletionResponse values where possible.
24
+ *
25
+ * Error handling
26
+ * - DB-level errors (not found / constraint failures) thrown by executeTakeFirstOrThrow
27
+ * are propagated into the module's error-handling pipeline and converted into
28
+ * DeletionResponse values by _handleErrors.
29
+ * - Ghost user protection surfaces a GhostUserError that is caught and turned into
30
+ * an appropriate DeletionResponse explaining that the internal user cannot be deleted.
31
+ * - Folder update failures are specially caught and returned with an explanatory message.
32
+ *
33
+ * Side effects
34
+ * - Cache/derived-data clearing routines are invoked where appropriate (e.g. page cache
35
+ * clearing after deleting page content).
36
+ * - Folder deletion triggers background updates to folder list and folder tree.
37
+ *
38
+ * Returns
39
+ * - An Effect that, when executed, yields an object containing the DELETE API
40
+ * described above. Each method itself is an Effect producing a DeletionResponse
41
+ * describing success or a mapped error.
42
+ *
43
+ * Example
44
+ * - const deleteModule = yield* SDKDeleteModule;
45
+ * - yield* deleteModule.page('page-id-123') // returns a DeletionResponse effect
46
+ */
47
+ export declare const SDKDeleteModule: Effect.Effect<{
48
+ /**
49
+ * Deletes a page by its ID.
50
+ *
51
+ * @param id - The ID of the page to delete.
52
+ * @returns An effect that resolves to a success or error message.
53
+ */
54
+ page: (id: string) => Effect.Effect<{
55
+ status: "success" | "error";
56
+ message: string;
57
+ }, never, never>;
58
+ /**
59
+ * Deletes page content by its ID.
60
+ *
61
+ * @param id - The ID of the page content to delete.
62
+ * @returns An effect that resolves to a success or error message.
63
+ */
64
+ pageContent: (id: string) => Effect.Effect<{
65
+ status: "success" | "error";
66
+ message: string;
67
+ }, never, never>;
68
+ /**
69
+ * Deletes page content for a specific language by its ID and language.
70
+ *
71
+ * @param id - The ID of the page content to delete.
72
+ * @param lang - The language of the page content to delete.
73
+ * @returns An effect that resolves to a success or error message.
74
+ */
75
+ pageContentLang: (id: string, lang: string) => Effect.Effect<{
76
+ status: "success" | "error";
77
+ message: string;
78
+ }, never, never>;
79
+ /**
80
+ * Deletes a tag by its ID.
81
+ *
82
+ * @param id - The ID of the tag to delete.
83
+ * @returns An effect that resolves to a success or error message.
84
+ */
85
+ tags: (id: number) => Effect.Effect<{
86
+ status: "success" | "error";
87
+ message: string;
88
+ }, never, never>;
89
+ /**
90
+ * Deletes a category by its ID.
91
+ *
92
+ * @param id - The ID of the category to delete.
93
+ * @returns An effect that resolves to a success or error message.
94
+ */
95
+ categories: (id: number) => Effect.Effect<{
96
+ status: "success" | "error";
97
+ message: string;
98
+ }, never, never>;
99
+ /**
100
+ * Deletes permissions for a specific user by their ID.
101
+ *
102
+ * @param userId - The ID of the user whose permissions to delete.
103
+ * @returns An effect that resolves to a success or error message.
104
+ */
105
+ permissions: (userId: string) => Effect.Effect<{
106
+ status: "success" | "error";
107
+ message: string;
108
+ }, never, never>;
109
+ /**
110
+ * Deletes diff tracking entry by diff ID.
111
+ *
112
+ * @param id - The ID of the diff tracking entry to be deleted.
113
+ * @returns An effect that represents the deletion operation.
114
+ */
115
+ diffTracking: (id: string) => Effect.Effect<{
116
+ status: "success" | "error";
117
+ message: string;
118
+ }, never, never>;
119
+ /**
120
+ * Deletes a folder by its ID.
121
+ *
122
+ * @param folderId - The ID of the folder to delete.
123
+ * @returns An effect that resolves to a success or error message.
124
+ */
125
+ folder: (folderId: string) => Effect.Effect<{
126
+ status: "success" | "error";
127
+ message: string;
128
+ }, never, never>;
129
+ /**
130
+ * Deletes a user by their ID.
131
+ *
132
+ * @param userId - The ID of the user to delete.
133
+ * @returns An effect that resolves to a success or error message.
134
+ */
135
+ user: (userId: string) => Effect.Effect<{
136
+ status: "success" | "error";
137
+ message: string;
138
+ }, never, never>;
139
+ }, never, DBClientLive | SDKDefaults | import("../../cache.js").CacheService | import("@withstudiocms/effect").Deepmerge>;
140
+ export default SDKDeleteModule;