@soulcraft/sdk 1.6.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/create-client-sdk.d.ts +16 -2
- package/dist/client/create-client-sdk.d.ts.map +1 -1
- package/dist/client/create-client-sdk.js +2 -7
- package/dist/client/create-client-sdk.js.map +1 -1
- package/dist/client/index.d.ts +48 -37
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +61 -42
- package/dist/client/index.js.map +1 -1
- package/dist/client/namespace-proxy.d.ts +108 -0
- package/dist/client/namespace-proxy.d.ts.map +1 -0
- package/dist/client/namespace-proxy.js +151 -0
- package/dist/client/namespace-proxy.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/app-context/index.d.ts +214 -0
- package/dist/modules/app-context/index.d.ts.map +1 -0
- package/dist/modules/app-context/index.js +569 -0
- package/dist/modules/app-context/index.js.map +1 -0
- package/dist/modules/auth/products.d.ts +208 -0
- package/dist/modules/auth/products.d.ts.map +1 -0
- package/dist/modules/auth/products.js +165 -0
- package/dist/modules/auth/products.js.map +1 -0
- package/dist/namespaces.d.ts +2942 -0
- package/dist/namespaces.d.ts.map +1 -0
- package/dist/namespaces.js +37 -0
- package/dist/namespaces.js.map +1 -0
- package/dist/rpc.d.ts +156 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +26 -0
- package/dist/rpc.js.map +1 -0
- package/dist/server/create-sdk.d.ts.map +1 -1
- package/dist/server/create-sdk.js +3 -13
- package/dist/server/create-sdk.js.map +1 -1
- package/dist/server/handlers/annotations.d.ts +52 -0
- package/dist/server/handlers/annotations.d.ts.map +1 -0
- package/dist/server/handlers/annotations.js +204 -0
- package/dist/server/handlers/annotations.js.map +1 -0
- package/dist/server/handlers/auth.d.ts +53 -0
- package/dist/server/handlers/auth.d.ts.map +1 -0
- package/dist/server/handlers/auth.js +66 -0
- package/dist/server/handlers/auth.js.map +1 -0
- package/dist/server/handlers/certification.d.ts +32 -0
- package/dist/server/handlers/certification.d.ts.map +1 -0
- package/dist/server/handlers/certification.js +253 -0
- package/dist/server/handlers/certification.js.map +1 -0
- package/dist/server/handlers/chat/conversations.d.ts +91 -0
- package/dist/server/handlers/chat/conversations.d.ts.map +1 -0
- package/dist/server/handlers/chat/conversations.js +314 -0
- package/dist/server/handlers/chat/conversations.js.map +1 -0
- package/dist/server/handlers/chat/delegator.d.ts +144 -0
- package/dist/server/handlers/chat/delegator.d.ts.map +1 -0
- package/dist/server/handlers/chat/delegator.js +431 -0
- package/dist/server/handlers/chat/delegator.js.map +1 -0
- package/dist/server/handlers/chat/engine.d.ts +81 -0
- package/dist/server/handlers/chat/engine.d.ts.map +1 -0
- package/dist/server/handlers/chat/engine.js +442 -0
- package/dist/server/handlers/chat/engine.js.map +1 -0
- package/dist/server/handlers/chat/executor.d.ts +65 -0
- package/dist/server/handlers/chat/executor.d.ts.map +1 -0
- package/dist/server/handlers/chat/executor.js +375 -0
- package/dist/server/handlers/chat/executor.js.map +1 -0
- package/dist/server/handlers/chat/index.d.ts +62 -0
- package/dist/server/handlers/chat/index.d.ts.map +1 -0
- package/dist/server/handlers/chat/index.js +182 -0
- package/dist/server/handlers/chat/index.js.map +1 -0
- package/dist/server/handlers/chat/memory.d.ts +91 -0
- package/dist/server/handlers/chat/memory.d.ts.map +1 -0
- package/dist/server/handlers/chat/memory.js +293 -0
- package/dist/server/handlers/chat/memory.js.map +1 -0
- package/dist/server/handlers/chat/models.d.ts +180 -0
- package/dist/server/handlers/chat/models.d.ts.map +1 -0
- package/dist/server/handlers/chat/models.js +304 -0
- package/dist/server/handlers/chat/models.js.map +1 -0
- package/dist/server/handlers/chat/planner.d.ts +116 -0
- package/dist/server/handlers/chat/planner.d.ts.map +1 -0
- package/dist/server/handlers/chat/planner.js +344 -0
- package/dist/server/handlers/chat/planner.js.map +1 -0
- package/dist/server/handlers/chat/types.d.ts +500 -0
- package/dist/server/handlers/chat/types.d.ts.map +1 -0
- package/dist/server/handlers/chat/types.js +11 -0
- package/dist/server/handlers/chat/types.js.map +1 -0
- package/dist/server/handlers/collections.d.ts +67 -0
- package/dist/server/handlers/collections.d.ts.map +1 -0
- package/dist/server/handlers/collections.js +484 -0
- package/dist/server/handlers/collections.js.map +1 -0
- package/dist/server/handlers/commerce.d.ts +106 -0
- package/dist/server/handlers/commerce.d.ts.map +1 -0
- package/dist/server/handlers/commerce.js +62 -0
- package/dist/server/handlers/commerce.js.map +1 -0
- package/dist/server/handlers/config.d.ts +112 -0
- package/dist/server/handlers/config.d.ts.map +1 -0
- package/dist/server/handlers/config.js +122 -0
- package/dist/server/handlers/config.js.map +1 -0
- package/dist/server/handlers/export.d.ts +72 -0
- package/dist/server/handlers/export.d.ts.map +1 -0
- package/dist/server/handlers/export.js +175 -0
- package/dist/server/handlers/export.js.map +1 -0
- package/dist/server/handlers/formats.d.ts +77 -0
- package/dist/server/handlers/formats.d.ts.map +1 -0
- package/dist/server/handlers/formats.js +65 -0
- package/dist/server/handlers/formats.js.map +1 -0
- package/dist/server/handlers/graph.d.ts +31 -0
- package/dist/server/handlers/graph.d.ts.map +1 -0
- package/dist/server/handlers/graph.js +490 -0
- package/dist/server/handlers/graph.js.map +1 -0
- package/dist/server/handlers/import.d.ts +96 -0
- package/dist/server/handlers/import.d.ts.map +1 -0
- package/dist/server/handlers/import.js +108 -0
- package/dist/server/handlers/import.js.map +1 -0
- package/dist/server/handlers/index.d.ts +68 -0
- package/dist/server/handlers/index.d.ts.map +1 -0
- package/dist/server/handlers/index.js +71 -0
- package/dist/server/handlers/index.js.map +1 -0
- package/dist/server/handlers/media.d.ts +76 -0
- package/dist/server/handlers/media.d.ts.map +1 -0
- package/dist/server/handlers/media.js +53 -0
- package/dist/server/handlers/media.js.map +1 -0
- package/dist/server/handlers/project.d.ts +45 -0
- package/dist/server/handlers/project.d.ts.map +1 -0
- package/dist/server/handlers/project.js +181 -0
- package/dist/server/handlers/project.js.map +1 -0
- package/dist/server/handlers/publish.d.ts +102 -0
- package/dist/server/handlers/publish.d.ts.map +1 -0
- package/dist/server/handlers/publish.js +130 -0
- package/dist/server/handlers/publish.js.map +1 -0
- package/dist/server/handlers/pulse.d.ts +39 -0
- package/dist/server/handlers/pulse.d.ts.map +1 -0
- package/dist/server/handlers/pulse.js +78 -0
- package/dist/server/handlers/pulse.js.map +1 -0
- package/dist/server/handlers/realtime.d.ts +55 -0
- package/dist/server/handlers/realtime.d.ts.map +1 -0
- package/dist/server/handlers/realtime.js +49 -0
- package/dist/server/handlers/realtime.js.map +1 -0
- package/dist/server/handlers/search.d.ts +21 -0
- package/dist/server/handlers/search.d.ts.map +1 -0
- package/dist/server/handlers/search.js +237 -0
- package/dist/server/handlers/search.js.map +1 -0
- package/dist/server/handlers/session.d.ts +47 -0
- package/dist/server/handlers/session.d.ts.map +1 -0
- package/dist/server/handlers/session.js +286 -0
- package/dist/server/handlers/session.js.map +1 -0
- package/dist/server/handlers/settings.d.ts +97 -0
- package/dist/server/handlers/settings.d.ts.map +1 -0
- package/dist/server/handlers/settings.js +131 -0
- package/dist/server/handlers/settings.js.map +1 -0
- package/dist/server/handlers/workspace.d.ts +78 -0
- package/dist/server/handlers/workspace.d.ts.map +1 -0
- package/dist/server/handlers/workspace.js +270 -0
- package/dist/server/handlers/workspace.js.map +1 -0
- package/dist/server/hono-router.d.ts +66 -0
- package/dist/server/hono-router.d.ts.map +1 -0
- package/dist/server/hono-router.js +203 -0
- package/dist/server/hono-router.js.map +1 -0
- package/dist/server/index.d.ts +29 -19
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +33 -19
- package/dist/server/index.js.map +1 -1
- package/dist/server/namespace-router.d.ts +204 -0
- package/dist/server/namespace-router.d.ts.map +1 -0
- package/dist/server/namespace-router.js +262 -0
- package/dist/server/namespace-router.js.map +1 -0
- package/dist/transports/http-namespace.d.ts +210 -0
- package/dist/transports/http-namespace.d.ts.map +1 -0
- package/dist/transports/http-namespace.js +514 -0
- package/dist/transports/http-namespace.js.map +1 -0
- package/dist/transports/workshop.d.ts +173 -0
- package/dist/transports/workshop.d.ts.map +1 -0
- package/dist/transports/workshop.js +307 -0
- package/dist/transports/workshop.js.map +1 -0
- package/dist/types.d.ts +65 -67
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -3
- package/dist/types.js.map +1 -1
- package/docs/ADR-004-product-registry.md +108 -0
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module server/handlers/publish
|
|
3
|
+
* @description Publish namespace handler — Living Links, Venue deploy, and
|
|
4
|
+
* Academy publish.
|
|
5
|
+
*
|
|
6
|
+
* Absorbs Workshop `routes/publish.ts`, `routes/deploy.ts`, and
|
|
7
|
+
* `routes/academy-publish.ts`. The handler delegates to an injected
|
|
8
|
+
* `PublishBackend` interface for link management and destination deployments.
|
|
9
|
+
*
|
|
10
|
+
* Methods:
|
|
11
|
+
* - `createLink` — Create a Living Link for sharing
|
|
12
|
+
* - `getLink` — Get an existing link by ID
|
|
13
|
+
* - `deleteLink` — Delete a link
|
|
14
|
+
* - `listLinks` — List all links for the workspace
|
|
15
|
+
* - `checkSlug` — Check slug availability
|
|
16
|
+
* - `getProjectInfo` — Get project info for publishing
|
|
17
|
+
* - `deployToVenue` — Deploy workspace to Venue
|
|
18
|
+
* - `publishToAcademy` — Publish content as Academy course
|
|
19
|
+
* - `to` — Unified publish dispatcher
|
|
20
|
+
*/
|
|
21
|
+
import type { NamespaceProvider } from '../namespace-router.js';
|
|
22
|
+
import type { PublishedLink } from '../../namespaces.js';
|
|
23
|
+
/**
|
|
24
|
+
* Publish backend interface for link management and deployment.
|
|
25
|
+
*
|
|
26
|
+
* Products implement this to connect to their publish registry and
|
|
27
|
+
* deployment infrastructure.
|
|
28
|
+
*/
|
|
29
|
+
export interface PublishBackend {
|
|
30
|
+
/** Create a Living Link entry. */
|
|
31
|
+
createLink(userId: string, workspaceId: string, options: {
|
|
32
|
+
type: string;
|
|
33
|
+
slug?: string;
|
|
34
|
+
entityIds?: string[];
|
|
35
|
+
expiresIn?: number;
|
|
36
|
+
}): Promise<PublishedLink>;
|
|
37
|
+
/** Get a link by ID. */
|
|
38
|
+
getLink(linkId: string): Promise<PublishedLink | null>;
|
|
39
|
+
/** Delete a link. */
|
|
40
|
+
deleteLink(linkId: string): Promise<void>;
|
|
41
|
+
/** List all links for a workspace. */
|
|
42
|
+
listLinks(userId: string, workspaceId: string): Promise<PublishedLink[]>;
|
|
43
|
+
/** Check if a slug is available. */
|
|
44
|
+
checkSlug(slug: string): Promise<boolean>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Venue deployment service interface.
|
|
48
|
+
*/
|
|
49
|
+
export interface VenueDeployService {
|
|
50
|
+
deploy(options: {
|
|
51
|
+
venueHandle: string;
|
|
52
|
+
venueSlug: string;
|
|
53
|
+
deploySecret: string;
|
|
54
|
+
workspaceId: string;
|
|
55
|
+
userId: string;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
url: string;
|
|
58
|
+
deployedAt: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Academy publish service interface.
|
|
63
|
+
*/
|
|
64
|
+
export interface AcademyPublishService {
|
|
65
|
+
publish(options: {
|
|
66
|
+
academyUrl: string;
|
|
67
|
+
publishSecret: string;
|
|
68
|
+
courseTitle?: string;
|
|
69
|
+
lessonIds?: string[];
|
|
70
|
+
workspaceId: string;
|
|
71
|
+
userId: string;
|
|
72
|
+
}): Promise<{
|
|
73
|
+
courseId: string;
|
|
74
|
+
url: string;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Options for {@link createPublishHandler}.
|
|
79
|
+
*/
|
|
80
|
+
export interface PublishHandlerOptions {
|
|
81
|
+
/** Publish backend for link management. */
|
|
82
|
+
publishBackend: PublishBackend;
|
|
83
|
+
/** Venue deployment service. Optional — `deployToVenue` throws if missing. */
|
|
84
|
+
venueService?: VenueDeployService;
|
|
85
|
+
/** Academy publish service. Optional — `publishToAcademy` throws if missing. */
|
|
86
|
+
academyService?: AcademyPublishService;
|
|
87
|
+
/** Pre-configured Venue deploy secret (for `to('venue')` unified API). */
|
|
88
|
+
venueDeploySecret?: string;
|
|
89
|
+
/** Pre-configured Academy URL and secret (for `to('academy')` unified API). */
|
|
90
|
+
academyConfig?: {
|
|
91
|
+
url: string;
|
|
92
|
+
secret: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates the `publish` namespace handler.
|
|
97
|
+
*
|
|
98
|
+
* @param options - Publish handler dependencies.
|
|
99
|
+
* @returns A {@link NamespaceProvider} implementing {@link PublishNamespace}.
|
|
100
|
+
*/
|
|
101
|
+
export declare function createPublishHandler(options: PublishHandlerOptions): NamespaceProvider;
|
|
102
|
+
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,wBAAwB,CAAA;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAMxD;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,UAAU,CACR,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GACjF,OAAO,CAAC,aAAa,CAAC,CAAA;IAEzB,wBAAwB;IACxB,OAAO,CAAC,MAAM,EAAE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AAqB,CAAA;IACtC,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,+EAA+E;IAC/E,aAAa,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAChD;AAMD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAyItF"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module server/handlers/publish
|
|
3
|
+
* @description Publish namespace handler — Living Links, Venue deploy, and
|
|
4
|
+
* Academy publish.
|
|
5
|
+
*
|
|
6
|
+
* Absorbs Workshop `routes/publish.ts`, `routes/deploy.ts`, and
|
|
7
|
+
* `routes/academy-publish.ts`. The handler delegates to an injected
|
|
8
|
+
* `PublishBackend` interface for link management and destination deployments.
|
|
9
|
+
*
|
|
10
|
+
* Methods:
|
|
11
|
+
* - `createLink` — Create a Living Link for sharing
|
|
12
|
+
* - `getLink` — Get an existing link by ID
|
|
13
|
+
* - `deleteLink` — Delete a link
|
|
14
|
+
* - `listLinks` — List all links for the workspace
|
|
15
|
+
* - `checkSlug` — Check slug availability
|
|
16
|
+
* - `getProjectInfo` — Get project info for publishing
|
|
17
|
+
* - `deployToVenue` — Deploy workspace to Venue
|
|
18
|
+
* - `publishToAcademy` — Publish content as Academy course
|
|
19
|
+
* - `to` — Unified publish dispatcher
|
|
20
|
+
*/
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
22
|
+
// Handler factory
|
|
23
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
24
|
+
/**
|
|
25
|
+
* Creates the `publish` namespace handler.
|
|
26
|
+
*
|
|
27
|
+
* @param options - Publish handler dependencies.
|
|
28
|
+
* @returns A {@link NamespaceProvider} implementing {@link PublishNamespace}.
|
|
29
|
+
*/
|
|
30
|
+
export function createPublishHandler(options) {
|
|
31
|
+
const { publishBackend, venueService, academyService, venueDeploySecret, academyConfig } = options;
|
|
32
|
+
return {
|
|
33
|
+
async createLink(linkOptions, ctx) {
|
|
34
|
+
return publishBackend.createLink(ctx.user.emailHash, ctx.workspaceId, linkOptions);
|
|
35
|
+
},
|
|
36
|
+
async getLink(linkId) {
|
|
37
|
+
return publishBackend.getLink(linkId);
|
|
38
|
+
},
|
|
39
|
+
async deleteLink(linkId) {
|
|
40
|
+
return publishBackend.deleteLink(linkId);
|
|
41
|
+
},
|
|
42
|
+
async listLinks(ctx) {
|
|
43
|
+
return publishBackend.listLinks(ctx.user.emailHash, ctx.workspaceId);
|
|
44
|
+
},
|
|
45
|
+
async checkSlug(slug) {
|
|
46
|
+
const available = await publishBackend.checkSlug(slug);
|
|
47
|
+
return { available };
|
|
48
|
+
},
|
|
49
|
+
async getProjectInfo(ctx) {
|
|
50
|
+
const { brain } = ctx;
|
|
51
|
+
const stats = await brain.indexStats();
|
|
52
|
+
let kitId = '';
|
|
53
|
+
try {
|
|
54
|
+
const meta = await brain.vfs.getxattr('/', 'workshop.project');
|
|
55
|
+
kitId = meta?.kitId || '';
|
|
56
|
+
}
|
|
57
|
+
catch { /* no project metadata */ }
|
|
58
|
+
let fileCount = 0;
|
|
59
|
+
try {
|
|
60
|
+
const entries = await brain.vfs.readdir('/', { recursive: true });
|
|
61
|
+
fileCount = Array.isArray(entries) ? entries.length : 0;
|
|
62
|
+
}
|
|
63
|
+
catch { /* empty VFS */ }
|
|
64
|
+
return {
|
|
65
|
+
name: ctx.workspaceId, // Products override via xattr
|
|
66
|
+
kitId,
|
|
67
|
+
entityCount: stats.entities ?? 0,
|
|
68
|
+
fileCount,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
async deployToVenue(deployOptions, ctx) {
|
|
72
|
+
if (!venueService) {
|
|
73
|
+
throw new Error('Venue deployment is not configured — provide a VenueDeployService');
|
|
74
|
+
}
|
|
75
|
+
return venueService.deploy({
|
|
76
|
+
...deployOptions,
|
|
77
|
+
workspaceId: ctx.workspaceId,
|
|
78
|
+
userId: ctx.user.emailHash,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
async publishToAcademy(academyOptions, ctx) {
|
|
82
|
+
if (!academyService) {
|
|
83
|
+
throw new Error('Academy publish is not configured — provide an AcademyPublishService');
|
|
84
|
+
}
|
|
85
|
+
return academyService.publish({
|
|
86
|
+
...academyOptions,
|
|
87
|
+
workspaceId: ctx.workspaceId,
|
|
88
|
+
userId: ctx.user.emailHash,
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
async to(destination, toOptions, ctx) {
|
|
92
|
+
const now = new Date().toISOString();
|
|
93
|
+
if (destination === 'venue') {
|
|
94
|
+
if (!venueService) {
|
|
95
|
+
throw new Error('Venue deployment is not configured');
|
|
96
|
+
}
|
|
97
|
+
if (!venueDeploySecret) {
|
|
98
|
+
throw new Error('Venue deploy secret is not configured — set WORKSHOP_DEPLOY_SECRET');
|
|
99
|
+
}
|
|
100
|
+
const result = await venueService.deploy({
|
|
101
|
+
venueHandle: toOptions?.handle || '',
|
|
102
|
+
venueSlug: toOptions?.slug || 'main',
|
|
103
|
+
deploySecret: venueDeploySecret,
|
|
104
|
+
workspaceId: ctx.workspaceId,
|
|
105
|
+
userId: ctx.user.emailHash,
|
|
106
|
+
});
|
|
107
|
+
return { url: result.url, publishedAt: result.deployedAt };
|
|
108
|
+
}
|
|
109
|
+
if (destination === 'academy') {
|
|
110
|
+
if (!academyService) {
|
|
111
|
+
throw new Error('Academy publish is not configured');
|
|
112
|
+
}
|
|
113
|
+
if (!academyConfig) {
|
|
114
|
+
throw new Error('Academy URL/secret not configured — set ACADEMY_PUBLISH_SECRET');
|
|
115
|
+
}
|
|
116
|
+
const result = await academyService.publish({
|
|
117
|
+
academyUrl: academyConfig.url,
|
|
118
|
+
publishSecret: academyConfig.secret,
|
|
119
|
+
...(toOptions?.courseTitle != null ? { courseTitle: toOptions.courseTitle } : {}),
|
|
120
|
+
...(toOptions?.entityIds != null ? { lessonIds: toOptions.entityIds } : {}),
|
|
121
|
+
workspaceId: ctx.workspaceId,
|
|
122
|
+
userId: ctx.user.emailHash,
|
|
123
|
+
});
|
|
124
|
+
return { url: result.url, destinationId: result.courseId, publishedAt: now };
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Unknown publish destination: ${destination}`);
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/server/handlers/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AA+EH,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,GAAG,OAAO,CAAA;IAElG,OAAO;QACL,KAAK,CAAC,UAAU,CACd,WAAsF,EACtF,GAAmB;YAEnB,OAAO,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;QACpF,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,MAAc;YAC1B,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACvC,CAAC;QAED,KAAK,CAAC,UAAU,CAAC,MAAc;YAC7B,OAAO,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QAC1C,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,GAAmB;YACjC,OAAO,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;QACtE,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,IAAY;YAC1B,MAAM,SAAS,GAAG,MAAM,c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AS,EAAE,CAAC;gBAC9B,IAAI,CAAC,cAAc,EAAE,CAAC;oBACpB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;gBACtD,CAAC;gBACD,IAAI,CAAC,aAAa,EAAE,CAAC;oBACnB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;gBACnF,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC;oBAC1C,UAAU,EAAE,aAAa,CAAC,GAAG;oBAC7B,aAAa,EAAE,aAAa,CAAC,MAAM;oBACnC,GAAG,CAAC,SAAS,EAAE,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACjF,GAAG,CAAC,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC3E,WAAW,EAAE,GAAG,CAAC,WAAW;oBAC5B,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS;iBAC3B,CAAC,CAAA;gBACF,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,CAAA;YAC9E,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,WAAW,EAAE,CAAC,CAAA;QAChE,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module server/handlers/pulse
|
|
3
|
+
* @description Pulse namespace handler — fire-and-forget analytics event forwarding.
|
|
4
|
+
*
|
|
5
|
+
* Absorbs the `pulse` section of Workshop `routes/app-services.ts`. Events are
|
|
6
|
+
* forwarded to the configured analytics sink URL via HTTP POST. The call returns
|
|
7
|
+
* immediately; delivery is best-effort (failures are logged, not thrown).
|
|
8
|
+
*
|
|
9
|
+
* Methods:
|
|
10
|
+
* - `track` — Forward an analytics event to the configured sink
|
|
11
|
+
*/
|
|
12
|
+
import type { NamespaceProvider } from '../namespace-router.js';
|
|
13
|
+
/**
|
|
14
|
+
* Options for {@link createPulseHandler}.
|
|
15
|
+
*/
|
|
16
|
+
export interface PulseHandlerOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Analytics sink URL to forward events to.
|
|
19
|
+
* If not provided, events are logged to the console in dev mode and silently
|
|
20
|
+
* dropped in production.
|
|
21
|
+
*/
|
|
22
|
+
sinkUrl?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional bearer token for authenticating with the analytics sink.
|
|
25
|
+
*/
|
|
26
|
+
sinkToken?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Request timeout in milliseconds. Default: 5000.
|
|
29
|
+
*/
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates the `pulse` namespace handler.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Pulse handler configuration.
|
|
36
|
+
* @returns A {@link NamespaceProvider} implementing {@link PulseNamespace}.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createPulseHandler(options?: PulseHandlerOptions): NamespaceProvider;
|
|
39
|
+
//# sourceMappingURL=pulse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulse.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/pulse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,wBAAwB,CAAA;AAM/E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAMD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,CAiEnF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module server/handlers/pulse
|
|
3
|
+
* @description Pulse namespace handler — fire-and-forget analytics event forwarding.
|
|
4
|
+
*
|
|
5
|
+
* Absorbs the `pulse` section of Workshop `routes/app-services.ts`. Events are
|
|
6
|
+
* forwarded to the configured analytics sink URL via HTTP POST. The call returns
|
|
7
|
+
* immediately; delivery is best-effort (failures are logged, not thrown).
|
|
8
|
+
*
|
|
9
|
+
* Methods:
|
|
10
|
+
* - `track` — Forward an analytics event to the configured sink
|
|
11
|
+
*/
|
|
12
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
+
// Handler factory
|
|
14
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
15
|
+
/**
|
|
16
|
+
* Creates the `pulse` namespace handler.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Pulse handler configuration.
|
|
19
|
+
* @returns A {@link NamespaceProvider} implementing {@link PulseNamespace}.
|
|
20
|
+
*/
|
|
21
|
+
export function createPulseHandler(options) {
|
|
22
|
+
const sinkUrl = options?.sinkUrl;
|
|
23
|
+
const sinkToken = options?.sinkToken;
|
|
24
|
+
const timeoutMs = options?.timeoutMs ?? 5000;
|
|
25
|
+
return {
|
|
26
|
+
/**
|
|
27
|
+
* Track an analytics event.
|
|
28
|
+
*
|
|
29
|
+
* Forwards the event to the configured sink URL. Best-effort delivery —
|
|
30
|
+
* failures are logged but do not throw. When no sink URL is configured,
|
|
31
|
+
* events are silently dropped (or logged in development).
|
|
32
|
+
*
|
|
33
|
+
* @param event - Event name (e.g. `'page_view'`, `'entity_created'`).
|
|
34
|
+
* @param properties - Optional key-value metadata for the event.
|
|
35
|
+
* @param ctx - Handler context with user identity.
|
|
36
|
+
*/
|
|
37
|
+
async track(event, properties, ctx) {
|
|
38
|
+
const payload = {
|
|
39
|
+
event,
|
|
40
|
+
properties: properties ?? {},
|
|
41
|
+
userId: ctx.user.id,
|
|
42
|
+
emailHash: ctx.user.emailHash,
|
|
43
|
+
workspaceId: ctx.workspaceId,
|
|
44
|
+
timestamp: new Date().toISOString(),
|
|
45
|
+
};
|
|
46
|
+
if (!sinkUrl) {
|
|
47
|
+
// No sink configured — log in dev, silent in prod
|
|
48
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
49
|
+
console.log(`[pulse] ${event}`, properties ?? '');
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Fire and forget — don't await in the request path
|
|
54
|
+
const headers = {
|
|
55
|
+
'Content-Type': 'application/json',
|
|
56
|
+
};
|
|
57
|
+
if (sinkToken) {
|
|
58
|
+
headers['Authorization'] = `Bearer ${sinkToken}`;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const controller = new AbortController();
|
|
62
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
63
|
+
await fetch(sinkUrl, {
|
|
64
|
+
method: 'POST',
|
|
65
|
+
headers,
|
|
66
|
+
body: JSON.stringify(payload),
|
|
67
|
+
signal: controller.signal,
|
|
68
|
+
});
|
|
69
|
+
clearTimeout(timeout);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
// Best-effort — log and continue
|
|
73
|
+
console.warn(`[pulse] Failed to forward event "${event}":`, err.message);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=pulse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulse.js","sourceRoot":"","sources":["../../../src/server/handlers/pulse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA8BH,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA6B;IAC9D,MAA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O,CAAC;oBAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;iBAC1B,CAAC,CAAA;gBAEF,YAAY,CAAC,OAAO,CAAC,CAAA;YACvB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,iCAAiC;gBACjC,OAAO,CAAC,IAAI,CAAC,oCAAoC,KAAK,IAAI,EAAG,GAAa,CAAC,OAAO,CAAC,CAAA;YACrF,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module server/handlers/realtime
|
|
3
|
+
* @description Realtime namespace handler — topic-based pub/sub messaging,
|
|
4
|
+
* broadcast, and presence tracking.
|
|
5
|
+
*
|
|
6
|
+
* Backed by the Hall server (hall.soulcraft.com). The handler delegates all
|
|
7
|
+
* operations to an injected `RealtimeBackend` interface. When no backend is
|
|
8
|
+
* configured, all methods throw with a clear "not configured" error.
|
|
9
|
+
*
|
|
10
|
+
* Hall is working on their realtime pipeline implementation. This handler is
|
|
11
|
+
* the SDK-side contract — once Hall publishes their backend, products wire
|
|
12
|
+
* it in via `providers.realtime`.
|
|
13
|
+
*
|
|
14
|
+
* Methods:
|
|
15
|
+
* - `subscribe` — Subscribe to a topic and receive messages
|
|
16
|
+
* - `broadcast` — Send a message to all topic subscribers
|
|
17
|
+
* - `presence` — Get peers currently subscribed to a topic
|
|
18
|
+
*/
|
|
19
|
+
import type { NamespaceProvider } from '../namespace-router.js';
|
|
20
|
+
/**
|
|
21
|
+
* Realtime backend interface — implemented by Hall.
|
|
22
|
+
*
|
|
23
|
+
* Products inject their Hall realtime client via `providers.realtime` in
|
|
24
|
+
* the SDK server config.
|
|
25
|
+
*/
|
|
26
|
+
export interface RealtimeBackend {
|
|
27
|
+
/** Subscribe to a topic. Returns a subscription handle. */
|
|
28
|
+
subscribe(topic: string, handler: (data: unknown) => void, userId: string): Promise<{
|
|
29
|
+
id: string;
|
|
30
|
+
unsubscribe: () => void;
|
|
31
|
+
}>;
|
|
32
|
+
/** Broadcast a message to all subscribers of a topic. */
|
|
33
|
+
broadcast(topic: string, data: unknown, senderId: string): Promise<void>;
|
|
34
|
+
/** Get the list of peers currently subscribed to a topic. */
|
|
35
|
+
presence(topic: string): Promise<Array<{
|
|
36
|
+
userId: string;
|
|
37
|
+
name: string;
|
|
38
|
+
joinedAt: string;
|
|
39
|
+
}>>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for {@link createRealtimeHandler}.
|
|
43
|
+
*/
|
|
44
|
+
export interface RealtimeHandlerOptions {
|
|
45
|
+
/** Hall realtime backend. */
|
|
46
|
+
backend: RealtimeBackend;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates the `realtime` namespace handler.
|
|
50
|
+
*
|
|
51
|
+
* @param options - Realtime handler dependencies. If omitted, all methods throw.
|
|
52
|
+
* @returns A {@link NamespaceProvider} implementing {@link RealtimeNamespace}.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createRealtimeHandler(options?: RealtimeHandlerOptions): NamespaceProvider;
|
|
55
|
+
//# sourceMappingURL=realtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/realtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,wBAAwB,CAAA;AAM/E;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,SAAS,CACP,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAChC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAA;IAEnD,yDAAyD;IACzD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExE,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QACrC,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAC,CAAC,CAAA;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6BAA6B;IAC7B,OAAO,EAAE,eAAe,CAAA;CACzB;AAMD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,iBAAiB,CAkCzF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module server/handlers/realtime
|
|
3
|
+
* @description Realtime namespace handler — topic-based pub/sub messaging,
|
|
4
|
+
* broadcast, and presence tracking.
|
|
5
|
+
*
|
|
6
|
+
* Backed by the Hall server (hall.soulcraft.com). The handler delegates all
|
|
7
|
+
* operations to an injected `RealtimeBackend` interface. When no backend is
|
|
8
|
+
* configured, all methods throw with a clear "not configured" error.
|
|
9
|
+
*
|
|
10
|
+
* Hall is working on their realtime pipeline implementation. This handler is
|
|
11
|
+
* the SDK-side contract — once Hall publishes their backend, products wire
|
|
12
|
+
* it in via `providers.realtime`.
|
|
13
|
+
*
|
|
14
|
+
* Methods:
|
|
15
|
+
* - `subscribe` — Subscribe to a topic and receive messages
|
|
16
|
+
* - `broadcast` — Send a message to all topic subscribers
|
|
17
|
+
* - `presence` — Get peers currently subscribed to a topic
|
|
18
|
+
*/
|
|
19
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
20
|
+
// Handler factory
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
22
|
+
/**
|
|
23
|
+
* Creates the `realtime` namespace handler.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Realtime handler dependencies. If omitted, all methods throw.
|
|
26
|
+
* @returns A {@link NamespaceProvider} implementing {@link RealtimeNamespace}.
|
|
27
|
+
*/
|
|
28
|
+
export function createRealtimeHandler(options) {
|
|
29
|
+
const backend = options?.backend;
|
|
30
|
+
function requireBackend() {
|
|
31
|
+
if (!backend) {
|
|
32
|
+
throw new Error('realtime namespace is not configured — provide a RealtimeBackend via providers.realtime. ' +
|
|
33
|
+
'The realtime pipeline is implemented by the Hall server.');
|
|
34
|
+
}
|
|
35
|
+
return backend;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
async subscribe(topic, handler, ctx) {
|
|
39
|
+
return requireBackend().subscribe(topic, handler, ctx.user.id);
|
|
40
|
+
},
|
|
41
|
+
async broadcast(topic, data, ctx) {
|
|
42
|
+
return requireBackend().broadcast(topic, data, ctx.user.id);
|
|
43
|
+
},
|
|
44
|
+
async presence(topic) {
|
|
45
|
+
return requireBackend().presence(topic);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=realtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.js","sourceRoot":"","sources":["../../../src/server/handlers/realtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAyCH,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgC;IACpE,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,CAAA;IAEhC,SAAS,cAAc;QACrB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,2FAA2F;gBAC3F,0DAA0D,CAC3D,CAAA;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,SAAS,CACb,KAAa,EACb,OAAgC,EAChC,GAAmB;YAEnB,OAAO,cAAc,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAChE,CAAC;QAED,KAAK,CAAC,SAAS,CACb,KAAa,EACb,IAAa,EACb,GAAmB;YAEnB,OAAO,cAAc,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC7D,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,KAAa;YAC1B,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACzC,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module server/handlers/search
|
|
3
|
+
* @description Search namespace handler — semantic vector search, unified search with
|
|
4
|
+
* rich results, and file content highlighting.
|
|
5
|
+
*
|
|
6
|
+
* Absorbs Workshop `routes/search.ts`. Uses Brainy's `brain.find()` for semantic
|
|
7
|
+
* vector search and `brain.highlight()` for in-file content matching.
|
|
8
|
+
*
|
|
9
|
+
* Methods:
|
|
10
|
+
* - `query` — Simple semantic search returning entity matches
|
|
11
|
+
* - `unified` — Rich search with type grouping, scope filtering, and context
|
|
12
|
+
* - `highlight` — Find text + semantic matches within a specific file
|
|
13
|
+
*/
|
|
14
|
+
import type { NamespaceProvider } from '../namespace-router.js';
|
|
15
|
+
/**
|
|
16
|
+
* Creates the `search` namespace handler.
|
|
17
|
+
*
|
|
18
|
+
* @returns A {@link NamespaceProvider} implementing {@link SearchNamespace}.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createSearchHandler(): NamespaceProvider;
|
|
21
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,wBAAwB,CAAA;AAsB/E;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,iBAAiB,CAsPvD"}
|