rimecms 0.28.9 → 0.29.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/README.md +3 -3
- package/dist/adapter-sqlite/generate-schema/{util.d.ts → util.server.d.ts} +2 -2
- package/dist/adapter-sqlite/generate-schema/{util.js → util.server.js} +2 -2
- package/dist/adapter-sqlite/generate-schema/write.server.js +1 -1
- package/dist/adapter-sqlite/index.server.d.ts +2 -1
- package/dist/adapter-sqlite/index.server.js +2 -0
- package/dist/adapter-sqlite/transform.server.js +1 -1
- package/dist/adapter-sqlite/with.server.js +1 -1
- package/dist/core/areas/{api → rest}/get.server.d.ts +4 -2
- package/dist/core/areas/rest/get.server.js +45 -0
- package/dist/core/areas/rest/index.server.d.ts +6 -0
- package/dist/core/areas/rest/index.server.js +3 -0
- package/dist/core/areas/{api → rest}/update.server.d.ts +4 -2
- package/dist/core/areas/rest/update.server.js +43 -0
- package/dist/core/collections/auth/hooks/before-upsert/augment-fields-password.server.d.ts +1 -1
- package/dist/core/collections/config/augment-panel.d.ts +1 -1
- package/dist/core/collections/local-api.server.js +2 -1
- package/dist/core/collections/operations/duplicate.js +2 -2
- package/dist/core/collections/{api → rest}/create.server.d.ts +4 -2
- package/dist/core/collections/rest/create.server.js +37 -0
- package/dist/core/collections/{api → rest}/delete.server.d.ts +4 -2
- package/dist/core/collections/rest/delete.server.js +37 -0
- package/dist/core/collections/{api → rest}/deleteById.server.d.ts +4 -2
- package/dist/core/collections/rest/deleteById.server.js +21 -0
- package/dist/core/collections/{api → rest}/duplicate.server.d.ts +1 -1
- package/dist/core/collections/rest/duplicate.server.js +16 -0
- package/dist/core/collections/{api → rest}/get.server.d.ts +4 -2
- package/dist/core/collections/rest/get.server.js +50 -0
- package/dist/core/collections/{api → rest}/getById.server.d.ts +4 -2
- package/dist/core/collections/rest/getById.server.js +35 -0
- package/dist/core/collections/rest/index.server.d.ts +16 -0
- package/dist/core/collections/rest/index.server.js +16 -0
- package/dist/core/collections/{api → rest}/updateById.server.d.ts +4 -2
- package/dist/core/collections/rest/updateById.server.js +44 -0
- package/dist/core/collections/upload/hooks/convert-base64.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/extract-path.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/handle-path-creation.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/process-file-upload.server.d.ts +1 -1
- package/dist/core/config/auth/better-auth.server.d.ts +2 -2
- package/dist/core/config/client/augment-directories.js +1 -1
- package/dist/core/config/config-context.server.d.ts +3 -3
- package/dist/core/config/server/augment-directories.server.js +1 -1
- package/dist/core/config/server/augment-panel-access.server.d.ts +1 -1
- package/dist/core/config/server/build-config.server.d.ts +11 -11
- package/dist/core/config/server/validate.server.js +3 -3
- package/dist/core/config/shared/find-thumbnail.js +1 -1
- package/dist/core/constant.d.ts +1 -1
- package/dist/core/constant.js +1 -1
- package/dist/core/dev/cli/build/index.d.ts +1 -0
- package/dist/core/dev/cli/build/index.js +39 -10
- package/dist/core/dev/cli/build/templates.d.ts +1 -0
- package/dist/core/dev/cli/build/templates.js +24 -0
- package/dist/core/dev/cli/clear/index.server.js +1 -1
- package/dist/core/dev/cli/index.js +20 -0
- package/dist/core/dev/cli/init/index.server.js +3 -3
- package/dist/core/dev/cli/init/templates.d.ts +1 -1
- package/dist/core/dev/cli/init/templates.js +2 -2
- package/dist/core/dev/cli/util/log.server.d.ts +1 -0
- package/dist/core/dev/cli/util/log.server.js +4 -0
- package/dist/core/dev/cli/util/package-manager.server.d.ts +9 -0
- package/dist/core/dev/cli/{init/package-manager-util.server.js → util/package-manager.server.js} +15 -0
- package/dist/core/dev/cli/util/package.server.d.ts +9 -0
- package/dist/core/dev/cli/{init/get-package-info.server.js → util/package.server.js} +10 -0
- package/dist/core/dev/generate/routes/common.server.d.ts +10 -1
- package/dist/core/dev/generate/routes/common.server.js +248 -29
- package/dist/core/dev/generate/routes/index.server.d.ts +7 -1
- package/dist/core/dev/generate/routes/index.server.js +16 -55
- package/dist/core/dev/generate/routes/util.server.d.ts +6 -16
- package/dist/core/dev/generate/routes/util.server.js +8 -21
- package/dist/core/dev/generate/types/index.server.js +5 -3
- package/dist/core/dev/vite/index.server.js +1 -1
- package/dist/core/errors/handler.server.d.ts +22 -1
- package/dist/core/errors/handler.server.js +25 -2
- package/dist/core/errors/index.d.ts +0 -1
- package/dist/core/errors/index.js +0 -1
- package/dist/core/fields/util.d.ts +1 -1
- package/dist/core/handlers/routes.server.d.ts +70 -1
- package/dist/core/handlers/routes.server.js +55 -1
- package/dist/core/operations/hooks/before-upsert/data-config-map.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/handle-new-version.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/original-config-map.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/set-default-values.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/validate-fields.server.d.ts +1 -1
- package/dist/core/plugins/api-init/index.server.js +10 -5
- package/dist/core/plugins/cache/cache.server.js +1 -1
- package/dist/core/rime.server.d.ts +10 -10
- package/dist/core/rime.server.js +5 -1
- package/dist/fields/checkbox/index.server.js +1 -1
- package/dist/fields/combobox/index.server.js +1 -1
- package/dist/fields/date/index.server.js +1 -1
- package/dist/fields/email/index.js +1 -1
- package/dist/fields/email/index.server.js +1 -1
- package/dist/fields/link/component/RessourceInput.svelte +1 -1
- package/dist/fields/link/index.d.ts +1 -1
- package/dist/fields/link/index.js +1 -1
- package/dist/fields/link/index.server.js +1 -1
- package/dist/fields/number/index.server.js +1 -1
- package/dist/fields/radio/index.server.js +1 -1
- package/dist/fields/relation/client.d.ts +1 -1
- package/dist/fields/relation/client.js +1 -1
- package/dist/fields/relation/component/Cell.svelte +1 -1
- package/dist/fields/relation/component/Relation.svelte +1 -1
- package/dist/fields/relation/component/upload/Browse.svelte +1 -1
- package/dist/fields/relation/index.d.ts +1 -1
- package/dist/fields/relation/index.js +2 -2
- package/dist/fields/relation/index.server.js +1 -1
- package/dist/fields/rich-text/core/features/fields/extension.d.ts +2 -2
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +1 -1
- package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +1 -1
- package/dist/fields/rich-text/core/features/resource/resource.svelte +1 -1
- package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +1 -1
- package/dist/fields/rich-text/core/features/upload/upload.svelte +1 -1
- package/dist/fields/rich-text/index.js +4 -2
- package/dist/fields/rich-text/index.server.js +1 -1
- package/dist/fields/select/index.server.js +1 -1
- package/dist/fields/slug/index.server.js +1 -1
- package/dist/fields/text/index.server.js +1 -1
- package/dist/fields/textarea/index.server.js +1 -1
- package/dist/fields/time/index.server.js +1 -1
- package/dist/fields/toggle/index.server.js +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7 -3
- package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +1 -1
- package/dist/panel/components/sections/document/ButtonStatus.svelte +1 -1
- package/dist/panel/components/sections/document/CurrentlyEdited.svelte +1 -1
- package/dist/panel/components/sections/document/Settings.svelte +1 -1
- package/dist/panel/context/collection.svelte.js +1 -1
- package/dist/panel/context/documentForm.svelte.js +1 -2
- package/dist/panel/context/form.svelte.d.ts +2 -0
- package/dist/panel/context/form.svelte.js +8 -2
- package/dist/panel/context/live.svelte.js +1 -1
- package/dist/panel/index.d.ts +9 -1
- package/dist/panel/index.js +7 -1
- package/dist/panel/pages/area/actions.server.d.ts +2 -21
- package/dist/panel/pages/area/actions.server.js +28 -27
- package/dist/panel/pages/area/load.server.d.ts +2 -17
- package/dist/panel/pages/area/load.server.js +37 -46
- package/dist/panel/pages/auth/sign-in/SignIn.svelte +7 -1
- package/dist/panel/pages/collection/load.server.d.ts +6 -6
- package/dist/panel/pages/collection/load.server.js +70 -72
- package/dist/panel/pages/collection-document/actions.server.d.ts +1 -1
- package/dist/panel/pages/collection-document/actions.server.js +78 -70
- package/dist/panel/pages/collection-document/load.server.d.ts +5 -20
- package/dist/panel/pages/collection-document/load.server.js +80 -82
- package/dist/server.d.ts +7 -0
- package/dist/server.js +7 -0
- package/dist/types.d.ts +1 -0
- package/dist/util/index.d.ts +9 -1
- package/dist/util/index.js +12 -1
- package/package.json +6 -49
- package/dist/core/api/index.d.ts +0 -7
- package/dist/core/api/index.js +0 -10
- package/dist/core/api/index.server.d.ts +0 -3
- package/dist/core/api/index.server.js +0 -3
- package/dist/core/areas/api/get.server.js +0 -36
- package/dist/core/areas/api/index.server.d.ts +0 -7
- package/dist/core/areas/api/index.server.js +0 -4
- package/dist/core/areas/api/update.server.js +0 -33
- package/dist/core/collections/api/create.server.js +0 -29
- package/dist/core/collections/api/delete.server.js +0 -32
- package/dist/core/collections/api/deleteById.server.js +0 -16
- package/dist/core/collections/api/duplicate.server.js +0 -18
- package/dist/core/collections/api/get.server.js +0 -45
- package/dist/core/collections/api/getById.server.js +0 -30
- package/dist/core/collections/api/index.server.d.ts +0 -17
- package/dist/core/collections/api/index.server.js +0 -9
- package/dist/core/collections/api/updateById.server.js +0 -38
- package/dist/core/dev/cli/init/get-package-info.server.d.ts +0 -1
- package/dist/core/dev/cli/init/package-manager-util.server.d.ts +0 -3
- package/dist/core/dev/generate/routes/area.server.d.ts +0 -7
- package/dist/core/dev/generate/routes/area.server.js +0 -69
- package/dist/core/dev/generate/routes/collection.server.d.ts +0 -14
- package/dist/core/dev/generate/routes/collection.server.js +0 -129
- package/dist/live.d.ts +0 -4
- package/dist/live.js +0 -4
- package/dist/panel/index.server.d.ts +0 -4
- package/dist/panel/index.server.js +0 -4
- package/dist/panel/pages/auth/index.d.ts +0 -4
- package/dist/panel/pages/auth/index.js +0 -4
- package/dist/panel/pages/auth/index.server.d.ts +0 -18
- package/dist/panel/pages/auth/index.server.js +0 -12
- package/dist/panel/pages/index.actions.server.d.ts +0 -13
- package/dist/panel/pages/index.actions.server.js +0 -10
- package/dist/panel/pages/index.load.server.d.ts +0 -23
- package/dist/panel/pages/index.load.server.js +0 -16
- package/dist/panel/ui.d.ts +0 -4
- package/dist/panel/ui.js +0 -5
- /package/dist/core/dev/cli/{util.server.d.ts → util/prompt.server.d.ts} +0 -0
- /package/dist/core/dev/cli/{util.server.js → util/prompt.server.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rimecms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"homepage": "https://github.com/bienbiendev/rime",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"svelte": "./dist/index.js",
|
|
37
37
|
"import": "./dist/index.js"
|
|
38
38
|
},
|
|
39
|
-
"./
|
|
40
|
-
"types": "./dist/
|
|
41
|
-
"import": "./dist/
|
|
39
|
+
"./server": {
|
|
40
|
+
"types": "./dist/server.d.ts",
|
|
41
|
+
"import": "./dist/server.js"
|
|
42
42
|
},
|
|
43
|
-
"./sqlite": {
|
|
43
|
+
"./adapter-sqlite": {
|
|
44
44
|
"types": "./dist/adapter-sqlite/index.server.d.ts",
|
|
45
45
|
"import": "./dist/adapter-sqlite/index.server.js"
|
|
46
46
|
},
|
|
47
|
-
"./config
|
|
47
|
+
"./config": {
|
|
48
48
|
"types": "./dist/core/config/client/index.d.ts",
|
|
49
49
|
"import": "./dist/core/config/client/index.js"
|
|
50
50
|
},
|
|
@@ -52,20 +52,10 @@
|
|
|
52
52
|
"types": "./dist/core/config/server/index.server.d.ts",
|
|
53
53
|
"import": "./dist/core/config/server/index.server.js"
|
|
54
54
|
},
|
|
55
|
-
"./core/plugins/*.js": {
|
|
56
|
-
"types": "./dist/core/plugins/*.d.ts",
|
|
57
|
-
"import": "./dist/core/plugins/*.js"
|
|
58
|
-
},
|
|
59
|
-
"./core/plugins/*.svelte": {
|
|
60
|
-
"import": "./dist/core/plugins/*.svelte"
|
|
61
|
-
},
|
|
62
55
|
"./fields": {
|
|
63
56
|
"types": "./dist/fields/index.d.ts",
|
|
64
57
|
"import": "./dist/fields/index.js"
|
|
65
58
|
},
|
|
66
|
-
"./fields/*.svelte": {
|
|
67
|
-
"import": "./dist/fields/*.svelte"
|
|
68
|
-
},
|
|
69
59
|
"./fields/rich-text": {
|
|
70
60
|
"types": "./dist/fields/rich-text/client.d.ts",
|
|
71
61
|
"import": "./dist/fields/rich-text/client.js"
|
|
@@ -74,49 +64,16 @@
|
|
|
74
64
|
"types": "./dist/fields/relation/client.d.ts",
|
|
75
65
|
"import": "./dist/fields/relation/client.js"
|
|
76
66
|
},
|
|
77
|
-
"./i18n": {
|
|
78
|
-
"types": "./dist/core/i18n/index.d.ts",
|
|
79
|
-
"import": "./dist/core/i18n/index.js"
|
|
80
|
-
},
|
|
81
|
-
"./i18n/*.js": {
|
|
82
|
-
"types": "./dist/core/i18n/*.d.ts",
|
|
83
|
-
"import": "./dist/core/i18n/*.js"
|
|
84
|
-
},
|
|
85
|
-
"./live": {
|
|
86
|
-
"types": "./dist/live.d.ts",
|
|
87
|
-
"import": "./dist/live.js"
|
|
88
|
-
},
|
|
89
67
|
"./panel": {
|
|
90
|
-
"types": "./dist/panel/index.server.d.ts",
|
|
91
|
-
"import": "./dist/panel/index.server.js"
|
|
92
|
-
},
|
|
93
|
-
"./panel/auth": {
|
|
94
|
-
"types": "./dist/panel/pages/auth/index.server.d.ts",
|
|
95
|
-
"import": "./dist/panel/pages/auth/index.server.js"
|
|
96
|
-
},
|
|
97
|
-
"./panel/auth/client": {
|
|
98
|
-
"types": "./dist/panel/pages/auth/index.d.ts",
|
|
99
|
-
"import": "./dist/panel/pages/auth/index.js"
|
|
100
|
-
},
|
|
101
|
-
"./panel/client": {
|
|
102
68
|
"types": "./dist/panel/index.d.ts",
|
|
103
69
|
"import": "./dist/panel/index.js"
|
|
104
70
|
},
|
|
105
71
|
"./panel/style/index.css": {
|
|
106
72
|
"import": "./dist/panel/style/index.css"
|
|
107
73
|
},
|
|
108
|
-
"./panel/ui": {
|
|
109
|
-
"types": "./dist/panel/ui.d.ts",
|
|
110
|
-
"svelte": "./dist/panel/ui.js",
|
|
111
|
-
"import": "./dist/panel/ui.js"
|
|
112
|
-
},
|
|
113
74
|
"./types": {
|
|
114
75
|
"types": "./dist/types.d.ts"
|
|
115
76
|
},
|
|
116
|
-
"./upload": {
|
|
117
|
-
"types": "./dist/core/collections/upload/util/client.d.ts",
|
|
118
|
-
"import": "./dist/core/collections/upload/util/client.js"
|
|
119
|
-
},
|
|
120
77
|
"./util": {
|
|
121
78
|
"types": "./dist/util/index.d.ts",
|
|
122
79
|
"import": "./dist/util/index.js"
|
package/dist/core/api/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build the api full url for given segments
|
|
3
|
-
* @example
|
|
4
|
-
* apiUrl('some-collection') // -> http://localhost:5713/api/some-collection
|
|
5
|
-
* apiUrl('some-collection', '12345') // -> http://localhost:5713/api/some-collection/12345
|
|
6
|
-
*/
|
|
7
|
-
export declare function apiUrl(...args: string[]): string;
|
package/dist/core/api/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { env } from '$env/dynamic/public';
|
|
2
|
-
/**
|
|
3
|
-
* Build the api full url for given segments
|
|
4
|
-
* @example
|
|
5
|
-
* apiUrl('some-collection') // -> http://localhost:5713/api/some-collection
|
|
6
|
-
* apiUrl('some-collection', '12345') // -> http://localhost:5713/api/some-collection/12345
|
|
7
|
-
*/
|
|
8
|
-
export function apiUrl(...args) {
|
|
9
|
-
return `${env.PUBLIC_RIME_URL}/api/${args.join('/')}`;
|
|
10
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { PARAMS } from '../../constant.js';
|
|
2
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
3
|
-
import { trycatch } from '../../../util/function.js';
|
|
4
|
-
import { json } from '@sveltejs/kit';
|
|
5
|
-
export default function (slug) {
|
|
6
|
-
//
|
|
7
|
-
async function GET(event) {
|
|
8
|
-
const { rime } = event.locals;
|
|
9
|
-
const params = event.url.searchParams;
|
|
10
|
-
const areaAPI = rime.area(slug);
|
|
11
|
-
function buildSelect(params) {
|
|
12
|
-
const paramSelect = params.get(PARAMS.SELECT)
|
|
13
|
-
? params.get(PARAMS.SELECT).split(',')
|
|
14
|
-
: undefined;
|
|
15
|
-
if (paramSelect &&
|
|
16
|
-
paramSelect.includes('title') &&
|
|
17
|
-
!paramSelect.includes(areaAPI.config.asTitle)) {
|
|
18
|
-
paramSelect.push(areaAPI.config.asTitle);
|
|
19
|
-
}
|
|
20
|
-
return paramSelect;
|
|
21
|
-
}
|
|
22
|
-
const apiParams = {
|
|
23
|
-
locale: rime.getLocale(),
|
|
24
|
-
draft: params.get(PARAMS.DRAFT) ? params.get(PARAMS.DRAFT) === 'true' : undefined,
|
|
25
|
-
versionId: params.get(PARAMS.VERSION_ID) || undefined,
|
|
26
|
-
depth: params.get(PARAMS.DEPTH) ? parseInt(params.get(PARAMS.DEPTH)) : 0,
|
|
27
|
-
select: buildSelect(params)
|
|
28
|
-
};
|
|
29
|
-
const [error, doc] = await trycatch(() => rime.area(slug).find(apiParams));
|
|
30
|
-
if (error) {
|
|
31
|
-
return handleError(error, { context: 'api' });
|
|
32
|
-
}
|
|
33
|
-
return json({ doc });
|
|
34
|
-
}
|
|
35
|
-
return GET;
|
|
36
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { PARAMS } from '../../constant.js';
|
|
2
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
3
|
-
import { extractData } from '../../operations/extract-data.server.js';
|
|
4
|
-
import { trycatch } from '../../../util/function.js';
|
|
5
|
-
import { json } from '@sveltejs/kit';
|
|
6
|
-
export default function (slug) {
|
|
7
|
-
//
|
|
8
|
-
async function POST(event) {
|
|
9
|
-
const { rime } = event.locals;
|
|
10
|
-
const versionId = event.url.searchParams.get(PARAMS.VERSION_ID) || undefined;
|
|
11
|
-
const draft = event.url.searchParams.get(PARAMS.DRAFT)
|
|
12
|
-
? event.url.searchParams.get(PARAMS.DRAFT) === 'true'
|
|
13
|
-
: undefined;
|
|
14
|
-
const [extractError, data] = await trycatch(() => extractData(event.request));
|
|
15
|
-
if (extractError) {
|
|
16
|
-
return handleError(extractError, { context: 'api' });
|
|
17
|
-
}
|
|
18
|
-
if (data.locale) {
|
|
19
|
-
rime.setLocale(data.locale);
|
|
20
|
-
}
|
|
21
|
-
const [error, doc] = await trycatch(() => rime.area(slug).update({
|
|
22
|
-
data,
|
|
23
|
-
versionId,
|
|
24
|
-
draft,
|
|
25
|
-
locale: rime.getLocale()
|
|
26
|
-
}));
|
|
27
|
-
if (error) {
|
|
28
|
-
return handleError(error, { context: 'api' });
|
|
29
|
-
}
|
|
30
|
-
return json({ doc });
|
|
31
|
-
}
|
|
32
|
-
return POST;
|
|
33
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
2
|
-
import { extractData } from '../../operations/extract-data.server.js';
|
|
3
|
-
import { trycatch } from '../../../util/function.js';
|
|
4
|
-
import { json } from '@sveltejs/kit';
|
|
5
|
-
import { isAuthConfig } from '../auth/util.js';
|
|
6
|
-
export default function (slug) {
|
|
7
|
-
//
|
|
8
|
-
async function POST(event) {
|
|
9
|
-
const { rime } = event.locals;
|
|
10
|
-
const collection = rime.collection(slug);
|
|
11
|
-
const [extractError, data] = await trycatch(() => extractData(event.request));
|
|
12
|
-
if (extractError) {
|
|
13
|
-
return handleError(extractError, { context: 'api' });
|
|
14
|
-
}
|
|
15
|
-
// Bypass confirm password for api auth collection creation calls
|
|
16
|
-
if (isAuthConfig(collection.config) && 'password' in data) {
|
|
17
|
-
data.confirmPassword = data.password;
|
|
18
|
-
}
|
|
19
|
-
if (data.locale) {
|
|
20
|
-
rime.setLocale(data.locale);
|
|
21
|
-
}
|
|
22
|
-
const [error, document] = await trycatch(() => collection.create({ data, locale: rime.getLocale() }));
|
|
23
|
-
if (error) {
|
|
24
|
-
return handleError(error, { context: 'api' });
|
|
25
|
-
}
|
|
26
|
-
return json({ doc: document });
|
|
27
|
-
}
|
|
28
|
-
return POST;
|
|
29
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { normalizeQuery } from '../../../adapter-sqlite/util.server.js';
|
|
2
|
-
import { PARAMS } from '../../constant.js';
|
|
3
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
4
|
-
import { trycatch } from '../../../util/function.js';
|
|
5
|
-
import { json } from '@sveltejs/kit';
|
|
6
|
-
export default function (slug) {
|
|
7
|
-
//
|
|
8
|
-
async function DELETE(event) {
|
|
9
|
-
const { rime } = event.locals;
|
|
10
|
-
const params = event.url.searchParams;
|
|
11
|
-
const hasQueryParams = !!params
|
|
12
|
-
.keys()
|
|
13
|
-
.filter((key) => key.startsWith('where'))
|
|
14
|
-
.toArray().length;
|
|
15
|
-
const query = hasQueryParams ? normalizeQuery(event.url.search.substring(1)) : undefined;
|
|
16
|
-
const apiParams = {
|
|
17
|
-
locale: rime.getLocale(),
|
|
18
|
-
sort: params.get(PARAMS.SORT) || undefined,
|
|
19
|
-
depth: params.get(PARAMS.DEPTH) ? parseInt(params.get(PARAMS.DEPTH)) : 0,
|
|
20
|
-
limit: params.get(PARAMS.LIMIT) ? parseInt(params.get(PARAMS.LIMIT)) : undefined,
|
|
21
|
-
offset: params.get(PARAMS.OFFSET) ? parseInt(params.get(PARAMS.OFFSET)) : undefined,
|
|
22
|
-
query,
|
|
23
|
-
select: params.get(PARAMS.SELECT) ? params.get(PARAMS.SELECT).split(',') : undefined
|
|
24
|
-
};
|
|
25
|
-
const [error, docs] = await trycatch(() => rime.collection(slug).delete(apiParams));
|
|
26
|
-
if (error) {
|
|
27
|
-
return handleError(error, { context: 'api' });
|
|
28
|
-
}
|
|
29
|
-
return json({ docs }, { status: 200 });
|
|
30
|
-
}
|
|
31
|
-
return DELETE;
|
|
32
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
2
|
-
import { trycatch } from '../../../util/function.js';
|
|
3
|
-
import { json } from '@sveltejs/kit';
|
|
4
|
-
export default function (slug) {
|
|
5
|
-
//
|
|
6
|
-
async function DELETE(event) {
|
|
7
|
-
const { rime } = event.locals;
|
|
8
|
-
const id = event.params.id || '';
|
|
9
|
-
const [error] = await trycatch(() => rime.collection(slug).deleteById({ id }));
|
|
10
|
-
if (error) {
|
|
11
|
-
return handleError(error, { context: 'api' });
|
|
12
|
-
}
|
|
13
|
-
return json({ id });
|
|
14
|
-
}
|
|
15
|
-
return DELETE;
|
|
16
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { RimeError } from '../../errors/index.js';
|
|
2
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
3
|
-
import { error, json } from '@sveltejs/kit';
|
|
4
|
-
export default function (slug) {
|
|
5
|
-
//
|
|
6
|
-
async function POST(event) {
|
|
7
|
-
const { rime } = event.locals;
|
|
8
|
-
if (!rime.config.isCollection(slug)) {
|
|
9
|
-
return handleError(new RimeError(RimeError.NOT_FOUND), { context: 'api' });
|
|
10
|
-
}
|
|
11
|
-
const collection = rime.collection(slug);
|
|
12
|
-
if (!event.params.id)
|
|
13
|
-
throw error(404);
|
|
14
|
-
const newId = await collection.duplicate({ id: event.params.id });
|
|
15
|
-
return json({ id: newId });
|
|
16
|
-
}
|
|
17
|
-
return POST;
|
|
18
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { normalizeQuery } from '../../../adapter-sqlite/util.server.js';
|
|
2
|
-
import { PARAMS } from '../../constant.js';
|
|
3
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
4
|
-
import { trycatch } from '../../../util/function.js';
|
|
5
|
-
import { json } from '@sveltejs/kit';
|
|
6
|
-
export default function (slug) {
|
|
7
|
-
//
|
|
8
|
-
async function GET(event) {
|
|
9
|
-
const { rime } = event.locals;
|
|
10
|
-
const params = event.url.searchParams;
|
|
11
|
-
const hasQueryParams = !!params
|
|
12
|
-
.keys()
|
|
13
|
-
.filter((key) => key.startsWith('where'))
|
|
14
|
-
.toArray().length;
|
|
15
|
-
const collectionAPI = rime.collection(slug);
|
|
16
|
-
function buildSelect(params) {
|
|
17
|
-
const paramSelect = params.get(PARAMS.SELECT)
|
|
18
|
-
? params.get(PARAMS.SELECT).split(',')
|
|
19
|
-
: undefined;
|
|
20
|
-
if (paramSelect &&
|
|
21
|
-
paramSelect.includes('title') &&
|
|
22
|
-
!paramSelect.includes(collectionAPI.config.asTitle)) {
|
|
23
|
-
paramSelect.push(collectionAPI.config.asTitle);
|
|
24
|
-
}
|
|
25
|
-
return paramSelect;
|
|
26
|
-
}
|
|
27
|
-
const query = hasQueryParams ? normalizeQuery(event.url.search.substring(1)) : undefined;
|
|
28
|
-
const apiParams = {
|
|
29
|
-
locale: rime.getLocale(),
|
|
30
|
-
sort: params.get(PARAMS.SORT) || undefined,
|
|
31
|
-
depth: params.get(PARAMS.DEPTH) ? parseInt(params.get(PARAMS.DEPTH)) : 0,
|
|
32
|
-
limit: params.get(PARAMS.LIMIT) ? parseInt(params.get(PARAMS.LIMIT)) : undefined,
|
|
33
|
-
offset: params.get(PARAMS.OFFSET) ? parseInt(params.get(PARAMS.OFFSET)) : undefined,
|
|
34
|
-
draft: params.get(PARAMS.DRAFT) ? params.get(PARAMS.DRAFT) === 'true' : undefined,
|
|
35
|
-
query,
|
|
36
|
-
select: buildSelect(params)
|
|
37
|
-
};
|
|
38
|
-
const [error, docs] = await trycatch(() => collectionAPI.find(apiParams));
|
|
39
|
-
if (error) {
|
|
40
|
-
return handleError(error, { context: 'api' });
|
|
41
|
-
}
|
|
42
|
-
return json({ docs }, { status: 200 });
|
|
43
|
-
}
|
|
44
|
-
return GET;
|
|
45
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { PARAMS } from '../../constant.js';
|
|
2
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
3
|
-
import { trycatch } from '../../../util/function.js';
|
|
4
|
-
import { json } from '@sveltejs/kit';
|
|
5
|
-
export default function (slug) {
|
|
6
|
-
//
|
|
7
|
-
async function GET(event) {
|
|
8
|
-
const { rime } = event.locals;
|
|
9
|
-
const id = event.params.id || '-1';
|
|
10
|
-
const paramDepth = event.url.searchParams.get(PARAMS.DEPTH);
|
|
11
|
-
const paramDraft = event.url.searchParams.get(PARAMS.DRAFT);
|
|
12
|
-
const versionId = event.url.searchParams.get(PARAMS.VERSION_ID) || undefined;
|
|
13
|
-
const draft = paramDraft ? paramDraft === 'true' : undefined;
|
|
14
|
-
const depth = typeof paramDepth === 'string' ? parseInt(paramDepth) : 0;
|
|
15
|
-
const select = event.url.searchParams.get(PARAMS.SELECT)?.split(',') || undefined;
|
|
16
|
-
const [error, document] = await trycatch(() => rime.collection(slug).findById({
|
|
17
|
-
id,
|
|
18
|
-
locale: rime.getLocale(),
|
|
19
|
-
depth,
|
|
20
|
-
draft,
|
|
21
|
-
versionId,
|
|
22
|
-
select
|
|
23
|
-
}));
|
|
24
|
-
if (error) {
|
|
25
|
-
return handleError(error, { context: 'api' });
|
|
26
|
-
}
|
|
27
|
-
return json({ doc: document });
|
|
28
|
-
}
|
|
29
|
-
return GET;
|
|
30
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import create from './create.server.js';
|
|
2
|
-
import deleteDocs from './delete.server.js';
|
|
3
|
-
import deleteById from './deleteById.server.js';
|
|
4
|
-
import duplicate from './duplicate.server.js';
|
|
5
|
-
import get from './get.server.js';
|
|
6
|
-
import getById from './getById.server.js';
|
|
7
|
-
import updateById from './updateById.server.js';
|
|
8
|
-
declare const operations: {
|
|
9
|
-
get: typeof get;
|
|
10
|
-
getById: typeof getById;
|
|
11
|
-
deleteById: typeof deleteById;
|
|
12
|
-
delete: typeof deleteDocs;
|
|
13
|
-
create: typeof create;
|
|
14
|
-
updateById: typeof updateById;
|
|
15
|
-
duplicate: typeof duplicate;
|
|
16
|
-
};
|
|
17
|
-
export default operations;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import create from './create.server.js';
|
|
2
|
-
import deleteDocs from './delete.server.js';
|
|
3
|
-
import deleteById from './deleteById.server.js';
|
|
4
|
-
import duplicate from './duplicate.server.js';
|
|
5
|
-
import get from './get.server.js';
|
|
6
|
-
import getById from './getById.server.js';
|
|
7
|
-
import updateById from './updateById.server.js';
|
|
8
|
-
const operations = { get, getById, deleteById, delete: deleteDocs, create, updateById, duplicate };
|
|
9
|
-
export default operations;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { PARAMS } from '../../constant.js';
|
|
2
|
-
import { handleError } from '../../errors/handler.server.js';
|
|
3
|
-
import { RimeError } from '../../errors/index.js';
|
|
4
|
-
import { extractData } from '../../operations/extract-data.server.js';
|
|
5
|
-
import { trycatch } from '../../../util/function.js';
|
|
6
|
-
import { json } from '@sveltejs/kit';
|
|
7
|
-
export default function (slug) {
|
|
8
|
-
//
|
|
9
|
-
async function PATCH(event) {
|
|
10
|
-
const { rime } = event.locals;
|
|
11
|
-
const id = event.params.id;
|
|
12
|
-
if (!id)
|
|
13
|
-
throw new RimeError(RimeError.NOT_FOUND);
|
|
14
|
-
const versionId = event.url.searchParams.get(PARAMS.VERSION_ID) || undefined;
|
|
15
|
-
const draft = event.url.searchParams.get(PARAMS.DRAFT)
|
|
16
|
-
? event.url.searchParams.get(PARAMS.DRAFT) === 'true'
|
|
17
|
-
: undefined;
|
|
18
|
-
const [extractError, data] = await trycatch(() => extractData(event.request));
|
|
19
|
-
if (extractError) {
|
|
20
|
-
return handleError(extractError, { context: 'api' });
|
|
21
|
-
}
|
|
22
|
-
if (data.locale) {
|
|
23
|
-
rime.setLocale(data.locale);
|
|
24
|
-
}
|
|
25
|
-
const [error, document] = await trycatch(() => rime.collection(slug).updateById({
|
|
26
|
-
id,
|
|
27
|
-
data,
|
|
28
|
-
locale: rime.getLocale(),
|
|
29
|
-
versionId,
|
|
30
|
-
draft
|
|
31
|
-
}));
|
|
32
|
-
if (error) {
|
|
33
|
-
return handleError(error, { context: 'api' });
|
|
34
|
-
}
|
|
35
|
-
return json({ doc: document });
|
|
36
|
-
}
|
|
37
|
-
return PATCH;
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getPackageInfoByKey(key: string): string;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Routes } from './util.server.js';
|
|
2
|
-
/**
|
|
3
|
-
* Area routes dictionary defining route patterns and their corresponding templates
|
|
4
|
-
*/
|
|
5
|
-
export declare const areaRoutes: Routes;
|
|
6
|
-
export declare const areaVersionsPanelRoutes: Routes;
|
|
7
|
-
export declare const areaAPIRoutes: Routes;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { PACKAGE_NAME } from '../../../constant.server.js';
|
|
2
|
-
import { TScastVersionSlug } from './util.server.js';
|
|
3
|
-
/**
|
|
4
|
-
* Area templates defined outside of the routes object
|
|
5
|
-
* (rime)/panel/{area.kebab}/+page.svelte
|
|
6
|
-
*/
|
|
7
|
-
const pageTemplate = () => `
|
|
8
|
-
<script>
|
|
9
|
-
import { Area } from '${PACKAGE_NAME}/panel/client'
|
|
10
|
-
const { data } = $props()
|
|
11
|
-
</script>
|
|
12
|
-
<Area {data} />`;
|
|
13
|
-
/**
|
|
14
|
-
* Page server template for area
|
|
15
|
-
* (rime)/panel/{area.kebab}/+page.server.ts
|
|
16
|
-
*/
|
|
17
|
-
const pageServerTemplate = (slug) => `
|
|
18
|
-
import { pagesLoad, pagesActions } from '${PACKAGE_NAME}/panel'
|
|
19
|
-
|
|
20
|
-
export const load = pagesLoad.area('${slug}')
|
|
21
|
-
export const actions = pagesActions.area('${slug}')
|
|
22
|
-
`;
|
|
23
|
-
const pageServerTemplateVersions = (slug) => `
|
|
24
|
-
import { pagesLoad, pagesActions } from '${PACKAGE_NAME}/panel'
|
|
25
|
-
|
|
26
|
-
export const load = pagesLoad.area('${slug}', true)
|
|
27
|
-
export const actions = pagesActions.area('${slug}')
|
|
28
|
-
`;
|
|
29
|
-
/**
|
|
30
|
-
* API collection list operations
|
|
31
|
-
* (rime)/api/{collection.slug}/+server.ts
|
|
32
|
-
*/
|
|
33
|
-
const apiAreaServer = (slug) => `
|
|
34
|
-
import * as api from '${PACKAGE_NAME}/api';
|
|
35
|
-
|
|
36
|
-
export const GET = api.area.get(${TScastVersionSlug(slug)})
|
|
37
|
-
export const PATCH = api.area.update(${TScastVersionSlug(slug)})
|
|
38
|
-
`;
|
|
39
|
-
/**
|
|
40
|
-
* Document page versions template
|
|
41
|
-
* (rime)/panel/{collection.slug}/[id]/versions/+page.svelte
|
|
42
|
-
*/
|
|
43
|
-
const pageVersions = () => `
|
|
44
|
-
<script lang="ts">
|
|
45
|
-
import { AreaVersionsDoc, type AreaDocData } from '${PACKAGE_NAME}/panel/client';
|
|
46
|
-
const { data }: { data: AreaDocData<true> } = $props();
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<AreaVersionsDoc {data} />`;
|
|
50
|
-
/**
|
|
51
|
-
* Area routes dictionary defining route patterns and their corresponding templates
|
|
52
|
-
*/
|
|
53
|
-
export const areaRoutes = {
|
|
54
|
-
'(rime)/panel/{area.kebab}/': {
|
|
55
|
-
page: pageTemplate,
|
|
56
|
-
pageServer: pageServerTemplate
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
export const areaVersionsPanelRoutes = {
|
|
60
|
-
'(rime)/panel/{area.kebab}/versions': {
|
|
61
|
-
page: pageVersions,
|
|
62
|
-
pageServer: pageServerTemplateVersions
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
export const areaAPIRoutes = {
|
|
66
|
-
'(rime)/api/{area.kebab}/': {
|
|
67
|
-
server: apiAreaServer
|
|
68
|
-
}
|
|
69
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type Routes } from './util.server.js';
|
|
2
|
-
/****************************************************/
|
|
3
|
-
/**
|
|
4
|
-
* Collection panel routes
|
|
5
|
-
*/
|
|
6
|
-
export declare const collectionPanelRoutes: Routes;
|
|
7
|
-
/**
|
|
8
|
-
* Collection verions panel routes
|
|
9
|
-
*/
|
|
10
|
-
export declare const collectionVersionsPanelRoutes: Routes;
|
|
11
|
-
/**
|
|
12
|
-
* Collection API routes
|
|
13
|
-
*/
|
|
14
|
-
export declare const collectionAPIRoutes: Routes;
|