@aphexcms/cms-core 9.8.1 → 9.10.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/api/organizations.d.ts +2 -1
- package/dist/api/organizations.d.ts.map +1 -1
- package/dist/api/organizations.js +2 -1
- package/dist/api/schemas/documents.d.ts +1 -0
- package/dist/api/schemas/documents.d.ts.map +1 -1
- package/dist/api/schemas/documents.js +1 -0
- package/dist/api/schemas/jobs.d.ts +15 -0
- package/dist/api/schemas/jobs.d.ts.map +1 -0
- package/dist/api/schemas/jobs.js +17 -0
- package/dist/api/schemas/user.d.ts.map +1 -1
- package/dist/api/schemas/user.js +6 -2
- package/dist/auth/account-deletion.d.ts +35 -0
- package/dist/auth/account-deletion.d.ts.map +1 -0
- package/dist/auth/account-deletion.js +65 -0
- package/dist/auth/bootstrap.d.ts +104 -0
- package/dist/auth/bootstrap.d.ts.map +1 -0
- package/dist/auth/bootstrap.js +164 -0
- package/dist/auth/instance-state.d.ts +13 -0
- package/dist/auth/instance-state.d.ts.map +1 -0
- package/dist/auth/instance-state.js +30 -0
- package/dist/auth/invitation-status.d.ts +25 -0
- package/dist/auth/invitation-status.d.ts.map +1 -0
- package/dist/auth/invitation-status.js +41 -0
- package/dist/auth/sign-up-policy.d.ts +62 -0
- package/dist/auth/sign-up-policy.d.ts.map +1 -0
- package/dist/auth/sign-up-policy.js +120 -0
- package/dist/components/AdminApp.svelte +83 -6
- package/dist/components/AdminApp.svelte.d.ts.map +1 -1
- package/dist/components/admin/ActivityView.svelte +263 -13
- package/dist/components/admin/ActivityView.svelte.d.ts +10 -1
- package/dist/components/admin/ActivityView.svelte.d.ts.map +1 -1
- package/dist/db/interfaces/document.d.ts +9 -0
- package/dist/db/interfaces/document.d.ts.map +1 -1
- package/dist/db/interfaces/events.d.ts +29 -2
- package/dist/db/interfaces/events.d.ts.map +1 -1
- package/dist/db/interfaces/index.d.ts +1 -0
- package/dist/db/interfaces/index.d.ts.map +1 -1
- package/dist/db/interfaces/index.js +1 -0
- package/dist/db/interfaces/instance.d.ts +29 -0
- package/dist/db/interfaces/instance.d.ts.map +1 -1
- package/dist/db/interfaces/instance.js +8 -1
- package/dist/events/built-in-consumers.d.ts +20 -0
- package/dist/events/built-in-consumers.d.ts.map +1 -0
- package/dist/events/built-in-consumers.js +49 -0
- package/dist/events/catalog.d.ts +16 -0
- package/dist/events/catalog.d.ts.map +1 -1
- package/dist/events/catalog.js +17 -0
- package/dist/events/consumer.d.ts +14 -0
- package/dist/events/consumer.d.ts.map +1 -1
- package/dist/events/consumer.js +1 -0
- package/dist/events/emit.d.ts +23 -0
- package/dist/events/emit.d.ts.map +1 -1
- package/dist/events/emit.js +32 -1
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -0
- package/dist/field-validation/utils.d.ts +27 -4
- package/dist/field-validation/utils.d.ts.map +1 -1
- package/dist/field-validation/utils.js +78 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/jobs/run-batch.d.ts +7 -1
- package/dist/jobs/run-batch.d.ts.map +1 -1
- package/dist/jobs/run-batch.js +3 -1
- package/dist/lib/api/organizations.d.ts +2 -1
- package/dist/lib/api/organizations.d.ts.map +1 -1
- package/dist/lib/api/organizations.js +2 -1
- package/dist/lib/api/organizations.js.map +1 -1
- package/dist/lib/api/schemas/api-keys.d.ts +4 -4
- package/dist/lib/api/schemas/documents.d.ts +1 -0
- package/dist/lib/api/schemas/documents.d.ts.map +1 -1
- package/dist/lib/api/schemas/documents.js +1 -0
- package/dist/lib/api/schemas/documents.js.map +1 -1
- package/dist/lib/api/schemas/jobs.d.ts +15 -0
- package/dist/lib/api/schemas/jobs.d.ts.map +1 -0
- package/dist/lib/api/schemas/jobs.js +18 -0
- package/dist/lib/api/schemas/jobs.js.map +1 -0
- package/dist/lib/api/schemas/user.d.ts.map +1 -1
- package/dist/lib/api/schemas/user.js +6 -2
- package/dist/lib/api/schemas/user.js.map +1 -1
- package/dist/lib/auth/account-deletion.d.ts +35 -0
- package/dist/lib/auth/account-deletion.d.ts.map +1 -0
- package/dist/lib/auth/account-deletion.js +66 -0
- package/dist/lib/auth/account-deletion.js.map +1 -0
- package/dist/lib/auth/bootstrap.d.ts +104 -0
- package/dist/lib/auth/bootstrap.d.ts.map +1 -0
- package/dist/lib/auth/bootstrap.js +165 -0
- package/dist/lib/auth/bootstrap.js.map +1 -0
- package/dist/lib/auth/instance-state.d.ts +13 -0
- package/dist/lib/auth/instance-state.d.ts.map +1 -0
- package/dist/lib/auth/instance-state.js +31 -0
- package/dist/lib/auth/instance-state.js.map +1 -0
- package/dist/lib/auth/invitation-status.d.ts +25 -0
- package/dist/lib/auth/invitation-status.d.ts.map +1 -0
- package/dist/lib/auth/invitation-status.js +42 -0
- package/dist/lib/auth/invitation-status.js.map +1 -0
- package/dist/lib/auth/sign-up-policy.d.ts +62 -0
- package/dist/lib/auth/sign-up-policy.d.ts.map +1 -0
- package/dist/lib/auth/sign-up-policy.js +121 -0
- package/dist/lib/auth/sign-up-policy.js.map +1 -0
- package/dist/lib/db/interfaces/document.d.ts +9 -0
- package/dist/lib/db/interfaces/document.d.ts.map +1 -1
- package/dist/lib/db/interfaces/events.d.ts +29 -2
- package/dist/lib/db/interfaces/events.d.ts.map +1 -1
- package/dist/lib/db/interfaces/index.d.ts +1 -0
- package/dist/lib/db/interfaces/index.d.ts.map +1 -1
- package/dist/lib/db/interfaces/index.js +1 -0
- package/dist/lib/db/interfaces/index.js.map +1 -1
- package/dist/lib/db/interfaces/instance.d.ts +29 -0
- package/dist/lib/db/interfaces/instance.d.ts.map +1 -1
- package/dist/lib/db/interfaces/instance.js +8 -1
- package/dist/lib/db/interfaces/instance.js.map +1 -1
- package/dist/lib/events/built-in-consumers.d.ts +20 -0
- package/dist/lib/events/built-in-consumers.d.ts.map +1 -0
- package/dist/lib/events/built-in-consumers.js +50 -0
- package/dist/lib/events/built-in-consumers.js.map +1 -0
- package/dist/lib/events/catalog.d.ts +16 -0
- package/dist/lib/events/catalog.d.ts.map +1 -1
- package/dist/lib/events/catalog.js +17 -0
- package/dist/lib/events/catalog.js.map +1 -1
- package/dist/lib/events/consumer.d.ts +14 -0
- package/dist/lib/events/consumer.d.ts.map +1 -1
- package/dist/lib/events/consumer.js +1 -0
- package/dist/lib/events/consumer.js.map +1 -1
- package/dist/lib/events/emit.d.ts +23 -0
- package/dist/lib/events/emit.d.ts.map +1 -1
- package/dist/lib/events/emit.js +32 -1
- package/dist/lib/events/emit.js.map +1 -1
- package/dist/lib/events/index.d.ts +2 -0
- package/dist/lib/events/index.d.ts.map +1 -1
- package/dist/lib/events/index.js +2 -0
- package/dist/lib/events/index.js.map +1 -1
- package/dist/lib/field-validation/utils.d.ts +27 -4
- package/dist/lib/field-validation/utils.d.ts.map +1 -1
- package/dist/lib/field-validation/utils.js +78 -10
- package/dist/lib/field-validation/utils.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/jobs/run-batch.d.ts +7 -1
- package/dist/lib/jobs/run-batch.d.ts.map +1 -1
- package/dist/lib/jobs/run-batch.js +3 -1
- package/dist/lib/jobs/run-batch.js.map +1 -1
- package/dist/lib/local-api/collection-api.d.ts +48 -1
- package/dist/lib/local-api/collection-api.d.ts.map +1 -1
- package/dist/lib/local-api/collection-api.js +110 -11
- package/dist/lib/local-api/collection-api.js.map +1 -1
- package/dist/lib/local-api/index.d.ts +1 -1
- package/dist/lib/local-api/index.d.ts.map +1 -1
- package/dist/lib/local-api/index.js +1 -1
- package/dist/lib/local-api/index.js.map +1 -1
- package/dist/lib/plugins/resolver.d.ts.map +1 -1
- package/dist/lib/plugins/resolver.js +7 -1
- package/dist/lib/plugins/resolver.js.map +1 -1
- package/dist/lib/schema-utils/utils.d.ts +31 -1
- package/dist/lib/schema-utils/utils.d.ts.map +1 -1
- package/dist/lib/schema-utils/utils.js +68 -0
- package/dist/lib/schema-utils/utils.js.map +1 -1
- package/dist/lib/server/api/rate-limit.d.ts +38 -0
- package/dist/lib/server/api/rate-limit.d.ts.map +1 -0
- package/dist/lib/server/api/rate-limit.js +71 -0
- package/dist/lib/server/api/rate-limit.js.map +1 -0
- package/dist/lib/server/api/routes/documents-by-id.d.ts.map +1 -1
- package/dist/lib/server/api/routes/documents-by-id.js +10 -1
- package/dist/lib/server/api/routes/documents-by-id.js.map +1 -1
- package/dist/lib/server/api/routes/documents-publish.d.ts.map +1 -1
- package/dist/lib/server/api/routes/documents-publish.js +10 -0
- package/dist/lib/server/api/routes/documents-publish.js.map +1 -1
- package/dist/lib/server/api/routes/documents.d.ts.map +1 -1
- package/dist/lib/server/api/routes/documents.js +11 -0
- package/dist/lib/server/api/routes/documents.js.map +1 -1
- package/dist/lib/server/api/routes/jobs.d.ts.map +1 -1
- package/dist/lib/server/api/routes/jobs.js +174 -20
- package/dist/lib/server/api/routes/jobs.js.map +1 -1
- package/dist/lib/server/api/routes/organizations-by-id.d.ts.map +1 -1
- package/dist/lib/server/api/routes/organizations-by-id.js +61 -3
- package/dist/lib/server/api/routes/organizations-by-id.js.map +1 -1
- package/dist/lib/server/api/routes/organizations-invitations.d.ts.map +1 -1
- package/dist/lib/server/api/routes/organizations-invitations.js +31 -2
- package/dist/lib/server/api/routes/organizations-invitations.js.map +1 -1
- package/dist/lib/server/api/routes/resolve-organization-names.d.ts +17 -0
- package/dist/lib/server/api/routes/resolve-organization-names.d.ts.map +1 -0
- package/dist/lib/server/api/routes/resolve-organization-names.js +26 -0
- package/dist/lib/server/api/routes/resolve-organization-names.js.map +1 -0
- package/dist/lib/server/api/routes/user.d.ts +0 -8
- package/dist/lib/server/api/routes/user.d.ts.map +1 -1
- package/dist/lib/server/api/routes/user.js +144 -0
- package/dist/lib/server/api/routes/user.js.map +1 -1
- package/dist/lib/server/index.d.ts +6 -1
- package/dist/lib/server/index.d.ts.map +1 -1
- package/dist/lib/server/index.js +9 -1
- package/dist/lib/server/index.js.map +1 -1
- package/dist/lib/type-gen.d.ts.map +1 -1
- package/dist/lib/type-gen.js +11 -5
- package/dist/lib/type-gen.js.map +1 -1
- package/dist/lib/types/capabilities.d.ts +14 -0
- package/dist/lib/types/capabilities.d.ts.map +1 -1
- package/dist/lib/types/capabilities.js +37 -18
- package/dist/lib/types/capabilities.js.map +1 -1
- package/dist/lib/types/events.d.ts +27 -4
- package/dist/lib/types/events.d.ts.map +1 -1
- package/dist/lib/types/filters.d.ts +31 -0
- package/dist/lib/types/filters.d.ts.map +1 -1
- package/dist/lib/types/schemas.d.ts +14 -0
- package/dist/lib/types/schemas.d.ts.map +1 -1
- package/dist/lib/utils/fetch-remote-file.d.ts.map +1 -1
- package/dist/lib/utils/fetch-remote-file.js +32 -3
- package/dist/lib/utils/fetch-remote-file.js.map +1 -1
- package/dist/local-api/collection-api.d.ts +48 -1
- package/dist/local-api/collection-api.d.ts.map +1 -1
- package/dist/local-api/collection-api.js +110 -11
- package/dist/local-api/index.d.ts +1 -1
- package/dist/local-api/index.d.ts.map +1 -1
- package/dist/local-api/index.js +1 -1
- package/dist/plugins/resolver.d.ts.map +1 -1
- package/dist/plugins/resolver.js +7 -1
- package/dist/schema-utils/utils.d.ts +31 -1
- package/dist/schema-utils/utils.d.ts.map +1 -1
- package/dist/schema-utils/utils.js +68 -0
- package/dist/server/api/rate-limit.d.ts +38 -0
- package/dist/server/api/rate-limit.d.ts.map +1 -0
- package/dist/server/api/rate-limit.js +70 -0
- package/dist/server/api/routes/documents-by-id.d.ts.map +1 -1
- package/dist/server/api/routes/documents-by-id.js +10 -1
- package/dist/server/api/routes/documents-publish.d.ts.map +1 -1
- package/dist/server/api/routes/documents-publish.js +10 -0
- package/dist/server/api/routes/documents.d.ts.map +1 -1
- package/dist/server/api/routes/documents.js +11 -0
- package/dist/server/api/routes/jobs.d.ts.map +1 -1
- package/dist/server/api/routes/jobs.js +174 -20
- package/dist/server/api/routes/organizations-by-id.d.ts.map +1 -1
- package/dist/server/api/routes/organizations-by-id.js +61 -3
- package/dist/server/api/routes/organizations-invitations.d.ts.map +1 -1
- package/dist/server/api/routes/organizations-invitations.js +31 -2
- package/dist/server/api/routes/resolve-organization-names.d.ts +17 -0
- package/dist/server/api/routes/resolve-organization-names.d.ts.map +1 -0
- package/dist/server/api/routes/resolve-organization-names.js +25 -0
- package/dist/server/api/routes/user.d.ts +0 -8
- package/dist/server/api/routes/user.d.ts.map +1 -1
- package/dist/server/api/routes/user.js +144 -0
- package/dist/server/index.d.ts +6 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +9 -1
- package/dist/type-gen.d.ts.map +1 -1
- package/dist/type-gen.js +11 -5
- package/dist/types/capabilities.d.ts +14 -0
- package/dist/types/capabilities.d.ts.map +1 -1
- package/dist/types/capabilities.js +37 -18
- package/dist/types/events.d.ts +27 -4
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/filters.d.ts +31 -0
- package/dist/types/filters.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +14 -0
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/utils/fetch-remote-file.d.ts.map +1 -1
- package/dist/utils/fetch-remote-file.js +32 -3
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-remote-file.js","sourceRoot":"","sources":["../../../src/lib/utils/fetch-remote-file.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,8FAA8F;AAC9F,6FAA6F;AAC7F,EAAE;AACF,gGAAgG;AAChG,8FAA8F;AAC9F,+FAA+F;AAC/F,0FAA0F;AAC1F,+FAA+F;AAC/F,8FAA8F;AAC9F,yFAAyF;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,GAAG,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch-remote-file.js","sourceRoot":"","sources":["../../../src/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AAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;IACxF,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -8,7 +8,7 @@ import type { Document } from '../types/document.js';
|
|
|
8
8
|
import type { LocalAPIContext } from './types.js';
|
|
9
9
|
import type { SchemaType } from '../types/schemas.js';
|
|
10
10
|
import { PermissionChecker } from './permissions.js';
|
|
11
|
-
import { type DocumentValidationResult } from '../field-validation/utils.js';
|
|
11
|
+
import { type DocumentValidationResult, type FieldErrors } from '../field-validation/utils.js';
|
|
12
12
|
import type { Job } from '../types/events.js';
|
|
13
13
|
/**
|
|
14
14
|
* Result from create/update operations that includes validation
|
|
@@ -25,6 +25,22 @@ export interface DocumentResult<T> {
|
|
|
25
25
|
export declare class SingletonOperationError extends Error {
|
|
26
26
|
constructor(message: string);
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Thrown when a write is rejected as *malformed* — a field the schema never
|
|
30
|
+
* declared, or a value of the wrong shape. The caller sent bad data, so this is
|
|
31
|
+
* a 400, not a 500.
|
|
32
|
+
*
|
|
33
|
+
* It exists as a type because the alternative was route handlers sniffing
|
|
34
|
+
* `error.message.includes('validation errors')`, which the structural message
|
|
35
|
+
* ("Invalid document data - …") doesn't match — so every rejected payload was
|
|
36
|
+
* reported to HTTP and MCP clients as a server error. Carries the structured
|
|
37
|
+
* `errors` so a handler (or an agent) can name the offending fields without
|
|
38
|
+
* parsing prose.
|
|
39
|
+
*/
|
|
40
|
+
export declare class DocumentValidationError extends Error {
|
|
41
|
+
readonly errors: FieldErrors[];
|
|
42
|
+
constructor(message: string, errors: FieldErrors[]);
|
|
43
|
+
}
|
|
28
44
|
/**
|
|
29
45
|
* Subset of CollectionAPI methods that are valid on a singleton schema.
|
|
30
46
|
* Codegen emits this type for singleton entries in the Collections interface
|
|
@@ -54,6 +70,12 @@ export declare class CollectionAPI<T = Document> {
|
|
|
54
70
|
* never thrown — a stale ref index doesn't block the user's save.
|
|
55
71
|
*/
|
|
56
72
|
private syncReferences;
|
|
73
|
+
/**
|
|
74
|
+
* Recompute the document's full-text search index from freshly-saved
|
|
75
|
+
* draftData. Best-effort, same shape as {@link syncReferences}: not part
|
|
76
|
+
* of the write transaction, self-healing on the next edit if missed.
|
|
77
|
+
*/
|
|
78
|
+
private syncSearchText;
|
|
57
79
|
/**
|
|
58
80
|
* Get the schema for this collection
|
|
59
81
|
*/
|
|
@@ -92,6 +114,31 @@ export declare class CollectionAPI<T = Document> {
|
|
|
92
114
|
find(context: LocalAPIContext, options?: FindOptions<T>): Promise<FindResult<T>>;
|
|
93
115
|
private resolveHiddenReadFields;
|
|
94
116
|
private resolveHiddenWriteFields;
|
|
117
|
+
/**
|
|
118
|
+
* Fetch a document by ID, scoped to this collection.
|
|
119
|
+
*
|
|
120
|
+
* Every permission check here is evaluated against `this.collectionName`, but
|
|
121
|
+
* document IDs are globally unique — so a lookup that matched on ID alone let a
|
|
122
|
+
* caller authorised for one collection read or mutate a known ID belonging to a
|
|
123
|
+
* restricted one, through the Local API, GraphQL, or MCP alike.
|
|
124
|
+
*
|
|
125
|
+
* A type mismatch is reported as "not found" rather than "forbidden" on purpose:
|
|
126
|
+
* the caller has no permission to learn that the ID exists elsewhere.
|
|
127
|
+
*
|
|
128
|
+
* Deliberately *not* used for reference lookups in `publish`, which resolve
|
|
129
|
+
* documents of arbitrary types by design.
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* Reject a write whose payload is malformed, draft or not.
|
|
133
|
+
*
|
|
134
|
+
* Drafts skip *content* validation on purpose — you must be able to save
|
|
135
|
+
* half-finished work. But "incomplete" and "malformed" are different
|
|
136
|
+
* questions: a missing title is a draft, a string where an array belongs (or a
|
|
137
|
+
* field the schema never declared) is corruption, and letting it through means
|
|
138
|
+
* it's already in storage by the time anyone validates at publish.
|
|
139
|
+
*/
|
|
140
|
+
private assertStructurallyValid;
|
|
141
|
+
private findOwnDocById;
|
|
95
142
|
/**
|
|
96
143
|
* Find a single document by ID
|
|
97
144
|
*
|
|
@@ -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;AACxE,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;
|
|
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,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,GAAG,IAAI,CAAC;IAuEpB;;;;;;;;;;OAUG;IACG,SAAS,CACd,OAAO,EAAE,eAAe,EACxB,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE;QAAE,gBAAgB,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"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Collection API - provides type-safe CRUD operations for a single collection
|
|
4
4
|
import { singletonId } from '../schema-utils/singleton.js';
|
|
5
|
+
import { resolveSearchPaths, buildSearchText } from '../schema-utils/utils.js';
|
|
5
6
|
import { validateDocumentData } from '../field-validation/utils.js';
|
|
6
7
|
import { runDocumentHooks } from './hooks.js';
|
|
7
8
|
import { collectReferenceIds } from '../utils/reference-walk.js';
|
|
@@ -32,6 +33,32 @@ function applyHiddenToDoc(doc, hidden) {
|
|
|
32
33
|
}
|
|
33
34
|
return copy;
|
|
34
35
|
}
|
|
36
|
+
const PUBLIC_STRIPPED_META_FIELDS = [
|
|
37
|
+
'organizationId',
|
|
38
|
+
'createdBy',
|
|
39
|
+
'updatedBy',
|
|
40
|
+
'publishedHash'
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* Re-project a FindResult's `_meta` for public reads without mutating the
|
|
44
|
+
* shared (potentially cached) original — same shape as `applyHiddenToResult`,
|
|
45
|
+
* applied after the cache read/write for the same reason: the cached payload
|
|
46
|
+
* must stay the full, unfiltered one so a later admin-context read of the
|
|
47
|
+
* same document isn't served the stripped version.
|
|
48
|
+
*/
|
|
49
|
+
function applyPublicMetaToResult(result, isPublic) {
|
|
50
|
+
if (!isPublic)
|
|
51
|
+
return result;
|
|
52
|
+
return { ...result, docs: result.docs.map((d) => applyPublicMetaToDoc(d, isPublic)) };
|
|
53
|
+
}
|
|
54
|
+
function applyPublicMetaToDoc(doc, isPublic) {
|
|
55
|
+
if (!isPublic || !doc || typeof doc !== 'object' || !('_meta' in doc))
|
|
56
|
+
return doc;
|
|
57
|
+
const meta = { ...doc._meta };
|
|
58
|
+
for (const field of PUBLIC_STRIPPED_META_FIELDS)
|
|
59
|
+
delete meta[field];
|
|
60
|
+
return { ...doc, _meta: meta };
|
|
61
|
+
}
|
|
35
62
|
/**
|
|
36
63
|
* Transform a raw database document into a typed document with data extracted
|
|
37
64
|
* based on perspective (draft or published). Optionally strips field-level
|
|
@@ -75,6 +102,26 @@ export class SingletonOperationError extends Error {
|
|
|
75
102
|
this.name = 'SingletonOperationError';
|
|
76
103
|
}
|
|
77
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Thrown when a write is rejected as *malformed* — a field the schema never
|
|
107
|
+
* declared, or a value of the wrong shape. The caller sent bad data, so this is
|
|
108
|
+
* a 400, not a 500.
|
|
109
|
+
*
|
|
110
|
+
* It exists as a type because the alternative was route handlers sniffing
|
|
111
|
+
* `error.message.includes('validation errors')`, which the structural message
|
|
112
|
+
* ("Invalid document data - …") doesn't match — so every rejected payload was
|
|
113
|
+
* reported to HTTP and MCP clients as a server error. Carries the structured
|
|
114
|
+
* `errors` so a handler (or an agent) can name the offending fields without
|
|
115
|
+
* parsing prose.
|
|
116
|
+
*/
|
|
117
|
+
export class DocumentValidationError extends Error {
|
|
118
|
+
errors;
|
|
119
|
+
constructor(message, errors) {
|
|
120
|
+
super(message);
|
|
121
|
+
this.errors = errors;
|
|
122
|
+
this.name = 'DocumentValidationError';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
78
125
|
/**
|
|
79
126
|
* Collection API - provides type-safe operations for a single collection
|
|
80
127
|
* Generic type T represents the document type for this collection
|
|
@@ -112,6 +159,15 @@ export class CollectionAPI {
|
|
|
112
159
|
return;
|
|
113
160
|
await this.referencesService.syncReferencesFor(organizationId, documentId, data, this._schema, this.schemaRegistry ?? []);
|
|
114
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Recompute the document's full-text search index from freshly-saved
|
|
164
|
+
* draftData. Best-effort, same shape as {@link syncReferences}: not part
|
|
165
|
+
* of the write transaction, self-healing on the next edit if missed.
|
|
166
|
+
*/
|
|
167
|
+
async syncSearchText(organizationId, documentId, data) {
|
|
168
|
+
const searchText = buildSearchText(resolveSearchPaths(this._schema), data);
|
|
169
|
+
await this.databaseAdapter.updateSearchText?.(organizationId, documentId, searchText);
|
|
170
|
+
}
|
|
115
171
|
/**
|
|
116
172
|
* Get the schema for this collection
|
|
117
173
|
*/
|
|
@@ -217,7 +273,7 @@ export class CollectionAPI {
|
|
|
217
273
|
if (perspective === 'published' && this.documentCache) {
|
|
218
274
|
await this.documentCache.setQuery(context.organizationId, this.collectionName, options, unfilteredResult);
|
|
219
275
|
}
|
|
220
|
-
return applyHiddenToResult(unfilteredResult, hidden);
|
|
276
|
+
return applyPublicMetaToResult(applyHiddenToResult(unfilteredResult, hidden), options.public);
|
|
221
277
|
}
|
|
222
278
|
resolveHiddenReadFields(context) {
|
|
223
279
|
if (context.overrideAccess)
|
|
@@ -229,6 +285,43 @@ export class CollectionAPI {
|
|
|
229
285
|
return EMPTY_SET;
|
|
230
286
|
return hiddenWriteFields(this._schema, context.auth);
|
|
231
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Fetch a document by ID, scoped to this collection.
|
|
290
|
+
*
|
|
291
|
+
* Every permission check here is evaluated against `this.collectionName`, but
|
|
292
|
+
* document IDs are globally unique — so a lookup that matched on ID alone let a
|
|
293
|
+
* caller authorised for one collection read or mutate a known ID belonging to a
|
|
294
|
+
* restricted one, through the Local API, GraphQL, or MCP alike.
|
|
295
|
+
*
|
|
296
|
+
* A type mismatch is reported as "not found" rather than "forbidden" on purpose:
|
|
297
|
+
* the caller has no permission to learn that the ID exists elsewhere.
|
|
298
|
+
*
|
|
299
|
+
* Deliberately *not* used for reference lookups in `publish`, which resolve
|
|
300
|
+
* documents of arbitrary types by design.
|
|
301
|
+
*/
|
|
302
|
+
/**
|
|
303
|
+
* Reject a write whose payload is malformed, draft or not.
|
|
304
|
+
*
|
|
305
|
+
* Drafts skip *content* validation on purpose — you must be able to save
|
|
306
|
+
* half-finished work. But "incomplete" and "malformed" are different
|
|
307
|
+
* questions: a missing title is a draft, a string where an array belongs (or a
|
|
308
|
+
* field the schema never declared) is corruption, and letting it through means
|
|
309
|
+
* it's already in storage by the time anyone validates at publish.
|
|
310
|
+
*/
|
|
311
|
+
assertStructurallyValid(result) {
|
|
312
|
+
if (result.structuralErrors.length === 0)
|
|
313
|
+
return;
|
|
314
|
+
const detail = result.structuralErrors
|
|
315
|
+
.map((e) => `${e.field}: ${e.errors.join(', ')}`)
|
|
316
|
+
.join('; ');
|
|
317
|
+
throw new DocumentValidationError(`Invalid document data - ${detail}`, result.structuralErrors);
|
|
318
|
+
}
|
|
319
|
+
async findOwnDocById(organizationId, id, options) {
|
|
320
|
+
const doc = await this.databaseAdapter.findByDocIdAdvanced(organizationId, id, options);
|
|
321
|
+
if (!doc || doc.type !== this.collectionName)
|
|
322
|
+
return null;
|
|
323
|
+
return doc;
|
|
324
|
+
}
|
|
232
325
|
/**
|
|
233
326
|
* Find a single document by ID
|
|
234
327
|
*
|
|
@@ -251,7 +344,7 @@ export class CollectionAPI {
|
|
|
251
344
|
if (perspective === 'published' && this.documentCache) {
|
|
252
345
|
const cached = await this.documentCache.getDocument(context.organizationId, id);
|
|
253
346
|
if (cached)
|
|
254
|
-
return applyHiddenToDoc(cached, hidden);
|
|
347
|
+
return applyPublicMetaToDoc(applyHiddenToDoc(cached, hidden), options?.public);
|
|
255
348
|
}
|
|
256
349
|
// Resolve org IDs via hierarchy service (cached) — avoids RLS transaction
|
|
257
350
|
const findOptions = { ...options };
|
|
@@ -259,7 +352,7 @@ export class CollectionAPI {
|
|
|
259
352
|
const orgIds = await this.hierarchyService.getOrgIdsWithChildren(context.organizationId);
|
|
260
353
|
findOptions.filterOrganizationIds = orgIds;
|
|
261
354
|
}
|
|
262
|
-
const result = await this.
|
|
355
|
+
const result = await this.findOwnDocById(context.organizationId, id, findOptions);
|
|
263
356
|
if (!result) {
|
|
264
357
|
return null;
|
|
265
358
|
}
|
|
@@ -269,7 +362,7 @@ export class CollectionAPI {
|
|
|
269
362
|
if (perspective === 'published' && this.documentCache) {
|
|
270
363
|
await this.documentCache.setDocument(context.organizationId, id, unfiltered);
|
|
271
364
|
}
|
|
272
|
-
const transformed = applyHiddenToDoc(unfiltered, hidden);
|
|
365
|
+
const transformed = applyPublicMetaToDoc(applyHiddenToDoc(unfiltered, hidden), options?.public);
|
|
273
366
|
return transformed;
|
|
274
367
|
}
|
|
275
368
|
/**
|
|
@@ -318,6 +411,7 @@ export class CollectionAPI {
|
|
|
318
411
|
validation: {
|
|
319
412
|
isValid: true,
|
|
320
413
|
errors: [],
|
|
414
|
+
structuralErrors: [],
|
|
321
415
|
normalizedData: existing
|
|
322
416
|
}
|
|
323
417
|
};
|
|
@@ -342,6 +436,7 @@ export class CollectionAPI {
|
|
|
342
436
|
// Validate and normalize data (dates converted to ISO). The document context
|
|
343
437
|
// for cross-field validators is built inside validateDocumentData.
|
|
344
438
|
const validationResult = await validateDocumentData(this._schema, hookedData);
|
|
439
|
+
this.assertStructurallyValid(validationResult);
|
|
345
440
|
if (options?.publish) {
|
|
346
441
|
await this.permissions.canPublish(context, this.collectionName);
|
|
347
442
|
// Block publish if validation fails
|
|
@@ -388,6 +483,7 @@ export class CollectionAPI {
|
|
|
388
483
|
// Post-commit side effects: ref index is best-effort, retention is one pass
|
|
389
484
|
// covering both the draft and publish snapshots written inside the tx.
|
|
390
485
|
await this.syncReferences(context.organizationId, document.id, validationResult.normalizedData);
|
|
486
|
+
await this.syncSearchText(context.organizationId, document.id, validationResult.normalizedData);
|
|
391
487
|
if (versionService) {
|
|
392
488
|
await versionService.enforceRetentionFor(this.databaseAdapter, context.organizationId, document.id);
|
|
393
489
|
}
|
|
@@ -419,6 +515,7 @@ export class CollectionAPI {
|
|
|
419
515
|
id: options?.id
|
|
420
516
|
});
|
|
421
517
|
await this.syncReferences(context.organizationId, document.id, validationResult.normalizedData);
|
|
518
|
+
await this.syncSearchText(context.organizationId, document.id, validationResult.normalizedData);
|
|
422
519
|
// Create initial draft version
|
|
423
520
|
if (versionService) {
|
|
424
521
|
await versionService.createVersion(this.databaseAdapter, context.organizationId, document.id, 'draft', validationResult.normalizedData, context.user?.id);
|
|
@@ -450,7 +547,7 @@ export class CollectionAPI {
|
|
|
450
547
|
// Fetch the doc first so ownership policies have access to the target.
|
|
451
548
|
// A missing doc still returns null below; capability/role rules stay
|
|
452
549
|
// unaffected by the reorder.
|
|
453
|
-
const existingDoc = await this.
|
|
550
|
+
const existingDoc = await this.findOwnDocById(context.organizationId, id);
|
|
454
551
|
if (!existingDoc) {
|
|
455
552
|
return null;
|
|
456
553
|
}
|
|
@@ -482,6 +579,7 @@ export class CollectionAPI {
|
|
|
482
579
|
});
|
|
483
580
|
// Validate and normalize the merged data
|
|
484
581
|
const validationResult = await validateDocumentData(this._schema, hookedData);
|
|
582
|
+
this.assertStructurallyValid(validationResult);
|
|
485
583
|
// Update draft with normalized data (dates in ISO format)
|
|
486
584
|
// Use VersionService for atomic save + version creation if available
|
|
487
585
|
// RevisionConflictError propagates un-swallowed — a stale caller (a second
|
|
@@ -494,6 +592,7 @@ export class CollectionAPI {
|
|
|
494
592
|
return null;
|
|
495
593
|
}
|
|
496
594
|
await this.syncReferences(context.organizationId, id, validationResult.normalizedData);
|
|
595
|
+
await this.syncSearchText(context.organizationId, id, validationResult.normalizedData);
|
|
497
596
|
if (options?.publish) {
|
|
498
597
|
await this.permissions.canPublish(context, this.collectionName, document);
|
|
499
598
|
// Block publish if validation fails
|
|
@@ -544,7 +643,7 @@ export class CollectionAPI {
|
|
|
544
643
|
// Fetch the target so ownership policies have a doc to inspect. For
|
|
545
644
|
// role/capability rules this extra read is a small cost; ergonomic
|
|
546
645
|
// wins outweigh it for operations that are rare by nature.
|
|
547
|
-
const existing = await this.
|
|
646
|
+
const existing = await this.findOwnDocById(context.organizationId, id);
|
|
548
647
|
if (!existing)
|
|
549
648
|
return false;
|
|
550
649
|
await this.permissions.canDelete(context, this.collectionName, existing);
|
|
@@ -584,7 +683,7 @@ export class CollectionAPI {
|
|
|
584
683
|
async publish(context, id, options) {
|
|
585
684
|
// Fetch first so policies can inspect the target. Order matters here:
|
|
586
685
|
// 404s beat 403s for missing docs.
|
|
587
|
-
const document = await this.
|
|
686
|
+
const document = await this.findOwnDocById(context.organizationId, id);
|
|
588
687
|
if (!document || !document.draftData) {
|
|
589
688
|
throw new Error('Document not found or has no draft content to publish');
|
|
590
689
|
}
|
|
@@ -646,7 +745,7 @@ export class CollectionAPI {
|
|
|
646
745
|
*/
|
|
647
746
|
async unpublish(context, id, options) {
|
|
648
747
|
// Fetch target for policy inspection before mutating.
|
|
649
|
-
const existing = await this.
|
|
748
|
+
const existing = await this.findOwnDocById(context.organizationId, id);
|
|
650
749
|
if (!existing)
|
|
651
750
|
return null;
|
|
652
751
|
await this.permissions.canUnpublish(context, this.collectionName, existing);
|
|
@@ -708,7 +807,7 @@ export class CollectionAPI {
|
|
|
708
807
|
* so a document has at most one pending schedule (rescheduling can't double-publish).
|
|
709
808
|
*/
|
|
710
809
|
async schedulePublish(context, id, runAt) {
|
|
711
|
-
const document = await this.
|
|
810
|
+
const document = await this.findOwnDocById(context.organizationId, id);
|
|
712
811
|
if (!document)
|
|
713
812
|
throw new Error('Document not found');
|
|
714
813
|
await this.permissions.canPublish(context, this.collectionName, document);
|
|
@@ -725,7 +824,7 @@ export class CollectionAPI {
|
|
|
725
824
|
}
|
|
726
825
|
/** Schedule an unpublish for a future `runAt`. Permission-checked now; replaces any existing pending schedule. */
|
|
727
826
|
async scheduleUnpublish(context, id, runAt) {
|
|
728
|
-
const document = await this.
|
|
827
|
+
const document = await this.findOwnDocById(context.organizationId, id);
|
|
729
828
|
if (!document)
|
|
730
829
|
throw new Error('Document not found');
|
|
731
830
|
await this.permissions.canUnpublish(context, this.collectionName, document);
|
|
@@ -747,7 +846,7 @@ export class CollectionAPI {
|
|
|
747
846
|
}
|
|
748
847
|
/** Cancel all pending scheduled publish/unpublish jobs for a document. Returns how many were cancelled. */
|
|
749
848
|
async cancelScheduled(context, id) {
|
|
750
|
-
const document = await this.
|
|
849
|
+
const document = await this.findOwnDocById(context.organizationId, id);
|
|
751
850
|
if (!document)
|
|
752
851
|
throw new Error('Document not found');
|
|
753
852
|
await this.permissions.canPublish(context, this.collectionName, document);
|
|
@@ -149,7 +149,7 @@ export declare function createLocalAPI(config: CMSConfig, userAdapter: DatabaseA
|
|
|
149
149
|
* ```
|
|
150
150
|
*/
|
|
151
151
|
export declare function getLocalAPI(): LocalAPI;
|
|
152
|
-
export { CollectionAPI, SingletonOperationError, type DocumentResult, type SingletonCollection } from './collection-api.js';
|
|
152
|
+
export { CollectionAPI, SingletonOperationError, DocumentValidationError, type DocumentResult, type SingletonCollection } from './collection-api.js';
|
|
153
153
|
export { PermissionChecker, PermissionError } from './permissions.js';
|
|
154
154
|
export type { LocalAPIContext, CreateOptions, UpdateOptions } from './types.js';
|
|
155
155
|
export { authToContext, requireAuth, systemContext } from './auth-helpers.js';
|
|
@@ -1 +1 @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GV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAKtC;AAGD,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/local-api/index.js
CHANGED
|
@@ -270,6 +270,6 @@ export function getLocalAPI() {
|
|
|
270
270
|
return localAPIInstance;
|
|
271
271
|
}
|
|
272
272
|
// Re-export types and classes for convenience
|
|
273
|
-
export { CollectionAPI, SingletonOperationError } from './collection-api.js';
|
|
273
|
+
export { CollectionAPI, SingletonOperationError, DocumentValidationError } from './collection-api.js';
|
|
274
274
|
export { PermissionChecker, PermissionError } from './permissions.js';
|
|
275
275
|
export { authToContext, requireAuth, systemContext } from './auth-helpers.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/lib/plugins/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAGN,KAAK,oBAAoB,EACzB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["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AE;QAAE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,aAAa,EAAE,CAAC;IAC1F,sEAAsE;IACtE,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAAC;IAC9D,+DAA+D;IAC/D,oBAAoB,IAAI,YAAY,EAAE,CAAC;IACvC,8DAA8D;IAC9D,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IAChE;;;;OAIG;IACH,WAAW,IAAI,aAAa,CAAC;IAC7B,gHAAgH;IAChH,cAAc,IAAI,iBAAiB,EAAE,CAAC;IACtC,mFAAmF;IACnF,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAAC;IAC1D;;;;;OAKG;IACH,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,CAAC;CAC7F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,SAAS,EAAO,GAAG,YAAY,CA+G1E"}
|
package/dist/plugins/resolver.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { defineCapability, mergeCapabilityCatalog } from '../types/capabilities.js';
|
|
2
|
+
import { BUILT_IN_EVENT_CONSUMERS } from '../events/built-in-consumers.js';
|
|
2
3
|
export function createPartResolver(plugins = []) {
|
|
3
|
-
|
|
4
|
+
// Core's own consumers come first, so a plugin declaring the same id collides in the
|
|
5
|
+
// duplicate check below rather than silently shadowing erasure.
|
|
6
|
+
const allParts = [
|
|
7
|
+
...BUILT_IN_EVENT_CONSUMERS,
|
|
8
|
+
...plugins.flatMap((p) => p.parts ?? [])
|
|
9
|
+
];
|
|
4
10
|
// Duplicate-id validation, per extension point. Parts without an id (schema,
|
|
5
11
|
// capabilities, field-component) are exempt.
|
|
6
12
|
const seen = new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SchemaType } from '../types/schemas.js';
|
|
1
|
+
import type { SchemaType, SearchFieldConfig } from '../types/schemas.js';
|
|
2
2
|
/**
|
|
3
3
|
* Schema utility functions that work with a schema registry
|
|
4
4
|
* These functions accept schemas as parameters to avoid package-level dependencies
|
|
@@ -19,6 +19,36 @@ export declare function getDocumentTypes(schemas: SchemaType[]): SchemaType[];
|
|
|
19
19
|
* Check if a schema type exists
|
|
20
20
|
*/
|
|
21
21
|
export declare function schemaExists(schemas: SchemaType[], name: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Build a `search` config from every top-level string-ish field on a schema
|
|
24
|
+
* (`string`, `text`, `slug`, `url`) — the fields worth full-text matching.
|
|
25
|
+
* Doesn't recurse into `object`/`array` fields.
|
|
26
|
+
*
|
|
27
|
+
* Use this to opt a document type into field-wide search instead of hand-listing
|
|
28
|
+
* paths:
|
|
29
|
+
* ```ts
|
|
30
|
+
* const fields = [ ...define fields here... ];
|
|
31
|
+
* export default defineType({
|
|
32
|
+
* name: 'post',
|
|
33
|
+
* fields,
|
|
34
|
+
* search: searchableFields({ fields })
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function searchableFields(schema: Pick<SchemaType, 'fields'>): SearchFieldConfig[];
|
|
39
|
+
/**
|
|
40
|
+
* Resolve which dot-paths a document's search index is built from: the
|
|
41
|
+
* schema's explicit `search` config if set, else the conventional title-ish
|
|
42
|
+
* fields (`title`/`heading`/`name`/`label`/`slug`) plus whatever
|
|
43
|
+
* `preview.select.title` points to — the same fields `resolvePreviewTitle`
|
|
44
|
+
* already uses to pick a display title.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveSearchPaths(schema: Pick<SchemaType, 'search' | 'preview'>): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Flatten the given dot-paths off a document's data into a single normalized
|
|
49
|
+
* string — the value stored in `search_text` and indexed for full-text search.
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildSearchText(paths: string[], data: Record<string, unknown> | null | undefined): string;
|
|
22
52
|
/**
|
|
23
53
|
* Get the available types for an array field
|
|
24
54
|
* Supports both schema references and inline object definitions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/schema-utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/schema-utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAatE;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAEtF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAElE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAEpE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,iBAAiB,EAAE,CAIxF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,CAQ3F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAC9C,MAAM,CAaR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,OAAO,EAAE,UAAU,EAAE,EACrB,UAAU,EAAE;IAAE,EAAE,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,GACzF,UAAU,EAAE,CA0Bd"}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { readPath } from '../utils/preview.js';
|
|
2
|
+
/** Field types treated as free text for the purposes of `searchableFields`. */
|
|
3
|
+
const SEARCHABLE_FIELD_TYPES = new Set(['string', 'text', 'slug', 'url']);
|
|
4
|
+
/**
|
|
5
|
+
* Conventional fallback field names for search when a schema doesn't declare
|
|
6
|
+
* an explicit `search` config. Mirrors the title-resolution fallback in
|
|
7
|
+
* `resolvePreviewTitle` (`title`/`heading`/`name`/`label`), plus `slug`.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_SEARCH_FIELDS = ['title', 'heading', 'name', 'label', 'slug'];
|
|
1
10
|
/**
|
|
2
11
|
* Schema utility functions that work with a schema registry
|
|
3
12
|
* These functions accept schemas as parameters to avoid package-level dependencies
|
|
@@ -26,6 +35,65 @@ export function getDocumentTypes(schemas) {
|
|
|
26
35
|
export function schemaExists(schemas, name) {
|
|
27
36
|
return schemas.some((schema) => schema.name === name);
|
|
28
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Build a `search` config from every top-level string-ish field on a schema
|
|
40
|
+
* (`string`, `text`, `slug`, `url`) — the fields worth full-text matching.
|
|
41
|
+
* Doesn't recurse into `object`/`array` fields.
|
|
42
|
+
*
|
|
43
|
+
* Use this to opt a document type into field-wide search instead of hand-listing
|
|
44
|
+
* paths:
|
|
45
|
+
* ```ts
|
|
46
|
+
* const fields = [ ...define fields here... ];
|
|
47
|
+
* export default defineType({
|
|
48
|
+
* name: 'post',
|
|
49
|
+
* fields,
|
|
50
|
+
* search: searchableFields({ fields })
|
|
51
|
+
* })
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function searchableFields(schema) {
|
|
55
|
+
return schema.fields
|
|
56
|
+
.filter((field) => SEARCHABLE_FIELD_TYPES.has(field.type))
|
|
57
|
+
.map((field) => ({ path: field.name }));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve which dot-paths a document's search index is built from: the
|
|
61
|
+
* schema's explicit `search` config if set, else the conventional title-ish
|
|
62
|
+
* fields (`title`/`heading`/`name`/`label`/`slug`) plus whatever
|
|
63
|
+
* `preview.select.title` points to — the same fields `resolvePreviewTitle`
|
|
64
|
+
* already uses to pick a display title.
|
|
65
|
+
*/
|
|
66
|
+
export function resolveSearchPaths(schema) {
|
|
67
|
+
if (schema.search?.length) {
|
|
68
|
+
return schema.search.map((field) => field.path);
|
|
69
|
+
}
|
|
70
|
+
const fallback = new Set(DEFAULT_SEARCH_FIELDS);
|
|
71
|
+
const titlePath = schema.preview?.select?.title;
|
|
72
|
+
if (titlePath)
|
|
73
|
+
fallback.add(titlePath);
|
|
74
|
+
return Array.from(fallback);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Flatten the given dot-paths off a document's data into a single normalized
|
|
78
|
+
* string — the value stored in `search_text` and indexed for full-text search.
|
|
79
|
+
*/
|
|
80
|
+
export function buildSearchText(paths, data) {
|
|
81
|
+
if (!data)
|
|
82
|
+
return '';
|
|
83
|
+
const parts = [];
|
|
84
|
+
for (const path of paths) {
|
|
85
|
+
const value = readPath(data, path);
|
|
86
|
+
if (typeof value === 'string') {
|
|
87
|
+
const trimmed = value.trim();
|
|
88
|
+
if (trimmed)
|
|
89
|
+
parts.push(trimmed);
|
|
90
|
+
}
|
|
91
|
+
else if (typeof value === 'number' || typeof value === 'boolean') {
|
|
92
|
+
parts.push(String(value));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return parts.join(' ').replace(/\s+/g, ' ').trim();
|
|
96
|
+
}
|
|
29
97
|
/**
|
|
30
98
|
* Get the available types for an array field
|
|
31
99
|
* Supports both schema references and inline object definitions
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface RateLimitRule {
|
|
2
|
+
/** Window length in milliseconds. */
|
|
3
|
+
windowMs: number;
|
|
4
|
+
/** Requests allowed per window. */
|
|
5
|
+
max: number;
|
|
6
|
+
}
|
|
7
|
+
export interface RateLimitResult {
|
|
8
|
+
allowed: boolean;
|
|
9
|
+
/** Seconds until the current window rolls over — for a `Retry-After` header. */
|
|
10
|
+
retryAfterSeconds: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A named bucket of windows.
|
|
14
|
+
*
|
|
15
|
+
* Entries are swept lazily on write rather than on a timer: an interval would keep a
|
|
16
|
+
* reference alive for the process's whole life (and in a test run, past the end of the
|
|
17
|
+
* suite), and the map only grows when requests are arriving anyway.
|
|
18
|
+
*/
|
|
19
|
+
export declare class RateLimiter {
|
|
20
|
+
private rule;
|
|
21
|
+
private windows;
|
|
22
|
+
private lastSweep;
|
|
23
|
+
constructor(rule: RateLimitRule);
|
|
24
|
+
/** Count one request against `key`, and say whether it may proceed. */
|
|
25
|
+
check(key: string): RateLimitResult;
|
|
26
|
+
/** Drop windows that have already rolled over. Runs at most once per window length. */
|
|
27
|
+
private sweep;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Best-effort client address for rate-limit keying.
|
|
31
|
+
*
|
|
32
|
+
* `x-forwarded-for` is caller-supplied and trivially spoofed unless a trusted proxy sets it,
|
|
33
|
+
* so an IP bucket alone is not a control — it's the half that stops casual abuse. Pair it
|
|
34
|
+
* with a bucket on something the attacker can't rotate freely (the target email address) so
|
|
35
|
+
* the limit still bites when the address is forged.
|
|
36
|
+
*/
|
|
37
|
+
export declare function clientAddress(headers: Headers): string;
|
|
38
|
+
//# sourceMappingURL=rate-limit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../../src/lib/server/api/rate-limit.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,aAAa;IAC7B,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,iBAAiB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,qBAAa,WAAW;IAIX,OAAO,CAAC,IAAI;IAHxB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAAK;gBAEF,IAAI,EAAE,aAAa;IAEvC,uEAAuE;IACvE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe;IAkBnC,uFAAuF;IACvF,OAAO,CAAC,KAAK;CAOb;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAKtD"}
|