@mano8/astro-prompt-m8 0.1.0-alpha.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/LICENSE +201 -0
- package/README.md +116 -0
- package/dist/src/integration.d.ts +42 -0
- package/dist/src/integration.d.ts.map +1 -0
- package/dist/src/integration.js +86 -0
- package/dist/src/integration.js.map +1 -0
- package/dist/src/lib/csp.d.ts +25 -0
- package/dist/src/lib/csp.d.ts.map +1 -0
- package/dist/src/lib/csp.js +53 -0
- package/dist/src/lib/csp.js.map +1 -0
- package/dist/src/middleware.d.ts +4 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/middleware.js +24 -0
- package/dist/src/middleware.js.map +1 -0
- package/dist/src/runtime/api/admin.d.ts +15 -0
- package/dist/src/runtime/api/admin.d.ts.map +1 -0
- package/dist/src/runtime/api/admin.js +39 -0
- package/dist/src/runtime/api/admin.js.map +1 -0
- package/dist/src/runtime/api/blocks.d.ts +24 -0
- package/dist/src/runtime/api/blocks.d.ts.map +1 -0
- package/dist/src/runtime/api/blocks.js +74 -0
- package/dist/src/runtime/api/blocks.js.map +1 -0
- package/dist/src/runtime/api/categories.d.ts +7 -0
- package/dist/src/runtime/api/categories.d.ts.map +1 -0
- package/dist/src/runtime/api/categories.js +49 -0
- package/dist/src/runtime/api/categories.js.map +1 -0
- package/dist/src/runtime/api/dashboard.d.ts +6 -0
- package/dist/src/runtime/api/dashboard.d.ts.map +1 -0
- package/dist/src/runtime/api/dashboard.js +21 -0
- package/dist/src/runtime/api/dashboard.js.map +1 -0
- package/dist/src/runtime/api/index.d.ts +46 -0
- package/dist/src/runtime/api/index.d.ts.map +1 -0
- package/dist/src/runtime/api/index.js +48 -0
- package/dist/src/runtime/api/index.js.map +1 -0
- package/dist/src/runtime/api/internal.server.d.ts +18 -0
- package/dist/src/runtime/api/internal.server.d.ts.map +1 -0
- package/dist/src/runtime/api/internal.server.js +43 -0
- package/dist/src/runtime/api/internal.server.js.map +1 -0
- package/dist/src/runtime/api/templates.d.ts +14 -0
- package/dist/src/runtime/api/templates.d.ts.map +1 -0
- package/dist/src/runtime/api/templates.js +108 -0
- package/dist/src/runtime/api/templates.js.map +1 -0
- package/dist/src/runtime/authAdapter.d.ts +48 -0
- package/dist/src/runtime/authAdapter.d.ts.map +1 -0
- package/dist/src/runtime/authAdapter.js +62 -0
- package/dist/src/runtime/authAdapter.js.map +1 -0
- package/dist/src/runtime/client.d.ts +24 -0
- package/dist/src/runtime/client.d.ts.map +1 -0
- package/dist/src/runtime/client.js +85 -0
- package/dist/src/runtime/client.js.map +1 -0
- package/dist/src/runtime/compatibility.d.ts +32 -0
- package/dist/src/runtime/compatibility.d.ts.map +1 -0
- package/dist/src/runtime/compatibility.js +97 -0
- package/dist/src/runtime/compatibility.js.map +1 -0
- package/dist/src/runtime/config.d.ts +16 -0
- package/dist/src/runtime/config.d.ts.map +1 -0
- package/dist/src/runtime/config.js +22 -0
- package/dist/src/runtime/config.js.map +1 -0
- package/dist/src/runtime/errors.d.ts +23 -0
- package/dist/src/runtime/errors.d.ts.map +1 -0
- package/dist/src/runtime/errors.js +50 -0
- package/dist/src/runtime/errors.js.map +1 -0
- package/dist/src/runtime/hooks/index.d.ts +9 -0
- package/dist/src/runtime/hooks/index.d.ts.map +1 -0
- package/dist/src/runtime/hooks/index.js +9 -0
- package/dist/src/runtime/hooks/index.js.map +1 -0
- package/dist/src/runtime/hooks/useComposePrompt.d.ts +13 -0
- package/dist/src/runtime/hooks/useComposePrompt.d.ts.map +1 -0
- package/dist/src/runtime/hooks/useComposePrompt.js +17 -0
- package/dist/src/runtime/hooks/useComposePrompt.js.map +1 -0
- package/dist/src/runtime/hooks/usePromptAdmin.d.ts +10 -0
- package/dist/src/runtime/hooks/usePromptAdmin.d.ts.map +1 -0
- package/dist/src/runtime/hooks/usePromptAdmin.js +33 -0
- package/dist/src/runtime/hooks/usePromptAdmin.js.map +1 -0
- package/dist/src/runtime/hooks/usePromptBlock.d.ts +18 -0
- package/dist/src/runtime/hooks/usePromptBlock.d.ts.map +1 -0
- package/dist/src/runtime/hooks/usePromptBlock.js +25 -0
- package/dist/src/runtime/hooks/usePromptBlock.js.map +1 -0
- package/dist/src/runtime/hooks/usePromptBlocks.d.ts +22 -0
- package/dist/src/runtime/hooks/usePromptBlocks.d.ts.map +1 -0
- package/dist/src/runtime/hooks/usePromptBlocks.js +53 -0
- package/dist/src/runtime/hooks/usePromptBlocks.js.map +1 -0
- package/dist/src/runtime/hooks/usePromptCategories.d.ts +20 -0
- package/dist/src/runtime/hooks/usePromptCategories.d.ts.map +1 -0
- package/dist/src/runtime/hooks/usePromptCategories.js +53 -0
- package/dist/src/runtime/hooks/usePromptCategories.js.map +1 -0
- package/dist/src/runtime/hooks/usePromptDashboard.d.ts +13 -0
- package/dist/src/runtime/hooks/usePromptDashboard.d.ts.map +1 -0
- package/dist/src/runtime/hooks/usePromptDashboard.js +11 -0
- package/dist/src/runtime/hooks/usePromptDashboard.js.map +1 -0
- package/dist/src/runtime/hooks/usePromptTemplate.d.ts +33 -0
- package/dist/src/runtime/hooks/usePromptTemplate.d.ts.map +1 -0
- package/dist/src/runtime/hooks/usePromptTemplate.js +43 -0
- package/dist/src/runtime/hooks/usePromptTemplate.js.map +1 -0
- package/dist/src/runtime/hooks/usePromptTemplates.d.ts +37 -0
- package/dist/src/runtime/hooks/usePromptTemplates.d.ts.map +1 -0
- package/dist/src/runtime/hooks/usePromptTemplates.js +106 -0
- package/dist/src/runtime/hooks/usePromptTemplates.js.map +1 -0
- package/dist/src/runtime/listParams.d.ts +27 -0
- package/dist/src/runtime/listParams.d.ts.map +1 -0
- package/dist/src/runtime/listParams.js +67 -0
- package/dist/src/runtime/listParams.js.map +1 -0
- package/dist/src/runtime/queryKeys.d.ts +25 -0
- package/dist/src/runtime/queryKeys.d.ts.map +1 -0
- package/dist/src/runtime/queryKeys.js +29 -0
- package/dist/src/runtime/queryKeys.js.map +1 -0
- package/dist/src/runtime/react/AdminPromptPanel.d.ts +21 -0
- package/dist/src/runtime/react/AdminPromptPanel.d.ts.map +1 -0
- package/dist/src/runtime/react/AdminPromptPanel.js +53 -0
- package/dist/src/runtime/react/AdminPromptPanel.js.map +1 -0
- package/dist/src/runtime/react/PromptBlockLibrary.d.ts +36 -0
- package/dist/src/runtime/react/PromptBlockLibrary.d.ts.map +1 -0
- package/dist/src/runtime/react/PromptBlockLibrary.js +122 -0
- package/dist/src/runtime/react/PromptBlockLibrary.js.map +1 -0
- package/dist/src/runtime/react/PromptComposer.d.ts +24 -0
- package/dist/src/runtime/react/PromptComposer.d.ts.map +1 -0
- package/dist/src/runtime/react/PromptComposer.js +48 -0
- package/dist/src/runtime/react/PromptComposer.js.map +1 -0
- package/dist/src/runtime/react/PromptProvider.d.ts +16 -0
- package/dist/src/runtime/react/PromptProvider.d.ts.map +1 -0
- package/dist/src/runtime/react/PromptProvider.js +79 -0
- package/dist/src/runtime/react/PromptProvider.js.map +1 -0
- package/dist/src/runtime/react/PromptQueryProvider.d.ts +8 -0
- package/dist/src/runtime/react/PromptQueryProvider.d.ts.map +1 -0
- package/dist/src/runtime/react/PromptQueryProvider.js +11 -0
- package/dist/src/runtime/react/PromptQueryProvider.js.map +1 -0
- package/dist/src/runtime/react/PromptTemplateEditor.d.ts +36 -0
- package/dist/src/runtime/react/PromptTemplateEditor.d.ts.map +1 -0
- package/dist/src/runtime/react/PromptTemplateEditor.js +141 -0
- package/dist/src/runtime/react/PromptTemplateEditor.js.map +1 -0
- package/dist/src/runtime/react/RequireSuperuser.d.ts +7 -0
- package/dist/src/runtime/react/RequireSuperuser.d.ts.map +1 -0
- package/dist/src/runtime/react/RequireSuperuser.js +10 -0
- package/dist/src/runtime/react/RequireSuperuser.js.map +1 -0
- package/dist/src/runtime/react/default-ui/index.d.ts +17 -0
- package/dist/src/runtime/react/default-ui/index.d.ts.map +1 -0
- package/dist/src/runtime/react/default-ui/index.js +23 -0
- package/dist/src/runtime/react/default-ui/index.js.map +1 -0
- package/dist/src/runtime/react/index.d.ts +8 -0
- package/dist/src/runtime/react/index.d.ts.map +1 -0
- package/dist/src/runtime/react/index.js +8 -0
- package/dist/src/runtime/react/index.js.map +1 -0
- package/dist/src/runtime/routes.d.ts +17 -0
- package/dist/src/runtime/routes.d.ts.map +1 -0
- package/dist/src/runtime/routes.js +33 -0
- package/dist/src/runtime/routes.js.map +1 -0
- package/dist/src/runtime/schemas.d.ts +286 -0
- package/dist/src/runtime/schemas.d.ts.map +1 -0
- package/dist/src/runtime/schemas.js +172 -0
- package/dist/src/runtime/schemas.js.map +1 -0
- package/package.json +99 -0
- package/registry/r/admin-prompt-dashboard.json +23 -0
- package/registry/r/prompt-block-editor.json +20 -0
- package/registry/r/prompt-dashboard-overview.json +22 -0
- package/registry/r/prompt-maintenance-panel.json +23 -0
- package/registry/r/prompt-template-editor.json +20 -0
- package/registry/r/registry.json +37 -0
- package/registry.json +86 -0
- package/src/routes/admin/prompts.astro +11 -0
- package/src/routes/blocks.astro +11 -0
- package/src/routes/composer.astro +12 -0
- package/src/routes/templates.astro +11 -0
- package/src/scaffold/styles/prompt.css +9 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type PromptBlockCreate, type PromptBlockListParams, type PromptBlockPublic, type PromptBlockUpdate, type PromptBlocksPublic, type ResponseMessage, type ResponseModelBase } from "../schemas.js";
|
|
2
|
+
export declare function listBlocks(params?: PromptBlockListParams): Promise<PromptBlocksPublic>;
|
|
3
|
+
export declare function getBlock(blockId: number): Promise<PromptBlockPublic>;
|
|
4
|
+
export declare function getBlockBySlug(slug: string): Promise<PromptBlockPublic | null>;
|
|
5
|
+
export declare function createBlock(body: PromptBlockCreate): Promise<PromptBlockPublic>;
|
|
6
|
+
export declare function updateBlock(blockId: number, body: PromptBlockUpdate): Promise<PromptBlockPublic>;
|
|
7
|
+
export declare function deleteBlock(blockId: number): Promise<ResponseMessage>;
|
|
8
|
+
/** Extract data from a ResponseModelBase, throwing a synthetic 500 error when missing. */
|
|
9
|
+
declare function unwrap<T>(value: ResponseModelBase): T;
|
|
10
|
+
/** Same as `unwrap` but accepts a ResponseMessage as a "not found" signal, yielding null. */
|
|
11
|
+
declare function unwrapOrNull<T>(value: ResponseModelBase | ResponseMessage): T | null;
|
|
12
|
+
declare const ResponseDataMissingError: {
|
|
13
|
+
new (): {
|
|
14
|
+
name: string;
|
|
15
|
+
message: string;
|
|
16
|
+
stack?: string;
|
|
17
|
+
cause?: unknown;
|
|
18
|
+
};
|
|
19
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
20
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
21
|
+
stackTraceLimit: number;
|
|
22
|
+
};
|
|
23
|
+
export { unwrap, unwrapOrNull, ResponseDataMissingError };
|
|
24
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/blocks.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AAEvB,wBAAsB,UAAU,CAAC,MAAM,GAAE,qBAA0B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAQhG;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAS1E;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CASpF;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAUrF;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAU5B;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAO3E;AAED,0FAA0F;AAC1F,iBAAS,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,GAAG,CAAC,CAK9C;AAED,6FAA6F;AAC7F,iBAAS,YAAY,CAAC,CAAC,EACrB,KAAK,EAAE,iBAAiB,GAAG,eAAe,GACzC,CAAC,GAAG,IAAI,CAKV;AAED,QAAA,MAAM,wBAAwB;;;;;;;;;;CAI7B,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { request } from "../client.js";
|
|
2
|
+
import { PromptBlocksPublicSchema, ResponseMessageSchema, ResponseModelBaseSchema } from "../schemas.js";
|
|
3
|
+
export async function listBlocks(params = {}) {
|
|
4
|
+
return request({
|
|
5
|
+
method: "GET",
|
|
6
|
+
path: "/prompt-block/",
|
|
7
|
+
query: { skip: params.skip ?? 0, limit: params.limit ?? 100 },
|
|
8
|
+
schema: PromptBlocksPublicSchema,
|
|
9
|
+
auth: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export async function getBlock(blockId) {
|
|
13
|
+
return unwrap(await request({
|
|
14
|
+
method: "GET",
|
|
15
|
+
path: `/prompt-block/get/${blockId}/`,
|
|
16
|
+
schema: ResponseModelBaseSchema,
|
|
17
|
+
auth: true
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
export async function getBlockBySlug(slug) {
|
|
21
|
+
return unwrapOrNull(await request({
|
|
22
|
+
method: "GET",
|
|
23
|
+
path: `/prompt-block/get_by_slug/${encodeURIComponent(slug)}/`,
|
|
24
|
+
schema: ResponseModelBaseSchema.or(ResponseMessageSchema),
|
|
25
|
+
auth: true
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
export async function createBlock(body) {
|
|
29
|
+
return unwrap(await request({
|
|
30
|
+
method: "POST",
|
|
31
|
+
path: "/prompt-block/add/",
|
|
32
|
+
body,
|
|
33
|
+
schema: ResponseModelBaseSchema,
|
|
34
|
+
auth: true
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
export async function updateBlock(blockId, body) {
|
|
38
|
+
return unwrap(await request({
|
|
39
|
+
method: "PUT",
|
|
40
|
+
path: `/prompt-block/edit/${blockId}/`,
|
|
41
|
+
body,
|
|
42
|
+
schema: ResponseModelBaseSchema,
|
|
43
|
+
auth: true
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
export async function deleteBlock(blockId) {
|
|
47
|
+
return request({
|
|
48
|
+
method: "DELETE",
|
|
49
|
+
path: `/prompt-block/delete/${blockId}/`,
|
|
50
|
+
schema: ResponseMessageSchema,
|
|
51
|
+
auth: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** Extract data from a ResponseModelBase, throwing a synthetic 500 error when missing. */
|
|
55
|
+
function unwrap(value) {
|
|
56
|
+
if (value.data === null || value.data === undefined) {
|
|
57
|
+
throw new ResponseDataMissingError();
|
|
58
|
+
}
|
|
59
|
+
return value.data;
|
|
60
|
+
}
|
|
61
|
+
/** Same as `unwrap` but accepts a ResponseMessage as a "not found" signal, yielding null. */
|
|
62
|
+
function unwrapOrNull(value) {
|
|
63
|
+
if ("data" in value && value.data !== null && value.data !== undefined) {
|
|
64
|
+
return value.data;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const ResponseDataMissingError = class extends Error {
|
|
69
|
+
constructor() {
|
|
70
|
+
super("Response reported failure with no data");
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export { unwrap, unwrapOrNull, ResponseDataMissingError };
|
|
74
|
+
//# sourceMappingURL=blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources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ryListParams, type CategoryPublic, type CategoryUpdate, type ResponseMessage } from "../schemas.js";
|
|
2
|
+
export declare function listCategories(params?: CategoryListParams): Promise<CategoriesPublic | null>;
|
|
3
|
+
export declare function getCategory(categoryId: number): Promise<CategoryPublic | null>;
|
|
4
|
+
export declare function createCategory(body: CategoryCreate): Promise<CategoryPublic>;
|
|
5
|
+
export declare function updateCategory(categoryId: number, body: CategoryUpdate): Promise<CategoryPublic>;
|
|
6
|
+
export declare function deleteCategory(categoryId: number): Promise<ResponseMessage>;
|
|
7
|
+
//# sourceMappingURL=categories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/categories.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EAErB,MAAM,eAAe,CAAC;AAIvB,wBAAsB,cAAc,CAClC,MAAM,GAAE,kBAAuB,GAC9B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CASlC;AAED,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CASpF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAUlF;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,cAAc,CAAC,CAUzB;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAOjF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { request } from "../client.js";
|
|
2
|
+
import { unwrap, unwrapOrNull } from "./blocks.js";
|
|
3
|
+
import { CategoriesPublicSchema, CategoryCreateSchema, CategoryUpdateSchema, ResponseMessageSchema, ResponseModelBaseSchema } from "../schemas.js";
|
|
4
|
+
const ModelOrMessage = ResponseModelBaseSchema.or(ResponseMessageSchema);
|
|
5
|
+
export async function listCategories(params = {}) {
|
|
6
|
+
return request({
|
|
7
|
+
method: "GET",
|
|
8
|
+
path: "/category/",
|
|
9
|
+
query: { skip: params.skip ?? 0, limit: params.limit ?? 100 },
|
|
10
|
+
// Service may return `null` when no categories exist (`Optional[CategoriesPublic]`).
|
|
11
|
+
schema: CategoriesPublicSchema.nullable(),
|
|
12
|
+
auth: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export async function getCategory(categoryId) {
|
|
16
|
+
return unwrapOrNull(await request({
|
|
17
|
+
method: "GET",
|
|
18
|
+
path: `/category/get/${categoryId}/`,
|
|
19
|
+
schema: ModelOrMessage,
|
|
20
|
+
auth: true
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
export async function createCategory(body) {
|
|
24
|
+
return unwrap(await request({
|
|
25
|
+
method: "POST",
|
|
26
|
+
path: "/category/add/",
|
|
27
|
+
body: CategoryCreateSchema.parse(body),
|
|
28
|
+
schema: ResponseModelBaseSchema,
|
|
29
|
+
auth: true
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
export async function updateCategory(categoryId, body) {
|
|
33
|
+
return unwrap(await request({
|
|
34
|
+
method: "PUT",
|
|
35
|
+
path: `/category/edit/${categoryId}/`,
|
|
36
|
+
body: CategoryUpdateSchema.parse(body),
|
|
37
|
+
schema: ResponseModelBaseSchema,
|
|
38
|
+
auth: true
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
export async function deleteCategory(categoryId) {
|
|
42
|
+
return request({
|
|
43
|
+
method: "DELETE",
|
|
44
|
+
path: `/category/delete/${categoryId}/`,
|
|
45
|
+
schema: ResponseMessageSchema,
|
|
46
|
+
auth: true
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=categories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categories.js","sourceRoot":"","sources":["../../../../src/runtime/api/categories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EAQxB,MAAM,eAAe,CAAC;AAEvB,MAAM,cAAc,GAAG,uBAAuB,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC;AAEzE,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,SAA6B,EAAE;IAE/B,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,EAAE;QAC7D,qFAAqF;QACrF,MAAM,EAAE,sBAAsB,CAAC,QAAQ,EAAE;QACzC,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,UAAkB;IAClD,OAAO,YAAY,CACjB,MAAM,OAAO,CAAsC;QACjD,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,iBAAiB,UAAU,GAAG;QACpC,MAAM,EAAE,cAAc;QACtB,IAAI,EAAE,IAAI;KACX,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAoB;IACvD,OAAO,MAAM,CACX,MAAM,OAAO,CAAoB;QAC/B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC;QACtC,MAAM,EAAE,uBAAuB;QAC/B,IAAI,EAAE,IAAI;KACX,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAkB,EAClB,IAAoB;IAEpB,OAAO,MAAM,CACX,MAAM,OAAO,CAAoB;QAC/B,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAkB,UAAU,GAAG;QACrC,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC;QACtC,MAAM,EAAE,uBAAuB;QAC/B,IAAI,EAAE,IAAI;KACX,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAAkB;IACrD,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,oBAAoB,UAAU,GAAG;QACvC,MAAM,EAAE,qBAAqB;QAC7B,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type UsersActivity } from "../schemas.js";
|
|
2
|
+
/** Site-wide user activity (any signed-in user). */
|
|
3
|
+
export declare function getActivityAll(): Promise<UsersActivity>;
|
|
4
|
+
/** Current user's activity. */
|
|
5
|
+
export declare function getActivityCurrent(): Promise<UsersActivity>;
|
|
6
|
+
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/dashboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAExE,oDAAoD;AACpD,wBAAgB,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAOvD;AAED,+BAA+B;AAC/B,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC,CAO3D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { request } from "../client.js";
|
|
2
|
+
import { UsersActivitySchema } from "../schemas.js";
|
|
3
|
+
/** Site-wide user activity (any signed-in user). */
|
|
4
|
+
export function getActivityAll() {
|
|
5
|
+
return request({
|
|
6
|
+
method: "GET",
|
|
7
|
+
path: "/dashboard/users/activity/",
|
|
8
|
+
schema: UsersActivitySchema,
|
|
9
|
+
auth: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/** Current user's activity. */
|
|
13
|
+
export function getActivityCurrent() {
|
|
14
|
+
return request({
|
|
15
|
+
method: "GET",
|
|
16
|
+
path: "/dashboard/users/activity/current/",
|
|
17
|
+
schema: UsersActivitySchema,
|
|
18
|
+
auth: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../../../src/runtime/api/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAsB,MAAM,eAAe,CAAC;AAExE,oDAAoD;AACpD,MAAM,UAAU,cAAc;IAC5B,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,4BAA4B;QAClC,MAAM,EAAE,mBAAmB;QAC3B,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,kBAAkB;IAChC,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,oCAAoC;QAC1C,MAAM,EAAE,mBAAmB;QAC3B,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as blocksApi from "./blocks.js";
|
|
2
|
+
import * as templatesApi from "./templates.js";
|
|
3
|
+
import * as categoriesApi from "./categories.js";
|
|
4
|
+
import * as dashboardApi from "./dashboard.js";
|
|
5
|
+
import * as adminApi from "./admin.js";
|
|
6
|
+
export * from "./blocks.js";
|
|
7
|
+
export * from "./templates.js";
|
|
8
|
+
export * from "./categories.js";
|
|
9
|
+
export * from "./dashboard.js";
|
|
10
|
+
export * from "./admin.js";
|
|
11
|
+
export declare const blocks: {
|
|
12
|
+
readonly list: typeof blocksApi.listBlocks;
|
|
13
|
+
readonly get: typeof blocksApi.getBlock;
|
|
14
|
+
readonly getBySlug: typeof blocksApi.getBlockBySlug;
|
|
15
|
+
readonly create: typeof blocksApi.createBlock;
|
|
16
|
+
readonly update: typeof blocksApi.updateBlock;
|
|
17
|
+
readonly delete: typeof blocksApi.deleteBlock;
|
|
18
|
+
};
|
|
19
|
+
export declare const templates: {
|
|
20
|
+
readonly list: typeof templatesApi.listTemplates;
|
|
21
|
+
readonly get: typeof templatesApi.getTemplate;
|
|
22
|
+
readonly getBySlug: typeof templatesApi.getTemplateBySlug;
|
|
23
|
+
readonly getBlocks: typeof templatesApi.getTemplateBlocks;
|
|
24
|
+
readonly compose: typeof templatesApi.composeTemplate;
|
|
25
|
+
readonly create: typeof templatesApi.createTemplate;
|
|
26
|
+
readonly update: typeof templatesApi.updateTemplate;
|
|
27
|
+
readonly delete: typeof templatesApi.deleteTemplate;
|
|
28
|
+
readonly addBlock: typeof templatesApi.addTemplateBlock;
|
|
29
|
+
readonly setBlockPosition: typeof templatesApi.setTemplateBlockPosition;
|
|
30
|
+
readonly removeBlock: typeof templatesApi.removeTemplateBlock;
|
|
31
|
+
};
|
|
32
|
+
export declare const categories: {
|
|
33
|
+
readonly list: typeof categoriesApi.listCategories;
|
|
34
|
+
readonly get: typeof categoriesApi.getCategory;
|
|
35
|
+
readonly create: typeof categoriesApi.createCategory;
|
|
36
|
+
readonly update: typeof categoriesApi.updateCategory;
|
|
37
|
+
readonly delete: typeof categoriesApi.deleteCategory;
|
|
38
|
+
};
|
|
39
|
+
export declare const dashboard: {
|
|
40
|
+
readonly activityAll: typeof dashboardApi.getActivityAll;
|
|
41
|
+
readonly activityCurrent: typeof dashboardApi.getActivityCurrent;
|
|
42
|
+
};
|
|
43
|
+
export declare const admin: {
|
|
44
|
+
readonly overview: typeof adminApi.getAdminOverview;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAGvC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAG3B,eAAO,MAAM,MAAM;;;;;;;CAOT,CAAC;AAEX,eAAO,MAAM,SAAS;;;;;;;;;;;;CAYZ,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;CAMb,CAAC;AAEX,eAAO,MAAM,SAAS;;;CAGZ,CAAC;AAEX,eAAO,MAAM,KAAK;;CAER,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as blocksApi from "./blocks.js";
|
|
2
|
+
import * as templatesApi from "./templates.js";
|
|
3
|
+
import * as categoriesApi from "./categories.js";
|
|
4
|
+
import * as dashboardApi from "./dashboard.js";
|
|
5
|
+
import * as adminApi from "./admin.js";
|
|
6
|
+
// Flat named exports (tree-shakeable direct imports).
|
|
7
|
+
export * from "./blocks.js";
|
|
8
|
+
export * from "./templates.js";
|
|
9
|
+
export * from "./categories.js";
|
|
10
|
+
export * from "./dashboard.js";
|
|
11
|
+
export * from "./admin.js";
|
|
12
|
+
// Grouped namespaces (`blocks.list`, `templates.compose`, ...).
|
|
13
|
+
export const blocks = {
|
|
14
|
+
list: blocksApi.listBlocks,
|
|
15
|
+
get: blocksApi.getBlock,
|
|
16
|
+
getBySlug: blocksApi.getBlockBySlug,
|
|
17
|
+
create: blocksApi.createBlock,
|
|
18
|
+
update: blocksApi.updateBlock,
|
|
19
|
+
delete: blocksApi.deleteBlock
|
|
20
|
+
};
|
|
21
|
+
export const templates = {
|
|
22
|
+
list: templatesApi.listTemplates,
|
|
23
|
+
get: templatesApi.getTemplate,
|
|
24
|
+
getBySlug: templatesApi.getTemplateBySlug,
|
|
25
|
+
getBlocks: templatesApi.getTemplateBlocks,
|
|
26
|
+
compose: templatesApi.composeTemplate,
|
|
27
|
+
create: templatesApi.createTemplate,
|
|
28
|
+
update: templatesApi.updateTemplate,
|
|
29
|
+
delete: templatesApi.deleteTemplate,
|
|
30
|
+
addBlock: templatesApi.addTemplateBlock,
|
|
31
|
+
setBlockPosition: templatesApi.setTemplateBlockPosition,
|
|
32
|
+
removeBlock: templatesApi.removeTemplateBlock
|
|
33
|
+
};
|
|
34
|
+
export const categories = {
|
|
35
|
+
list: categoriesApi.listCategories,
|
|
36
|
+
get: categoriesApi.getCategory,
|
|
37
|
+
create: categoriesApi.createCategory,
|
|
38
|
+
update: categoriesApi.updateCategory,
|
|
39
|
+
delete: categoriesApi.deleteCategory
|
|
40
|
+
};
|
|
41
|
+
export const dashboard = {
|
|
42
|
+
activityAll: dashboardApi.getActivityAll,
|
|
43
|
+
activityCurrent: dashboardApi.getActivityCurrent
|
|
44
|
+
};
|
|
45
|
+
export const admin = {
|
|
46
|
+
overview: adminApi.getAdminOverview
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/runtime/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,K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CAC5B,CAAC;AAEX,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,WAAW,EAAE,YAAY,CAAC,cAAc;IACxC,eAAe,EAAE,YAAY,CAAC,kBAAkB;CACxC,CAAC;AAEX,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,QAAQ,EAAE,QAAQ,CAAC,gBAAgB;CAC3B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type InternalClientOptions = {
|
|
2
|
+
/** Env var holding the shared service token. Default PROMPT_INTERNAL_SERVICE_TOKEN. */
|
|
3
|
+
serviceTokenEnv?: string;
|
|
4
|
+
/** Explicit token override (e.g. injected by a secret manager). */
|
|
5
|
+
token?: string;
|
|
6
|
+
};
|
|
7
|
+
export type InternalPromptClient = {
|
|
8
|
+
ping(): Promise<{
|
|
9
|
+
ok: true;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Build a server-only client for service-to-service calls against
|
|
14
|
+
* prompt-engine-m8. The shared service token is attached directly (never via
|
|
15
|
+
* the user auth adapter) and refresh is disabled.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createInternalPromptClient(options?: InternalClientOptions): InternalPromptClient;
|
|
18
|
+
//# sourceMappingURL=internal.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/internal.server.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,qBAAqB,GAAG;IAClC,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;CAC/B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAgBtB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { request } from "../client.js";
|
|
2
|
+
const DEFAULT_TOKEN_ENV = "PROMPT_INTERNAL_SERVICE_TOKEN";
|
|
3
|
+
/**
|
|
4
|
+
* Fail fast if this module is ever pulled into a browser bundle. The internal
|
|
5
|
+
* surface is authenticated with a shared service token that must never leave
|
|
6
|
+
* the server. prompt-engine-m8 has no internal endpoints today, but we expose
|
|
7
|
+
* the same shape as media-m8 for symmetry and future use.
|
|
8
|
+
*/
|
|
9
|
+
function assertServerOnly() {
|
|
10
|
+
if (typeof window !== "undefined") {
|
|
11
|
+
throw new Error("@mano8/astro-prompt-m8/internal-server must only be imported on the server");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function resolveServiceToken(envVar) {
|
|
15
|
+
const env = globalThis.process?.env;
|
|
16
|
+
const token = env?.[envVar];
|
|
17
|
+
if (!token) {
|
|
18
|
+
throw new Error(`Missing service token: set ${envVar} in the server environment`);
|
|
19
|
+
}
|
|
20
|
+
return token;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build a server-only client for service-to-service calls against
|
|
24
|
+
* prompt-engine-m8. The shared service token is attached directly (never via
|
|
25
|
+
* the user auth adapter) and refresh is disabled.
|
|
26
|
+
*/
|
|
27
|
+
export function createInternalPromptClient(options = {}) {
|
|
28
|
+
assertServerOnly();
|
|
29
|
+
const token = options.token ?? resolveServiceToken(options.serviceTokenEnv ?? DEFAULT_TOKEN_ENV);
|
|
30
|
+
const headers = { Authorization: `Bearer ${token}` };
|
|
31
|
+
return {
|
|
32
|
+
async ping() {
|
|
33
|
+
await request({
|
|
34
|
+
method: "GET",
|
|
35
|
+
path: "/",
|
|
36
|
+
headers,
|
|
37
|
+
skipRefresh: true
|
|
38
|
+
});
|
|
39
|
+
return { ok: true };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=internal.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.server.js","sourceRoot":"","sources":["../../../../src/runtime/api/internal.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,iBAAiB,GAAG,+BAA+B,CAAC;AAE1D;;;;;GAKG;AACH,SAAS,gBAAgB;IACvB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc;IACzC,MAAM,GAAG,GAAI,UAAyE,CAAC,OAAO,EAAE,GAAG,CAAC;IACpG,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,4BAA4B,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAaD;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAAiC,EAAE;IAEnC,gBAAgB,EAAE,CAAC;IACnB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,mBAAmB,CAAC,OAAO,CAAC,eAAe,IAAI,iBAAiB,CAAC,CAAC;IACjG,MAAM,OAAO,GAAG,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;IAErD,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,OAAO,CAAC;gBACZ,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,GAAG;gBACT,OAAO;gBACP,WAAW,EAAE,IAAI;aAClB,CAAC,CAAC;YACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ComposedPrompt, type DynamicBlock, type PromptTemplateCreate, type PromptTemplateListParams, type PromptTemplatePublic, type PromptTemplateUpdate, type PromptTemplatesPublic, type ResponseMessage, type ResponseModelBase, type TemplateBlockPublic } from "../schemas.js";
|
|
2
|
+
export declare function listTemplates(params?: PromptTemplateListParams): Promise<PromptTemplatesPublic>;
|
|
3
|
+
export declare function getTemplate(templateId: number): Promise<PromptTemplatePublic>;
|
|
4
|
+
export declare function getTemplateBySlug(slug: string): Promise<PromptTemplatePublic | null>;
|
|
5
|
+
export declare function getTemplateBlocks(templateId: number): Promise<TemplateBlockPublic[]>;
|
|
6
|
+
/** Composes dynamic-content payload and parses a ComposedPrompt response. */
|
|
7
|
+
export declare function composeTemplate(templateId: number, dynamicContent?: DynamicBlock[]): Promise<ComposedPrompt>;
|
|
8
|
+
export declare function createTemplate(body: PromptTemplateCreate): Promise<PromptTemplatePublic>;
|
|
9
|
+
export declare function updateTemplate(templateId: number, body: PromptTemplateUpdate): Promise<PromptTemplatePublic>;
|
|
10
|
+
export declare function deleteTemplate(templateId: number): Promise<ResponseMessage>;
|
|
11
|
+
export declare function addTemplateBlock(templateId: number, blockId: number, position?: number): Promise<ResponseModelBase>;
|
|
12
|
+
export declare function setTemplateBlockPosition(templateId: number, blockId: number, position?: number): Promise<ResponseModelBase>;
|
|
13
|
+
export declare function removeTemplateBlock(templateId: number, blockId: number): Promise<ResponseMessage>;
|
|
14
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,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
|
|
3
|
+
import { ComposedPromptSchema, PromptTemplatesPublicSchema, ResponseMessageSchema, ResponseModelBaseSchema, TemplateBlockPublicSchema } from "../schemas.js";
|
|
4
|
+
const ModelOrMessage = ResponseModelBaseSchema.or(ResponseMessageSchema);
|
|
5
|
+
export async function listTemplates(params = {}) {
|
|
6
|
+
return request({
|
|
7
|
+
method: "GET",
|
|
8
|
+
path: "/prompt-template/",
|
|
9
|
+
query: { skip: params.skip ?? 0, limit: params.limit ?? 100 },
|
|
10
|
+
schema: PromptTemplatesPublicSchema,
|
|
11
|
+
auth: true
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export async function getTemplate(templateId) {
|
|
15
|
+
return unwrap(await request({
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: `/prompt-template/get/${templateId}/`,
|
|
18
|
+
schema: ResponseModelBaseSchema,
|
|
19
|
+
auth: true
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
export async function getTemplateBySlug(slug) {
|
|
23
|
+
return unwrapOrNull(await request({
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: `/prompt-template/get_by_slug/${encodeURIComponent(slug)}/`,
|
|
26
|
+
schema: ModelOrMessage,
|
|
27
|
+
auth: true
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
export async function getTemplateBlocks(templateId) {
|
|
31
|
+
const body = await request({
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: `/prompt-template/get-blocks/${templateId}/`,
|
|
34
|
+
schema: ModelOrMessage,
|
|
35
|
+
auth: true
|
|
36
|
+
});
|
|
37
|
+
if ("data" in body && Array.isArray(body.data)) {
|
|
38
|
+
return TemplateBlockPublicSchema.array().parse(body.data);
|
|
39
|
+
}
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
/** Composes dynamic-content payload and parses a ComposedPrompt response. */
|
|
43
|
+
export async function composeTemplate(templateId, dynamicContent = []) {
|
|
44
|
+
const body = await request({
|
|
45
|
+
method: "POST",
|
|
46
|
+
path: `/prompt-template/compose/${templateId}/`,
|
|
47
|
+
body: dynamicContent,
|
|
48
|
+
schema: ModelOrMessage,
|
|
49
|
+
auth: true
|
|
50
|
+
});
|
|
51
|
+
if ("data" in body && body.data) {
|
|
52
|
+
return ComposedPromptSchema.parse(body.data);
|
|
53
|
+
}
|
|
54
|
+
return { content: "" };
|
|
55
|
+
}
|
|
56
|
+
export async function createTemplate(body) {
|
|
57
|
+
return unwrap(await request({
|
|
58
|
+
method: "POST",
|
|
59
|
+
path: "/prompt-template/add/",
|
|
60
|
+
body,
|
|
61
|
+
schema: ResponseModelBaseSchema,
|
|
62
|
+
auth: true
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
export async function updateTemplate(templateId, body) {
|
|
66
|
+
return unwrap(await request({
|
|
67
|
+
method: "PUT",
|
|
68
|
+
path: `/prompt-template/edit/${templateId}/`,
|
|
69
|
+
body,
|
|
70
|
+
schema: ResponseModelBaseSchema,
|
|
71
|
+
auth: true
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
export async function deleteTemplate(templateId) {
|
|
75
|
+
return request({
|
|
76
|
+
method: "DELETE",
|
|
77
|
+
path: `/prompt-template/delete/${templateId}/`,
|
|
78
|
+
schema: ResponseMessageSchema,
|
|
79
|
+
auth: true
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export async function addTemplateBlock(templateId, blockId, position = 0) {
|
|
83
|
+
return request({
|
|
84
|
+
method: "GET",
|
|
85
|
+
path: `/prompt-template/${templateId}/add-block/${blockId}/`,
|
|
86
|
+
query: { position },
|
|
87
|
+
schema: ResponseModelBaseSchema,
|
|
88
|
+
auth: true
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export async function setTemplateBlockPosition(templateId, blockId, position = 1) {
|
|
92
|
+
return request({
|
|
93
|
+
method: "GET",
|
|
94
|
+
path: `/prompt-template/${templateId}/set-block-position/${blockId}/`,
|
|
95
|
+
query: { position },
|
|
96
|
+
schema: ResponseModelBaseSchema,
|
|
97
|
+
auth: true
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export async function removeTemplateBlock(templateId, blockId) {
|
|
101
|
+
return request({
|
|
102
|
+
method: "DELETE",
|
|
103
|
+
path: `/prompt-template/${templateId}/delete-block/${blockId}/`,
|
|
104
|
+
schema: ResponseMessageSchema,
|
|
105
|
+
auth: true
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../../src/runtime/api/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,oBAAoB,EAEpB,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EAW1B,MAAM,eAAe,CAAC;AAEvB,MAAM,cAAc,GAAG,uBAAuB,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC;AAEzE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,SAAmC,EAAE;IAErC,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,EAAE;QAC7D,MAAM,EAAE,2BAA2B;QACnC,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,UAAkB;IAClD,OAAO,MAAM,CACX,MAAM,OAAO,CAAoB;QAC/B,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,wBAAwB,UAAU,GAAG;QAC3C,MAAM,EAAE,uBAAuB;QAC/B,IAAI,EAAE,IAAI;K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QAAQ,EAAE;QACnB,MAAM,EAAE,uBAAuB;QAC/B,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,OAAe;IAEf,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,oBAAoB,UAAU,iBAAiB,OAAO,GAAG;QAC/D,MAAM,EAAE,qBAAqB;QAC7B,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrow runtime contract the prompt plugin consumes for authentication.
|
|
3
|
+
*
|
|
4
|
+
* The prompt plugin never owns token storage or refresh logic; it delegates to
|
|
5
|
+
* whatever the host stack provides. `@mano8/astro-auth-m8` is the official
|
|
6
|
+
* provider, but any object that satisfies this shape works.
|
|
7
|
+
*/
|
|
8
|
+
export type PromptAuthAdapter = {
|
|
9
|
+
getAccessToken(): string | null | Promise<string | null>;
|
|
10
|
+
refresh?(): Promise<string | null>;
|
|
11
|
+
getUser?(): unknown | Promise<unknown>;
|
|
12
|
+
requireUser?(): Promise<unknown>;
|
|
13
|
+
isSuperuser?(user?: unknown): boolean;
|
|
14
|
+
hasRole?(role: string, user?: unknown): boolean;
|
|
15
|
+
onUnauthenticated?(reason: unknown): void;
|
|
16
|
+
};
|
|
17
|
+
export type InMemoryAuthAdapter = PromptAuthAdapter & {
|
|
18
|
+
/** Set or clear the in-memory access token (never persisted). */
|
|
19
|
+
setAccessToken(token: string | null): void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Best-effort superuser detection that does not depend on a specific user
|
|
23
|
+
* shape: honours an explicit `is_superuser` flag, the configured admin role,
|
|
24
|
+
* or a `roles` array containing it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function defaultIsSuperuser(user: unknown, adminRole?: string): boolean;
|
|
27
|
+
/** A self-contained adapter that holds the token in memory only. */
|
|
28
|
+
export declare function createInMemoryAuthAdapter(initialToken?: string | null): InMemoryAuthAdapter;
|
|
29
|
+
export type FaAuthBindings = {
|
|
30
|
+
getToken: () => string | null;
|
|
31
|
+
refreshToken?: () => Promise<{
|
|
32
|
+
access_token?: string;
|
|
33
|
+
} | string | null | undefined>;
|
|
34
|
+
getUser?: () => unknown | Promise<unknown>;
|
|
35
|
+
isSuperuser?: (user?: unknown) => boolean;
|
|
36
|
+
hasRole?: (role: string, user?: unknown) => boolean;
|
|
37
|
+
onUnauthenticated?: (reason: unknown) => void;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Build the official adapter from `@mano8/astro-auth-m8` bindings. The bindings
|
|
41
|
+
* are injected by the consumer so the prompt plugin keeps the auth plugin as an
|
|
42
|
+
* optional peer and never statically imports it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createFaAuthAdapter(bindings: FaAuthBindings): PromptAuthAdapter;
|
|
45
|
+
export declare function setPromptAuthAdapter(next: PromptAuthAdapter): PromptAuthAdapter;
|
|
46
|
+
export declare function getPromptAuthAdapter(): PromptAuthAdapter;
|
|
47
|
+
export declare function resetPromptAuthAdapter(): void;
|
|
48
|
+
//# sourceMappingURL=authAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/authAdapter.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,IAAI,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,WAAW,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,WAAW,CAAC,CAA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