@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,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from '@withstudiocms/effect';
|
|
2
|
-
import { StudioCMSPageContent, StudioCMSPageData } from '@withstudiocms/kysely';
|
|
3
2
|
import CacheService from '../../cache.js';
|
|
4
3
|
import { DBClientLive } from '../../context.js';
|
|
4
|
+
import { StudioCMSPageContent, StudioCMSPageData } from '../../tables.js';
|
|
5
5
|
/**
|
|
6
6
|
* CombinedPageUpdateData
|
|
7
7
|
*
|
|
@@ -67,15 +67,15 @@ export declare const SDKUpdateModule: Effect.Effect<{
|
|
|
67
67
|
*/
|
|
68
68
|
pageContent: (input: {
|
|
69
69
|
readonly id: string;
|
|
70
|
-
readonly contentId: string;
|
|
71
70
|
readonly contentLang: string;
|
|
71
|
+
readonly contentId: string;
|
|
72
72
|
readonly content: string;
|
|
73
73
|
}) => Effect.Effect<{
|
|
74
74
|
readonly id: string;
|
|
75
|
-
readonly contentId: string;
|
|
76
75
|
readonly contentLang: string;
|
|
76
|
+
readonly contentId: string;
|
|
77
77
|
readonly content: string;
|
|
78
|
-
}, import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
78
|
+
}, import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
79
79
|
/**
|
|
80
80
|
* Update Tag
|
|
81
81
|
*
|
|
@@ -83,20 +83,20 @@ export declare const SDKUpdateModule: Effect.Effect<{
|
|
|
83
83
|
* @returns The updated tag.
|
|
84
84
|
*/
|
|
85
85
|
tags: (input: {
|
|
86
|
-
readonly name: string;
|
|
87
86
|
readonly id: number;
|
|
87
|
+
readonly name: string;
|
|
88
88
|
readonly description: string;
|
|
89
89
|
readonly slug: string;
|
|
90
90
|
readonly meta: string;
|
|
91
91
|
}) => Effect.Effect<{
|
|
92
|
-
readonly name: string;
|
|
93
92
|
readonly id: number;
|
|
93
|
+
readonly name: string;
|
|
94
94
|
readonly description: string;
|
|
95
95
|
readonly slug: string;
|
|
96
96
|
readonly meta: {
|
|
97
97
|
readonly [x: string]: unknown;
|
|
98
98
|
};
|
|
99
|
-
}, import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
99
|
+
}, import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
100
100
|
/**
|
|
101
101
|
* Update Category
|
|
102
102
|
*
|
|
@@ -104,22 +104,22 @@ export declare const SDKUpdateModule: Effect.Effect<{
|
|
|
104
104
|
* @returns The updated category.
|
|
105
105
|
*/
|
|
106
106
|
categories: (input: {
|
|
107
|
-
readonly parent?: number | null | undefined;
|
|
108
|
-
readonly name: string;
|
|
109
107
|
readonly id: number;
|
|
108
|
+
readonly name: string;
|
|
110
109
|
readonly description: string;
|
|
110
|
+
readonly parent?: number | null | undefined;
|
|
111
111
|
readonly slug: string;
|
|
112
112
|
readonly meta: string;
|
|
113
113
|
}) => Effect.Effect<{
|
|
114
|
-
readonly name: string;
|
|
115
114
|
readonly id: number;
|
|
116
|
-
readonly
|
|
115
|
+
readonly name: string;
|
|
117
116
|
readonly description: string;
|
|
117
|
+
readonly parent?: number | null | undefined;
|
|
118
118
|
readonly slug: string;
|
|
119
119
|
readonly meta: {
|
|
120
120
|
readonly [x: string]: unknown;
|
|
121
121
|
};
|
|
122
|
-
}, import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
122
|
+
}, import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
123
123
|
/**
|
|
124
124
|
* Update Permissions
|
|
125
125
|
*
|
|
@@ -132,15 +132,15 @@ export declare const SDKUpdateModule: Effect.Effect<{
|
|
|
132
132
|
}) => Effect.Effect<{
|
|
133
133
|
readonly user: string;
|
|
134
134
|
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
|
|
135
|
-
}, import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
135
|
+
}, import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
136
136
|
/**
|
|
137
137
|
* Update Folder Tree Cache
|
|
138
138
|
*/
|
|
139
|
-
folderTree: Effect.Effect<import("../../types.js").FolderNode[], import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError | import("../util/folderTree.js").FolderTreeError, never>;
|
|
139
|
+
folderTree: Effect.Effect<import("../../types.js").FolderNode[], import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError | import("../util/folderTree.js").FolderTreeError, never>;
|
|
140
140
|
/**
|
|
141
141
|
* Update Folder List Cache
|
|
142
142
|
*/
|
|
143
|
-
folderList: Effect.Effect<import("../../types.js").FolderListItem[], import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
143
|
+
folderList: Effect.Effect<import("../../types.js").FolderListItem[], import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
144
144
|
/**
|
|
145
145
|
* Update Folder Entry and Invalidate Related Caches
|
|
146
146
|
*
|
|
@@ -148,25 +148,25 @@ export declare const SDKUpdateModule: Effect.Effect<{
|
|
|
148
148
|
* @returns The updated folder entry.
|
|
149
149
|
*/
|
|
150
150
|
folder: (data: {
|
|
151
|
-
readonly name: string;
|
|
152
151
|
readonly id: string;
|
|
153
|
-
readonly parent: string | null | undefined;
|
|
154
|
-
}) => Effect.Effect<{
|
|
155
152
|
readonly name: string;
|
|
153
|
+
readonly parent?: string | null | undefined;
|
|
154
|
+
}) => Effect.Effect<{
|
|
156
155
|
readonly id: string;
|
|
157
|
-
readonly
|
|
158
|
-
|
|
156
|
+
readonly name: string;
|
|
157
|
+
readonly parent?: string | null | undefined;
|
|
158
|
+
}, import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError | import("../util/folderTree.js").FolderTreeError, never>;
|
|
159
159
|
/**
|
|
160
160
|
* Update Latest NPM Package Version
|
|
161
161
|
*/
|
|
162
162
|
latestVersion: () => Effect.Effect<{
|
|
163
163
|
version: string;
|
|
164
164
|
lastCacheUpdate: Date;
|
|
165
|
-
}, import("effect/Cause").UnknownException |
|
|
165
|
+
}, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../util/getFromNPM.js").GetFromNPMError, never>;
|
|
166
166
|
/**
|
|
167
167
|
* Update Site Configuration
|
|
168
168
|
*/
|
|
169
|
-
siteConfig: (data: import("../../types.js").ConfigFinal<import("../../types.js").StudioCMSSiteConfig>) => Effect.Effect<import("../../types.js").DynamicConfigEntry<import("../../types.js").StudioCMSSiteConfig>, import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
169
|
+
siteConfig: (data: import("../../types.js").ConfigFinal<import("../../types.js").StudioCMSSiteConfig>) => Effect.Effect<import("../../types.js").DynamicConfigEntry<import("../../types.js").StudioCMSSiteConfig>, import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
170
170
|
/**
|
|
171
171
|
* Page Operations
|
|
172
172
|
*/
|
|
@@ -174,11 +174,11 @@ export declare const SDKUpdateModule: Effect.Effect<{
|
|
|
174
174
|
/**
|
|
175
175
|
* Update Page by ID
|
|
176
176
|
*/
|
|
177
|
-
byId: (pageId: string, data: CombinedPageUpdateData) => Effect.Effect<import("../../types.js").CombinedPageData | undefined, import("effect/ParseResult").ParseError | import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").QueryParseError | import("@withstudiocms/kysely/core/errors").QueryError | import("@withstudiocms/kysely/core/errors").NotFoundError | import("../util/folderTree.js").FolderTreeError | import("../util/collectors.js").CollectorError | import("../get/index.js").PaginateError, never>;
|
|
177
|
+
byId: (pageId: string, data: CombinedPageUpdateData) => Effect.Effect<import("../../types.js").CombinedPageData | undefined, import("effect/ParseResult").ParseError | import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").QueryParseError | import("@withstudiocms/kysely/core/errors").QueryError | import("@withstudiocms/kysely/core/errors").NotFoundError | import("../util/folderTree.js").FolderTreeError | import("../util/collectors.js").CollectorError | import("../get/index.js").PaginateError, never>;
|
|
178
178
|
/**
|
|
179
179
|
* Update Page by Slug
|
|
180
180
|
*/
|
|
181
|
-
bySlug: (slug: string, data: CombinedPageUpdateData) => Effect.Effect<import("../../types.js").CombinedPageData | undefined, import("effect/ParseResult").ParseError | import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError | import("../util/folderTree.js").FolderTreeError | import("../util/collectors.js").CollectorError | import("../get/index.js").PaginateError, never>;
|
|
181
|
+
bySlug: (slug: string, data: CombinedPageUpdateData) => Effect.Effect<import("../../types.js").CombinedPageData | undefined, import("effect/ParseResult").ParseError | import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError | import("../util/folderTree.js").FolderTreeError | import("../util/collectors.js").CollectorError | import("../get/index.js").PaginateError, never>;
|
|
182
182
|
};
|
|
183
|
-
}, never, DBClientLive | import("../../context.js").SDKDefaults | CacheService | import("@withstudiocms/effect").Deepmerge>;
|
|
183
|
+
}, never, DBClientLive | import("../../context.js").SDKDefaults | import("../../context.js").StorageManagerResolver | CacheService | import("@withstudiocms/effect").Deepmerge>;
|
|
184
184
|
export default SDKUpdateModule;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Effect, Schema } from "@withstudiocms/effect";
|
|
2
|
+
import CacheService from "../../cache.js";
|
|
3
|
+
import { cacheKeyGetters, cacheTags } from "../../consts.js";
|
|
4
|
+
import { DBClientLive } from "../../context.js";
|
|
2
5
|
import {
|
|
3
6
|
StudioCMSPageContent,
|
|
4
7
|
StudioCMSPageData,
|
|
@@ -6,10 +9,7 @@ import {
|
|
|
6
9
|
StudioCMSPageDataTags,
|
|
7
10
|
StudioCMSPageFolderStructure,
|
|
8
11
|
StudioCMSPermissions
|
|
9
|
-
} from "
|
|
10
|
-
import CacheService from "../../cache.js";
|
|
11
|
-
import { cacheKeyGetters, cacheTags } from "../../consts.js";
|
|
12
|
-
import { DBClientLive } from "../../context.js";
|
|
12
|
+
} from "../../tables.js";
|
|
13
13
|
import SDKClearModule from "../clear/index.js";
|
|
14
14
|
import SDKConfigModule from "../config/index.js";
|
|
15
15
|
import SDKGetModule from "../get/index.js";
|
|
@@ -25,42 +25,60 @@ const SDKUpdateModule = Effect.gen(function* () {
|
|
|
25
25
|
encoder: StudioCMSPageContent.Update,
|
|
26
26
|
decoder: StudioCMSPageContent.Select,
|
|
27
27
|
callbackFn: (db, data) => db(
|
|
28
|
-
(client) => client.
|
|
28
|
+
(client) => client.transaction().execute(async (trx) => {
|
|
29
|
+
await trx.updateTable("StudioCMSPageContent").set(data).where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
30
|
+
return await trx.selectFrom("StudioCMSPageContent").selectAll().where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
31
|
+
})
|
|
29
32
|
)
|
|
30
33
|
});
|
|
31
34
|
const _updateTag = withCodec({
|
|
32
35
|
encoder: StudioCMSPageDataTags.Update,
|
|
33
36
|
decoder: StudioCMSPageDataTags.Select,
|
|
34
37
|
callbackFn: (db, data) => db(
|
|
35
|
-
(client) => client.
|
|
38
|
+
(client) => client.transaction().execute(async (trx) => {
|
|
39
|
+
await trx.updateTable("StudioCMSPageDataTags").set(data).where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
40
|
+
return await trx.selectFrom("StudioCMSPageDataTags").selectAll().where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
41
|
+
})
|
|
36
42
|
)
|
|
37
43
|
});
|
|
38
44
|
const _updateCategory = withCodec({
|
|
39
45
|
encoder: StudioCMSPageDataCategories.Update,
|
|
40
46
|
decoder: StudioCMSPageDataCategories.Select,
|
|
41
47
|
callbackFn: (db, data) => db(
|
|
42
|
-
(client) => client.
|
|
48
|
+
(client) => client.transaction().execute(async (trx) => {
|
|
49
|
+
await trx.updateTable("StudioCMSPageDataCategories").set(data).where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
50
|
+
return await trx.selectFrom("StudioCMSPageDataCategories").selectAll().where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
51
|
+
})
|
|
43
52
|
)
|
|
44
53
|
});
|
|
45
54
|
const _updatePermission = withCodec({
|
|
46
55
|
encoder: StudioCMSPermissions.Update,
|
|
47
56
|
decoder: StudioCMSPermissions.Select,
|
|
48
57
|
callbackFn: (db, data) => db(
|
|
49
|
-
(client) => client.
|
|
58
|
+
(client) => client.transaction().execute(async (trx) => {
|
|
59
|
+
await trx.updateTable("StudioCMSPermissions").set(data).where("user", "=", data.user).executeTakeFirstOrThrow();
|
|
60
|
+
return await trx.selectFrom("StudioCMSPermissions").selectAll().where("user", "=", data.user).executeTakeFirstOrThrow();
|
|
61
|
+
})
|
|
50
62
|
)
|
|
51
63
|
});
|
|
52
64
|
const _updateFolderEntry = withCodec({
|
|
53
65
|
encoder: StudioCMSPageFolderStructure.Update,
|
|
54
66
|
decoder: StudioCMSPageFolderStructure.Select,
|
|
55
67
|
callbackFn: (db, data) => db(
|
|
56
|
-
(client) => client.
|
|
68
|
+
(client) => client.transaction().execute(async (trx) => {
|
|
69
|
+
await trx.updateTable("StudioCMSPageFolderStructure").set(data).where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
70
|
+
return await trx.selectFrom("StudioCMSPageFolderStructure").selectAll().where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
71
|
+
})
|
|
57
72
|
)
|
|
58
73
|
});
|
|
59
74
|
const _updatePageDataEntry = withCodec({
|
|
60
75
|
encoder: StudioCMSPageData.Update,
|
|
61
76
|
decoder: StudioCMSPageData.Select,
|
|
62
77
|
callbackFn: (db, data) => db(
|
|
63
|
-
(client) => client.
|
|
78
|
+
(client) => client.transaction().execute(async (trx) => {
|
|
79
|
+
await trx.updateTable("StudioCMSPageData").set(data).where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
80
|
+
return await trx.selectFrom("StudioCMSPageData").selectAll().where("id", "=", data.id).executeTakeFirstOrThrow();
|
|
81
|
+
})
|
|
64
82
|
)
|
|
65
83
|
});
|
|
66
84
|
const _findPageDataBySlug = withCodec({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, type ParseResult } from '@withstudiocms/effect';
|
|
2
|
-
import {
|
|
2
|
+
import type { DBCallbackFailure } from '@withstudiocms/kysely/client';
|
|
3
3
|
import type { DatabaseError } from '@withstudiocms/kysely/core/errors';
|
|
4
|
-
import { DBClientLive } from '../../context.js';
|
|
4
|
+
import { DBClientLive, StorageManagerResolver } from '../../context.js';
|
|
5
5
|
import type { CombinedPageData, CombinedUserData, FolderNode, MetaOnlyPageData, tsPageDataSelect } from '../../types.js';
|
|
6
6
|
import { type FolderTreeError } from './folderTree.js';
|
|
7
7
|
declare const CollectorError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
@@ -85,155 +85,19 @@ export declare const useCollectorError: <T>(_try: () => T) => Effect.Effect<T, C
|
|
|
85
85
|
* SDK modules to obtain normalized, assembled data for pages, users, tags, and categories.
|
|
86
86
|
*/
|
|
87
87
|
export declare const SDKCollectors: Effect.Effect<{
|
|
88
|
-
collectCategories: (input: {
|
|
89
|
-
readonly [x: number]: number;
|
|
90
|
-
readonly length: number;
|
|
91
|
-
toString: {};
|
|
92
|
-
toLocaleString: {};
|
|
93
|
-
concat: {};
|
|
94
|
-
join: {};
|
|
95
|
-
slice: {};
|
|
96
|
-
indexOf: {};
|
|
97
|
-
lastIndexOf: {};
|
|
98
|
-
every: {};
|
|
99
|
-
some: {};
|
|
100
|
-
forEach: {};
|
|
101
|
-
map: {};
|
|
102
|
-
filter: {};
|
|
103
|
-
reduce: {};
|
|
104
|
-
reduceRight: {};
|
|
105
|
-
find: {};
|
|
106
|
-
findIndex: {};
|
|
107
|
-
entries: {};
|
|
108
|
-
keys: {};
|
|
109
|
-
values: {};
|
|
110
|
-
includes: {};
|
|
111
|
-
flatMap: {};
|
|
112
|
-
flat: {};
|
|
113
|
-
at: {};
|
|
114
|
-
findLast: {};
|
|
115
|
-
findLastIndex: {};
|
|
116
|
-
toReversed: {};
|
|
117
|
-
toSorted: {};
|
|
118
|
-
toSpliced: {};
|
|
119
|
-
with: {};
|
|
120
|
-
[Symbol.iterator]: {};
|
|
121
|
-
readonly [Symbol.unscopables]: {
|
|
122
|
-
readonly [x: number]: boolean | undefined;
|
|
123
|
-
readonly length?: boolean | undefined;
|
|
124
|
-
toString?: boolean | undefined;
|
|
125
|
-
toLocaleString?: boolean | undefined;
|
|
126
|
-
concat?: boolean | undefined;
|
|
127
|
-
join?: boolean | undefined;
|
|
128
|
-
slice?: boolean | undefined;
|
|
129
|
-
indexOf?: boolean | undefined;
|
|
130
|
-
lastIndexOf?: boolean | undefined;
|
|
131
|
-
every?: boolean | undefined;
|
|
132
|
-
some?: boolean | undefined;
|
|
133
|
-
forEach?: boolean | undefined;
|
|
134
|
-
map?: boolean | undefined;
|
|
135
|
-
filter?: boolean | undefined;
|
|
136
|
-
reduce?: boolean | undefined;
|
|
137
|
-
reduceRight?: boolean | undefined;
|
|
138
|
-
find?: boolean | undefined;
|
|
139
|
-
findIndex?: boolean | undefined;
|
|
140
|
-
entries?: boolean | undefined;
|
|
141
|
-
keys?: boolean | undefined;
|
|
142
|
-
values?: boolean | undefined;
|
|
143
|
-
includes?: boolean | undefined;
|
|
144
|
-
flatMap?: boolean | undefined;
|
|
145
|
-
flat?: boolean | undefined;
|
|
146
|
-
at?: boolean | undefined;
|
|
147
|
-
findLast?: boolean | undefined;
|
|
148
|
-
findLastIndex?: boolean | undefined;
|
|
149
|
-
toReversed?: boolean | undefined;
|
|
150
|
-
toSorted?: boolean | undefined;
|
|
151
|
-
toSpliced?: boolean | undefined;
|
|
152
|
-
with?: boolean | undefined;
|
|
153
|
-
[Symbol.iterator]?: boolean | undefined;
|
|
154
|
-
readonly [Symbol.unscopables]?: boolean | undefined;
|
|
155
|
-
};
|
|
156
|
-
}) => Effect.Effect<readonly {
|
|
157
|
-
readonly name: string;
|
|
88
|
+
collectCategories: (input: readonly number[]) => Effect.Effect<readonly {
|
|
158
89
|
readonly id: number;
|
|
159
|
-
readonly
|
|
90
|
+
readonly name: string;
|
|
160
91
|
readonly description: string;
|
|
92
|
+
readonly parent?: number | null | undefined;
|
|
161
93
|
readonly slug: string;
|
|
162
94
|
readonly meta: {
|
|
163
95
|
readonly [x: string]: unknown;
|
|
164
96
|
};
|
|
165
97
|
}[], DBCallbackFailure | DatabaseError, never>;
|
|
166
|
-
collectTags: (input: {
|
|
167
|
-
readonly [x: number]: number;
|
|
168
|
-
readonly length: number;
|
|
169
|
-
toString: {};
|
|
170
|
-
toLocaleString: {};
|
|
171
|
-
concat: {};
|
|
172
|
-
join: {};
|
|
173
|
-
slice: {};
|
|
174
|
-
indexOf: {};
|
|
175
|
-
lastIndexOf: {};
|
|
176
|
-
every: {};
|
|
177
|
-
some: {};
|
|
178
|
-
forEach: {};
|
|
179
|
-
map: {};
|
|
180
|
-
filter: {};
|
|
181
|
-
reduce: {};
|
|
182
|
-
reduceRight: {};
|
|
183
|
-
find: {};
|
|
184
|
-
findIndex: {};
|
|
185
|
-
entries: {};
|
|
186
|
-
keys: {};
|
|
187
|
-
values: {};
|
|
188
|
-
includes: {};
|
|
189
|
-
flatMap: {};
|
|
190
|
-
flat: {};
|
|
191
|
-
at: {};
|
|
192
|
-
findLast: {};
|
|
193
|
-
findLastIndex: {};
|
|
194
|
-
toReversed: {};
|
|
195
|
-
toSorted: {};
|
|
196
|
-
toSpliced: {};
|
|
197
|
-
with: {};
|
|
198
|
-
[Symbol.iterator]: {};
|
|
199
|
-
readonly [Symbol.unscopables]: {
|
|
200
|
-
readonly [x: number]: boolean | undefined;
|
|
201
|
-
readonly length?: boolean | undefined;
|
|
202
|
-
toString?: boolean | undefined;
|
|
203
|
-
toLocaleString?: boolean | undefined;
|
|
204
|
-
concat?: boolean | undefined;
|
|
205
|
-
join?: boolean | undefined;
|
|
206
|
-
slice?: boolean | undefined;
|
|
207
|
-
indexOf?: boolean | undefined;
|
|
208
|
-
lastIndexOf?: boolean | undefined;
|
|
209
|
-
every?: boolean | undefined;
|
|
210
|
-
some?: boolean | undefined;
|
|
211
|
-
forEach?: boolean | undefined;
|
|
212
|
-
map?: boolean | undefined;
|
|
213
|
-
filter?: boolean | undefined;
|
|
214
|
-
reduce?: boolean | undefined;
|
|
215
|
-
reduceRight?: boolean | undefined;
|
|
216
|
-
find?: boolean | undefined;
|
|
217
|
-
findIndex?: boolean | undefined;
|
|
218
|
-
entries?: boolean | undefined;
|
|
219
|
-
keys?: boolean | undefined;
|
|
220
|
-
values?: boolean | undefined;
|
|
221
|
-
includes?: boolean | undefined;
|
|
222
|
-
flatMap?: boolean | undefined;
|
|
223
|
-
flat?: boolean | undefined;
|
|
224
|
-
at?: boolean | undefined;
|
|
225
|
-
findLast?: boolean | undefined;
|
|
226
|
-
findLastIndex?: boolean | undefined;
|
|
227
|
-
toReversed?: boolean | undefined;
|
|
228
|
-
toSorted?: boolean | undefined;
|
|
229
|
-
toSpliced?: boolean | undefined;
|
|
230
|
-
with?: boolean | undefined;
|
|
231
|
-
[Symbol.iterator]?: boolean | undefined;
|
|
232
|
-
readonly [Symbol.unscopables]?: boolean | undefined;
|
|
233
|
-
};
|
|
234
|
-
}) => Effect.Effect<readonly {
|
|
235
|
-
readonly name: string;
|
|
98
|
+
collectTags: (input: readonly number[]) => Effect.Effect<readonly {
|
|
236
99
|
readonly id: number;
|
|
100
|
+
readonly name: string;
|
|
237
101
|
readonly description: string;
|
|
238
102
|
readonly slug: string;
|
|
239
103
|
readonly meta: {
|
|
@@ -245,17 +109,17 @@ export declare const SDKCollectors: Effect.Effect<{
|
|
|
245
109
|
(page: tsPageDataSelect, tree: FolderNode[], metaOnly: boolean): Effect.Effect<MetaOnlyPageData, CollectorError | FolderTreeError | DBCallbackFailure | DatabaseError | ParseResult.ParseError, never>;
|
|
246
110
|
};
|
|
247
111
|
collectUserData: (user: {
|
|
248
|
-
readonly name: string;
|
|
249
112
|
readonly id: string;
|
|
250
|
-
readonly url
|
|
251
|
-
readonly
|
|
252
|
-
readonly
|
|
113
|
+
readonly url?: string | null | undefined;
|
|
114
|
+
readonly name: string;
|
|
115
|
+
readonly email?: string | null | undefined;
|
|
116
|
+
readonly avatar?: string | null | undefined;
|
|
253
117
|
readonly username: string;
|
|
254
|
-
readonly password
|
|
118
|
+
readonly password?: string | null | undefined;
|
|
255
119
|
readonly updatedAt: Date;
|
|
256
120
|
readonly createdAt: Date;
|
|
257
121
|
readonly emailVerified: boolean;
|
|
258
|
-
readonly notifications
|
|
122
|
+
readonly notifications?: string | null | undefined;
|
|
259
123
|
}) => Effect.Effect<CombinedUserData, DBCallbackFailure | DatabaseError, never>;
|
|
260
|
-
}, never, DBClientLive>;
|
|
124
|
+
}, never, DBClientLive | StorageManagerResolver>;
|
|
261
125
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Data, Effect, Schema } from "@withstudiocms/effect";
|
|
2
|
+
import { DBClientLive, StorageManagerResolver } from "../../context.js";
|
|
3
|
+
import { resolveStorageManagerUrls } from "../../lib/storage-manager.js";
|
|
2
4
|
import {
|
|
3
5
|
StudioCMSOAuthAccounts,
|
|
4
6
|
StudioCMSPageContent,
|
|
@@ -6,8 +8,7 @@ import {
|
|
|
6
8
|
StudioCMSPageDataTags,
|
|
7
9
|
StudioCMSPermissions,
|
|
8
10
|
StudioCMSUsersTable
|
|
9
|
-
} from "
|
|
10
|
-
import { DBClientLive } from "../../context.js";
|
|
11
|
+
} from "../../tables.js";
|
|
11
12
|
import { SDKFolderTree } from "./folderTree.js";
|
|
12
13
|
import { SDKParsers } from "./parsers.js";
|
|
13
14
|
import { slugify } from "./slugify.js";
|
|
@@ -18,7 +19,13 @@ const useCollectorError = (_try) => Effect.try({
|
|
|
18
19
|
catch: (error) => new CollectorError({ cause: error })
|
|
19
20
|
});
|
|
20
21
|
const SDKCollectors = Effect.gen(function* () {
|
|
21
|
-
const [
|
|
22
|
+
const [
|
|
23
|
+
{ withCodec },
|
|
24
|
+
{ findNodesAlongPathToId },
|
|
25
|
+
{ parseIdNumberArray, parseIdStringArray },
|
|
26
|
+
smResolver
|
|
27
|
+
] = yield* Effect.all([DBClientLive, SDKFolderTree, SDKParsers, StorageManagerResolver]);
|
|
28
|
+
const resolveUrls = resolveStorageManagerUrls(smResolver);
|
|
22
29
|
const _getUserData = withCodec({
|
|
23
30
|
encoder: Schema.String,
|
|
24
31
|
decoder: Schema.UndefinedOr(StudioCMSUsersTable.Select),
|
|
@@ -99,17 +106,37 @@ const SDKCollectors = Effect.gen(function* () {
|
|
|
99
106
|
const folderPath = urlParts.map(({ name }) => slugify(name)).join("/");
|
|
100
107
|
urlRoute = folderPath.length > 0 ? `/${folderPath}${safeSlug === "/" ? "" : `/${safeSlug}`}` : safeSlug;
|
|
101
108
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
let authorDataTyped;
|
|
110
|
+
if (authorData) {
|
|
111
|
+
const { email, password, ...rest } = authorData;
|
|
112
|
+
authorDataTyped = {
|
|
113
|
+
...rest
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
let contributorsDataTyped;
|
|
117
|
+
if (contributorsData) {
|
|
118
|
+
contributorsDataTyped = contributorsData.map(({ email, password, ...rest }) => ({
|
|
119
|
+
...rest
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
const returnData = yield* resolveUrls(
|
|
123
|
+
{
|
|
124
|
+
...page,
|
|
125
|
+
urlRoute,
|
|
126
|
+
categories,
|
|
127
|
+
tags,
|
|
128
|
+
authorData: authorDataTyped,
|
|
129
|
+
contributorsData: contributorsDataTyped,
|
|
130
|
+
multiLangContent,
|
|
131
|
+
defaultContent
|
|
132
|
+
},
|
|
133
|
+
["heroImage"]
|
|
134
|
+
).pipe(Effect.catchTag("UnknownException", (e) => new CollectorError({ cause: e })));
|
|
135
|
+
if (!returnData) {
|
|
136
|
+
return yield* new CollectorError({
|
|
137
|
+
cause: "Unknown error occurred while resolving storage manager URL"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
113
140
|
if (metaOnly) {
|
|
114
141
|
return yield* _transformPageDataToMetaOnly(returnData);
|
|
115
142
|
}
|
|
@@ -84,9 +84,9 @@ export declare const useFolderTreeError: <T>(_try: () => T) => Effect.Effect<T,
|
|
|
84
84
|
*/
|
|
85
85
|
export declare const SDKFolderTree: Effect.Effect<{
|
|
86
86
|
generateFolderTree: (folders: readonly {
|
|
87
|
-
readonly name: string;
|
|
88
87
|
readonly id: string;
|
|
89
|
-
readonly
|
|
88
|
+
readonly name: string;
|
|
89
|
+
readonly parent?: string | null | undefined;
|
|
90
90
|
}[]) => Effect.Effect<FolderNode[], FolderTreeError, never>;
|
|
91
91
|
getFullPath: (tree: FolderNode[], path: string[]) => Effect.Effect<string[], FolderTreeError, never>;
|
|
92
92
|
findNodeByPath: (tree: FolderNode[], path: string[]) => Effect.Effect<FolderNode | null, FolderTreeError, never>;
|
|
@@ -94,7 +94,7 @@ export declare const SDKFolderTree: Effect.Effect<{
|
|
|
94
94
|
findNodesAlongPathToId: (tree: FolderNode[], id: string) => Effect.Effect<FolderNode[], FolderTreeError, never>;
|
|
95
95
|
findNodeById: (tree: FolderNode[], id: string) => Effect.Effect<FolderNode | null, FolderTreeError, never>;
|
|
96
96
|
addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => Effect.Effect<FolderNode[], FolderTreeError, never>;
|
|
97
|
-
buildFolderTree: Effect.Effect<FolderNode[], import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError | FolderTreeError, never>;
|
|
98
|
-
getAvailableFolders: Effect.Effect<FolderListItem[], import("@withstudiocms/kysely").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
97
|
+
buildFolderTree: Effect.Effect<FolderNode[], import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError | FolderTreeError, never>;
|
|
98
|
+
getAvailableFolders: Effect.Effect<FolderListItem[], import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError, never>;
|
|
99
99
|
}, never, DBClientLive>;
|
|
100
100
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Data, Effect, Schema } from "@withstudiocms/effect";
|
|
2
|
-
import { StudioCMSPageFolderStructure } from "@withstudiocms/kysely";
|
|
3
2
|
import { DBClientLive } from "../../context.js";
|
|
3
|
+
import { StudioCMSPageFolderStructure } from "../../tables.js";
|
|
4
4
|
class FolderTreeError extends Data.TaggedError("FolderTreeError") {
|
|
5
5
|
}
|
|
6
6
|
const useFolderTreeError = (_try) => Effect.try({
|
|
@@ -106,19 +106,19 @@ declare const NpmRegistryResponseSchema_base: Schema.Class<NpmRegistryResponseSc
|
|
|
106
106
|
}[];
|
|
107
107
|
} & {
|
|
108
108
|
readonly author?: {
|
|
109
|
-
readonly name: string;
|
|
110
109
|
readonly url: string;
|
|
110
|
+
readonly name: string;
|
|
111
111
|
} | undefined;
|
|
112
112
|
} & {
|
|
113
113
|
readonly repository?: {
|
|
114
|
-
readonly type: string;
|
|
115
114
|
readonly url: string;
|
|
115
|
+
readonly type: string;
|
|
116
116
|
readonly directory?: string | undefined;
|
|
117
117
|
} | undefined;
|
|
118
118
|
} & {
|
|
119
119
|
readonly contributors?: readonly {
|
|
120
|
-
readonly name: string;
|
|
121
120
|
readonly url?: string | undefined;
|
|
121
|
+
readonly name: string;
|
|
122
122
|
}[] | undefined;
|
|
123
123
|
} & {
|
|
124
124
|
readonly keywords: readonly string[];
|
|
@@ -154,6 +154,14 @@ export declare class NpmRegistryResponseSchema extends NpmRegistryResponseSchema
|
|
|
154
154
|
* Helper to process and validate the HTTP response from the NPM registry.
|
|
155
155
|
*/
|
|
156
156
|
export declare const parseNpmRegistryResponse: (response: Response) => Effect.Effect<NpmRegistryResponseSchema, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError, never>;
|
|
157
|
+
declare const GetFromNPMError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
158
|
+
readonly _tag: "GetFromNPMError";
|
|
159
|
+
} & Readonly<A>;
|
|
160
|
+
export declare class GetFromNPMError extends GetFromNPMError_base<{
|
|
161
|
+
message: string;
|
|
162
|
+
cause?: unknown;
|
|
163
|
+
}> {
|
|
164
|
+
}
|
|
157
165
|
/**
|
|
158
166
|
* Cache key for NPM package data.
|
|
159
167
|
*/
|
|
@@ -185,7 +193,7 @@ export declare const GetFromNPM: Effect.Effect<{
|
|
|
185
193
|
getVersion: (pkg: string, ver?: string | undefined) => Effect.Effect<{
|
|
186
194
|
version: string;
|
|
187
195
|
lastCacheUpdate: Date;
|
|
188
|
-
}, import("effect/Cause").UnknownException |
|
|
189
|
-
getDataFromNPM: (pkg: string, ver?: string | undefined) => Effect.Effect<NpmRegistryResponseSchema, import("effect/Cause").UnknownException |
|
|
196
|
+
}, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | GetFromNPMError, never>;
|
|
197
|
+
getDataFromNPM: (pkg: string, ver?: string | undefined) => Effect.Effect<NpmRegistryResponseSchema, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | GetFromNPMError, never>;
|
|
190
198
|
}, never, CacheService>;
|
|
191
199
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, HTTPClient, Schema } from "@withstudiocms/effect";
|
|
1
|
+
import { Data, Effect, HTTPClient, Schema } from "@withstudiocms/effect";
|
|
2
2
|
import { CacheService } from "../../cache.js";
|
|
3
3
|
import { cacheKeyGetters, cacheTags } from "../../consts.js";
|
|
4
4
|
class NpmRegistryResponseSchema extends Schema.Class(
|
|
@@ -60,6 +60,8 @@ const parseNpmRegistryResponse = Effect.fn(function* (response) {
|
|
|
60
60
|
const data = yield* Effect.tryPromise(() => response.json());
|
|
61
61
|
return yield* Schema.decodeUnknown(NpmRegistryResponseSchema)(data);
|
|
62
62
|
});
|
|
63
|
+
class GetFromNPMError extends Data.TaggedError("GetFromNPMError") {
|
|
64
|
+
}
|
|
63
65
|
const cacheKey = cacheKeyGetters.npmPackage;
|
|
64
66
|
const cacheOpts = { tags: cacheTags.npmPackage };
|
|
65
67
|
const GetFromNPM = Effect.gen(function* () {
|
|
@@ -67,7 +69,10 @@ const GetFromNPM = Effect.gen(function* () {
|
|
|
67
69
|
const effectFetch = Effect.fn(
|
|
68
70
|
(url) => Effect.tryPromise({
|
|
69
71
|
try: () => fetch(url),
|
|
70
|
-
catch: (error) => new
|
|
72
|
+
catch: (error) => new GetFromNPMError({
|
|
73
|
+
message: `Failed to fetch NPM package data: ${String(error)}`,
|
|
74
|
+
cause: error
|
|
75
|
+
})
|
|
71
76
|
})
|
|
72
77
|
);
|
|
73
78
|
const _remapCacheStatusData = (status) => status ? status.lastUpdatedAt : /* @__PURE__ */ new Date();
|
|
@@ -93,6 +98,7 @@ const GetFromNPM = Effect.gen(function* () {
|
|
|
93
98
|
}).pipe(Effect.provide(HTTPClient.Default));
|
|
94
99
|
export {
|
|
95
100
|
GetFromNPM,
|
|
101
|
+
GetFromNPMError,
|
|
96
102
|
NpmRegistryResponseSchema,
|
|
97
103
|
cacheKey,
|
|
98
104
|
cacheOpts,
|