contentbase 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/node-fs.d.ts +17 -0
- package/dist/adapters/node-fs.d.ts.map +1 -0
- package/dist/adapters/node-fs.js +71 -0
- package/dist/adapters/node-fs.js.map +1 -0
- package/dist/ast-query.d.ts +44 -0
- package/dist/ast-query.d.ts.map +1 -0
- package/dist/ast-query.js +95 -0
- package/dist/ast-query.js.map +1 -0
- package/dist/base-model.d.ts +8 -0
- package/dist/base-model.d.ts.map +1 -0
- package/dist/base-model.js +12 -0
- package/dist/base-model.js.map +1 -0
- package/dist/cli/commands/action.d.ts +2 -0
- package/dist/cli/commands/action.d.ts.map +1 -0
- package/dist/cli/commands/action.js +73 -0
- package/dist/cli/commands/action.js.map +1 -0
- package/dist/cli/commands/api/endpoints/actions.d.ts +13 -0
- package/dist/cli/commands/api/endpoints/actions.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/actions.js +28 -0
- package/dist/cli/commands/api/endpoints/actions.js.map +1 -0
- package/dist/cli/commands/api/endpoints/doc.d.ts +5 -0
- package/dist/cli/commands/api/endpoints/doc.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/doc.js +186 -0
- package/dist/cli/commands/api/endpoints/doc.js.map +1 -0
- package/dist/cli/commands/api/endpoints/docs-index.d.ts +8 -0
- package/dist/cli/commands/api/endpoints/docs-index.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/docs-index.js +23 -0
- package/dist/cli/commands/api/endpoints/docs-index.js.map +1 -0
- package/dist/cli/commands/api/endpoints/document.d.ts +47 -0
- package/dist/cli/commands/api/endpoints/document.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/document.js +146 -0
- package/dist/cli/commands/api/endpoints/document.js.map +1 -0
- package/dist/cli/commands/api/endpoints/documents.d.ts +35 -0
- package/dist/cli/commands/api/endpoints/documents.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/documents.js +56 -0
- package/dist/cli/commands/api/endpoints/documents.js.map +1 -0
- package/dist/cli/commands/api/endpoints/index.d.ts +22 -0
- package/dist/cli/commands/api/endpoints/index.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/index.js +38 -0
- package/dist/cli/commands/api/endpoints/index.js.map +1 -0
- package/dist/cli/commands/api/endpoints/inspect.d.ts +10 -0
- package/dist/cli/commands/api/endpoints/inspect.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/inspect.js +15 -0
- package/dist/cli/commands/api/endpoints/inspect.js.map +1 -0
- package/dist/cli/commands/api/endpoints/models.d.ts +5 -0
- package/dist/cli/commands/api/endpoints/models.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/models.js +9 -0
- package/dist/cli/commands/api/endpoints/models.js.map +1 -0
- package/dist/cli/commands/api/endpoints/query.d.ts +40 -0
- package/dist/cli/commands/api/endpoints/query.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/query.js +106 -0
- package/dist/cli/commands/api/endpoints/query.js.map +1 -0
- package/dist/cli/commands/api/endpoints/root.d.ts +5 -0
- package/dist/cli/commands/api/endpoints/root.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/root.js +7 -0
- package/dist/cli/commands/api/endpoints/root.js.map +1 -0
- package/dist/cli/commands/api/endpoints/search-reindex.d.ts +10 -0
- package/dist/cli/commands/api/endpoints/search-reindex.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/search-reindex.js +38 -0
- package/dist/cli/commands/api/endpoints/search-reindex.js.map +1 -0
- package/dist/cli/commands/api/endpoints/search-status.d.ts +7 -0
- package/dist/cli/commands/api/endpoints/search-status.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/search-status.js +33 -0
- package/dist/cli/commands/api/endpoints/search-status.js.map +1 -0
- package/dist/cli/commands/api/endpoints/search.d.ts +24 -0
- package/dist/cli/commands/api/endpoints/search.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/search.js +61 -0
- package/dist/cli/commands/api/endpoints/search.js.map +1 -0
- package/dist/cli/commands/api/endpoints/semantic-search.d.ts +28 -0
- package/dist/cli/commands/api/endpoints/semantic-search.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/semantic-search.js +76 -0
- package/dist/cli/commands/api/endpoints/semantic-search.js.map +1 -0
- package/dist/cli/commands/api/endpoints/text-search.d.ts +17 -0
- package/dist/cli/commands/api/endpoints/text-search.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/text-search.js +55 -0
- package/dist/cli/commands/api/endpoints/text-search.js.map +1 -0
- package/dist/cli/commands/api/endpoints/validate.d.ts +12 -0
- package/dist/cli/commands/api/endpoints/validate.d.ts.map +1 -0
- package/dist/cli/commands/api/endpoints/validate.js +27 -0
- package/dist/cli/commands/api/endpoints/validate.js.map +1 -0
- package/dist/cli/commands/api/helpers.d.ts +8 -0
- package/dist/cli/commands/api/helpers.d.ts.map +1 -0
- package/dist/cli/commands/api/helpers.js +89 -0
- package/dist/cli/commands/api/helpers.js.map +1 -0
- package/dist/cli/commands/console.d.ts +2 -0
- package/dist/cli/commands/console.d.ts.map +1 -0
- package/dist/cli/commands/console.js +117 -0
- package/dist/cli/commands/console.js.map +1 -0
- package/dist/cli/commands/create.d.ts +2 -0
- package/dist/cli/commands/create.d.ts.map +1 -0
- package/dist/cli/commands/create.js +185 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/embed.d.ts +2 -0
- package/dist/cli/commands/embed.d.ts.map +1 -0
- package/dist/cli/commands/embed.js +231 -0
- package/dist/cli/commands/embed.js.map +1 -0
- package/dist/cli/commands/export.d.ts +2 -0
- package/dist/cli/commands/export.d.ts.map +1 -0
- package/dist/cli/commands/export.js +55 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/extract.d.ts +2 -0
- package/dist/cli/commands/extract.d.ts.map +1 -0
- package/dist/cli/commands/extract.js +149 -0
- package/dist/cli/commands/extract.js.map +1 -0
- package/dist/cli/commands/help.d.ts +2 -0
- package/dist/cli/commands/help.d.ts.map +1 -0
- package/dist/cli/commands/help.js +58 -0
- package/dist/cli/commands/help.js.map +1 -0
- package/dist/cli/commands/index.d.ts +18 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +19 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +82 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/inspect.d.ts +2 -0
- package/dist/cli/commands/inspect.d.ts.map +1 -0
- package/dist/cli/commands/inspect.js +53 -0
- package/dist/cli/commands/inspect.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +2 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/mcp.js +92 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/search.d.ts +2 -0
- package/dist/cli/commands/search.d.ts.map +1 -0
- package/dist/cli/commands/search.js +212 -0
- package/dist/cli/commands/search.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +2 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +298 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/summary.d.ts +2 -0
- package/dist/cli/commands/summary.d.ts.map +1 -0
- package/dist/cli/commands/summary.js +58 -0
- package/dist/cli/commands/summary.js.map +1 -0
- package/dist/cli/commands/teach.d.ts +2 -0
- package/dist/cli/commands/teach.d.ts.map +1 -0
- package/dist/cli/commands/teach.js +80 -0
- package/dist/cli/commands/teach.js.map +1 -0
- package/dist/cli/commands/text-search.d.ts +2 -0
- package/dist/cli/commands/text-search.d.ts.map +1 -0
- package/dist/cli/commands/text-search.js +125 -0
- package/dist/cli/commands/text-search.js.map +1 -0
- package/dist/cli/commands/update.d.ts +2 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +167 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +2 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +129 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +84 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/load-collection.d.ts +7 -0
- package/dist/cli/load-collection.d.ts.map +1 -0
- package/dist/cli/load-collection.js +201 -0
- package/dist/cli/load-collection.js.map +1 -0
- package/dist/cli/registry.d.ts +17 -0
- package/dist/cli/registry.d.ts.map +1 -0
- package/dist/cli/registry.js +16 -0
- package/dist/cli/registry.js.map +1 -0
- package/dist/cnotes +0 -0
- package/dist/collection.d.ts +145 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +684 -0
- package/dist/collection.js.map +1 -0
- package/dist/define-model.d.ts +45 -0
- package/dist/define-model.d.ts.map +1 -0
- package/dist/define-model.js +106 -0
- package/dist/define-model.js.map +1 -0
- package/dist/document.d.ts +123 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +434 -0
- package/dist/document.js.map +1 -0
- package/dist/extract-sections.d.ts +46 -0
- package/dist/extract-sections.d.ts.map +1 -0
- package/dist/extract-sections.js +153 -0
- package/dist/extract-sections.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/helpers.d.ts +14 -0
- package/dist/mcp/helpers.d.ts.map +1 -0
- package/dist/mcp/helpers.js +7 -0
- package/dist/mcp/helpers.js.map +1 -0
- package/dist/mcp/model-info.d.ts +2 -0
- package/dist/mcp/model-info.d.ts.map +1 -0
- package/dist/mcp/model-info.js +94 -0
- package/dist/mcp/model-info.js.map +1 -0
- package/dist/mcp/prompts.d.ts +2 -0
- package/dist/mcp/prompts.d.ts.map +1 -0
- package/dist/mcp/prompts.js +180 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/readme.d.ts +2 -0
- package/dist/mcp/readme.d.ts.map +1 -0
- package/dist/mcp/readme.js +71 -0
- package/dist/mcp/readme.js.map +1 -0
- package/dist/mcp/resources.d.ts +2 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +85 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/server.d.ts +18 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +83 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/mutation.d.ts +2 -0
- package/dist/mcp/tools/mutation.d.ts.map +1 -0
- package/dist/mcp/tools/mutation.js +155 -0
- package/dist/mcp/tools/mutation.js.map +1 -0
- package/dist/mcp/tools/query.d.ts +2 -0
- package/dist/mcp/tools/query.d.ts.map +1 -0
- package/dist/mcp/tools/query.js +130 -0
- package/dist/mcp/tools/query.js.map +1 -0
- package/dist/mcp/tools/search.d.ts +2 -0
- package/dist/mcp/tools/search.d.ts.map +1 -0
- package/dist/mcp/tools/search.js +168 -0
- package/dist/mcp/tools/search.js.map +1 -0
- package/dist/model-instance.d.ts +11 -0
- package/dist/model-instance.d.ts.map +1 -0
- package/dist/model-instance.js +208 -0
- package/dist/model-instance.js.map +1 -0
- package/dist/node-shortcuts.d.ts +25 -0
- package/dist/node-shortcuts.d.ts.map +1 -0
- package/dist/node-shortcuts.js +67 -0
- package/dist/node-shortcuts.js.map +1 -0
- package/dist/parse.d.ts +45 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +98 -0
- package/dist/parse.js.map +1 -0
- package/dist/query/collection-query.d.ts +39 -0
- package/dist/query/collection-query.d.ts.map +1 -0
- package/dist/query/collection-query.js +184 -0
- package/dist/query/collection-query.js.map +1 -0
- package/dist/query/index.d.ts +8 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +5 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/operators.d.ts +3 -0
- package/dist/query/operators.d.ts.map +1 -0
- package/dist/query/operators.js +18 -0
- package/dist/query/operators.js.map +1 -0
- package/dist/query/query-builder.d.ts +34 -0
- package/dist/query/query-builder.d.ts.map +1 -0
- package/dist/query/query-builder.js +84 -0
- package/dist/query/query-builder.js.map +1 -0
- package/dist/query/query-dsl.d.ts +36 -0
- package/dist/query/query-dsl.d.ts.map +1 -0
- package/dist/query/query-dsl.js +195 -0
- package/dist/query/query-dsl.js.map +1 -0
- package/dist/relationships/belongs-to.d.ts +9 -0
- package/dist/relationships/belongs-to.d.ts.map +1 -0
- package/dist/relationships/belongs-to.js +34 -0
- package/dist/relationships/belongs-to.js.map +1 -0
- package/dist/relationships/has-many.d.ts +23 -0
- package/dist/relationships/has-many.d.ts.map +1 -0
- package/dist/relationships/has-many.js +136 -0
- package/dist/relationships/has-many.js.map +1 -0
- package/dist/relationships/index.d.ts +26 -0
- package/dist/relationships/index.d.ts.map +1 -0
- package/dist/relationships/index.js +32 -0
- package/dist/relationships/index.js.map +1 -0
- package/dist/relationships/types.d.ts +2 -0
- package/dist/relationships/types.d.ts.map +1 -0
- package/dist/relationships/types.js +2 -0
- package/dist/relationships/types.js.map +1 -0
- package/dist/search/document-inputs.d.ts +30 -0
- package/dist/search/document-inputs.d.ts.map +1 -0
- package/dist/search/document-inputs.js +52 -0
- package/dist/search/document-inputs.js.map +1 -0
- package/dist/search/luca-semantic-search.d.ts +27 -0
- package/dist/search/luca-semantic-search.d.ts.map +1 -0
- package/dist/search/luca-semantic-search.js +56 -0
- package/dist/search/luca-semantic-search.js.map +1 -0
- package/dist/section.d.ts +21 -0
- package/dist/section.d.ts.map +1 -0
- package/dist/section.js +21 -0
- package/dist/section.js.map +1 -0
- package/dist/types.d.ts +185 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/inflect.d.ts +6 -0
- package/dist/utils/inflect.d.ts.map +1 -0
- package/dist/utils/inflect.js +75 -0
- package/dist/utils/inflect.js.map +1 -0
- package/dist/utils/match-pattern.d.ts +25 -0
- package/dist/utils/match-pattern.d.ts.map +1 -0
- package/dist/utils/match-pattern.js +52 -0
- package/dist/utils/match-pattern.js.map +1 -0
- package/dist/utils/normalize-headings.d.ts +8 -0
- package/dist/utils/normalize-headings.d.ts.map +1 -0
- package/dist/utils/normalize-headings.js +19 -0
- package/dist/utils/normalize-headings.js.map +1 -0
- package/dist/utils/parse-table.d.ts +7 -0
- package/dist/utils/parse-table.d.ts.map +1 -0
- package/dist/utils/parse-table.js +17 -0
- package/dist/utils/parse-table.js.map +1 -0
- package/dist/utils/read-directory.d.ts +5 -0
- package/dist/utils/read-directory.d.ts.map +1 -0
- package/dist/utils/read-directory.js +29 -0
- package/dist/utils/read-directory.js.map +1 -0
- package/dist/utils/stringify-ast.d.ts +6 -0
- package/dist/utils/stringify-ast.d.ts.map +1 -0
- package/dist/utils/stringify-ast.js +8 -0
- package/dist/utils/stringify-ast.js.map +1 -0
- package/dist/utils/strip-markdown.d.ts +11 -0
- package/dist/utils/strip-markdown.d.ts.map +1 -0
- package/dist/utils/strip-markdown.js +48 -0
- package/dist/utils/strip-markdown.js.map +1 -0
- package/dist/validator.d.ts +10 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +55 -0
- package/dist/validator.js.map +1 -0
- package/package.json +3 -3
- package/src/document.ts +26 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/root.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,MAAM,CAAA;AACvB,eAAO,MAAM,WAAW,wEAAwE,CAAA;AAChG,eAAO,MAAM,IAAI,UAAW,CAAA;AAE5B,wBAAsB,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,iBAE/C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const path = '/';
|
|
2
|
+
export const description = 'Redirect to docs table of contents when no static index.html exists';
|
|
3
|
+
export const tags = ['docs'];
|
|
4
|
+
export async function get(_params, ctx) {
|
|
5
|
+
ctx.response.redirect('/docs/');
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/root.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA;AACvB,MAAM,CAAC,MAAM,WAAW,GAAG,qEAAqE,CAAA;AAChG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;AAE5B,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAY,EAAE,GAAQ;IAC9C,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const path = "/api/search/reindex";
|
|
3
|
+
export declare const description = "Trigger search index rebuild";
|
|
4
|
+
export declare const tags: string[];
|
|
5
|
+
export declare const postSchema: z.ZodObject<{
|
|
6
|
+
pathIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare function post(params: any, ctx: any): Promise<any>;
|
|
10
|
+
//# sourceMappingURL=search-reindex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-reindex.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/search-reindex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,IAAI,wBAAwB,CAAA;AACzC,eAAO,MAAM,WAAW,iCAAiC,CAAA;AACzD,eAAO,MAAM,IAAI,UAAe,CAAA;AAEhC,eAAO,MAAM,UAAU;;;iBAGrB,CAAA;AAEF,wBAAsB,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,gBAgC/C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { collectDocumentInputs } from '../../../../search/document-inputs.js';
|
|
3
|
+
import { getInitializedSemanticSearch } from '../../../../search/luca-semantic-search.js';
|
|
4
|
+
export const path = '/api/search/reindex';
|
|
5
|
+
export const description = 'Trigger search index rebuild';
|
|
6
|
+
export const tags = ['mutation'];
|
|
7
|
+
export const postSchema = z.object({
|
|
8
|
+
pathIds: z.array(z.string()).optional(),
|
|
9
|
+
force: z.boolean().optional(),
|
|
10
|
+
});
|
|
11
|
+
export async function post(params, ctx) {
|
|
12
|
+
const collection = ctx.container._contentbaseCollection;
|
|
13
|
+
const rootPath = collection.rootPath;
|
|
14
|
+
const ss = await getInitializedSemanticSearch(ctx.container, rootPath);
|
|
15
|
+
if (params.pathIds) {
|
|
16
|
+
await ss.reindex(params.pathIds);
|
|
17
|
+
}
|
|
18
|
+
else if (params.force) {
|
|
19
|
+
await ss.reindex();
|
|
20
|
+
}
|
|
21
|
+
// Collect and re-index documents
|
|
22
|
+
const targetIds = params.pathIds || collection.available;
|
|
23
|
+
const targetSet = new Set(targetIds);
|
|
24
|
+
const docs = collectDocumentInputs(collection)
|
|
25
|
+
.filter((doc) => targetSet.has(doc.pathId));
|
|
26
|
+
const toIndex = params.force ? docs : docs.filter((d) => ss.needsReindex(d));
|
|
27
|
+
if (toIndex.length > 0) {
|
|
28
|
+
await ss.indexDocuments(toIndex);
|
|
29
|
+
}
|
|
30
|
+
ss.removeStale(collection.available);
|
|
31
|
+
const stats = ss.getStats();
|
|
32
|
+
return {
|
|
33
|
+
reindexed: toIndex.length,
|
|
34
|
+
total: docs.length,
|
|
35
|
+
...stats,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=search-reindex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-reindex.js","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/search-reindex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAA;AAEzF,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAA;AACzC,MAAM,CAAC,MAAM,WAAW,GAAG,8BAA8B,CAAA;AACzD,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,CAAA;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACvC,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAA;AAEF,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,MAAW,EAAE,GAAQ;IAC9C,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAA;IACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAA;IAEpC,MAAM,EAAE,GAAG,MAAM,4BAA4B,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IAEtE,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC;SAAM,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACxB,MAAM,EAAE,CAAC,OAAO,EAAE,CAAA;IACpB,CAAC;IAED,iCAAiC;IACjC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,IAAI,UAAU,CAAC,SAAS,CAAA;IACxD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAA;IACpC,MAAM,IAAI,GAAG,qBAAqB,CAAC,UAAU,CAAC;SAC3C,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAE7C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;IAEjF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC;IAED,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IAEpC,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;IAC3B,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,MAAM;QACzB,KAAK,EAAE,IAAI,CAAC,MAAM;QAClB,GAAG,KAAK;KACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const path = "/api/search/status";
|
|
3
|
+
export declare const description = "Search index health and statistics";
|
|
4
|
+
export declare const tags: string[];
|
|
5
|
+
export declare const getSchema: z.ZodObject<{}, z.core.$strip>;
|
|
6
|
+
export declare function get(_params: any, ctx: any): Promise<any>;
|
|
7
|
+
//# sourceMappingURL=search-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-status.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/search-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,IAAI,uBAAuB,CAAA;AACxC,eAAO,MAAM,WAAW,uCAAuC,CAAA;AAC/D,eAAO,MAAM,IAAI,UAAY,CAAA;AAE7B,eAAO,MAAM,SAAS,gCAAe,CAAA;AAErC,wBAAsB,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,gBA4B/C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getInitializedSemanticSearch, hasSearchIndex } from '../../../../search/luca-semantic-search.js';
|
|
3
|
+
export const path = '/api/search/status';
|
|
4
|
+
export const description = 'Search index health and statistics';
|
|
5
|
+
export const tags = ['query'];
|
|
6
|
+
export const getSchema = z.object({});
|
|
7
|
+
export async function get(_params, ctx) {
|
|
8
|
+
const collection = ctx.container._contentbaseCollection;
|
|
9
|
+
const rootPath = collection.rootPath;
|
|
10
|
+
const hasIndex = hasSearchIndex(rootPath);
|
|
11
|
+
if (!hasIndex) {
|
|
12
|
+
return {
|
|
13
|
+
exists: false,
|
|
14
|
+
documentCount: 0,
|
|
15
|
+
chunkCount: 0,
|
|
16
|
+
embeddingCount: 0,
|
|
17
|
+
lastIndexedAt: null,
|
|
18
|
+
provider: null,
|
|
19
|
+
model: null,
|
|
20
|
+
dimensions: 0,
|
|
21
|
+
dbSizeBytes: 0,
|
|
22
|
+
collectionDocumentCount: collection.available.length,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const ss = await getInitializedSemanticSearch(ctx.container, rootPath);
|
|
26
|
+
const stats = ss.getStats();
|
|
27
|
+
return {
|
|
28
|
+
exists: true,
|
|
29
|
+
...stats,
|
|
30
|
+
collectionDocumentCount: collection.available.length,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=search-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-status.js","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/search-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAEzG,MAAM,CAAC,MAAM,IAAI,GAAG,oBAAoB,CAAA;AACxC,MAAM,CAAC,MAAM,WAAW,GAAG,oCAAoC,CAAA;AAC/D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,CAAA;AAE7B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAErC,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAY,EAAE,GAAQ;IAC9C,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAA;IACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAA;IACpC,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAA;IAEzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;YACL,MAAM,EAAE,KAAK;YACb,aAAa,EAAE,CAAC;YAChB,UAAU,EAAE,CAAC;YACb,cAAc,EAAE,CAAC;YACjB,aAAa,EAAE,IAAI;YACnB,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,CAAC;YACb,WAAW,EAAE,CAAC;YACd,uBAAuB,EAAE,UAAU,CAAC,SAAS,CAAC,MAAM;SACrD,CAAA;IACH,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,4BAA4B,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IAEtE,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;IAC3B,OAAO;QACL,MAAM,EAAE,IAAI;QACZ,GAAG,KAAK;QACR,uBAAuB,EAAE,UAAU,CAAC,SAAS,CAAC,MAAM;KACrD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const path = "/api/search";
|
|
3
|
+
export declare const description = "Search across collection documents using keyword, semantic, or hybrid modes";
|
|
4
|
+
export declare const tags: string[];
|
|
5
|
+
export declare const getSchema: z.ZodObject<{
|
|
6
|
+
q: z.ZodString;
|
|
7
|
+
mode: z.ZodOptional<z.ZodString>;
|
|
8
|
+
model: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare function get(params: any, ctx: any): Promise<any>;
|
|
12
|
+
export declare const postSchema: z.ZodObject<{
|
|
13
|
+
query: z.ZodString;
|
|
14
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
keyword: "keyword";
|
|
16
|
+
vector: "vector";
|
|
17
|
+
hybrid: "hybrid";
|
|
18
|
+
}>>;
|
|
19
|
+
model: z.ZodOptional<z.ZodString>;
|
|
20
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare function post(params: any, ctx: any): Promise<any>;
|
|
24
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,IAAI,gBAAgB,CAAA;AACjC,eAAO,MAAM,WAAW,gFAAgF,CAAA;AACxG,eAAO,MAAM,IAAI,UAAY,CAAA;AAgB7B,eAAO,MAAM,SAAS;;;;;iBAKpB,CAAA;AAEF,wBAAsB,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,gBAe9C;AAID,eAAO,MAAM,UAAU;;;;;;;;;;iBAMrB,CAAA;AAEF,wBAAsB,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,gBAkB/C"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getInitializedSemanticSearch, hasSearchIndex } from '../../../../search/luca-semantic-search.js';
|
|
3
|
+
export const path = '/api/search';
|
|
4
|
+
export const description = 'Search across collection documents using keyword, semantic, or hybrid modes';
|
|
5
|
+
export const tags = ['query'];
|
|
6
|
+
async function doSearch(ss, query, mode, options) {
|
|
7
|
+
switch (mode) {
|
|
8
|
+
case 'keyword':
|
|
9
|
+
return ss.search(query, options);
|
|
10
|
+
case 'vector':
|
|
11
|
+
return ss.vectorSearch(query, options);
|
|
12
|
+
case 'hybrid':
|
|
13
|
+
default:
|
|
14
|
+
return ss.hybridSearch(query, options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// ── GET /api/search ──────────────────────────────────────────────────
|
|
18
|
+
export const getSchema = z.object({
|
|
19
|
+
q: z.string(),
|
|
20
|
+
mode: z.string().optional(),
|
|
21
|
+
model: z.string().optional(),
|
|
22
|
+
limit: z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
export async function get(params, ctx) {
|
|
25
|
+
const collection = ctx.container._contentbaseCollection;
|
|
26
|
+
const rootPath = collection.rootPath;
|
|
27
|
+
if (!hasSearchIndex(rootPath)) {
|
|
28
|
+
ctx.response.status(400);
|
|
29
|
+
return { error: 'No search index found. Run: cnotes embed' };
|
|
30
|
+
}
|
|
31
|
+
const ss = await getInitializedSemanticSearch(ctx.container, rootPath);
|
|
32
|
+
const mode = params.mode || 'hybrid';
|
|
33
|
+
const limit = params.limit ? parseInt(params.limit, 10) : 10;
|
|
34
|
+
const searchOptions = { limit, model: params.model };
|
|
35
|
+
return doSearch(ss, params.q, mode, searchOptions);
|
|
36
|
+
}
|
|
37
|
+
// ── POST /api/search ─────────────────────────────────────────────────
|
|
38
|
+
export const postSchema = z.object({
|
|
39
|
+
query: z.string(),
|
|
40
|
+
mode: z.enum(['hybrid', 'keyword', 'vector']).optional(),
|
|
41
|
+
model: z.string().optional(),
|
|
42
|
+
limit: z.number().optional(),
|
|
43
|
+
where: z.record(z.string(), z.any()).optional(),
|
|
44
|
+
});
|
|
45
|
+
export async function post(params, ctx) {
|
|
46
|
+
const collection = ctx.container._contentbaseCollection;
|
|
47
|
+
const rootPath = collection.rootPath;
|
|
48
|
+
if (!hasSearchIndex(rootPath)) {
|
|
49
|
+
ctx.response.status(400);
|
|
50
|
+
return { error: 'No search index found. Run: cnotes embed' };
|
|
51
|
+
}
|
|
52
|
+
const ss = await getInitializedSemanticSearch(ctx.container, rootPath);
|
|
53
|
+
const mode = params.mode || 'hybrid';
|
|
54
|
+
const searchOptions = {
|
|
55
|
+
limit: params.limit || 10,
|
|
56
|
+
model: params.model,
|
|
57
|
+
where: params.where,
|
|
58
|
+
};
|
|
59
|
+
return doSearch(ss, params.query, mode, searchOptions);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAEzG,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAA;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG,6EAA6E,CAAA;AACxG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,CAAA;AAE7B,KAAK,UAAU,QAAQ,CAAC,EAAO,EAAE,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,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAA;IACpC,MAAM,aAAa,GAAG;QACpB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;QACzB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAA;IAED,OAAO,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,aAAa,CAAC,CAAA;AACxD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const path = "/api/semantic-search";
|
|
3
|
+
export declare const description = "Semantic search across collection documents";
|
|
4
|
+
export declare const tags: string[];
|
|
5
|
+
export declare const getSchema: z.ZodObject<{
|
|
6
|
+
q: z.ZodString;
|
|
7
|
+
mode: z.ZodOptional<z.ZodString>;
|
|
8
|
+
model: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare function get(params: any, ctx: any): Promise<any[] | {
|
|
12
|
+
error: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const postSchema: z.ZodObject<{
|
|
15
|
+
query: z.ZodString;
|
|
16
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
keyword: "keyword";
|
|
18
|
+
vector: "vector";
|
|
19
|
+
hybrid: "hybrid";
|
|
20
|
+
}>>;
|
|
21
|
+
model: z.ZodOptional<z.ZodString>;
|
|
22
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare function post(params: any, ctx: any): Promise<any[] | {
|
|
26
|
+
error: string;
|
|
27
|
+
}>;
|
|
28
|
+
//# sourceMappingURL=semantic-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-search.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/semantic-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,IAAI,yBAAyB,CAAA;AAC1C,eAAO,MAAM,WAAW,gDAAgD,CAAA;AACxE,eAAO,MAAM,IAAI,UAAY,CAAA;AAI7B,eAAO,MAAM,SAAS;;;;;iBAKpB,CAAA;AAEF,wBAAsB,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;;GA6B9C;AAID,eAAO,MAAM,UAAU;;;;;;;;;;iBAMrB,CAAA;AAEF,wBAAsB,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;;GAgC/C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getInitializedSemanticSearch, hasSearchIndex } from '../../../../search/luca-semantic-search.js';
|
|
3
|
+
export const path = '/api/semantic-search';
|
|
4
|
+
export const description = 'Semantic search across collection documents';
|
|
5
|
+
export const tags = ['query'];
|
|
6
|
+
// ── GET /api/semantic-search ─────────────────────────────────────────
|
|
7
|
+
export const getSchema = z.object({
|
|
8
|
+
q: z.string(),
|
|
9
|
+
mode: z.string().optional(),
|
|
10
|
+
model: z.string().optional(),
|
|
11
|
+
limit: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
export async function get(params, ctx) {
|
|
14
|
+
const collection = ctx.container._contentbaseCollection;
|
|
15
|
+
const rootPath = collection.rootPath;
|
|
16
|
+
if (!hasSearchIndex(rootPath)) {
|
|
17
|
+
ctx.response.status(400);
|
|
18
|
+
return { error: 'No search index found. Run: cnotes embed' };
|
|
19
|
+
}
|
|
20
|
+
const ss = await getInitializedSemanticSearch(ctx.container, rootPath);
|
|
21
|
+
const mode = params.mode || 'hybrid';
|
|
22
|
+
const limit = params.limit ? parseInt(params.limit, 10) : 10;
|
|
23
|
+
const searchOptions = { limit, model: params.model };
|
|
24
|
+
let results;
|
|
25
|
+
switch (mode) {
|
|
26
|
+
case 'keyword':
|
|
27
|
+
results = await ss.search(params.q, searchOptions);
|
|
28
|
+
break;
|
|
29
|
+
case 'vector':
|
|
30
|
+
results = await ss.vectorSearch(params.q, searchOptions);
|
|
31
|
+
break;
|
|
32
|
+
case 'hybrid':
|
|
33
|
+
default:
|
|
34
|
+
results = await ss.hybridSearch(params.q, searchOptions);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return results;
|
|
38
|
+
}
|
|
39
|
+
// ── POST /api/semantic-search ────────────────────────────────────────
|
|
40
|
+
export const postSchema = z.object({
|
|
41
|
+
query: z.string(),
|
|
42
|
+
mode: z.enum(['hybrid', 'keyword', 'vector']).optional(),
|
|
43
|
+
model: z.string().optional(),
|
|
44
|
+
limit: z.number().optional(),
|
|
45
|
+
where: z.record(z.string(), z.any()).optional(),
|
|
46
|
+
});
|
|
47
|
+
export async function post(params, ctx) {
|
|
48
|
+
const collection = ctx.container._contentbaseCollection;
|
|
49
|
+
const rootPath = collection.rootPath;
|
|
50
|
+
if (!hasSearchIndex(rootPath)) {
|
|
51
|
+
ctx.response.status(400);
|
|
52
|
+
return { error: 'No search index found. Run: cnotes embed' };
|
|
53
|
+
}
|
|
54
|
+
const ss = await getInitializedSemanticSearch(ctx.container, rootPath);
|
|
55
|
+
const mode = params.mode || 'hybrid';
|
|
56
|
+
const searchOptions = {
|
|
57
|
+
limit: params.limit || 10,
|
|
58
|
+
model: params.model,
|
|
59
|
+
where: params.where,
|
|
60
|
+
};
|
|
61
|
+
let results;
|
|
62
|
+
switch (mode) {
|
|
63
|
+
case 'keyword':
|
|
64
|
+
results = await ss.search(params.query, searchOptions);
|
|
65
|
+
break;
|
|
66
|
+
case 'vector':
|
|
67
|
+
results = await ss.vectorSearch(params.query, searchOptions);
|
|
68
|
+
break;
|
|
69
|
+
case 'hybrid':
|
|
70
|
+
default:
|
|
71
|
+
results = await ss.hybridSearch(params.query, searchOptions);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
return results;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=semantic-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-search.js","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/semantic-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAEzG,MAAM,CAAC,MAAM,IAAI,GAAG,sBAAsB,CAAA;AAC1C,MAAM,CAAC,MAAM,WAAW,GAAG,6CAA6C,CAAA;AACxE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,CAAA;AAE7B,wEAAwE;AAExE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;IACb,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAA;AAEF,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,MAAW,EAAE,GAAQ;IAC7C,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAA;IACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAA;IAEpC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACxB,OAAO,EAAE,KAAK,EAAE,0CAA0C,EAAE,CAAA;IAC9D,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,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@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const path = "/api/text-search";
|
|
3
|
+
export declare const description = "Search file contents with pattern matching";
|
|
4
|
+
export declare const tags: string[];
|
|
5
|
+
export declare const getSchema: z.ZodObject<{
|
|
6
|
+
pattern: z.ZodString;
|
|
7
|
+
expanded: z.ZodOptional<z.ZodString>;
|
|
8
|
+
include: z.ZodOptional<z.ZodString>;
|
|
9
|
+
exclude: z.ZodOptional<z.ZodString>;
|
|
10
|
+
ignoreCase: z.ZodOptional<z.ZodString>;
|
|
11
|
+
maxResults: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export declare function get(params: any, ctx: any): Promise<{
|
|
14
|
+
files: any;
|
|
15
|
+
count: any;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=text-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-search.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/text-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,IAAI,qBAAqB,CAAA;AACtC,eAAO,MAAM,WAAW,+CAA+C,CAAA;AACvE,eAAO,MAAM,IAAI,UAAY,CAAA;AAE7B,eAAO,MAAM,SAAS;;;;;;;iBAOpB,CAAA;AAEF,wBAAsB,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;;;GA+C9C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const path = '/api/text-search';
|
|
3
|
+
export const description = 'Search file contents with pattern matching';
|
|
4
|
+
export const tags = ['query'];
|
|
5
|
+
export const getSchema = z.object({
|
|
6
|
+
pattern: z.string(),
|
|
7
|
+
expanded: z.string().optional(),
|
|
8
|
+
include: z.string().optional(),
|
|
9
|
+
exclude: z.string().optional(),
|
|
10
|
+
ignoreCase: z.string().optional(),
|
|
11
|
+
maxResults: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
export async function get(params, ctx) {
|
|
14
|
+
const collection = ctx.container._contentbaseCollection;
|
|
15
|
+
const grep = ctx.container.feature('grep');
|
|
16
|
+
const searchPath = collection.rootPath;
|
|
17
|
+
const expanded = params.expanded === 'true';
|
|
18
|
+
const ignoreCase = params.ignoreCase === 'true';
|
|
19
|
+
const maxResults = params.maxResults ? parseInt(params.maxResults, 10) : undefined;
|
|
20
|
+
if (!expanded) {
|
|
21
|
+
const files = await grep.filesContaining(params.pattern, {
|
|
22
|
+
path: searchPath,
|
|
23
|
+
ignoreCase,
|
|
24
|
+
maxResults,
|
|
25
|
+
include: params.include,
|
|
26
|
+
exclude: params.exclude,
|
|
27
|
+
});
|
|
28
|
+
return { files, count: files.length };
|
|
29
|
+
}
|
|
30
|
+
const results = await grep.search({
|
|
31
|
+
pattern: params.pattern,
|
|
32
|
+
path: searchPath,
|
|
33
|
+
ignoreCase,
|
|
34
|
+
maxResults,
|
|
35
|
+
include: params.include,
|
|
36
|
+
exclude: params.exclude,
|
|
37
|
+
});
|
|
38
|
+
// Group by file
|
|
39
|
+
const grouped = new Map();
|
|
40
|
+
for (const match of results) {
|
|
41
|
+
if (!grouped.has(match.file))
|
|
42
|
+
grouped.set(match.file, []);
|
|
43
|
+
grouped.get(match.file).push({
|
|
44
|
+
line: match.line,
|
|
45
|
+
column: match.column,
|
|
46
|
+
content: match.content,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const files = Array.from(grouped.entries()).map(([file, matches]) => ({
|
|
50
|
+
file,
|
|
51
|
+
matches,
|
|
52
|
+
}));
|
|
53
|
+
return { files, count: files.length };
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=text-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-search.js","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/text-search.ts"],"names":[],"mappings":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ACvC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const path = "/api/validate";
|
|
3
|
+
export declare const description = "Validate a document against its model schema";
|
|
4
|
+
export declare const tags: string[];
|
|
5
|
+
export declare const getSchema: z.ZodObject<{
|
|
6
|
+
pathId: z.ZodString;
|
|
7
|
+
model: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare function get(params: any, ctx: any): Promise<import("../../../../types.js").ValidationResult | {
|
|
10
|
+
error: string;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,IAAI,kBAAkB,CAAA;AACnC,eAAO,MAAM,WAAW,iDAAiD,CAAA;AACzE,eAAO,MAAM,IAAI,UAAiB,CAAA;AAElC,eAAO,MAAM,SAAS;;;iBAGpB,CAAA;AAEF,wBAAsB,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;;GAoB9C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { validateDocument } from '../../../../index.js';
|
|
3
|
+
import { resolveModelDef } from '../helpers.js';
|
|
4
|
+
export const path = '/api/validate';
|
|
5
|
+
export const description = 'Validate a document against its model schema';
|
|
6
|
+
export const tags = ['validation'];
|
|
7
|
+
export const getSchema = z.object({
|
|
8
|
+
pathId: z.string(),
|
|
9
|
+
model: z.string().optional(),
|
|
10
|
+
});
|
|
11
|
+
export async function get(params, ctx) {
|
|
12
|
+
const collection = ctx.container._contentbaseCollection;
|
|
13
|
+
if (!collection.available.includes(params.pathId)) {
|
|
14
|
+
ctx.response.status(404);
|
|
15
|
+
return { error: `Document not found: ${params.pathId}` };
|
|
16
|
+
}
|
|
17
|
+
const doc = collection.document(params.pathId);
|
|
18
|
+
const def = params.model
|
|
19
|
+
? resolveModelDef(collection, params.model)
|
|
20
|
+
: collection.findModelDefinition(params.pathId);
|
|
21
|
+
if (!def) {
|
|
22
|
+
ctx.response.status(400);
|
|
23
|
+
return { error: `No model definition found for ${params.pathId}` };
|
|
24
|
+
}
|
|
25
|
+
return validateDocument(doc, def);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../../src/cli/commands/api/endpoints/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAA;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,8CAA8C,CAAA;AACzE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,YAAY,CAAC,CAAA;AAElC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAA;AAEF,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,MAAW,EAAE,GAAQ;IAC7C,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAA;IAEvD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACxB,OAAO,EAAE,KAAK,EAAE,uBAAuB,MAAM,CAAC,MAAM,EAAE,EAAE,CAAA;IAC1D,CAAC;IAED,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAE9C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK;QACtB,CAAC,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC;QAC3C,CAAC,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAEjD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACxB,OAAO,EAAE,KAAK,EAAE,iCAAiC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAA;IACpE,CAAC;IAED,OAAO,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AACnC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Collection } from '../../../collection.js';
|
|
2
|
+
export declare function renderMarkdownToHtml(markdown: string): Promise<string>;
|
|
3
|
+
export declare function rewriteDocLinks(html: string): string;
|
|
4
|
+
export declare const tocPageStyle = "<style>\n *, *::before, *::after { box-sizing: border-box; }\n body {\n font-family: 'Inter', system-ui, -apple-system, sans-serif;\n max-width: 52rem;\n margin: 0 auto;\n padding: 2rem 1.5rem;\n line-height: 1.7;\n color: #1a1a2e;\n background: #fafafa;\n }\n h1 { font-size: 2rem; font-weight: 600; margin: 2rem 0 1rem; color: #0f0f23; }\n h2 { font-size: 1.5rem; font-weight: 600; margin: 2.5rem 0 0.75rem; color: #16163a; border-bottom: 1px solid #e2e2e8; padding-bottom: 0.4rem; }\n a { color: #2563eb; text-decoration: none; }\n a:hover { text-decoration: underline; }\n ul { padding-left: 1.5rem; margin: 0.5rem 0 1rem; }\n li { margin: 0.3rem 0; }\n</style>";
|
|
5
|
+
export declare function renderTocPage(collection: Collection): Promise<string>;
|
|
6
|
+
export declare function resolveModelDef(collection: Collection, name: string): import("../../../types.js").ModelDefinition<any, any, any, any, any> | undefined;
|
|
7
|
+
export declare function buildSchemaJSON(collection: Collection): Record<string, any>;
|
|
8
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/api/helpers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGxD,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ5E;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED,eAAO,MAAM,YAAY,4rBAiBhB,CAAA;AAET,wBAAsB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAc3E;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,oFAKnE;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,uBA2BrD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { unified } from 'unified';
|
|
2
|
+
import remarkParse from 'remark-parse';
|
|
3
|
+
import remarkGfm from 'remark-gfm';
|
|
4
|
+
import remarkRehype from 'remark-rehype';
|
|
5
|
+
import rehypeStringify from 'rehype-stringify';
|
|
6
|
+
import { introspectMetaSchema } from '../../../collection.js';
|
|
7
|
+
export async function renderMarkdownToHtml(markdown) {
|
|
8
|
+
const result = await unified()
|
|
9
|
+
.use(remarkParse)
|
|
10
|
+
.use(remarkGfm)
|
|
11
|
+
.use(remarkRehype)
|
|
12
|
+
.use(rehypeStringify)
|
|
13
|
+
.process(markdown);
|
|
14
|
+
return String(result);
|
|
15
|
+
}
|
|
16
|
+
export function rewriteDocLinks(html) {
|
|
17
|
+
return html.replace(/href="([^"]*\.(?:md|mdx))"/g, (match, href) => {
|
|
18
|
+
if (href.startsWith('http://') || href.startsWith('https://') || href.startsWith('//')) {
|
|
19
|
+
return match;
|
|
20
|
+
}
|
|
21
|
+
return `href="${href.replace(/\.mdx?$/, '')}"`;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export const tocPageStyle = `<style>
|
|
25
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
26
|
+
body {
|
|
27
|
+
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
|
28
|
+
max-width: 52rem;
|
|
29
|
+
margin: 0 auto;
|
|
30
|
+
padding: 2rem 1.5rem;
|
|
31
|
+
line-height: 1.7;
|
|
32
|
+
color: #1a1a2e;
|
|
33
|
+
background: #fafafa;
|
|
34
|
+
}
|
|
35
|
+
h1 { font-size: 2rem; font-weight: 600; margin: 2rem 0 1rem; color: #0f0f23; }
|
|
36
|
+
h2 { font-size: 1.5rem; font-weight: 600; margin: 2.5rem 0 0.75rem; color: #16163a; border-bottom: 1px solid #e2e2e8; padding-bottom: 0.4rem; }
|
|
37
|
+
a { color: #2563eb; text-decoration: none; }
|
|
38
|
+
a:hover { text-decoration: underline; }
|
|
39
|
+
ul { padding-left: 1.5rem; margin: 0.5rem 0 1rem; }
|
|
40
|
+
li { margin: 0.3rem 0; }
|
|
41
|
+
</style>`;
|
|
42
|
+
export async function renderTocPage(collection) {
|
|
43
|
+
const tocMarkdown = collection.tableOfContents({ title: 'Table of Contents', basePath: '.' });
|
|
44
|
+
const tocHtml = rewriteDocLinks(await renderMarkdownToHtml(tocMarkdown));
|
|
45
|
+
return `<!DOCTYPE html>
|
|
46
|
+
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
47
|
+
<title>Table of Contents</title>
|
|
48
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
49
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
50
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
|
51
|
+
${tocPageStyle}
|
|
52
|
+
</head>
|
|
53
|
+
<body>
|
|
54
|
+
${tocHtml}
|
|
55
|
+
</body></html>`;
|
|
56
|
+
}
|
|
57
|
+
export function resolveModelDef(collection, name) {
|
|
58
|
+
const lower = name.toLowerCase();
|
|
59
|
+
return collection.modelDefinitions.find((d) => d.name.toLowerCase() === lower || d.prefix.toLowerCase() === lower);
|
|
60
|
+
}
|
|
61
|
+
export function buildSchemaJSON(collection) {
|
|
62
|
+
const models = {};
|
|
63
|
+
for (const def of collection.modelDefinitions) {
|
|
64
|
+
const fields = introspectMetaSchema(def.meta);
|
|
65
|
+
const sections = Object.entries(def.sections || {}).map(([key, sec]) => ({
|
|
66
|
+
key,
|
|
67
|
+
heading: sec.heading,
|
|
68
|
+
alternatives: sec.alternatives || [],
|
|
69
|
+
hasSchema: !!sec.schema,
|
|
70
|
+
}));
|
|
71
|
+
const relationships = Object.entries(def.relationships || {}).map(([key, rel]) => ({
|
|
72
|
+
key,
|
|
73
|
+
type: rel.type,
|
|
74
|
+
model: rel.model,
|
|
75
|
+
}));
|
|
76
|
+
models[def.name] = {
|
|
77
|
+
name: def.name,
|
|
78
|
+
prefix: def.prefix,
|
|
79
|
+
description: def.description,
|
|
80
|
+
fields,
|
|
81
|
+
sections,
|
|
82
|
+
relationships,
|
|
83
|
+
computed: Object.keys(def.computed || {}),
|
|
84
|
+
scopes: Object.keys(def.scopes || {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return models;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/cli/commands/api/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,WAAW,M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