@studiocms/devapps 0.1.0-beta.9 → 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 +1 -1
- package/README.md +3 -23
- package/dist/effects/WordPressAPI/configs.d.ts +87 -0
- package/dist/effects/WordPressAPI/configs.js +88 -0
- package/dist/effects/WordPressAPI/converters.d.ts +57 -0
- package/dist/effects/WordPressAPI/converters.js +331 -0
- package/dist/effects/WordPressAPI/errors.d.ts +12 -0
- package/dist/effects/WordPressAPI/errors.js +6 -0
- package/dist/effects/WordPressAPI/importers.d.ts +19 -0
- package/dist/effects/WordPressAPI/importers.js +122 -0
- package/dist/effects/WordPressAPI/schema.d.ts +478 -0
- package/dist/effects/WordPressAPI/schema.js +127 -0
- package/dist/effects/WordPressAPI/utils.d.ts +17 -0
- package/dist/effects/WordPressAPI/utils.js +239 -0
- package/dist/effects/wpImporter.d.ts +14 -0
- package/dist/effects/wpImporter.js +88 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -16
- package/dist/routes/wp-importer.d.ts +0 -25
- package/dist/routes/wp-importer.js +9 -54
- package/dist/schema/index.d.ts +0 -24
- package/dist/schema/index.js +1 -13
- package/dist/utils/pathGenerator.js +3 -1
- package/dist/virt.d.ts +1 -5
- package/package.json +25 -31
- package/dist/apps/libsql-viewer.d.ts +0 -46
- package/dist/apps/libsql-viewer.js +0 -95
- package/dist/schema/wp-api.d.ts +0 -439
- package/dist/schema/wp-api.js +0 -72
- package/dist/utils/wp-api/converters.d.ts +0 -74
- package/dist/utils/wp-api/converters.js +0 -181
- package/dist/utils/wp-api/index.d.ts +0 -6
- package/dist/utils/wp-api/index.js +0 -3
- package/dist/utils/wp-api/pages.d.ts +0 -13
- package/dist/utils/wp-api/pages.js +0 -38
- package/dist/utils/wp-api/posts.d.ts +0 -10
- package/dist/utils/wp-api/posts.js +0 -38
- package/dist/utils/wp-api/settings.d.ts +0 -18
- package/dist/utils/wp-api/settings.js +0 -45
- package/dist/utils/wp-api/utils.d.ts +0 -66
- package/dist/utils/wp-api/utils.js +0 -138
- package/dist/virt.d.js +0 -0
package/dist/schema/index.d.ts
CHANGED
|
@@ -23,10 +23,6 @@ import { z } from 'astro/zod';
|
|
|
23
23
|
* - `wpImporter` - An object with `enabled` and `endpoint` properties for the app's configuration.
|
|
24
24
|
*/
|
|
25
25
|
export declare const AppsConfigSchema: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
26
|
-
/**
|
|
27
|
-
* Astro DB LibSQL Viewer App Config
|
|
28
|
-
*/
|
|
29
|
-
libSQLViewer: z.ZodDefault<z.ZodBoolean>;
|
|
30
26
|
/**
|
|
31
27
|
* StudioCMS WP API Importer App Config
|
|
32
28
|
*/
|
|
@@ -38,7 +34,6 @@ export declare const AppsConfigSchema: z.ZodEffects<z.ZodDefault<z.ZodOptional<z
|
|
|
38
34
|
endpoint?: string | undefined;
|
|
39
35
|
}>]>;
|
|
40
36
|
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
libSQLViewer: boolean;
|
|
42
37
|
wpImporter: boolean | {
|
|
43
38
|
endpoint: string;
|
|
44
39
|
};
|
|
@@ -46,11 +41,7 @@ export declare const AppsConfigSchema: z.ZodEffects<z.ZodDefault<z.ZodOptional<z
|
|
|
46
41
|
wpImporter: boolean | {
|
|
47
42
|
endpoint?: string | undefined;
|
|
48
43
|
};
|
|
49
|
-
libSQLViewer?: boolean | undefined;
|
|
50
44
|
}>>>, {
|
|
51
|
-
libSQLViewer: {
|
|
52
|
-
enabled: boolean;
|
|
53
|
-
};
|
|
54
45
|
wpImporter: {
|
|
55
46
|
enabled: boolean;
|
|
56
47
|
endpoint: string;
|
|
@@ -59,7 +50,6 @@ export declare const AppsConfigSchema: z.ZodEffects<z.ZodDefault<z.ZodOptional<z
|
|
|
59
50
|
wpImporter: boolean | {
|
|
60
51
|
endpoint?: string | undefined;
|
|
61
52
|
};
|
|
62
|
-
libSQLViewer?: boolean | undefined;
|
|
63
53
|
} | undefined>;
|
|
64
54
|
/**
|
|
65
55
|
* Schema definition for StudioCMS development applications configuration.
|
|
@@ -79,10 +69,6 @@ export declare const StudioCMSDevAppsSchema: z.ZodDefault<z.ZodOptional<z.ZodObj
|
|
|
79
69
|
endpoint: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
80
70
|
verbose: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
81
71
|
appsConfig: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
82
|
-
/**
|
|
83
|
-
* Astro DB LibSQL Viewer App Config
|
|
84
|
-
*/
|
|
85
|
-
libSQLViewer: z.ZodDefault<z.ZodBoolean>;
|
|
86
72
|
/**
|
|
87
73
|
* StudioCMS WP API Importer App Config
|
|
88
74
|
*/
|
|
@@ -94,7 +80,6 @@ export declare const StudioCMSDevAppsSchema: z.ZodDefault<z.ZodOptional<z.ZodObj
|
|
|
94
80
|
endpoint?: string | undefined;
|
|
95
81
|
}>]>;
|
|
96
82
|
}, "strip", z.ZodTypeAny, {
|
|
97
|
-
libSQLViewer: boolean;
|
|
98
83
|
wpImporter: boolean | {
|
|
99
84
|
endpoint: string;
|
|
100
85
|
};
|
|
@@ -102,11 +87,7 @@ export declare const StudioCMSDevAppsSchema: z.ZodDefault<z.ZodOptional<z.ZodObj
|
|
|
102
87
|
wpImporter: boolean | {
|
|
103
88
|
endpoint?: string | undefined;
|
|
104
89
|
};
|
|
105
|
-
libSQLViewer?: boolean | undefined;
|
|
106
90
|
}>>>, {
|
|
107
|
-
libSQLViewer: {
|
|
108
|
-
enabled: boolean;
|
|
109
|
-
};
|
|
110
91
|
wpImporter: {
|
|
111
92
|
enabled: boolean;
|
|
112
93
|
endpoint: string;
|
|
@@ -115,15 +96,11 @@ export declare const StudioCMSDevAppsSchema: z.ZodDefault<z.ZodOptional<z.ZodObj
|
|
|
115
96
|
wpImporter: boolean | {
|
|
116
97
|
endpoint?: string | undefined;
|
|
117
98
|
};
|
|
118
|
-
libSQLViewer?: boolean | undefined;
|
|
119
99
|
} | undefined>;
|
|
120
100
|
}, "strip", z.ZodTypeAny, {
|
|
121
101
|
endpoint: string;
|
|
122
102
|
verbose: boolean;
|
|
123
103
|
appsConfig: {
|
|
124
|
-
libSQLViewer: {
|
|
125
|
-
enabled: boolean;
|
|
126
|
-
};
|
|
127
104
|
wpImporter: {
|
|
128
105
|
enabled: boolean;
|
|
129
106
|
endpoint: string;
|
|
@@ -136,7 +113,6 @@ export declare const StudioCMSDevAppsSchema: z.ZodDefault<z.ZodOptional<z.ZodObj
|
|
|
136
113
|
wpImporter: boolean | {
|
|
137
114
|
endpoint?: string | undefined;
|
|
138
115
|
};
|
|
139
|
-
libSQLViewer?: boolean | undefined;
|
|
140
116
|
} | undefined;
|
|
141
117
|
}>>>;
|
|
142
118
|
/**
|
package/dist/schema/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { z } from "astro/zod";
|
|
2
2
|
const AppsConfigSchema = z.object({
|
|
3
|
-
/**
|
|
4
|
-
* Astro DB LibSQL Viewer App Config
|
|
5
|
-
*/
|
|
6
|
-
libSQLViewer: z.boolean().default(true),
|
|
7
3
|
/**
|
|
8
4
|
* StudioCMS WP API Importer App Config
|
|
9
5
|
*/
|
|
@@ -14,23 +10,15 @@ const AppsConfigSchema = z.object({
|
|
|
14
10
|
})
|
|
15
11
|
])
|
|
16
12
|
}).optional().default({
|
|
17
|
-
wpImporter: { endpoint: "wp-api-importer" }
|
|
18
|
-
libSQLViewer: true
|
|
13
|
+
wpImporter: { endpoint: "wp-api-importer" }
|
|
19
14
|
}).transform((val) => {
|
|
20
|
-
let libSQL;
|
|
21
15
|
let wpAPI;
|
|
22
|
-
if (typeof val.libSQLViewer === "boolean") {
|
|
23
|
-
libSQL = { enabled: val.libSQLViewer };
|
|
24
|
-
} else {
|
|
25
|
-
libSQL = { enabled: true };
|
|
26
|
-
}
|
|
27
16
|
if (typeof val.wpImporter === "boolean") {
|
|
28
17
|
wpAPI = { enabled: val.wpImporter, endpoint: "wp-api-importer" };
|
|
29
18
|
} else {
|
|
30
19
|
wpAPI = { enabled: true, endpoint: val.wpImporter.endpoint };
|
|
31
20
|
}
|
|
32
21
|
return {
|
|
33
|
-
libSQLViewer: libSQL,
|
|
34
22
|
wpImporter: wpAPI
|
|
35
23
|
};
|
|
36
24
|
});
|
|
@@ -25,7 +25,9 @@ const pathGenerator = (endpointPath, _base) => {
|
|
|
25
25
|
const newEndpointPath = stripTrailingSlash(endpointPath);
|
|
26
26
|
return function pathBuilder(path) {
|
|
27
27
|
const newPath = stripLeadingSlash(path);
|
|
28
|
-
|
|
28
|
+
const base2 = pathWithBase(newEndpointPath, _base);
|
|
29
|
+
const sep = base2.endsWith("/") ? "" : "/";
|
|
30
|
+
return `${base2}${sep}${newPath}`;
|
|
29
31
|
};
|
|
30
32
|
};
|
|
31
33
|
export {
|
package/dist/virt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="
|
|
1
|
+
/// <reference types="studiocms/v/types" />
|
|
2
2
|
|
|
3
3
|
declare module 'virtual:studiocms-devapps/endpoints' {
|
|
4
4
|
export const wpAPIEndpoint: string;
|
|
@@ -6,8 +6,4 @@ declare module 'virtual:studiocms-devapps/endpoints' {
|
|
|
6
6
|
|
|
7
7
|
declare module 'virtual:studiocms-devapps/config' {
|
|
8
8
|
export const userProjectRoot: string;
|
|
9
|
-
export const dbEnv: {
|
|
10
|
-
remoteUrl: string;
|
|
11
|
-
token: string;
|
|
12
|
-
};
|
|
13
9
|
}
|
package/package.json
CHANGED
|
@@ -1,36 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/devapps",
|
|
3
|
-
"version": "0.1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Devapps for StudioCMS Astro projects, including a WordPress importer.",
|
|
5
5
|
"author": {
|
|
6
|
-
"name": "
|
|
6
|
+
"name": "withstudiocms",
|
|
7
7
|
"url": "https://studiocms.dev"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/withstudiocms/studiocms.git",
|
|
12
|
-
"directory": "packages/
|
|
12
|
+
"directory": "packages/@studiocms/devapps"
|
|
13
13
|
},
|
|
14
14
|
"contributors": [
|
|
15
15
|
"Adammatthiesen",
|
|
16
16
|
"jdtjenkins",
|
|
17
|
-
"dreyfus92"
|
|
17
|
+
"dreyfus92",
|
|
18
|
+
"code.spirit"
|
|
18
19
|
],
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"keywords": [
|
|
21
22
|
"astro",
|
|
22
|
-
"astrodb",
|
|
23
|
-
"astrolicious",
|
|
24
23
|
"astro-integration",
|
|
25
24
|
"studiocms",
|
|
26
25
|
"withastro",
|
|
27
26
|
"wordpress",
|
|
28
27
|
"wordpress-import",
|
|
29
28
|
"wordpress-importer",
|
|
30
|
-
"libsql",
|
|
31
|
-
"libsql-viewer",
|
|
32
|
-
"libsql-client",
|
|
33
|
-
"libsqlstudio",
|
|
34
29
|
"devapp",
|
|
35
30
|
"astro-devapp",
|
|
36
31
|
"astro-devtoolbarapp"
|
|
@@ -53,31 +48,30 @@
|
|
|
53
48
|
},
|
|
54
49
|
"type": "module",
|
|
55
50
|
"dependencies": {
|
|
56
|
-
"astro-integration-kit": "^0.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"html-entities": "^2.5.2",
|
|
61
|
-
"@outerbase/sdk-transform": "^1.0.5"
|
|
51
|
+
"astro-integration-kit": "^0.19.1",
|
|
52
|
+
"cheerio": "^1.1.2",
|
|
53
|
+
"turndown": "^7.2.2",
|
|
54
|
+
"sanitize-html": "^2.17.0"
|
|
62
55
|
},
|
|
63
56
|
"devDependencies": {
|
|
64
|
-
"@types/
|
|
65
|
-
"@types/
|
|
66
|
-
"typescript": "^5.
|
|
57
|
+
"@types/turndown": "^5.0.6",
|
|
58
|
+
"@types/sanitize-html": "^2.16.0",
|
|
59
|
+
"typescript": "^5.9.3"
|
|
67
60
|
},
|
|
68
61
|
"peerDependencies": {
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"vite": "^6.
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"studiocms": {
|
|
76
|
-
"optional": true
|
|
77
|
-
}
|
|
62
|
+
"astro": "^5.12.9",
|
|
63
|
+
"effect": "^3.19.14",
|
|
64
|
+
"vite": "^6.3.4",
|
|
65
|
+
"@withstudiocms/kysely": "0.1.0",
|
|
66
|
+
"@withstudiocms/sdk": "0.1.0",
|
|
67
|
+
"studiocms": "0.1.0"
|
|
78
68
|
},
|
|
79
69
|
"scripts": {
|
|
80
|
-
"build": "
|
|
81
|
-
"dev": "
|
|
70
|
+
"build": "buildkit build 'src/**/*.{ts,astro,css,json,png,d.ts}'",
|
|
71
|
+
"dev": "buildkit dev 'src/**/*.{ts,astro,css,json,png,d.ts}'",
|
|
72
|
+
"typecheck": "tspc -p tsconfig.tspc.json",
|
|
73
|
+
"effect-check": "pnpm effect-language-service diagnostics --project tsconfig.tspc.json",
|
|
74
|
+
"ci:effect-check": "pnpm effect-check --format github-actions",
|
|
75
|
+
"test": "vitest"
|
|
82
76
|
}
|
|
83
77
|
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the source URL for an iframe based on the provided database URL.
|
|
3
|
-
*
|
|
4
|
-
* @param dbUrl - The URL of the database.
|
|
5
|
-
* @returns The source URL for the iframe. If the database URL contains 'turso.io',
|
|
6
|
-
* it returns `tursoURL`. Otherwise, it returns `sqlLiteUrl`.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getIFrameSrc(dbUrl: string): "https://studio.outerbase.com/embed/sqlite?theme=dark" | "https://studio.outerbase.com/embed/turso?theme=dark";
|
|
9
|
-
/**
|
|
10
|
-
* Defines a toolbar application for viewing and interacting with a libSQL database.
|
|
11
|
-
*
|
|
12
|
-
* @param {HTMLCanvasElement} canvas - The canvas element where the app will be initialized.
|
|
13
|
-
* @param {EventTarget} eventTarget - The event target for handling outside click events.
|
|
14
|
-
*
|
|
15
|
-
* @returns {void}
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import libsqlViewer from './libsql-viewer';
|
|
20
|
-
*
|
|
21
|
-
* const canvas = document.getElementById('appCanvas') as HTMLCanvasElement;
|
|
22
|
-
* const eventTarget = new EventTarget();
|
|
23
|
-
*
|
|
24
|
-
* libsqlViewer.init(canvas, eventTarget);
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* This function creates an iframe to display the libSQL database viewer and sets up
|
|
29
|
-
* event listeners to handle SQL query and transaction requests via postMessage.
|
|
30
|
-
*
|
|
31
|
-
* The iframe's source URL and authentication token are retrieved from the `dbEnv` object.
|
|
32
|
-
*
|
|
33
|
-
* The `createClient` function is used to create a client for executing SQL queries and transactions.
|
|
34
|
-
*
|
|
35
|
-
* The `closeOnOutsideClick` function is used to close the app window when a click is detected outside of it.
|
|
36
|
-
*
|
|
37
|
-
* The `transformTursoResult` function is used to transform the results of SQL queries and transactions.
|
|
38
|
-
*
|
|
39
|
-
* The `biome-ignore` comments are used to suppress linting warnings for non-null assertions.
|
|
40
|
-
*
|
|
41
|
-
* @see {@link createClient}
|
|
42
|
-
* @see {@link closeOnOutsideClick}
|
|
43
|
-
* @see {@link transformTursoResult}
|
|
44
|
-
*/
|
|
45
|
-
declare const _default: import("astro").DevToolbarApp;
|
|
46
|
-
export default _default;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { dbEnv } from "virtual:studiocms-devapps/config";
|
|
2
|
-
import { createClient } from "@libsql/client/web";
|
|
3
|
-
import { transformTursoResult } from "@outerbase/sdk-transform";
|
|
4
|
-
import { defineToolbarApp } from "astro/toolbar";
|
|
5
|
-
import { closeOnOutsideClick } from "../utils/app-utils.js";
|
|
6
|
-
const sqlLiteUrl = "https://studio.outerbase.com/embed/sqlite?theme=dark";
|
|
7
|
-
const tursoURL = "https://studio.outerbase.com/embed/turso?theme=dark";
|
|
8
|
-
function getIFrameSrc(dbUrl) {
|
|
9
|
-
if (dbUrl.includes("turso.io")) {
|
|
10
|
-
return tursoURL;
|
|
11
|
-
}
|
|
12
|
-
return sqlLiteUrl;
|
|
13
|
-
}
|
|
14
|
-
var libsql_viewer_default = defineToolbarApp({
|
|
15
|
-
init(canvas, eventTarget) {
|
|
16
|
-
const appWindow = document.createElement("astro-dev-toolbar-window");
|
|
17
|
-
appWindow.style.width = "95%";
|
|
18
|
-
appWindow.style.height = "95%";
|
|
19
|
-
closeOnOutsideClick(eventTarget);
|
|
20
|
-
const viewerIframe = document.createElement("iframe");
|
|
21
|
-
viewerIframe.src = getIFrameSrc(dbEnv.remoteUrl);
|
|
22
|
-
viewerIframe.id = "sqlIframe";
|
|
23
|
-
viewerIframe.title = "libSQL Database Viewer";
|
|
24
|
-
Object.assign(viewerIframe.dataset, {
|
|
25
|
-
url: dbEnv.remoteUrl,
|
|
26
|
-
authtoken: dbEnv.token
|
|
27
|
-
});
|
|
28
|
-
Object.assign(viewerIframe.style, {
|
|
29
|
-
height: "100%",
|
|
30
|
-
width: "100%",
|
|
31
|
-
border: "1px solid rgba(27, 30, 36, 1)"
|
|
32
|
-
});
|
|
33
|
-
appWindow.appendChild(viewerIframe);
|
|
34
|
-
const client = createClient({
|
|
35
|
-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
36
|
-
url: viewerIframe.dataset.url,
|
|
37
|
-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
38
|
-
authToken: viewerIframe.dataset.authtoken
|
|
39
|
-
});
|
|
40
|
-
window.addEventListener("message", async (e) => {
|
|
41
|
-
const contentWindow = viewerIframe.contentWindow;
|
|
42
|
-
if (contentWindow && e.data) {
|
|
43
|
-
const { type, id, statement, statements } = e.data;
|
|
44
|
-
if (type === "query" && statement) {
|
|
45
|
-
try {
|
|
46
|
-
const result = await client.execute(statement);
|
|
47
|
-
contentWindow.postMessage(
|
|
48
|
-
{
|
|
49
|
-
type,
|
|
50
|
-
id,
|
|
51
|
-
data: transformTursoResult(result)
|
|
52
|
-
},
|
|
53
|
-
"*"
|
|
54
|
-
);
|
|
55
|
-
} catch (err) {
|
|
56
|
-
contentWindow.postMessage(
|
|
57
|
-
{
|
|
58
|
-
type,
|
|
59
|
-
id,
|
|
60
|
-
error: err.message
|
|
61
|
-
},
|
|
62
|
-
"*"
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
} else if (type === "transaction" && statements) {
|
|
66
|
-
try {
|
|
67
|
-
const result = await client.batch(statements, "write");
|
|
68
|
-
contentWindow.postMessage(
|
|
69
|
-
{
|
|
70
|
-
type,
|
|
71
|
-
id,
|
|
72
|
-
data: result.map(transformTursoResult)
|
|
73
|
-
},
|
|
74
|
-
"*"
|
|
75
|
-
);
|
|
76
|
-
} catch (err) {
|
|
77
|
-
contentWindow.postMessage(
|
|
78
|
-
{
|
|
79
|
-
type,
|
|
80
|
-
id,
|
|
81
|
-
error: err.message
|
|
82
|
-
},
|
|
83
|
-
"*"
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
canvas.appendChild(appWindow);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
export {
|
|
93
|
-
libsql_viewer_default as default,
|
|
94
|
-
getIFrameSrc
|
|
95
|
-
};
|