@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,100 @@
|
|
|
1
|
+
import { Deepmerge, Effect } from '@withstudiocms/effect';
|
|
2
|
+
import type { DBCallbackFailure } from '@withstudiocms/kysely/client';
|
|
3
|
+
import type { DatabaseError } from '@withstudiocms/kysely/core/errors';
|
|
4
|
+
import { CacheService } from '../../cache.js';
|
|
5
|
+
import { DBClientLive, StorageManagerResolver } from '../../context.js';
|
|
6
|
+
import type { ConfigFinal, DynamicConfigEntry, StudioCMSMailerConfig, StudioCMSNotificationSettings, StudioCMSSiteConfig, StudioCMSTemplateConfig } from '../../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* StudioCMS Configuration Modules
|
|
9
|
+
*/
|
|
10
|
+
export declare const SDKConfigModule: Effect.Effect<{
|
|
11
|
+
siteConfig: {
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the site configuration.
|
|
14
|
+
*
|
|
15
|
+
* @returns An effect that yields the site configuration entry or undefined if not found, or a database error.
|
|
16
|
+
*/
|
|
17
|
+
get: <T extends StudioCMSSiteConfig>() => Effect.Effect<DynamicConfigEntry<T> | undefined, import("effect/Cause").UnknownException | DBCallbackFailure | DatabaseError, never>;
|
|
18
|
+
/**
|
|
19
|
+
* Updates the site configuration.
|
|
20
|
+
*
|
|
21
|
+
* @param data - The new site configuration data to store.
|
|
22
|
+
* @returns An effect that yields the updated site configuration entry or a database error.
|
|
23
|
+
*/
|
|
24
|
+
update: (data: ConfigFinal<StudioCMSSiteConfig>) => Effect.Effect<DynamicConfigEntry<StudioCMSSiteConfig>, DBCallbackFailure | DatabaseError, never>;
|
|
25
|
+
/**
|
|
26
|
+
* Initializes the site configuration.
|
|
27
|
+
*
|
|
28
|
+
* @param data - The site configuration data to store.
|
|
29
|
+
* @returns An effect that yields the created site configuration entry or a database error.
|
|
30
|
+
*/
|
|
31
|
+
init: (data: ConfigFinal<StudioCMSSiteConfig>) => Effect.Effect<DynamicConfigEntry<StudioCMSSiteConfig>, DBCallbackFailure | DatabaseError, never>;
|
|
32
|
+
};
|
|
33
|
+
mailerConfig: {
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves the mailer configuration.
|
|
36
|
+
*
|
|
37
|
+
* @returns An effect that yields the mailer configuration entry or undefined if not found, or a database error.
|
|
38
|
+
*/
|
|
39
|
+
get: () => Effect.Effect<DynamicConfigEntry<StudioCMSMailerConfig> | undefined, DBCallbackFailure | DatabaseError, never>;
|
|
40
|
+
/**
|
|
41
|
+
* Updates the mailer configuration.
|
|
42
|
+
*
|
|
43
|
+
* @param data - The new mailer configuration data to store.
|
|
44
|
+
* @returns An effect that yields the updated mailer configuration entry or a database error.
|
|
45
|
+
*/
|
|
46
|
+
update: (data: ConfigFinal<StudioCMSMailerConfig>) => Effect.Effect<DynamicConfigEntry<StudioCMSMailerConfig>, DBCallbackFailure | DatabaseError, never>;
|
|
47
|
+
/**
|
|
48
|
+
* Initializes the mailer configuration.
|
|
49
|
+
*
|
|
50
|
+
* @param data - The mailer configuration data to store.
|
|
51
|
+
* @returns An effect that yields the created mailer configuration entry or a database error.
|
|
52
|
+
*/
|
|
53
|
+
init: (data: ConfigFinal<StudioCMSMailerConfig>) => Effect.Effect<DynamicConfigEntry<StudioCMSMailerConfig>, DBCallbackFailure | DatabaseError, never>;
|
|
54
|
+
};
|
|
55
|
+
notificationConfig: {
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves the notification settings configuration.
|
|
58
|
+
*
|
|
59
|
+
* @returns An effect that yields the notification settings configuration entry or undefined if not found, or a database error.
|
|
60
|
+
*/
|
|
61
|
+
get: () => Effect.Effect<DynamicConfigEntry<StudioCMSNotificationSettings> | undefined, DBCallbackFailure | DatabaseError, never>;
|
|
62
|
+
/**
|
|
63
|
+
* Updates the notification settings configuration.
|
|
64
|
+
*
|
|
65
|
+
* @param data - The new notification settings configuration data to store.
|
|
66
|
+
* @returns An effect that yields the updated notification settings configuration entry or a database error.
|
|
67
|
+
*/
|
|
68
|
+
update: (data: ConfigFinal<StudioCMSNotificationSettings>) => Effect.Effect<DynamicConfigEntry<StudioCMSNotificationSettings>, DBCallbackFailure | DatabaseError, never>;
|
|
69
|
+
/**
|
|
70
|
+
* Initializes the notification settings configuration.
|
|
71
|
+
*
|
|
72
|
+
* @param data - The notification settings configuration data to store.
|
|
73
|
+
* @returns An effect that yields the created notification settings configuration entry or a database error.
|
|
74
|
+
*/
|
|
75
|
+
init: (data: ConfigFinal<StudioCMSNotificationSettings>) => Effect.Effect<DynamicConfigEntry<StudioCMSNotificationSettings>, DBCallbackFailure | DatabaseError, never>;
|
|
76
|
+
};
|
|
77
|
+
templateConfig: {
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the template configuration.
|
|
80
|
+
*
|
|
81
|
+
* @returns An effect that yields the template configuration entry or undefined if not found, or a database error.
|
|
82
|
+
*/
|
|
83
|
+
get: () => Effect.Effect<DynamicConfigEntry<StudioCMSTemplateConfig> | undefined, DBCallbackFailure | DatabaseError, never>;
|
|
84
|
+
/**
|
|
85
|
+
* Updates the template configuration by merging with existing data.
|
|
86
|
+
*
|
|
87
|
+
* @param data - The new template configuration data to merge and store.
|
|
88
|
+
* @returns An effect that yields the updated template configuration entry or a database error.
|
|
89
|
+
*/
|
|
90
|
+
update: (data: ConfigFinal<StudioCMSTemplateConfig>) => Effect.Effect<DynamicConfigEntry<StudioCMSTemplateConfig>, DBCallbackFailure | DatabaseError | import("@withstudiocms/effect").DeepmergeError, never>;
|
|
91
|
+
/**
|
|
92
|
+
* Initializes the template configuration.
|
|
93
|
+
*
|
|
94
|
+
* @param data - The template configuration data to store.
|
|
95
|
+
* @returns An effect that yields the created template configuration entry or a database error.
|
|
96
|
+
*/
|
|
97
|
+
init: (data: ConfigFinal<StudioCMSTemplateConfig>) => Effect.Effect<DynamicConfigEntry<StudioCMSTemplateConfig>, DBCallbackFailure | DatabaseError, never>;
|
|
98
|
+
};
|
|
99
|
+
}, never, DBClientLive | StorageManagerResolver | CacheService | Deepmerge>;
|
|
100
|
+
export default SDKConfigModule;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { Deepmerge, Effect, Schema } from "@withstudiocms/effect";
|
|
2
|
+
import { CacheMissError, CacheService } from "../../cache.js";
|
|
3
|
+
import { cacheKeyGetters, cacheTags } from "../../consts.js";
|
|
4
|
+
import { DBClientLive, StorageManagerResolver } from "../../context.js";
|
|
5
|
+
import { resolveStorageManagerUrls } from "../../lib/storage-manager.js";
|
|
6
|
+
import { StudioCMSDynamicConfigSettings } from "../../tables.js";
|
|
7
|
+
import {
|
|
8
|
+
MailerConfigId,
|
|
9
|
+
MailerConfigVersion,
|
|
10
|
+
NotificationSettingsId,
|
|
11
|
+
NotificationSettingsVersion,
|
|
12
|
+
SiteConfigId,
|
|
13
|
+
SiteConfigVersion,
|
|
14
|
+
TemplateConfigId,
|
|
15
|
+
TemplateConfigVersion
|
|
16
|
+
} from "./consts.js";
|
|
17
|
+
import defaultTemplates from "./templates/mailer.js";
|
|
18
|
+
import { castData } from "./type-utils.js";
|
|
19
|
+
const cacheKey = cacheKeyGetters.dynamicConfig;
|
|
20
|
+
const cacheOpts = { tags: cacheTags.dynamicConfig };
|
|
21
|
+
const SDKConfigModule = Effect.gen(function* () {
|
|
22
|
+
const [{ withCodec }, { merge }, cache, smResolver] = yield* Effect.all([
|
|
23
|
+
DBClientLive,
|
|
24
|
+
Deepmerge,
|
|
25
|
+
CacheService,
|
|
26
|
+
StorageManagerResolver
|
|
27
|
+
]);
|
|
28
|
+
const resolveUrls = resolveStorageManagerUrls(smResolver);
|
|
29
|
+
const resolveStorageManagerUrl = (attributes) => (obj) => resolveUrls(obj?.data, attributes).pipe(
|
|
30
|
+
Effect.map((data) => {
|
|
31
|
+
if (!data) return obj;
|
|
32
|
+
return { ...obj, data };
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
const _insert = withCodec({
|
|
36
|
+
decoder: StudioCMSDynamicConfigSettings.Select,
|
|
37
|
+
encoder: StudioCMSDynamicConfigSettings.Insert,
|
|
38
|
+
callbackFn: (db, data) => db(
|
|
39
|
+
(client) => client.transaction().execute(async (trx) => {
|
|
40
|
+
await trx.insertInto("StudioCMSDynamicConfigSettings").values(data).executeTakeFirstOrThrow();
|
|
41
|
+
return await trx.selectFrom("StudioCMSDynamicConfigSettings").selectAll().where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
42
|
+
})
|
|
43
|
+
)
|
|
44
|
+
});
|
|
45
|
+
const _select = withCodec({
|
|
46
|
+
decoder: Schema.UndefinedOr(StudioCMSDynamicConfigSettings.Select),
|
|
47
|
+
encoder: Schema.String,
|
|
48
|
+
callbackFn: (db, id) => db(
|
|
49
|
+
(client) => client.selectFrom("StudioCMSDynamicConfigSettings").selectAll().where("id", "=", id).executeTakeFirst()
|
|
50
|
+
)
|
|
51
|
+
});
|
|
52
|
+
const _update = withCodec({
|
|
53
|
+
decoder: StudioCMSDynamicConfigSettings.Select,
|
|
54
|
+
encoder: StudioCMSDynamicConfigSettings.Update,
|
|
55
|
+
callbackFn: (db, { id, data }) => db(
|
|
56
|
+
(client) => client.transaction().execute(async (trx) => {
|
|
57
|
+
await trx.updateTable("StudioCMSDynamicConfigSettings").set({ data }).where("id", "=", id).executeTakeFirstOrThrow();
|
|
58
|
+
return await trx.selectFrom("StudioCMSDynamicConfigSettings").selectAll().where("id", "=", id).executeTakeFirstOrThrow();
|
|
59
|
+
})
|
|
60
|
+
)
|
|
61
|
+
});
|
|
62
|
+
const _tappedCacheUpdate = (fn) => Effect.fn(
|
|
63
|
+
(id, data) => fn({ id, data: JSON.stringify(data) }).pipe(
|
|
64
|
+
Effect.tap(() => cache.set(cacheKey(id), data, cacheOpts))
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
const setAndReturn = (id, data) => Effect.gen(function* () {
|
|
68
|
+
yield* cache.set(cacheKey(id), data, cacheOpts);
|
|
69
|
+
return yield* castData({ id, data });
|
|
70
|
+
});
|
|
71
|
+
const freshGet = Effect.fn(function* (id) {
|
|
72
|
+
const uncached = yield* _select(id);
|
|
73
|
+
if (!uncached) return void 0;
|
|
74
|
+
return yield* setAndReturn(id, uncached.data);
|
|
75
|
+
});
|
|
76
|
+
const create = _tappedCacheUpdate(_insert);
|
|
77
|
+
const update = _tappedCacheUpdate(_update);
|
|
78
|
+
const get = Effect.fn(
|
|
79
|
+
(id) => cache.get(cacheKey(id)).pipe(
|
|
80
|
+
Effect.flatMap(
|
|
81
|
+
(cached) => cached ? castData({ id, data: cached }) : Effect.fail(new CacheMissError())
|
|
82
|
+
),
|
|
83
|
+
Effect.catchTag("CacheMissError", () => freshGet(id))
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
const siteConfig = {
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves the site configuration.
|
|
89
|
+
*
|
|
90
|
+
* @returns An effect that yields the site configuration entry or undefined if not found, or a database error.
|
|
91
|
+
*/
|
|
92
|
+
get: () => get(SiteConfigId).pipe(
|
|
93
|
+
Effect.flatMap(
|
|
94
|
+
resolveStorageManagerUrl(["siteIcon", "defaultOgImage", "loginPageCustomImage"])
|
|
95
|
+
)
|
|
96
|
+
),
|
|
97
|
+
/**
|
|
98
|
+
* Updates the site configuration.
|
|
99
|
+
*
|
|
100
|
+
* @param data - The new site configuration data to store.
|
|
101
|
+
* @returns An effect that yields the updated site configuration entry or a database error.
|
|
102
|
+
*/
|
|
103
|
+
update: (data) => update(SiteConfigId, {
|
|
104
|
+
...data,
|
|
105
|
+
_config_version: SiteConfigVersion
|
|
106
|
+
}),
|
|
107
|
+
/**
|
|
108
|
+
* Initializes the site configuration.
|
|
109
|
+
*
|
|
110
|
+
* @param data - The site configuration data to store.
|
|
111
|
+
* @returns An effect that yields the created site configuration entry or a database error.
|
|
112
|
+
*/
|
|
113
|
+
init: (data) => create(SiteConfigId, {
|
|
114
|
+
...data,
|
|
115
|
+
_config_version: SiteConfigVersion
|
|
116
|
+
})
|
|
117
|
+
};
|
|
118
|
+
const mailerConfig = {
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves the mailer configuration.
|
|
121
|
+
*
|
|
122
|
+
* @returns An effect that yields the mailer configuration entry or undefined if not found, or a database error.
|
|
123
|
+
*/
|
|
124
|
+
get: () => get(MailerConfigId),
|
|
125
|
+
/**
|
|
126
|
+
* Updates the mailer configuration.
|
|
127
|
+
*
|
|
128
|
+
* @param data - The new mailer configuration data to store.
|
|
129
|
+
* @returns An effect that yields the updated mailer configuration entry or a database error.
|
|
130
|
+
*/
|
|
131
|
+
update: (data) => update(MailerConfigId, {
|
|
132
|
+
...data,
|
|
133
|
+
_config_version: MailerConfigVersion
|
|
134
|
+
}),
|
|
135
|
+
/**
|
|
136
|
+
* Initializes the mailer configuration.
|
|
137
|
+
*
|
|
138
|
+
* @param data - The mailer configuration data to store.
|
|
139
|
+
* @returns An effect that yields the created mailer configuration entry or a database error.
|
|
140
|
+
*/
|
|
141
|
+
init: (data) => create(MailerConfigId, {
|
|
142
|
+
...data,
|
|
143
|
+
_config_version: MailerConfigVersion
|
|
144
|
+
})
|
|
145
|
+
};
|
|
146
|
+
const notificationConfig = {
|
|
147
|
+
/**
|
|
148
|
+
* Retrieves the notification settings configuration.
|
|
149
|
+
*
|
|
150
|
+
* @returns An effect that yields the notification settings configuration entry or undefined if not found, or a database error.
|
|
151
|
+
*/
|
|
152
|
+
get: () => get(NotificationSettingsId),
|
|
153
|
+
/**
|
|
154
|
+
* Updates the notification settings configuration.
|
|
155
|
+
*
|
|
156
|
+
* @param data - The new notification settings configuration data to store.
|
|
157
|
+
* @returns An effect that yields the updated notification settings configuration entry or a database error.
|
|
158
|
+
*/
|
|
159
|
+
update: (data) => update(NotificationSettingsId, {
|
|
160
|
+
...data,
|
|
161
|
+
_config_version: NotificationSettingsVersion
|
|
162
|
+
}),
|
|
163
|
+
/**
|
|
164
|
+
* Initializes the notification settings configuration.
|
|
165
|
+
*
|
|
166
|
+
* @param data - The notification settings configuration data to store.
|
|
167
|
+
* @returns An effect that yields the created notification settings configuration entry or a database error.
|
|
168
|
+
*/
|
|
169
|
+
init: (data) => create(NotificationSettingsId, {
|
|
170
|
+
...data,
|
|
171
|
+
_config_version: NotificationSettingsVersion
|
|
172
|
+
})
|
|
173
|
+
};
|
|
174
|
+
const templateConfig = {
|
|
175
|
+
/**
|
|
176
|
+
* Retrieves the template configuration.
|
|
177
|
+
*
|
|
178
|
+
* @returns An effect that yields the template configuration entry or undefined if not found, or a database error.
|
|
179
|
+
*/
|
|
180
|
+
get: () => get(TemplateConfigId),
|
|
181
|
+
/**
|
|
182
|
+
* Updates the template configuration by merging with existing data.
|
|
183
|
+
*
|
|
184
|
+
* @param data - The new template configuration data to merge and store.
|
|
185
|
+
* @returns An effect that yields the updated template configuration entry or a database error.
|
|
186
|
+
*/
|
|
187
|
+
update: (data) => Effect.gen(function* () {
|
|
188
|
+
const currentData = yield* get(TemplateConfigId);
|
|
189
|
+
if (!currentData) {
|
|
190
|
+
const updatedData2 = yield* merge((m) => m(defaultTemplates, data));
|
|
191
|
+
return yield* create(TemplateConfigId, {
|
|
192
|
+
...updatedData2,
|
|
193
|
+
_config_version: TemplateConfigVersion
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const updatedData = yield* merge((m) => m(currentData.data, data));
|
|
197
|
+
return yield* update(TemplateConfigId, {
|
|
198
|
+
...updatedData,
|
|
199
|
+
_config_version: TemplateConfigVersion
|
|
200
|
+
});
|
|
201
|
+
}),
|
|
202
|
+
/**
|
|
203
|
+
* Initializes the template configuration.
|
|
204
|
+
*
|
|
205
|
+
* @param data - The template configuration data to store.
|
|
206
|
+
* @returns An effect that yields the created template configuration entry or a database error.
|
|
207
|
+
*/
|
|
208
|
+
init: (data) => create(TemplateConfigId, {
|
|
209
|
+
...data,
|
|
210
|
+
_config_version: TemplateConfigVersion
|
|
211
|
+
})
|
|
212
|
+
};
|
|
213
|
+
return {
|
|
214
|
+
siteConfig,
|
|
215
|
+
mailerConfig,
|
|
216
|
+
notificationConfig,
|
|
217
|
+
templateConfig
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
var config_default = SDKConfigModule;
|
|
221
|
+
export {
|
|
222
|
+
SDKConfigModule,
|
|
223
|
+
config_default as default
|
|
224
|
+
};
|
|
@@ -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>>;
|