@aphexcms/cms-core 11.1.1 → 11.2.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/dist/api/docs-ui.d.ts +22 -0
- package/dist/api/docs-ui.d.ts.map +1 -0
- package/dist/api/docs-ui.js +19 -0
- package/dist/api/schemas/assets.d.ts +11 -0
- package/dist/api/schemas/assets.d.ts.map +1 -1
- package/dist/api/schemas/assets.js +24 -0
- package/dist/auth/auth-hooks.d.ts.map +1 -1
- package/dist/auth/auth-hooks.js +4 -1
- package/dist/local-api/collection-api.d.ts.map +1 -1
- package/dist/local-api/collection-api.js +23 -6
- package/dist/server/api/index.d.ts.map +1 -1
- package/dist/server/api/index.js +7 -0
- package/dist/server/api/openapi/generate.d.ts +13 -0
- package/dist/server/api/openapi/generate.d.ts.map +1 -0
- package/dist/server/api/openapi/generate.js +529 -0
- package/dist/server/api/openapi/json-schema.d.ts +45 -0
- package/dist/server/api/openapi/json-schema.d.ts.map +1 -0
- package/dist/server/api/openapi/json-schema.js +206 -0
- package/dist/server/api/openapi/registry.d.ts +78 -0
- package/dist/server/api/openapi/registry.d.ts.map +1 -0
- package/dist/server/api/openapi/registry.js +628 -0
- package/dist/server/api/routes/agent-change-sets.d.ts +6 -0
- package/dist/server/api/routes/agent-change-sets.d.ts.map +1 -1
- package/dist/server/api/routes/agent-change-sets.js +2 -1
- package/dist/server/api/routes/jobs.d.ts +32 -0
- package/dist/server/api/routes/jobs.d.ts.map +1 -1
- package/dist/server/api/routes/jobs.js +7 -3
- package/dist/server/api/routes/openapi.d.ts +34 -0
- package/dist/server/api/routes/openapi.d.ts.map +1 -0
- package/dist/server/api/routes/openapi.js +97 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/types/config.d.ts +15 -0
- package/dist/types/config.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this instance serves the rendered API reference at `GET /api/docs`.
|
|
3
|
+
*
|
|
4
|
+
* Its own tiny module, no imports, for the same reason as `limits.ts`: the
|
|
5
|
+
* route that mounts the page and the admin UI that links to it have to agree,
|
|
6
|
+
* and two copies of `!== false` agree right up until someone changes one of
|
|
7
|
+
* them. A link to a 404 is worse than no link.
|
|
8
|
+
*
|
|
9
|
+
* On by default. The page is authenticated, so anyone who can load it could
|
|
10
|
+
* already read `/api/openapi.json` — this instance's whole content model — and
|
|
11
|
+
* the page shows them nothing further. The one thing it does that the JSON
|
|
12
|
+
* endpoint doesn't is load Scalar from a public CDN, so `docsUi: false` is the
|
|
13
|
+
* switch for a deployment that shouldn't pull third-party scripts.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isApiDocsEnabled(config: {
|
|
16
|
+
openapi?: {
|
|
17
|
+
docsUi?: boolean;
|
|
18
|
+
};
|
|
19
|
+
} | null | undefined): boolean;
|
|
20
|
+
/** Where that reference lives, for anything that wants to link to it. */
|
|
21
|
+
export declare const API_DOCS_PATH = "/api/docs";
|
|
22
|
+
//# sourceMappingURL=docs-ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-ui.d.ts","sourceRoot":"","sources":["../../src/lib/api/docs-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,WAE7F;AAED,yEAAyE;AACzE,eAAO,MAAM,aAAa,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this instance serves the rendered API reference at `GET /api/docs`.
|
|
3
|
+
*
|
|
4
|
+
* Its own tiny module, no imports, for the same reason as `limits.ts`: the
|
|
5
|
+
* route that mounts the page and the admin UI that links to it have to agree,
|
|
6
|
+
* and two copies of `!== false` agree right up until someone changes one of
|
|
7
|
+
* them. A link to a 404 is worse than no link.
|
|
8
|
+
*
|
|
9
|
+
* On by default. The page is authenticated, so anyone who can load it could
|
|
10
|
+
* already read `/api/openapi.json` — this instance's whole content model — and
|
|
11
|
+
* the page shows them nothing further. The one thing it does that the JSON
|
|
12
|
+
* endpoint doesn't is load Scalar from a public CDN, so `docsUi: false` is the
|
|
13
|
+
* switch for a deployment that shouldn't pull third-party scripts.
|
|
14
|
+
*/
|
|
15
|
+
export function isApiDocsEnabled(config) {
|
|
16
|
+
return config?.openapi?.docsUi !== false;
|
|
17
|
+
}
|
|
18
|
+
/** Where that reference lives, for anything that wants to link to it. */
|
|
19
|
+
export const API_DOCS_PATH = '/api/docs';
|
|
@@ -91,6 +91,17 @@ export declare const listAssetsResponse: z.ZodObject<{
|
|
|
91
91
|
hasNextPage: z.ZodBoolean;
|
|
92
92
|
hasPrevPage: z.ZodBoolean;
|
|
93
93
|
}, z.core.$strip>;
|
|
94
|
+
indexing: z.ZodBoolean;
|
|
95
|
+
limits: z.ZodObject<{
|
|
96
|
+
maxUploadBytes: z.ZodNumber;
|
|
97
|
+
allowedMimeTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
98
|
+
directUpload: z.ZodBoolean;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
images: z.ZodNullable<z.ZodObject<{
|
|
101
|
+
widths: z.ZodArray<z.ZodNumber>;
|
|
102
|
+
quality: z.ZodNumber;
|
|
103
|
+
configHash: z.ZodString;
|
|
104
|
+
}, z.core.$strip>>;
|
|
94
105
|
}, z.core.$strip>;
|
|
95
106
|
export declare const getAssetResponse: z.ZodObject<{
|
|
96
107
|
success: z.ZodLiteral<true>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/lib/api/schemas/assets.ts"],"names":[],"mappings":"AAAA,OAAO,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F,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEpF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AACtF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAExF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC5E,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -81,7 +81,31 @@ export const listAssetsResponse = z.object({
|
|
|
81
81
|
totalPages: z.number(),
|
|
82
82
|
hasNextPage: z.boolean(),
|
|
83
83
|
hasPrevPage: z.boolean()
|
|
84
|
+
}),
|
|
85
|
+
/**
|
|
86
|
+
* True when a `usage` filter was requested before the asset-reference index
|
|
87
|
+
* exists, so the admin can say "indexing" rather than present an empty or
|
|
88
|
+
* wholly-unused library as fact.
|
|
89
|
+
*/
|
|
90
|
+
indexing: z.boolean(),
|
|
91
|
+
/**
|
|
92
|
+
* Server-side upload limits, reported so a client can refuse an oversized file
|
|
93
|
+
* before sending it instead of hardcoding a number that drifts.
|
|
94
|
+
*/
|
|
95
|
+
limits: z.object({
|
|
96
|
+
maxUploadBytes: z.number(),
|
|
97
|
+
allowedMimeTypes: z.array(z.string()).nullable().optional(),
|
|
98
|
+
/** Whether `/assets/upload-url` will work — depends on adapter and config. */
|
|
99
|
+
directUpload: z.boolean()
|
|
100
|
+
}),
|
|
101
|
+
/** Responsive-variant config, or null when image processing is off. */
|
|
102
|
+
images: z
|
|
103
|
+
.object({
|
|
104
|
+
widths: z.array(z.number()),
|
|
105
|
+
quality: z.number(),
|
|
106
|
+
configHash: z.string()
|
|
84
107
|
})
|
|
108
|
+
.nullable()
|
|
85
109
|
});
|
|
86
110
|
// ---------- GET /assets/[id] ----------
|
|
87
111
|
export const getAssetResponse = z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-hooks.d.ts","sourceRoot":"","sources":["../../src/lib/auth/auth-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAQ,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAsB,cAAc,CACnC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,eAAe,EACnB,YAAY,EAAE,YAAY,GACxB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"auth-hooks.d.ts","sourceRoot":"","sources":["../../src/lib/auth/auth-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAQ,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAsB,cAAc,CACnC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,eAAe,EACnB,YAAY,EAAE,YAAY,GACxB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA8J1B"}
|
package/dist/auth/auth-hooks.js
CHANGED
|
@@ -84,7 +84,10 @@ export async function handleAuthHook(event, config, authProvider, db, rolesServi
|
|
|
84
84
|
'/api/invitations',
|
|
85
85
|
'/api/roles',
|
|
86
86
|
'/api/settings',
|
|
87
|
-
'/api/instance-settings'
|
|
87
|
+
'/api/instance-settings',
|
|
88
|
+
// The generated spec enumerates this deployment's whole content model.
|
|
89
|
+
// No content, but not for anonymous callers either.
|
|
90
|
+
'/api/openapi.json'
|
|
88
91
|
];
|
|
89
92
|
if (graphqlEndpoint) {
|
|
90
93
|
protectedApiRoutes.push(graphqlEndpoint);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-api.d.ts","sourceRoot":"","sources":["../../src/lib/local-api/collection-api.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAS7D;;GAEG;AACH,MAA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B,CAAC,EAAE,MAAM,CAAA;KAAE,GACrC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IA8BpB;;;;OAIG;YACW,mBAAmB;IAajC;;;;;;;;OAQG;YACW,2BAA2B;IAazC;;;;;;;;;;OAUG;IACG,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;IAgBtF,kHAAkH;IAC5G,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;IAgBxF,kHAAkH;IAC5G,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAKxE,2GAA2G;IACrG,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAU5E"}
|
|
@@ -280,9 +280,23 @@ export class CollectionAPI {
|
|
|
280
280
|
// roles see different projections even when the underlying cache hit
|
|
281
281
|
// is shared. Cached payloads are stored unfiltered for this reason.
|
|
282
282
|
const hidden = this.resolveHiddenReadFields(context);
|
|
283
|
+
// The resolved perspective has to travel *in the options*, not just be used
|
|
284
|
+
// for `transformDocument` below. The adapter reads `options.perspective`
|
|
285
|
+
// (defaulting to 'draft') to pick which JSONB column `where`/`sort` compile
|
|
286
|
+
// against and — for 'published' — to exclude never-published rows. A
|
|
287
|
+
// perspective that only came from the context would otherwise be dropped
|
|
288
|
+
// on the way to the adapter: the query would run against every document
|
|
289
|
+
// and its draft data, then `transformDocument` would read the published
|
|
290
|
+
// side, so a draft-only document came back as an empty shell.
|
|
291
|
+
//
|
|
292
|
+
// The cache is keyed on the same resolved options — before the hierarchy
|
|
293
|
+
// org ids are added below, so the get and set keys agree — because the
|
|
294
|
+
// perspective changes the result set, not just its projection.
|
|
295
|
+
const queryKey = { ...options, perspective };
|
|
296
|
+
const findOptions = { ...queryKey };
|
|
283
297
|
// Check cache for published queries
|
|
284
298
|
if (perspective === 'published' && this.documentCache) {
|
|
285
|
-
const cached = await this.documentCache.getQuery(context.organizationId, this.collectionName,
|
|
299
|
+
const cached = await this.documentCache.getQuery(context.organizationId, this.collectionName, queryKey);
|
|
286
300
|
// Both projections, in the same order as the uncached return below. A
|
|
287
301
|
// cache hit must not be a weaker projection than a miss: `public` strips
|
|
288
302
|
// `_meta` fields that identify the tenant and its users, so applying it
|
|
@@ -295,7 +309,6 @@ export class CollectionAPI {
|
|
|
295
309
|
}
|
|
296
310
|
// Resolve org IDs via hierarchy service (cached) and pass directly —
|
|
297
311
|
// this avoids the adapter opening a transaction just to set RLS context
|
|
298
|
-
const findOptions = { ...options };
|
|
299
312
|
if (this.hierarchyService && !findOptions.filterOrganizationIds) {
|
|
300
313
|
const orgIds = await this.hierarchyService.getOrgIdsWithChildren(context.organizationId);
|
|
301
314
|
findOptions.filterOrganizationIds = orgIds;
|
|
@@ -310,7 +323,7 @@ export class CollectionAPI {
|
|
|
310
323
|
};
|
|
311
324
|
// Populate cache for published queries (unfiltered payload)
|
|
312
325
|
if (perspective === 'published' && this.documentCache) {
|
|
313
|
-
await this.documentCache.setQuery(context.organizationId, this.collectionName,
|
|
326
|
+
await this.documentCache.setQuery(context.organizationId, this.collectionName, queryKey, unfilteredResult);
|
|
314
327
|
}
|
|
315
328
|
return applyPublicMetaToResult(applyHiddenToResult(unfilteredResult, hidden), options.public);
|
|
316
329
|
}
|
|
@@ -385,14 +398,18 @@ export class CollectionAPI {
|
|
|
385
398
|
if (cached)
|
|
386
399
|
return applyPublicMetaToDoc(applyHiddenToDoc(cached, hidden), options?.public);
|
|
387
400
|
}
|
|
388
|
-
// Resolve org IDs via hierarchy service (cached) — avoids RLS transaction
|
|
389
|
-
|
|
401
|
+
// Resolve org IDs via hierarchy service (cached) — avoids RLS transaction.
|
|
402
|
+
// Same as `find`: the resolved perspective must reach the adapter.
|
|
403
|
+
const findOptions = { ...options, perspective };
|
|
390
404
|
if (this.hierarchyService && !findOptions.filterOrganizationIds) {
|
|
391
405
|
const orgIds = await this.hierarchyService.getOrgIdsWithChildren(context.organizationId);
|
|
392
406
|
findOptions.filterOrganizationIds = orgIds;
|
|
393
407
|
}
|
|
394
408
|
const result = await this.findOwnDocById(context.organizationId, id, findOptions);
|
|
395
|
-
|
|
409
|
+
// A by-id read is the one path the adapter doesn't gate on status, so a
|
|
410
|
+
// never-published (or unpublished) document would come back as a shell:
|
|
411
|
+
// `id` and `_meta`, no fields. Match `find`, which excludes such rows.
|
|
412
|
+
if (!result || (perspective === 'published' && result.status !== 'published')) {
|
|
396
413
|
return null;
|
|
397
414
|
}
|
|
398
415
|
// Cache the unfiltered projection; apply hidden fields per-caller.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/server/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/server/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AA8B7C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,SAAS,EAAE;QACV,QAAQ,EAAE,YAAY,CAAC;QACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;KAClB,CAAC;IACF,QAAQ,EAAE;QACT,QAAQ,EAAE,YAAY,CAAC;QACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAClB,wEAAwE;QACxE,aAAa,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACF,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,cAAc,kGAqC7B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,QA0GrD;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AA0C1D;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,IACtE,GAAG,OAAO,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,uBAejD"}
|
package/dist/server/api/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import { workersRunRouter } from './routes/workers-run.js';
|
|
|
26
26
|
import { jobsRouter } from './routes/jobs.js';
|
|
27
27
|
import { agentChatRouter } from './routes/agent-chat.js';
|
|
28
28
|
import { agentChangeSetsRouter } from './routes/agent-change-sets.js';
|
|
29
|
+
import { openapiRouter, openapiDocsRouter } from './routes/openapi.js';
|
|
29
30
|
/**
|
|
30
31
|
* Build the Aphex API Hono app shell.
|
|
31
32
|
*
|
|
@@ -118,6 +119,12 @@ export function mountAphexBuiltins(app) {
|
|
|
118
119
|
app.route('/internal/workers', workersRunRouter);
|
|
119
120
|
// Read-only job/event history (observability). → GET /api/jobs, GET /api/events
|
|
120
121
|
app.route('/', jobsRouter);
|
|
122
|
+
// Machine-readable description of everything mounted above, generated from the
|
|
123
|
+
// zod contracts and this instance's schema types. → GET /api/openapi.json
|
|
124
|
+
app.route('/openapi.json', openapiRouter);
|
|
125
|
+
// Rendered reference over that document. Static shell; it fetches the spec
|
|
126
|
+
// client-side, so it needs no auth of its own. → GET /api/docs
|
|
127
|
+
app.route('/docs', openapiDocsRouter);
|
|
121
128
|
// In-admin agent streaming chat — 404s unless `aiProvider` is configured.
|
|
122
129
|
// → POST /api/agent/chat
|
|
123
130
|
app.route('/agent', agentChatRouter);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SchemaType } from '../../../types/schemas.js';
|
|
2
|
+
import { type JsonSchema } from './json-schema.js';
|
|
3
|
+
export interface OpenApiOptions {
|
|
4
|
+
/** Document types drive the per-collection request bodies. */
|
|
5
|
+
schemaTypes?: SchemaType[];
|
|
6
|
+
/** Server URL to advertise, e.g. `https://cms.example.com`. */
|
|
7
|
+
serverUrl?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Build the full OpenAPI document. */
|
|
12
|
+
export declare function generateOpenApiDocument(options?: OpenApiOptions): JsonSchema;
|
|
13
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/openapi/generate.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,EAIN,KAAK,UAAU,EACf,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,cAAc;IAC9B,8DAA8D;IAC9D,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAmeD,uCAAuC;AACvC,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,cAAmB,GAAG,UAAU,CAyEhF"}
|