@terreno/api 0.30.0 → 56.0.0-beta.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.d.ts +10 -0
- package/dist/api.js +110 -361
- package/dist/auth.d.ts +26 -0
- package/dist/auth.js +100 -1
- package/dist/betterAuth.d.ts +5 -0
- package/dist/betterAuthSetup.js +23 -4
- package/dist/docLoader.js +12 -9
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +29 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +29 -1
- package/dist/middleware.d.ts +7 -0
- package/dist/middleware.js +16 -1
- package/dist/openApiCompat.d.ts +10 -1
- package/dist/openApiCompat.js +115 -47
- package/dist/permissions.d.ts +27 -0
- package/dist/permissions.js +42 -1
- package/dist/plugins.d.ts +13 -0
- package/dist/plugins.js +35 -1
- package/dist/realtime/changeStreamWatcher.d.ts +100 -3
- package/dist/realtime/changeStreamWatcher.js +542 -137
- package/dist/realtime/realtimeApp.d.ts +2 -0
- package/dist/realtime/realtimeApp.js +73 -21
- package/dist/realtime/sessionRevalidation.d.ts +90 -0
- package/dist/realtime/sessionRevalidation.js +438 -0
- package/dist/realtime/socketAuth.d.ts +97 -0
- package/dist/realtime/socketAuth.js +272 -0
- package/dist/realtime/socketUser.d.ts +54 -0
- package/dist/realtime/socketUser.js +75 -5
- package/dist/realtime/types.d.ts +40 -0
- package/dist/secretProviders.d.ts +23 -0
- package/dist/secretProviders.js +9 -3
- package/dist/sync/executors.d.ts +198 -0
- package/dist/sync/executors.js +670 -0
- package/dist/sync/loadHarness.js +807 -0
- package/dist/sync/models.d.ts +216 -0
- package/dist/sync/models.js +644 -0
- package/dist/sync/mutationHandler.d.ts +97 -0
- package/dist/sync/mutationHandler.js +886 -0
- package/dist/sync/registry.d.ts +73 -0
- package/dist/sync/registry.js +223 -0
- package/dist/sync/routes.d.ts +62 -0
- package/dist/sync/routes.js +936 -0
- package/dist/sync/scripts/compactTombstones.d.ts +47 -0
- package/dist/sync/scripts/compactTombstones.js +270 -0
- package/dist/sync/serialize.d.ts +20 -0
- package/dist/{tests/bunSetup.js → sync/serialize.js} +35 -68
- package/dist/sync/socketHandlers.d.ts +54 -0
- package/dist/sync/socketHandlers.js +470 -0
- package/dist/sync/streams.d.ts +85 -0
- package/dist/sync/streams.js +221 -0
- package/dist/sync/syncApp.d.ts +29 -0
- package/dist/sync/syncApp.js +44 -0
- package/dist/sync/syncBatch.d.ts +71 -0
- package/dist/sync/syncBatch.js +252 -0
- package/dist/sync/syncSeqPlugin.d.ts +8 -0
- package/dist/sync/syncSeqPlugin.js +903 -0
- package/dist/sync/types.d.ts +254 -0
- package/dist/sync/types.js +9 -0
- package/dist/terrenoApp.js +90 -27
- package/dist/vendor/wesleytodd-openapi/index.d.ts +1 -1
- package/dist/vendor/wesleytodd-openapi/lib/ui.d.ts +2 -1
- package/package.json +7 -6
- package/src/__tests__/openApiCompat.test.ts +20 -0
- package/src/actions.openApi.test.ts +7 -10
- package/src/api.test.ts +12 -0
- package/src/api.ts +87 -295
- package/src/auth.test.ts +128 -176
- package/src/auth.ts +109 -0
- package/src/betterAuth.ts +6 -0
- package/src/betterAuthSetup.test.ts +34 -0
- package/src/betterAuthSetup.ts +20 -1
- package/src/docLoader.ts +3 -1
- package/src/errors.ts +33 -0
- package/src/expressServer.test.ts +7 -1
- package/src/index.ts +42 -0
- package/src/middleware.test.ts +40 -1
- package/src/middleware.ts +15 -0
- package/src/openApiCompat.ts +99 -45
- package/src/permissions.test.ts +75 -1
- package/src/permissions.ts +49 -0
- package/src/plugins.test.ts +54 -0
- package/src/plugins.ts +43 -0
- package/src/realtime/changeStreamWatcher.ts +552 -114
- package/src/realtime/realtime.test.ts +157 -0
- package/src/realtime/realtimeApp.ts +75 -11
- package/src/realtime/sessionRevalidation.test.ts +423 -0
- package/src/realtime/sessionRevalidation.ts +273 -0
- package/src/realtime/socketAuth.test.ts +355 -0
- package/src/realtime/socketAuth.ts +228 -0
- package/src/realtime/socketUser.ts +69 -0
- package/src/realtime/types.ts +40 -0
- package/src/secretProviders.test.ts +7 -1
- package/src/secretProviders.ts +15 -3
- package/src/sync/ensureSyncIndexes.test.ts +144 -0
- package/src/sync/executors.test.ts +882 -0
- package/src/sync/executors.ts +703 -0
- package/src/sync/integration.test.ts +1160 -0
- package/src/sync/loadHarness.ts +618 -0
- package/src/sync/models.ts +640 -0
- package/src/sync/mutationHandler.test.ts +1252 -0
- package/src/sync/mutationHandler.ts +850 -0
- package/src/sync/registry.ts +232 -0
- package/src/sync/routes.ts +812 -0
- package/src/sync/scripts/compactTombstones.test.ts +249 -0
- package/src/sync/scripts/compactTombstones.ts +145 -0
- package/src/sync/serialize.ts +48 -0
- package/src/sync/sessionRevalidationIntegration.test.ts +281 -0
- package/src/sync/socketHandlers.ts +320 -0
- package/src/sync/streams.ts +188 -0
- package/src/sync/sync.test.ts +582 -0
- package/src/sync/syncApp.ts +44 -0
- package/src/sync/syncBatch.ts +219 -0
- package/src/sync/syncFrontier.test.ts +494 -0
- package/src/sync/syncPhaseC.test.ts +718 -0
- package/src/sync/syncRoutes.test.ts +865 -0
- package/src/sync/syncSeqPlugin.ts +738 -0
- package/src/sync/syncSocket.test.ts +1440 -0
- package/src/sync/types.ts +270 -0
- package/src/terrenoApp.ts +37 -17
- package/src/tests/bunSetup.ts +8 -0
- package/tsconfig.json +4 -4
- package/tsconfig.typedoc.json +7 -1
- package/dist/__tests__/openApiCompat.test.js +0 -317
- package/dist/__tests__/versionCheckPlugin.test.d.ts +0 -1
- package/dist/__tests__/versionCheckPlugin.test.js +0 -597
- package/dist/actions.openApi.test.d.ts +0 -1
- package/dist/actions.openApi.test.js +0 -255
- package/dist/actions.test.d.ts +0 -1
- package/dist/actions.test.js +0 -1089
- package/dist/api.arrayOperations.test.d.ts +0 -1
- package/dist/api.arrayOperations.test.js +0 -878
- package/dist/api.asyncHandler.test.d.ts +0 -1
- package/dist/api.asyncHandler.test.js +0 -236
- package/dist/api.coverage.test.d.ts +0 -1
- package/dist/api.coverage.test.js +0 -194
- package/dist/api.errorPaths.test.d.ts +0 -1
- package/dist/api.errorPaths.test.js +0 -801
- package/dist/api.errors.test.d.ts +0 -1
- package/dist/api.errors.test.js +0 -185
- package/dist/api.hooks.test.d.ts +0 -1
- package/dist/api.hooks.test.js +0 -950
- package/dist/api.query.test.d.ts +0 -1
- package/dist/api.query.test.js +0 -948
- package/dist/api.test.d.ts +0 -1
- package/dist/api.test.js +0 -2820
- package/dist/auth.compile.test.d.ts +0 -1
- package/dist/auth.compile.test.js +0 -201
- package/dist/auth.coverage.test.d.ts +0 -1
- package/dist/auth.coverage.test.js +0 -202
- package/dist/auth.test.d.ts +0 -1
- package/dist/auth.test.js +0 -2286
- package/dist/betterAuth.test.d.ts +0 -1
- package/dist/betterAuth.test.js +0 -181
- package/dist/betterAuthApp.test.d.ts +0 -1
- package/dist/betterAuthApp.test.js +0 -242
- package/dist/betterAuthSetup.test.d.ts +0 -1
- package/dist/betterAuthSetup.test.js +0 -762
- package/dist/config.test.d.ts +0 -1
- package/dist/config.test.js +0 -353
- package/dist/configuration.test.d.ts +0 -1
- package/dist/configuration.test.js +0 -980
- package/dist/configurationPlugin.test.d.ts +0 -1
- package/dist/configurationPlugin.test.js +0 -827
- package/dist/consentApp.test.d.ts +0 -1
- package/dist/consentApp.test.js +0 -1415
- package/dist/docLoader.test.d.ts +0 -1
- package/dist/docLoader.test.js +0 -137
- package/dist/envConfigurationPlugin.test.d.ts +0 -1
- package/dist/envConfigurationPlugin.test.js +0 -369
- package/dist/errors.test.d.ts +0 -1
- package/dist/errors.test.js +0 -607
- package/dist/expressServer.test.d.ts +0 -1
- package/dist/expressServer.test.js +0 -1249
- package/dist/githubAuth.test.d.ts +0 -1
- package/dist/githubAuth.test.js +0 -1142
- package/dist/httpClient.test.d.ts +0 -1
- package/dist/httpClient.test.js +0 -1471
- package/dist/logger.test.d.ts +0 -1
- package/dist/logger.test.js +0 -685
- package/dist/middleware.test.d.ts +0 -1
- package/dist/middleware.test.js +0 -241
- package/dist/notifiers/googleChatNotifier.test.d.ts +0 -1
- package/dist/notifiers/googleChatNotifier.test.js +0 -298
- package/dist/notifiers/slackNotifier.test.d.ts +0 -1
- package/dist/notifiers/slackNotifier.test.js +0 -297
- package/dist/notifiers/zoomNotifier.test.d.ts +0 -1
- package/dist/notifiers/zoomNotifier.test.js +0 -373
- package/dist/openApi.test.d.ts +0 -1
- package/dist/openApi.test.js +0 -620
- package/dist/openApiBuilder.test.d.ts +0 -1
- package/dist/openApiBuilder.test.js +0 -601
- package/dist/openApiEtag.test.d.ts +0 -1
- package/dist/openApiEtag.test.js +0 -86
- package/dist/openApiValidator.test.d.ts +0 -1
- package/dist/openApiValidator.test.js +0 -761
- package/dist/permissions.middleware.test.d.ts +0 -1
- package/dist/permissions.middleware.test.js +0 -308
- package/dist/permissions.test.d.ts +0 -1
- package/dist/permissions.test.js +0 -439
- package/dist/plugins.test.d.ts +0 -1
- package/dist/plugins.test.js +0 -890
- package/dist/populate.test.d.ts +0 -1
- package/dist/populate.test.js +0 -373
- package/dist/realtime/realtime.test.d.ts +0 -10
- package/dist/realtime/realtime.test.js +0 -3982
- package/dist/requestContext.test.d.ts +0 -1
- package/dist/requestContext.test.js +0 -412
- package/dist/scriptRunner.test.d.ts +0 -1
- package/dist/scriptRunner.test.js +0 -386
- package/dist/secretProviders.test.d.ts +0 -1
- package/dist/secretProviders.test.js +0 -726
- package/dist/syncConsents.test.d.ts +0 -1
- package/dist/syncConsents.test.js +0 -522
- package/dist/terrenoApp.test.d.ts +0 -1
- package/dist/terrenoApp.test.js +0 -489
- package/dist/tests/bunSetup.d.ts +0 -1
- package/dist/tests/fixtures/compileAuthEntry.d.ts +0 -1
- package/dist/tests/fixtures/compileAuthEntry.js +0 -37
- package/dist/tests/testEnv.d.ts +0 -0
- package/dist/tests/testEnv.js +0 -6
- package/dist/transformers.test.d.ts +0 -1
- package/dist/transformers.test.js +0 -423
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -242
- /package/dist/{__tests__/openApiCompat.test.d.ts → sync/loadHarness.d.ts} +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport-agnostic CRUD executors extracted from modelRouter's Express handlers.
|
|
3
|
+
*
|
|
4
|
+
* These run the full write pipeline — method-level and object-level permission checks,
|
|
5
|
+
* the deprecated `transformer.transform`, pre/post hooks, Mongoose validation, population,
|
|
6
|
+
* and soft-delete semantics — without requiring an HTTP request/response. The REST handlers
|
|
7
|
+
* in `api.ts` are thin wrappers over these, and the sync mutation channel
|
|
8
|
+
* (`applySyncMutation`) calls them directly.
|
|
9
|
+
*
|
|
10
|
+
* Hook compatibility: ModelRouterOptions hooks receive an `express.Request`. When an
|
|
11
|
+
* executor is called without `req` (e.g. from the sync channel), a minimal stub object
|
|
12
|
+
* `{user}` is passed instead, cast to `express.Request`. Hooks that only read `req.user`
|
|
13
|
+
* keep working; hooks that read other request properties (headers, params, body) will see
|
|
14
|
+
* `undefined` for those. REST handlers always pass the real request through, so existing
|
|
15
|
+
* behavior over HTTP is unchanged.
|
|
16
|
+
*/
|
|
17
|
+
import type express from "express";
|
|
18
|
+
import type { Document, Model } from "mongoose";
|
|
19
|
+
import { type ModelRouterOptions } from "../api";
|
|
20
|
+
import type { User } from "../auth";
|
|
21
|
+
import { APIError, type APIErrorConstructor } from "../errors";
|
|
22
|
+
/** A hydrated mongoose document joined with the router's base type. */
|
|
23
|
+
export type ExecutorDoc<T> = Document<unknown, unknown, unknown> & T;
|
|
24
|
+
/** Result of a successful executor run. */
|
|
25
|
+
export interface ExecutorResult<T> {
|
|
26
|
+
/**
|
|
27
|
+
* The document after the operation completed: the created doc, the saved update, or the
|
|
28
|
+
* deleted doc (tombstoned with `deleted: true` for soft-delete models). Populated per
|
|
29
|
+
* `options.populatePaths` for create/update, matching the REST handlers.
|
|
30
|
+
*/
|
|
31
|
+
doc: ExecutorDoc<T>;
|
|
32
|
+
/**
|
|
33
|
+
* C5 (FIX 6): present only when `executeUpdate` was called with
|
|
34
|
+
* `skipPostHooks: true` — the cleaned/transformed update body, needed to
|
|
35
|
+
* run `postUpdate` later via `runPostUpdate`.
|
|
36
|
+
*/
|
|
37
|
+
cleanedBody?: Partial<T>;
|
|
38
|
+
/**
|
|
39
|
+
* C5 (FIX 6): present only when `executeUpdate` was called with
|
|
40
|
+
* `skipPostHooks: true` — the pre-update document snapshot, needed to
|
|
41
|
+
* run `postUpdate` later via `runPostUpdate`.
|
|
42
|
+
*/
|
|
43
|
+
prevDoc?: T;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Optimistic-concurrency check for executeUpdate.
|
|
47
|
+
*
|
|
48
|
+
* - `timestamp`: replicates the REST `If-Unmodified-Since` last-write-wins check. The update
|
|
49
|
+
* is rejected with an `ExecutorConflictError` (409) when `ifUnmodifiedSince` is older than
|
|
50
|
+
* the document's `updated` (falling back to `created`) timestamp. An invalid Date throws a
|
|
51
|
+
* 400 "Invalid conflict-detection timestamp" carrying `invalidTimestampDetail` so REST
|
|
52
|
+
* handlers can report which header/body field failed to parse.
|
|
53
|
+
* - `seq`: compares `baseSeq` against the document's `_syncSeq`; any mismatch throws an
|
|
54
|
+
* `ExecutorConflictError` (409) carrying the current server doc and seq.
|
|
55
|
+
*
|
|
56
|
+
* The check runs after `preUpdate` (same as the REST handler) so unauthorized mutations are
|
|
57
|
+
* rejected before document data can leak in a conflict response.
|
|
58
|
+
*/
|
|
59
|
+
export type ExecutorConcurrencyCheck = {
|
|
60
|
+
type: "timestamp";
|
|
61
|
+
/** Reject the update if the doc was modified after this instant. */
|
|
62
|
+
ifUnmodifiedSince: Date;
|
|
63
|
+
/** Detail for the 400 error when `ifUnmodifiedSince` is an invalid Date. */
|
|
64
|
+
invalidTimestampDetail?: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: "seq";
|
|
67
|
+
/** The `_syncSeq` the client last saw; must match the doc's current `_syncSeq`. */
|
|
68
|
+
baseSeq: number;
|
|
69
|
+
};
|
|
70
|
+
interface ExecutorConflictErrorConstructor extends APIErrorConstructor {
|
|
71
|
+
conflictType: "timestamp" | "seq";
|
|
72
|
+
doc: unknown;
|
|
73
|
+
serverSeq?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Thrown by executeUpdate when a concurrency check fails. Carries the current server document
|
|
77
|
+
* (canonical copy) so callers can serialize it into a conflict response: the REST handler
|
|
78
|
+
* turns timestamp conflicts into the legacy 409 `{data, error, message}` body, and the sync
|
|
79
|
+
* mutation channel returns the doc + seq in its conflict nack.
|
|
80
|
+
*/
|
|
81
|
+
export declare class ExecutorConflictError extends APIError {
|
|
82
|
+
/** Which concurrency mode detected the conflict. */
|
|
83
|
+
conflictType: "timestamp" | "seq";
|
|
84
|
+
/** The current server document at conflict time. */
|
|
85
|
+
doc: unknown;
|
|
86
|
+
/** The doc's `_syncSeq` at conflict time (seq mode only). */
|
|
87
|
+
serverSeq?: number;
|
|
88
|
+
constructor({ conflictType, doc, serverSeq, ...apiErrorData }: ExecutorConflictErrorConstructor);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Duck-typed guard for {@link ExecutorConflictError}. The package compiles to ES5, where
|
|
92
|
+
* TypeScript's emit for classes extending built-ins (Error) breaks the prototype chain, so
|
|
93
|
+
* `instanceof` returns false for consumers running the compiled dist (bun running the TS
|
|
94
|
+
* source directly is unaffected — which is why unit/integration tests never caught it).
|
|
95
|
+
* Always use this guard instead of `instanceof ExecutorConflictError`.
|
|
96
|
+
*/
|
|
97
|
+
export declare const isExecutorConflictError: (error: unknown) => error is ExecutorConflictError;
|
|
98
|
+
/**
|
|
99
|
+
* True for the Mongoose error thrown when an `optimisticConcurrency` save matched no
|
|
100
|
+
* document (its `__v` filter failed) — i.e. another write landed since the load.
|
|
101
|
+
* Name-checked rather than `instanceof` for the same ES5-dist reason as
|
|
102
|
+
* {@link isExecutorConflictError}.
|
|
103
|
+
*/
|
|
104
|
+
export declare const isVersionError: (error: unknown) => boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Create a document through the same pipeline as `POST /`: method-level permissions,
|
|
107
|
+
* `transformer.transform`, `preCreate`, `Model.create` (Mongoose validation), population,
|
|
108
|
+
* and `postCreate`. Throws APIErrors with the same statuses/titles as the REST handler.
|
|
109
|
+
*/
|
|
110
|
+
export declare const executeCreate: <T>({ model, options, user, body, req, skipPostHooks, }: {
|
|
111
|
+
model: Model<T>;
|
|
112
|
+
options: ModelRouterOptions<T>;
|
|
113
|
+
user?: User;
|
|
114
|
+
body: unknown;
|
|
115
|
+
/** The real Express request when called over HTTP; hooks receive a `{user}` stub otherwise. */
|
|
116
|
+
req?: express.Request;
|
|
117
|
+
/**
|
|
118
|
+
* C5 (FIX 6): when true, skip the built-in `postCreate` call — the caller
|
|
119
|
+
* (the sync mutation handler) runs it manually AFTER finalizing the
|
|
120
|
+
* idempotency ledger `applied`, so a post-hook throw can never make a
|
|
121
|
+
* committed write look like a failure. REST handlers never set this.
|
|
122
|
+
*/
|
|
123
|
+
skipPostHooks?: boolean;
|
|
124
|
+
}) => Promise<ExecutorResult<T>>;
|
|
125
|
+
/**
|
|
126
|
+
* C5 (FIX 6): run `postCreate` outside the write transaction/ledger-finalize
|
|
127
|
+
* window. Errors are the caller's responsibility to catch — the sync mutation
|
|
128
|
+
* handler logs them and reports a warning, never converting them into a nack
|
|
129
|
+
* (the document write already committed and the ledger already finalized
|
|
130
|
+
* `applied`).
|
|
131
|
+
*/
|
|
132
|
+
export declare const runPostCreate: <T>({ doc, options, request, }: {
|
|
133
|
+
doc: ExecutorDoc<T>;
|
|
134
|
+
options: ModelRouterOptions<T>;
|
|
135
|
+
request: express.Request;
|
|
136
|
+
}) => Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Update a document through the same pipeline as `PATCH /:id`: method-level and object-level
|
|
139
|
+
* permissions, doc loading (404), `transformer.transform`, `_updatedAt` stripping,
|
|
140
|
+
* `preUpdate`, the optional concurrency check, `doc.set` + `doc.save` (Mongoose validation),
|
|
141
|
+
* population, and `postUpdate`. Throws APIErrors with the same statuses/titles as the REST
|
|
142
|
+
* handler; concurrency conflicts throw `ExecutorConflictError` (409) carrying the server doc.
|
|
143
|
+
*/
|
|
144
|
+
export declare const executeUpdate: <T>({ model, options, user, id, body, concurrencyCheck, existingDoc, req, skipPostHooks, }: {
|
|
145
|
+
model: Model<T>;
|
|
146
|
+
options: ModelRouterOptions<T>;
|
|
147
|
+
user?: User;
|
|
148
|
+
id: string;
|
|
149
|
+
body: unknown;
|
|
150
|
+
concurrencyCheck?: ExecutorConcurrencyCheck;
|
|
151
|
+
/**
|
|
152
|
+
* Pre-loaded document, used by the REST handler where permissionMiddleware already loaded
|
|
153
|
+
* and authorized it (avoids a second fetch). Permission checks still run either way.
|
|
154
|
+
*/
|
|
155
|
+
existingDoc?: ExecutorDoc<T>;
|
|
156
|
+
/** The real Express request when called over HTTP; hooks receive a `{user}` stub otherwise. */
|
|
157
|
+
req?: express.Request;
|
|
158
|
+
/** C5 (FIX 6): see `executeCreate`'s `skipPostHooks` doc comment. */
|
|
159
|
+
skipPostHooks?: boolean;
|
|
160
|
+
}) => Promise<ExecutorResult<T>>;
|
|
161
|
+
/** C5 (FIX 6): run `postUpdate` outside the write/ledger-finalize window — see `runPostCreate`. */
|
|
162
|
+
export declare const runPostUpdate: <T>({ doc, cleanedBody, prevDoc, options, request, }: {
|
|
163
|
+
doc: ExecutorDoc<T>;
|
|
164
|
+
cleanedBody: Partial<T>;
|
|
165
|
+
prevDoc: T;
|
|
166
|
+
options: ModelRouterOptions<T>;
|
|
167
|
+
request: express.Request;
|
|
168
|
+
}) => Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Delete a document through the same pipeline as `DELETE /:id`: method-level and object-level
|
|
171
|
+
* permissions, doc loading (404), `preDelete`, soft delete (`deleted = true` + save when the
|
|
172
|
+
* schema has a Boolean `deleted` path, else `doc.deleteOne()`), and `postDelete`. Throws
|
|
173
|
+
* APIErrors with the same statuses/titles as the REST handler.
|
|
174
|
+
*/
|
|
175
|
+
export declare const executeDelete: <T>({ model, options, user, id, existingDoc, req, skipPostHooks, }: {
|
|
176
|
+
model: Model<T>;
|
|
177
|
+
options: ModelRouterOptions<T>;
|
|
178
|
+
user?: User;
|
|
179
|
+
id: string;
|
|
180
|
+
/**
|
|
181
|
+
* Pre-loaded document, used by the REST handler where permissionMiddleware already loaded
|
|
182
|
+
* and authorized it (avoids a second fetch). Permission checks still run either way.
|
|
183
|
+
*/
|
|
184
|
+
existingDoc?: ExecutorDoc<T> & {
|
|
185
|
+
deleted?: boolean;
|
|
186
|
+
};
|
|
187
|
+
/** The real Express request when called over HTTP; hooks receive a `{user}` stub otherwise. */
|
|
188
|
+
req?: express.Request;
|
|
189
|
+
/** C5 (FIX 6): see `executeCreate`'s `skipPostHooks` doc comment. */
|
|
190
|
+
skipPostHooks?: boolean;
|
|
191
|
+
}) => Promise<ExecutorResult<T>>;
|
|
192
|
+
/** C5 (FIX 6): run `postDelete` outside the write/ledger-finalize window — see `runPostCreate`. */
|
|
193
|
+
export declare const runPostDelete: <T>({ doc, options, request, }: {
|
|
194
|
+
doc: ExecutorDoc<T>;
|
|
195
|
+
options: ModelRouterOptions<T>;
|
|
196
|
+
request: express.Request;
|
|
197
|
+
}) => Promise<void>;
|
|
198
|
+
export {};
|