@cosmicdrift/kumiko-framework 0.411.0 → 0.413.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/agents/api/framework-db.md +1 -1
- package/agents/api/framework-engine.md +48 -1
- package/agents/api/framework-errors.md +2 -0
- package/agents/api/types.md +8 -0
- package/agents/api.md +2 -2
- package/agents/boot-rules.md +343 -0
- package/agents/examples/api-docs.md +710 -0
- package/agents/examples/golden-path.md +11 -11
- package/agents/examples/{contact.md → helpdesk.md} +31 -31
- package/agents/examples.md +2 -1
- package/agents/features-index.md +2 -2
- package/agents/features.md +16 -16
- package/dist/api/auth-middleware.d.ts +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/pat-auth-reject.d.ts +7 -0
- package/dist/api/pat-auth-reject.js +7 -0
- package/dist/api/server-middleware.js +2 -1
- package/dist/compliance/sub-processors.js +2 -2
- package/dist/config/index.d.ts +25 -0
- package/dist/config/index.js +28 -1
- package/dist/db/event-store-executor-read-paging.d.ts +1 -0
- package/dist/db/event-store-executor-read-paging.js +2 -1
- package/dist/db/read-gate-clause.js +26 -7
- package/dist/db/table-builder.d.ts +1 -2
- package/dist/engine/boot-validator/boot-report.d.ts +3 -0
- package/dist/engine/boot-validator/boot-report.js +2 -2
- package/dist/engine/boot-validator/boot-rules.d.ts +570 -0
- package/dist/engine/boot-validator/boot-rules.js +20 -0
- package/dist/engine/boot-validator/definition-config-events-jobs-rules.d.ts +77 -0
- package/dist/engine/boot-validator/definition-config-events-jobs-rules.js +77 -0
- package/dist/engine/boot-validator/definition-events-rules.d.ts +42 -0
- package/dist/engine/boot-validator/definition-events-rules.js +42 -0
- package/dist/engine/boot-validator/definition-feature-rules.d.ts +42 -0
- package/dist/engine/boot-validator/definition-feature-rules.js +42 -0
- package/dist/engine/boot-validator/definition-field-factories-rules.d.ts +17 -0
- package/dist/engine/boot-validator/definition-field-factories-rules.js +17 -0
- package/dist/engine/boot-validator/definition-handlers-rules.d.ts +72 -0
- package/dist/engine/boot-validator/definition-handlers-rules.js +72 -0
- package/dist/engine/boot-validator/definition-ownership-from-rules.d.ts +27 -0
- package/dist/engine/boot-validator/definition-ownership-from-rules.js +27 -0
- package/dist/engine/boot-validator/definition-probes-rules.d.ts +47 -0
- package/dist/engine/boot-validator/definition-probes-rules.js +47 -0
- package/dist/engine/boot-validator/definition-role-assignment-rules.d.ts +27 -0
- package/dist/engine/boot-validator/definition-role-assignment-rules.js +27 -0
- package/dist/engine/boot-validator/definition-ui-extensions-rules.d.ts +197 -0
- package/dist/engine/boot-validator/definition-ui-extensions-rules.js +197 -0
- package/dist/engine/boot-validator/definition-webhook-events-rules.d.ts +32 -0
- package/dist/engine/boot-validator/definition-webhook-events-rules.js +32 -0
- package/dist/engine/define-feature.js +29 -9
- package/dist/engine/define-handler.js +8 -4
- package/dist/engine/definition-violations.d.ts +14 -0
- package/dist/engine/definition-violations.js +71 -0
- package/dist/engine/entity-handlers.js +39 -13
- package/dist/engine/entity-list-runtime-options.js +12 -0
- package/dist/engine/event-def.js +32 -12
- package/dist/engine/factories.d.ts +2 -0
- package/dist/engine/factories.js +16 -5
- package/dist/engine/feature-builder-state.d.ts +2 -1
- package/dist/engine/feature-builder-state.js +1 -0
- package/dist/engine/feature-config-events-jobs.js +63 -27
- package/dist/engine/feature-entity-handlers.js +15 -6
- package/dist/engine/feature-probes.js +29 -9
- package/dist/engine/feature-ui-extensions.js +178 -92
- package/dist/engine/index.d.ts +5 -2
- package/dist/engine/index.js +4 -1
- package/dist/engine/object-form.js +8 -2
- package/dist/engine/ownership.js +17 -5
- package/dist/engine/registry-facade.js +13 -0
- package/dist/engine/role-assignment.js +17 -5
- package/dist/engine/webhook-contracts.d.ts +12 -0
- package/dist/engine/webhook-contracts.js +172 -0
- package/dist/engine/webhook-events.d.ts +34 -0
- package/dist/engine/webhook-events.js +85 -0
- package/dist/errors/docs-url.js +2 -19
- package/dist/errors/error-codes.d.ts +20 -0
- package/dist/errors/error-codes.js +19 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +1 -0
- package/dist/files/file-routes.js +1 -1
- package/dist/i18n/required-surface-keys.d.ts +4 -0
- package/dist/i18n/required-surface-keys.js +15 -0
- package/dist/schema-cli/shared.d.ts +11 -0
- package/dist/schema-cli/shared.js +37 -3
- package/dist/schema-cli/validate-command.js +10 -3
- package/package.json +3 -3
- package/src/changes.json +42 -0
package/dist/engine/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { ConfigAccessor, ConfigAccessorFactory, ConfigCascade, ConfigCascad
|
|
|
3
3
|
export type { ConfigScope } from "@cosmicdrift/kumiko-types/config-scope";
|
|
4
4
|
export type { KumikoEventTypeMap } from "@cosmicdrift/kumiko-types/event-type-map";
|
|
5
5
|
export type { ExtensionOptionsArgs, ExtensionOptionsFor, KumikoExtensionOptionsMap, } from "@cosmicdrift/kumiko-types/extension-options-map";
|
|
6
|
-
export type { BootOptionName, SecretKeyDefinition, SecretKeyHandle, SecretNamespaceDefinition, SecretNamespaceHandle, SecretNamespaceOptions, } from "@cosmicdrift/kumiko-types/feature";
|
|
6
|
+
export type { BootOptionName, SecretKeyDefinition, SecretKeyHandle, SecretNamespaceDefinition, SecretNamespaceHandle, SecretNamespaceOptions, WebhookEntityVerb, WebhookEventContract, WebhookEventHandle, } from "@cosmicdrift/kumiko-types/feature";
|
|
7
7
|
export type { FeatureRegistrar } from "@cosmicdrift/kumiko-types/feature-registrar";
|
|
8
8
|
export type { DeriveContext, EntityDefinition, FieldDefinition, JsonbFieldDef, ResolvedPiiFlags, RetentionDef, } from "@cosmicdrift/kumiko-types/fields";
|
|
9
9
|
export type { AccessRule, AgentEffect, AgentHandlerHints, AgentRisk, AuthClaimsContext, BeforeTransactionResult, ChatSendFailureCode, ClaimKeyType, DeliveryErrorCode, DeliveryFailureCode, DeliverySkipReason, EscapeHatchAuditSink, EscapeHatchDeclaration, EscapeHatchKind, EscapeHatchUseEvent, EventDef, JobContext, JobDeferral, NotifyDelivery, NotifyDeliveryStatus, NotifyDispatched, NotifyFactory, NotifyFn, NotifyJobDispatcher, NotifyOptions, NotifyPriority, NotifyResult, QueryHandlerDef, RateLimitPer, RoleAccessPersonalData, RoleAccessRule, StreamHandlerDef, TenantWriteTarget, WriteEvent, WriteHandlerDef, WriteHandlerFn, WriteResult, } from "@cosmicdrift/kumiko-types/handlers";
|
|
@@ -18,7 +18,8 @@ export type { ActionFormScreenDefinition, BundledListsOptions, ConfigEditScreenD
|
|
|
18
18
|
export type { TargetRef } from "@cosmicdrift/kumiko-types/target-ref";
|
|
19
19
|
export type { TreeAction, TreeActionDef, TreeChildrenSubscribe, TreeNode, } from "@cosmicdrift/kumiko-types/tree-node";
|
|
20
20
|
export type { WorkspaceDefinition } from "@cosmicdrift/kumiko-types/workspace";
|
|
21
|
-
export {
|
|
21
|
+
export { DEFAULT_LIST_LIMIT } from "../db/event-store-executor-read-paging.ts";
|
|
22
|
+
export { handlerDescriptionKey, handlerFieldLabelKey, handlerTitleKey, webhookEventDescriptionKey, webhookEventFieldKey, } from "../i18n/required-surface-keys.ts";
|
|
22
23
|
export { attachOutsideTransaction } from "../pipeline/attach-outside-transaction.ts";
|
|
23
24
|
export { hasAccess } from "./access.ts";
|
|
24
25
|
export type { PrincipalProfile, PrincipalStatus, PrincipalStatusPlugin, TenantLifecycleStatusPlugin, } from "./active-membership.ts";
|
|
@@ -103,4 +104,6 @@ export { isSystemTenant, isUuid, parseTenantId, SYSTEM_TENANT_ID } from "./types
|
|
|
103
104
|
export type { AppContext, BeforeTransactionContext, FeatureDefinition, HandlerAuth, HandlerContext, HandlerDb, HandlerDispatch, HandlerEvents, HandlerObservability, JobDispatch, JobEvents, JobObservability, QueryEvent, Registry, ReservationContext, SessionUser, TenantId, } from "./types/index.ts";
|
|
104
105
|
export type { AwaitedEventType, PipelineCtx, StepInstance, StepResolver, } from "./types/step.ts";
|
|
105
106
|
export { walkStepInstances } from "./walk-step-instances.ts";
|
|
107
|
+
export { createWebhookContractResolver, type WebhookContractResolver, } from "./webhook-contracts.ts";
|
|
108
|
+
export { formatWebhookPayloadIssues, parseWebhookPayload, toEntityWebhookPayload, type WebhookPayloadIssue, type WebhookPayloadResult, } from "./webhook-events.ts";
|
|
106
109
|
export { withFormDerivations } from "./with-form-derivations.ts";
|
package/dist/engine/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Public API
|
|
2
2
|
export { isAgentVisibleScreen, resolveAgentExposure, } from "@cosmicdrift/kumiko-types/agent-exposure";
|
|
3
3
|
export { DELIVERY_FAILURE_CODES, DELIVERY_SKIP_REASONS, HTTP_ERROR_CODE_PATTERN, isDeliveryErrorCode, isOpenToAllGranted, } from "@cosmicdrift/kumiko-types/handlers";
|
|
4
|
-
export {
|
|
4
|
+
export { DEFAULT_LIST_LIMIT } from "../db/event-store-executor-read-paging.js";
|
|
5
|
+
export { handlerDescriptionKey, handlerFieldLabelKey, handlerTitleKey, webhookEventDescriptionKey, webhookEventFieldKey, } from "../i18n/required-surface-keys.js";
|
|
5
6
|
export { attachOutsideTransaction } from "../pipeline/attach-outside-transaction.js";
|
|
6
7
|
export { hasAccess } from "./access.js";
|
|
7
8
|
export { collectBootRuleViolations } from "./boot-validator/boot-report.js";
|
|
@@ -83,4 +84,6 @@ export { findTierResolverUsage, isTierResolverPlugin, requireTierResolverPlugin,
|
|
|
83
84
|
export { findOverDeepTransferChain, resolveTransferAdjacency as resolveEntityTransferAdjacency, } from "./transfer-adjacency.js";
|
|
84
85
|
export { isSystemTenant, isUuid, parseTenantId, SYSTEM_TENANT_ID } from "./types/identifiers.js";
|
|
85
86
|
export { walkStepInstances } from "./walk-step-instances.js";
|
|
87
|
+
export { createWebhookContractResolver, } from "./webhook-contracts.js";
|
|
88
|
+
export { formatWebhookPayloadIssues, parseWebhookPayload, toEntityWebhookPayload, } from "./webhook-events.js";
|
|
86
89
|
export { withFormDerivations } from "./with-form-derivations.js";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bootRuleError } from "./boot-validator/boot-rule.js";
|
|
2
|
+
import { FEATURE_DEFINITION_RULES } from "./boot-validator/definition-feature-rules.js";
|
|
1
3
|
// Shared helpers for registrar methods that take a single object argument
|
|
2
4
|
// (`r.entity({ name: "item", ... })`).
|
|
3
5
|
export function splitNamedDefinition(definition) {
|
|
@@ -8,7 +10,9 @@ export function splitNamedDefinition(definition) {
|
|
|
8
10
|
// the implementation signature has to stay optional, so untyped callers are caught here.
|
|
9
11
|
export function requireArgument(value, featureName, method, argument) {
|
|
10
12
|
if (value === undefined) {
|
|
11
|
-
throw
|
|
13
|
+
throw bootRuleError(FEATURE_DEFINITION_RULES.argumentMissing, {
|
|
14
|
+
message: `[Feature ${featureName}] r.${method}() needs its ${argument} argument`,
|
|
15
|
+
});
|
|
12
16
|
}
|
|
13
17
|
return value;
|
|
14
18
|
}
|
|
@@ -29,5 +33,7 @@ export function isObjectArgument(value) {
|
|
|
29
33
|
// Untyped JS callers bypass the types; without this check a positional call would
|
|
30
34
|
// register a definition built from undefined fields instead of failing.
|
|
31
35
|
export function throwObjectArgumentRequired(featureName, method) {
|
|
32
|
-
throw
|
|
36
|
+
throw bootRuleError(FEATURE_DEFINITION_RULES.optionsObjectRequired, {
|
|
37
|
+
message: `[Feature ${featureName}] r.${method}() takes one options object`,
|
|
38
|
+
});
|
|
33
39
|
}
|
package/dist/engine/ownership.js
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
20
20
|
import { toSnakeCase } from "../db/table-builder.js";
|
|
21
21
|
import { columnSqlNameOf, schemaTableName } from "../db/table-introspection.js";
|
|
22
|
+
import { bootRuleError } from "./boot-validator/boot-rule.js";
|
|
23
|
+
import { DEFINITION_OWNERSHIP_FROM_RULES } from "./boot-validator/definition-ownership-from-rules.js";
|
|
22
24
|
import { assertQualifiedWhereFragment, tableColumnSqlNames } from "./where-rule-lint.js";
|
|
23
25
|
// Parse an OwnershipRef into kind + resolved path + default column.
|
|
24
26
|
// Throws on malformed input so the error surfaces at `from()`-call-site (in
|
|
@@ -26,7 +28,9 @@ import { assertQualifiedWhereFragment, tableColumnSqlNames } from "./where-rule-
|
|
|
26
28
|
export function from(ref, column) {
|
|
27
29
|
const firstColon = ref.indexOf(":");
|
|
28
30
|
if (firstColon < 0) {
|
|
29
|
-
throw
|
|
31
|
+
throw bootRuleError(DEFINITION_OWNERSHIP_FROM_RULES.refWithoutColon, {
|
|
32
|
+
message: `from("${ref}"): expected "user:<field>" or "claim:<featureName>:<key>" — no colon found.`,
|
|
33
|
+
});
|
|
30
34
|
}
|
|
31
35
|
const prefix = ref.slice(0, firstColon);
|
|
32
36
|
const rest = ref.slice(firstColon + 1);
|
|
@@ -35,17 +39,23 @@ export function from(ref, column) {
|
|
|
35
39
|
// column on the row must be given explicitly (a user.id is rarely
|
|
36
40
|
// named `id` on a child table — usually `ownerId`, `assigneeId`, ...).
|
|
37
41
|
if (!column) {
|
|
38
|
-
throw
|
|
42
|
+
throw bootRuleError(DEFINITION_OWNERSHIP_FROM_RULES.userColumnMissing, {
|
|
43
|
+
message: `from("${ref}"): user-refs require an explicit column name — e.g. from("user:id", "assigneeId").`,
|
|
44
|
+
});
|
|
39
45
|
}
|
|
40
46
|
if (rest !== "id" && rest !== "tenantId") {
|
|
41
|
-
throw
|
|
47
|
+
throw bootRuleError(DEFINITION_OWNERSHIP_FROM_RULES.userRefUnsupported, {
|
|
48
|
+
message: `from("${ref}"): user-ref supports only "user:id" or "user:tenantId" (got "user:${rest}").`,
|
|
49
|
+
});
|
|
42
50
|
}
|
|
43
51
|
return { kind: "from", refKind: "user", refPath: rest, column };
|
|
44
52
|
}
|
|
45
53
|
if (prefix === "claim") {
|
|
46
54
|
// "claim:<feature>:<key>" — rest is the 2-segment claim QN.
|
|
47
55
|
if (!rest.includes(":")) {
|
|
48
|
-
throw
|
|
56
|
+
throw bootRuleError(DEFINITION_OWNERSHIP_FROM_RULES.claimRefInvalid, {
|
|
57
|
+
message: `from("${ref}"): claim-ref must be "claim:<featureName>:<shortName>" (got "claim:${rest}").`,
|
|
58
|
+
});
|
|
49
59
|
}
|
|
50
60
|
// Default column = claim shortName (second segment).
|
|
51
61
|
const defaultColumn = rest.slice(rest.indexOf(":") + 1);
|
|
@@ -56,7 +66,9 @@ export function from(ref, column) {
|
|
|
56
66
|
column: column ?? defaultColumn,
|
|
57
67
|
};
|
|
58
68
|
}
|
|
59
|
-
throw
|
|
69
|
+
throw bootRuleError(DEFINITION_OWNERSHIP_FROM_RULES.prefixUnsupported, {
|
|
70
|
+
message: `from("${ref}"): unsupported ref prefix "${prefix}". Supported: "user", "claim".`,
|
|
71
|
+
});
|
|
60
72
|
}
|
|
61
73
|
// Evaluate an ownership rule against a concrete row (plain data, no Drizzle).
|
|
62
74
|
// Used by field-level filters on query responses and by field-level
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { filterByPhase, filterOwned } from "./registry-state.js";
|
|
2
|
+
import { assertUniqueWebhookWireNames, createWebhookContractResolver, } from "./webhook-contracts.js";
|
|
2
3
|
function isFeatureSystemScoped(state, featureName) {
|
|
3
4
|
if (!featureName)
|
|
4
5
|
return false;
|
|
@@ -9,6 +10,12 @@ function isFeatureSystemScoped(state, featureName) {
|
|
|
9
10
|
// return-object literal, only the closure-captured variable changed
|
|
10
11
|
// (state.X instead of bare X, done in the RegistryState-threading step).
|
|
11
12
|
export function buildRegistryFacade(state) {
|
|
13
|
+
assertUniqueWebhookWireNames([...state.featureMap.values()]);
|
|
14
|
+
let resolver;
|
|
15
|
+
const webhookContracts = () => {
|
|
16
|
+
resolver ??= createWebhookContractResolver([...state.featureMap.values()]);
|
|
17
|
+
return resolver;
|
|
18
|
+
};
|
|
12
19
|
return {
|
|
13
20
|
features: state.featureMap,
|
|
14
21
|
getFeature(name) {
|
|
@@ -149,6 +156,12 @@ export function buildRegistryFacade(state) {
|
|
|
149
156
|
getEvent(qualifiedName) {
|
|
150
157
|
return state.eventMap.get(qualifiedName);
|
|
151
158
|
},
|
|
159
|
+
getWebhookEventContract(qualifiedName) {
|
|
160
|
+
return webhookContracts().get(qualifiedName);
|
|
161
|
+
},
|
|
162
|
+
getWebhookEventContracts() {
|
|
163
|
+
return webhookContracts().declared();
|
|
164
|
+
},
|
|
152
165
|
getEventUpcasters() {
|
|
153
166
|
return state.eventUpcasterMap;
|
|
154
167
|
},
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ROLES } from "../auth/roles.js";
|
|
2
|
+
import { bootRuleError } from "./boot-validator/boot-rule.js";
|
|
3
|
+
import { DEFINITION_ROLE_ASSIGNMENT_RULES } from "./boot-validator/definition-role-assignment-rules.js";
|
|
2
4
|
import { EXT_ASSIGNABLE_ROLE } from "./extension-names.js";
|
|
3
5
|
import { isForbiddenMembershipRole } from "./membership-roles.js";
|
|
4
6
|
const PLATFORM_ROLE_NAMES = new Set(Object.values(ROLES));
|
|
@@ -39,25 +41,35 @@ export function assignableAppRolesFromUsages(usages) {
|
|
|
39
41
|
for (const usage of usages) {
|
|
40
42
|
const role = usage.entityName;
|
|
41
43
|
if (role === "") {
|
|
42
|
-
throw
|
|
44
|
+
throw bootRuleError(DEFINITION_ROLE_ASSIGNMENT_RULES.nameEmpty, {
|
|
45
|
+
message: "assignableRole: role name must not be empty",
|
|
46
|
+
});
|
|
43
47
|
}
|
|
44
48
|
// Platform roles (TenantOwner, DataProtectionOfficer) gate handlers that
|
|
45
49
|
// TenantAdmin/Admin cannot reach — declaring one would let an Admin
|
|
46
50
|
// self-grant it, so they stay out of reach of app declarations.
|
|
47
51
|
if (ROLE_RANKS.has(role) || PLATFORM_ROLE_NAMES.has(role)) {
|
|
48
|
-
throw
|
|
52
|
+
throw bootRuleError(DEFINITION_ROLE_ASSIGNMENT_RULES.builtIn, {
|
|
53
|
+
message: `assignableRole: "${role}" is a built-in role and cannot be redeclared`,
|
|
54
|
+
});
|
|
49
55
|
}
|
|
50
56
|
if (isForbiddenMembershipRole(role)) {
|
|
51
|
-
throw
|
|
57
|
+
throw bootRuleError(DEFINITION_ROLE_ASSIGNMENT_RULES.reservedMembership, {
|
|
58
|
+
message: `assignableRole: "${role}" is a reserved role and cannot be a membership role`,
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
const declaredAssignableFrom = usage.options?.["assignableFrom"];
|
|
54
62
|
if (declaredAssignableFrom !== undefined && !isAssignableFromRole(declaredAssignableFrom)) {
|
|
55
|
-
throw
|
|
63
|
+
throw bootRuleError(DEFINITION_ROLE_ASSIGNMENT_RULES.assignableFromInvalid, {
|
|
64
|
+
message: `assignableRole: "${role}" has invalid assignableFrom, expected one of ${[...ASSIGNABLE_FROM_ROLES].join(", ")}`,
|
|
65
|
+
});
|
|
56
66
|
}
|
|
57
67
|
const assignableFrom = declaredAssignableFrom ?? DEFAULT_APP_ROLE_ASSIGNABLE_FROM;
|
|
58
68
|
const existing = result.get(role);
|
|
59
69
|
if (existing !== undefined && existing !== assignableFrom) {
|
|
60
|
-
throw
|
|
70
|
+
throw bootRuleError(DEFINITION_ROLE_ASSIGNMENT_RULES.assignableFromConflict, {
|
|
71
|
+
message: `assignableRole: "${role}" is declared with conflicting assignableFrom (${existing} vs ${assignableFrom})`,
|
|
72
|
+
});
|
|
61
73
|
}
|
|
62
74
|
result.set(role, assignableFrom);
|
|
63
75
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WebhookEventContract } from "@cosmicdrift/kumiko-types/feature";
|
|
2
|
+
import type { FeatureDefinition } from "./types/index.ts";
|
|
3
|
+
export type WebhookContractResolver = {
|
|
4
|
+
/** Declared contract, or one derived from an entity lifecycle event (`entity.verb`). */
|
|
5
|
+
get(qualifiedName: string): WebhookEventContract | undefined;
|
|
6
|
+
/** Declared contracts only, sorted by QN. */
|
|
7
|
+
declared(): readonly WebhookEventContract[];
|
|
8
|
+
};
|
|
9
|
+
/** Works on the feature list so a boot check, which has no registry, resolves the same contracts. */
|
|
10
|
+
export declare function createWebhookContractResolver(features: readonly FeatureDefinition[]): WebhookContractResolver;
|
|
11
|
+
/** Receivers tell events apart by wire name, so two contracts must never share one. */
|
|
12
|
+
export declare function assertUniqueWebhookWireNames(features: readonly FeatureDefinition[]): void;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { DEFAULT_CURRENCIES } from "./field-helpers.js";
|
|
3
|
+
import { personalFieldNames } from "./personal-data-fields.js";
|
|
4
|
+
import { fieldToZod } from "./schema-builder.js";
|
|
5
|
+
const ENTITY_VERBS = ["created", "updated", "deleted"];
|
|
6
|
+
const CONTRACT_VERSION = 1;
|
|
7
|
+
// money and locatedTimestamp are stored as several flat columns (amount plus currency, instant
|
|
8
|
+
// plus zone); the event shape of such a field is not mapped yet, so they stay out instead of
|
|
9
|
+
// being described wrongly.
|
|
10
|
+
const COMPOUND_FIELD_TYPES = new Set([
|
|
11
|
+
"money",
|
|
12
|
+
"locatedTimestamp",
|
|
13
|
+
]);
|
|
14
|
+
function isEncryptedText(field) {
|
|
15
|
+
return (field.type === "text" || field.type === "longText") && field.encrypted === true;
|
|
16
|
+
}
|
|
17
|
+
function isSecretText(field) {
|
|
18
|
+
return field.type === "text" && field.writeOnly === true;
|
|
19
|
+
}
|
|
20
|
+
function isSensitive(field) {
|
|
21
|
+
return "sensitive" in field && field.sensitive === true;
|
|
22
|
+
}
|
|
23
|
+
// A webhook leaves the system: credentials, client addresses, restricted-read fields and system-written
|
|
24
|
+
// plaintext fields stay out even when not personal. `allowPlaintext` is a plain string, hence the patterns.
|
|
25
|
+
const NEVER_RELEASED_NAME = /hash|secret|token|password|passcode|totp|recovery|salt|storagekey|fromip|useragent/i;
|
|
26
|
+
const CREDENTIAL_REASON = /credential|hash|secret|token/i;
|
|
27
|
+
function plaintextReason(field) {
|
|
28
|
+
return "allowPlaintext" in field && typeof field.allowPlaintext === "string"
|
|
29
|
+
? field.allowPlaintext
|
|
30
|
+
: undefined;
|
|
31
|
+
}
|
|
32
|
+
function hasRestrictedAccess(field, mode) {
|
|
33
|
+
return "access" in field && field.access?.[mode] !== undefined;
|
|
34
|
+
}
|
|
35
|
+
function isCredentialOrInternal(name, field) {
|
|
36
|
+
const reason = plaintextReason(field);
|
|
37
|
+
return (hasRestrictedAccess(field, "read") ||
|
|
38
|
+
(reason !== undefined && hasRestrictedAccess(field, "write")) ||
|
|
39
|
+
NEVER_RELEASED_NAME.test(name) ||
|
|
40
|
+
(reason !== undefined && CREDENTIAL_REASON.test(reason)));
|
|
41
|
+
}
|
|
42
|
+
function releasableFields(entity, excludedFields) {
|
|
43
|
+
const personal = personalFieldNames(entity, false);
|
|
44
|
+
return Object.entries(entity.fields).filter(([name, field]) => !personal.has(name) &&
|
|
45
|
+
!excludedFields.has(name) &&
|
|
46
|
+
!COMPOUND_FIELD_TYPES.has(field.type) &&
|
|
47
|
+
!isEncryptedText(field) &&
|
|
48
|
+
!isSecretText(field) &&
|
|
49
|
+
!isSensitive(field) &&
|
|
50
|
+
!isCredentialOrInternal(name, field));
|
|
51
|
+
}
|
|
52
|
+
function isAlwaysPresent(field) {
|
|
53
|
+
return (("required" in field && field.required === true) ||
|
|
54
|
+
("default" in field && field.default !== undefined));
|
|
55
|
+
}
|
|
56
|
+
function fieldShape(fields, presence) {
|
|
57
|
+
return Object.fromEntries(fields.map(([name, field]) => {
|
|
58
|
+
const schema = fieldToZod(field, DEFAULT_CURRENCIES, { applyDefaults: false });
|
|
59
|
+
const required = presence === "as-declared" && isAlwaysPresent(field);
|
|
60
|
+
return [name, required ? schema : schema.nullable().optional()];
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
// The executor appends `changes` and `previous` (the whole pre-update row, which always has `id`)
|
|
64
|
+
// on update and `{ previous }` on delete; create appends the flat fields without `id`. Receivers
|
|
65
|
+
// need the id, so the contract carries it on the top level; `toEntityWebhookPayload` takes it from
|
|
66
|
+
// the event's aggregate id.
|
|
67
|
+
function payloadFor(verb, fields) {
|
|
68
|
+
const row = z.object({ id: z.uuid(), ...fieldShape(fields, "optional") });
|
|
69
|
+
if (verb === "created")
|
|
70
|
+
return z.object({ id: z.uuid(), ...fieldShape(fields, "as-declared") });
|
|
71
|
+
if (verb === "updated")
|
|
72
|
+
return z.object({
|
|
73
|
+
id: z.uuid(),
|
|
74
|
+
changes: z.object(fieldShape(fields, "optional")),
|
|
75
|
+
previous: row,
|
|
76
|
+
});
|
|
77
|
+
return z.object({ id: z.uuid(), previous: row });
|
|
78
|
+
}
|
|
79
|
+
const VERB_DESCRIPTION = {
|
|
80
|
+
created: "was created",
|
|
81
|
+
updated: "was updated",
|
|
82
|
+
deleted: "was deleted",
|
|
83
|
+
};
|
|
84
|
+
function entityContract(entityName, verb, entity, excludedFields) {
|
|
85
|
+
return {
|
|
86
|
+
qn: `${entityName}.${verb}`,
|
|
87
|
+
wireName: `${entityName}.${verb}`,
|
|
88
|
+
description: `A ${entityName} ${VERB_DESCRIPTION[verb]}.`,
|
|
89
|
+
payload: payloadFor(verb, releasableFields(entity, excludedFields)),
|
|
90
|
+
version: CONTRACT_VERSION,
|
|
91
|
+
origin: "entity",
|
|
92
|
+
entity: entityName,
|
|
93
|
+
verb,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function excludedFieldsByEntity(features) {
|
|
97
|
+
const byEntity = new Map();
|
|
98
|
+
for (const feature of features) {
|
|
99
|
+
for (const [handlerName, handler] of Object.entries(feature.writeHandlers)) {
|
|
100
|
+
const entityName = feature.handlerEntityMappings[handlerName];
|
|
101
|
+
if (entityName === undefined || handler.excludedFields === undefined)
|
|
102
|
+
continue;
|
|
103
|
+
const names = byEntity.get(entityName) ?? new Set();
|
|
104
|
+
for (const field of handler.excludedFields)
|
|
105
|
+
names.add(field);
|
|
106
|
+
byEntity.set(entityName, names);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return byEntity;
|
|
110
|
+
}
|
|
111
|
+
function entityVerbOf(qualifiedName) {
|
|
112
|
+
const dot = qualifiedName.lastIndexOf(".");
|
|
113
|
+
if (dot <= 0)
|
|
114
|
+
return undefined;
|
|
115
|
+
const verb = ENTITY_VERBS.find((candidate) => candidate === qualifiedName.slice(dot + 1));
|
|
116
|
+
return verb === undefined ? undefined : { entity: qualifiedName.slice(0, dot), verb };
|
|
117
|
+
}
|
|
118
|
+
/** Works on the feature list so a boot check, which has no registry, resolves the same contracts. */
|
|
119
|
+
export function createWebhookContractResolver(features) {
|
|
120
|
+
const declared = new Map();
|
|
121
|
+
const entities = new Map();
|
|
122
|
+
for (const feature of features) {
|
|
123
|
+
for (const def of Object.values(feature.webhookEvents ?? {})) {
|
|
124
|
+
declared.set(def.qn, { ...def, origin: "declared" });
|
|
125
|
+
}
|
|
126
|
+
for (const [name, entity] of Object.entries(feature.entities ?? {}))
|
|
127
|
+
entities.set(name, entity);
|
|
128
|
+
}
|
|
129
|
+
const excluded = excludedFieldsByEntity(features);
|
|
130
|
+
const derived = new Map();
|
|
131
|
+
return {
|
|
132
|
+
get(qualifiedName) {
|
|
133
|
+
const own = declared.get(qualifiedName);
|
|
134
|
+
if (own !== undefined)
|
|
135
|
+
return own;
|
|
136
|
+
if (!derived.has(qualifiedName)) {
|
|
137
|
+
const target = entityVerbOf(qualifiedName);
|
|
138
|
+
const entity = target === undefined ? undefined : entities.get(target.entity);
|
|
139
|
+
derived.set(qualifiedName, target === undefined || entity === undefined || entity.webhookEvents !== true
|
|
140
|
+
? undefined
|
|
141
|
+
: entityContract(target.entity, target.verb, entity, excluded.get(target.entity) ?? new Set()));
|
|
142
|
+
}
|
|
143
|
+
return derived.get(qualifiedName);
|
|
144
|
+
},
|
|
145
|
+
declared() {
|
|
146
|
+
return [...declared.values()].sort((a, b) => (a.qn < b.qn ? -1 : a.qn > b.qn ? 1 : 0));
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Receivers tell events apart by wire name, so two contracts must never share one. */
|
|
151
|
+
export function assertUniqueWebhookWireNames(features) {
|
|
152
|
+
const qnByWireName = new Map();
|
|
153
|
+
const claim = (wireName, qn) => {
|
|
154
|
+
const existing = qnByWireName.get(wireName);
|
|
155
|
+
if (existing !== undefined && existing !== qn) {
|
|
156
|
+
throw new Error(`Webhook wire name "${wireName}" is used by both "${existing}" and "${qn}"; give one of them another wireName.`);
|
|
157
|
+
}
|
|
158
|
+
qnByWireName.set(wireName, qn);
|
|
159
|
+
};
|
|
160
|
+
for (const feature of features) {
|
|
161
|
+
for (const def of Object.values(feature.webhookEvents ?? {}))
|
|
162
|
+
claim(def.wireName, def.qn);
|
|
163
|
+
}
|
|
164
|
+
for (const feature of features) {
|
|
165
|
+
for (const [name, entity] of Object.entries(feature.entities ?? {})) {
|
|
166
|
+
if (entity.webhookEvents !== true)
|
|
167
|
+
continue;
|
|
168
|
+
for (const verb of ENTITY_VERBS)
|
|
169
|
+
claim(`${name}.${verb}`, `${name}.${verb}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { WebhookEventContract, WebhookEventHandle } from "@cosmicdrift/kumiko-types/feature";
|
|
2
|
+
import { ZodObject } from "zod";
|
|
3
|
+
import type { FeatureBuilderState } from "./feature-builder-state.ts";
|
|
4
|
+
export type WebhookPayloadIssue = {
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
};
|
|
8
|
+
export type WebhookPayloadResult = {
|
|
9
|
+
readonly ok: true;
|
|
10
|
+
readonly payload: Record<string, unknown>;
|
|
11
|
+
} | {
|
|
12
|
+
readonly ok: false;
|
|
13
|
+
readonly issues: readonly WebhookPayloadIssue[];
|
|
14
|
+
};
|
|
15
|
+
/** Delivery sends the returned payload, never the input: zod strips keys the contract does not
|
|
16
|
+
* declare, so a field added to the source row cannot leak into a webhook by accident. */
|
|
17
|
+
export declare function parseWebhookPayload(contract: Pick<WebhookEventContract, "payload">, payload: unknown): WebhookPayloadResult;
|
|
18
|
+
/** Maps a stored entity lifecycle event to the contract's payload: the aggregate id joins the
|
|
19
|
+
* event payload, and the contract parse drops every field it does not release, personal ones
|
|
20
|
+
* included, even when the event payload carries them. */
|
|
21
|
+
export declare function toEntityWebhookPayload(contract: Pick<WebhookEventContract, "payload" | "verb">, event: {
|
|
22
|
+
readonly aggregateId: string;
|
|
23
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
24
|
+
}): WebhookPayloadResult;
|
|
25
|
+
export declare function formatWebhookPayloadIssues(issues: readonly WebhookPayloadIssue[]): string;
|
|
26
|
+
export declare function buildWebhookEventMethods(state: FeatureBuilderState, featureName: string): {
|
|
27
|
+
defineWebhookEvent(definition: {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly description: string;
|
|
30
|
+
readonly payload: ZodObject;
|
|
31
|
+
readonly version: number;
|
|
32
|
+
readonly wireName?: string;
|
|
33
|
+
}): WebhookEventHandle;
|
|
34
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ZodObject } from "zod";
|
|
2
|
+
import { bootRuleError } from "./boot-validator/boot-rule.js";
|
|
3
|
+
import { DEFINITION_WEBHOOK_EVENT_RULES } from "./boot-validator/definition-webhook-events-rules.js";
|
|
4
|
+
import { isObjectArgument, throwObjectArgumentRequired } from "./object-form.js";
|
|
5
|
+
import { isKebabSegment, toKebab } from "./qualified-name.js";
|
|
6
|
+
/** Delivery sends the returned payload, never the input: zod strips keys the contract does not
|
|
7
|
+
* declare, so a field added to the source row cannot leak into a webhook by accident. */
|
|
8
|
+
export function parseWebhookPayload(contract, payload) {
|
|
9
|
+
const parsed = contract.payload.safeParse(payload);
|
|
10
|
+
if (parsed.success)
|
|
11
|
+
return { ok: true, payload: parsed.data };
|
|
12
|
+
return {
|
|
13
|
+
ok: false,
|
|
14
|
+
issues: parsed.error.issues.map((issue) => ({
|
|
15
|
+
path: issue.path.map(String).join("."),
|
|
16
|
+
message: issue.message,
|
|
17
|
+
})),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Maps a stored entity lifecycle event to the contract's payload: the aggregate id joins the
|
|
21
|
+
* event payload, and the contract parse drops every field it does not release, personal ones
|
|
22
|
+
* included, even when the event payload carries them. */
|
|
23
|
+
export function toEntityWebhookPayload(contract, event) {
|
|
24
|
+
const { aggregateId, payload } = event;
|
|
25
|
+
const shaped = contract.verb === "created"
|
|
26
|
+
? { ...payload, id: aggregateId }
|
|
27
|
+
: { id: aggregateId, changes: payload["changes"], previous: payload["previous"] };
|
|
28
|
+
return parseWebhookPayload(contract, shaped);
|
|
29
|
+
}
|
|
30
|
+
export function formatWebhookPayloadIssues(issues) {
|
|
31
|
+
return issues
|
|
32
|
+
.map((issue) => `${issue.path === "" ? "(root)" : issue.path}: ${issue.message}`)
|
|
33
|
+
.join("; ");
|
|
34
|
+
}
|
|
35
|
+
export function buildWebhookEventMethods(state, featureName) {
|
|
36
|
+
return {
|
|
37
|
+
defineWebhookEvent(definition) {
|
|
38
|
+
if (!isObjectArgument(definition))
|
|
39
|
+
throwObjectArgumentRequired(featureName, "defineWebhookEvent");
|
|
40
|
+
const { name, description, payload, version } = definition;
|
|
41
|
+
const where = `[Feature ${featureName}] defineWebhookEvent`;
|
|
42
|
+
if (typeof name !== "string" || !isKebabSegment(name)) {
|
|
43
|
+
throw bootRuleError(DEFINITION_WEBHOOK_EVENT_RULES.nameNotKebab, {
|
|
44
|
+
message: `${where}: name must be kebab-case, got ${JSON.stringify(name)}`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (typeof description !== "string" || description.trim() === "") {
|
|
48
|
+
throw bootRuleError(DEFINITION_WEBHOOK_EVENT_RULES.descriptionEmpty, {
|
|
49
|
+
message: `${where}("${name}"): description must be a non-empty sentence`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!(payload instanceof ZodObject)) {
|
|
53
|
+
throw bootRuleError(DEFINITION_WEBHOOK_EVENT_RULES.payloadNotZodObject, {
|
|
54
|
+
message: `${where}("${name}"): payload must be a zod object schema`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (!Number.isInteger(version) || version < 1) {
|
|
58
|
+
throw bootRuleError(DEFINITION_WEBHOOK_EVENT_RULES.versionInvalid, {
|
|
59
|
+
message: `${where}("${name}"): version must be a positive integer`,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (definition.wireName !== undefined &&
|
|
63
|
+
(typeof definition.wireName !== "string" || definition.wireName.trim() === "")) {
|
|
64
|
+
throw bootRuleError(DEFINITION_WEBHOOK_EVENT_RULES.wireNameEmpty, {
|
|
65
|
+
message: `${where}("${name}"): wireName must be a non-empty string`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const wireName = definition.wireName?.trim() ?? name;
|
|
69
|
+
const qn = `${toKebab(featureName)}:${name}`;
|
|
70
|
+
if (state.webhookEvents[qn] !== undefined) {
|
|
71
|
+
throw bootRuleError(DEFINITION_WEBHOOK_EVENT_RULES.duplicate, {
|
|
72
|
+
message: `${where}("${name}"): already registered in this feature`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
state.webhookEvents[qn] = {
|
|
76
|
+
qn,
|
|
77
|
+
wireName,
|
|
78
|
+
description: description.trim(),
|
|
79
|
+
payload,
|
|
80
|
+
version,
|
|
81
|
+
};
|
|
82
|
+
return { name: qn, payload, version };
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
package/dist/errors/docs-url.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { frameworkErrorHttpStatus } from "./error-codes.js";
|
|
1
2
|
import { AgentReasons, FrameworkReasons } from "./reasons.js";
|
|
2
3
|
const DEFAULT_DOCS_BASE_URL = "https://docs.kumiko.rocks";
|
|
3
4
|
const REASON_SLUG_RE = /^[a-z0-9_.-]+$/;
|
|
@@ -6,25 +7,7 @@ const frameworkReasons = new Set([
|
|
|
6
7
|
...Object.values(AgentReasons),
|
|
7
8
|
]);
|
|
8
9
|
// Codes of the built-in error classes: only these have a framework docs page.
|
|
9
|
-
const frameworkErrorCodes = new Set(
|
|
10
|
-
"validation_error",
|
|
11
|
-
"feature_disabled",
|
|
12
|
-
"access_denied",
|
|
13
|
-
"unauthenticated",
|
|
14
|
-
"not_found",
|
|
15
|
-
"conflict",
|
|
16
|
-
"version_conflict",
|
|
17
|
-
"precondition_failed",
|
|
18
|
-
"record_locked",
|
|
19
|
-
"idempotent_replay",
|
|
20
|
-
"unique_violation",
|
|
21
|
-
"unprocessable",
|
|
22
|
-
"unconfigured",
|
|
23
|
-
"internal_error",
|
|
24
|
-
"member_read_timeout",
|
|
25
|
-
"rate_limited",
|
|
26
|
-
"rate_limit_unavailable",
|
|
27
|
-
]);
|
|
10
|
+
const frameworkErrorCodes = new Set(Object.keys(frameworkErrorHttpStatus));
|
|
28
11
|
function reasonOf(err) {
|
|
29
12
|
if (!err.details || typeof err.details !== "object")
|
|
30
13
|
return undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const frameworkErrorHttpStatus: {
|
|
2
|
+
readonly validation_error: 400;
|
|
3
|
+
readonly feature_disabled: 403;
|
|
4
|
+
readonly access_denied: 403;
|
|
5
|
+
readonly unauthenticated: 401;
|
|
6
|
+
readonly not_found: 404;
|
|
7
|
+
readonly conflict: 409;
|
|
8
|
+
readonly version_conflict: 409;
|
|
9
|
+
readonly precondition_failed: 409;
|
|
10
|
+
readonly record_locked: 409;
|
|
11
|
+
readonly idempotent_replay: 409;
|
|
12
|
+
readonly unique_violation: 409;
|
|
13
|
+
readonly unprocessable: 422;
|
|
14
|
+
readonly unconfigured: 422;
|
|
15
|
+
readonly internal_error: 500;
|
|
16
|
+
readonly member_read_timeout: 504;
|
|
17
|
+
readonly rate_limited: 429;
|
|
18
|
+
readonly rate_limit_unavailable: 503;
|
|
19
|
+
};
|
|
20
|
+
export type FrameworkErrorCode = keyof typeof frameworkErrorHttpStatus;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const frameworkErrorHttpStatus = {
|
|
2
|
+
validation_error: 400,
|
|
3
|
+
feature_disabled: 403,
|
|
4
|
+
access_denied: 403,
|
|
5
|
+
unauthenticated: 401,
|
|
6
|
+
not_found: 404,
|
|
7
|
+
conflict: 409,
|
|
8
|
+
version_conflict: 409,
|
|
9
|
+
precondition_failed: 409,
|
|
10
|
+
record_locked: 409,
|
|
11
|
+
idempotent_replay: 409,
|
|
12
|
+
unique_violation: 409,
|
|
13
|
+
unprocessable: 422,
|
|
14
|
+
unconfigured: 422,
|
|
15
|
+
internal_error: 500,
|
|
16
|
+
member_read_timeout: 504,
|
|
17
|
+
rate_limited: 429,
|
|
18
|
+
rate_limit_unavailable: 503,
|
|
19
|
+
};
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type { FieldIssue } from "./classes.ts";
|
|
2
2
|
export { AccessDeniedError, ConflictError, FeatureDisabledError, InternalError, NotFoundError, RateLimitError, UnconfiguredError, UniqueViolationError, UnprocessableError, ValidationError, VersionConflictError, } from "./classes.ts";
|
|
3
3
|
export type { ErrorDocsConfig } from "./docs-url.ts";
|
|
4
|
+
export type { FrameworkErrorCode } from "./error-codes.ts";
|
|
5
|
+
export { frameworkErrorHttpStatus } from "./error-codes.ts";
|
|
4
6
|
export { isKumikoError, KumikoError } from "./kumiko-error.ts";
|
|
5
7
|
export { FrameworkReasons } from "./reasons.ts";
|
|
6
8
|
export { subjectErasedConflict } from "./subject-erased.ts";
|
package/dist/errors/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AccessDeniedError, ConflictError, FeatureDisabledError, InternalError, NotFoundError, RateLimitError, UnconfiguredError, UniqueViolationError, UnprocessableError, ValidationError, VersionConflictError, } from "./classes.js";
|
|
2
|
+
export { frameworkErrorHttpStatus } from "./error-codes.js";
|
|
2
3
|
export { isKumikoError, KumikoError } from "./kumiko-error.js";
|
|
3
4
|
export { FrameworkReasons } from "./reasons.js";
|
|
4
5
|
export { subjectErasedConflict } from "./subject-erased.js";
|
|
@@ -499,7 +499,7 @@ export function createFileRoutes(options) {
|
|
|
499
499
|
const meta = await loadReadableFileMeta(c.req.param("id"), getUser(c));
|
|
500
500
|
return meta ? c.json(meta) : c.json({ error: "not_found" }, 404);
|
|
501
501
|
});
|
|
502
|
-
// Read-only crossing: SYSTEM_TENANT_ID files (e.g.
|
|
502
|
+
// Read-only crossing: SYSTEM_TENANT_ID files (e.g. helpdesk attachments) are
|
|
503
503
|
// visible to a SystemAdmin whose session sits in another tenant. Delete,
|
|
504
504
|
// variant and upload keep using loadFileForTenant and stay tenant-equal.
|
|
505
505
|
async function loadReadableFileRef(id, user) {
|
|
@@ -14,6 +14,10 @@ export declare const PROJECTION_DETAIL_ENTITY = "__projection-detail__";
|
|
|
14
14
|
export declare const WRITE_FORM_SECTION_ENTITY = "__write-form-section__";
|
|
15
15
|
export declare function fieldLabelKey(featureName: string, entityName: string, fieldName: string): string;
|
|
16
16
|
export declare function handlerTitleKey(handlerQn: string): string;
|
|
17
|
+
export declare function handlerDescriptionKey(handlerQn: string): string;
|
|
18
|
+
export declare function webhookEventDescriptionKey(webhookEventQn: string): string;
|
|
19
|
+
/** `fieldPath` is the payload row name as the docs list it, nested fields dotted. */
|
|
20
|
+
export declare function webhookEventFieldKey(webhookEventQn: string, fieldPath: string): string;
|
|
17
21
|
export declare function handlerFieldLabelKey(handlerQn: string, fieldName: string): string;
|
|
18
22
|
export declare function booleanFacetOptionKeys(featureName: string, entityName: string, fieldName: string): readonly string[];
|
|
19
23
|
export declare function selectFacetOptionKey(featureName: string, entityName: string, fieldName: string, value: string): string;
|