@uploadista/server 0.0.20-beta.6 → 0.0.20-beta.8
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/README.md +16 -16
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +188 -188
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +188 -188
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/adapter/types.ts +3 -3
- package/src/core/http-handlers/flow-http-handlers.ts +14 -14
- package/src/core/http-handlers/upload-http-handlers.ts +16 -9
- package/src/core/plugin-types.ts +10 -10
- package/src/core/routes.ts +4 -1
- package/src/core/server.ts +7 -9
- package/src/core/websocket-handlers/flow-websocket-handlers.ts +5 -5
- package/src/core/websocket-handlers/upload-websocket-handlers.ts +5 -5
- package/src/core/websocket-handlers/websocket-handlers.ts +10 -10
- package/src/error-types.ts +1 -1
- package/src/layer-utils.ts +24 -24
- package/src/permissions/errors.ts +3 -1
- package/src/permissions/index.ts +2 -2
- package/src/permissions/types.ts +3 -12
- package/src/plugins-typing.ts +15 -13
- package/src/service.ts +9 -4
- package/src/usage-hooks/index.ts +1 -1
- package/src/usage-hooks/service.ts +51 -59
- package/src/usage-hooks/types.ts +2 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { n as getAuthCredentials, t as AuthCredentialsResponse } from "./index-mMP18lsw.cjs";
|
|
2
2
|
import * as _uploadista_core0 from "@uploadista/core";
|
|
3
|
-
import { DataStoreCapabilities, DeadLetterCleanupOptions, DeadLetterCleanupResult, DeadLetterItem, DeadLetterItemStatus, DeadLetterListOptions, DeadLetterQueueStats, Flow, FlowData,
|
|
3
|
+
import { DataStoreCapabilities, DeadLetterCleanupOptions, DeadLetterCleanupResult, DeadLetterItem, DeadLetterItemStatus, DeadLetterListOptions, DeadLetterQueueStats, Flow, FlowData, FlowEngine, FlowJob, HealthResponse as HealthResponse$1, PluginLayer, UploadEngine, UploadEvent, UploadFile, UploadistaError, VideoPluginLayer } from "@uploadista/core";
|
|
4
4
|
import { Context, Effect, Layer } from "effect";
|
|
5
|
-
import { CredentialProviderLayer, ExtractLayerServices, Flow as Flow$1,
|
|
5
|
+
import { CredentialProviderLayer, ExtractLayerServices, Flow as Flow$1, FlowEngineShape, FlowProvider, ImageAiPluginLayer, ImagePluginLayer, ZipPluginLayer } from "@uploadista/core/flow";
|
|
6
6
|
import z$1, { z } from "zod";
|
|
7
7
|
import { BaseEventEmitterService, BaseKvStoreService, DataStoreConfig, EventBroadcasterService, HealthCheckConfig, UploadFileDataStore, UploadFileDataStores, UploadFileKVStore } from "@uploadista/core/types";
|
|
8
8
|
import { GenerateId } from "@uploadista/core/utils";
|
|
9
9
|
import { MetricsService } from "@uploadista/observability";
|
|
10
|
-
import {
|
|
10
|
+
import { UploadEngine as UploadEngine$1, UploadEngineShape } from "@uploadista/core/upload";
|
|
11
11
|
import { UploadistaError as UploadistaError$1 } from "@uploadista/core/errors";
|
|
12
12
|
|
|
13
13
|
//#region src/core/routes.d.ts
|
|
@@ -408,12 +408,12 @@ interface ServerAdapter<TContext, TResponse, TWebSocketHandler = unknown> {
|
|
|
408
408
|
*
|
|
409
409
|
* @param ws - Framework-specific WebSocket object
|
|
410
410
|
* @param ctx - Framework-specific context object (for initial handshake)
|
|
411
|
-
* @param context - Server context with baseUrl,
|
|
411
|
+
* @param context - Server context with baseUrl, uploadEngine, and flowServer
|
|
412
412
|
* @returns WebSocketHandler with callbacks for message, close, and error events
|
|
413
413
|
*/
|
|
414
414
|
webSocketHandler(context: {
|
|
415
415
|
baseUrl: string;
|
|
416
|
-
}): Effect.Effect<TWebSocketHandler, never,
|
|
416
|
+
}): Effect.Effect<TWebSocketHandler, never, UploadEngine | FlowEngine>;
|
|
417
417
|
/**
|
|
418
418
|
* Optional: Extract waitUntil callback from the framework context.
|
|
419
419
|
*
|
|
@@ -639,7 +639,7 @@ type TypeSafePluginConfig<TPlugins extends PluginTuple, TFlowRequirements> = Val
|
|
|
639
639
|
* Extracts plugin requirements from a flow function type.
|
|
640
640
|
*
|
|
641
641
|
* This navigates through the flow function signature to extract the requirements
|
|
642
|
-
* from the Flow type it returns, excluding
|
|
642
|
+
* from the Flow type it returns, excluding UploadEngine (provided by runtime).
|
|
643
643
|
*
|
|
644
644
|
* @template TFlowFn - The flow function type to extract requirements from
|
|
645
645
|
*
|
|
@@ -1797,7 +1797,7 @@ type WebSocketConnectionRequest = {
|
|
|
1797
1797
|
* Handles WebSocket connection opening
|
|
1798
1798
|
* Subscribes to the appropriate events based on the connection request
|
|
1799
1799
|
*/
|
|
1800
|
-
declare const handleWebSocketOpen: (request: WebSocketConnectionRequest,
|
|
1800
|
+
declare const handleWebSocketOpen: (request: WebSocketConnectionRequest, uploadEngine: UploadEngineShape, flowEngine: FlowEngineShape) => Effect.Effect<void, never, never>;
|
|
1801
1801
|
/**
|
|
1802
1802
|
* Handles incoming WebSocket messages
|
|
1803
1803
|
* Currently supports ping/pong for connection keep-alive
|
|
@@ -1807,7 +1807,7 @@ declare const handleWebSocketMessage: (message: string, connection: WebSocketCon
|
|
|
1807
1807
|
* Handles WebSocket connection closing
|
|
1808
1808
|
* Unsubscribes from all events and cleans up resources
|
|
1809
1809
|
*/
|
|
1810
|
-
declare const handleWebSocketClose: (request: WebSocketConnectionRequest,
|
|
1810
|
+
declare const handleWebSocketClose: (request: WebSocketConnectionRequest, uploadEngine: UploadEngineShape, flowEngine: FlowEngineShape) => Effect.Effect<void, never, never>;
|
|
1811
1811
|
/**
|
|
1812
1812
|
* Handles WebSocket errors
|
|
1813
1813
|
*/
|
|
@@ -1909,7 +1909,7 @@ declare const createErrorResponseBody: (error: AdapterError) => {
|
|
|
1909
1909
|
* import { createUploadistaErrorResponseBody } from "@uploadista/server";
|
|
1910
1910
|
*
|
|
1911
1911
|
* try {
|
|
1912
|
-
* const result = yield*
|
|
1912
|
+
* const result = yield* uploadEngine.handleUpload(input);
|
|
1913
1913
|
* } catch (err) {
|
|
1914
1914
|
* if (err instanceof UploadistaError) {
|
|
1915
1915
|
* const errorResponse = createUploadistaErrorResponseBody(err);
|
|
@@ -2102,8 +2102,8 @@ declare const extractFlowAndStorageId: (urlSegments: string[]) => {
|
|
|
2102
2102
|
//#endregion
|
|
2103
2103
|
//#region src/layer-utils.d.ts
|
|
2104
2104
|
/**
|
|
2105
|
-
* Configuration for creating upload
|
|
2106
|
-
* Specifies all dependencies needed by the upload
|
|
2105
|
+
* Configuration for creating upload engine layers.
|
|
2106
|
+
* Specifies all dependencies needed by the upload engine Effect Layer.
|
|
2107
2107
|
*
|
|
2108
2108
|
* @property kvStore - Key-value store for upload metadata
|
|
2109
2109
|
* @property eventEmitter - Event emitter for upload progress events
|
|
@@ -2113,16 +2113,16 @@ declare const extractFlowAndStorageId: (urlSegments: string[]) => {
|
|
|
2113
2113
|
*
|
|
2114
2114
|
* @example
|
|
2115
2115
|
* ```typescript
|
|
2116
|
-
* import {
|
|
2116
|
+
* import { createUploadEngineLayer } from "@uploadista/server";
|
|
2117
2117
|
*
|
|
2118
|
-
* const uploadLayerConfig:
|
|
2118
|
+
* const uploadLayerConfig: UploadEngineLayerConfig = {
|
|
2119
2119
|
* kvStore: redisKvStore,
|
|
2120
2120
|
* eventEmitter: webSocketEventEmitter,
|
|
2121
2121
|
* dataStore: s3DataStore,
|
|
2122
2122
|
* };
|
|
2123
2123
|
* ```
|
|
2124
2124
|
*/
|
|
2125
|
-
interface
|
|
2125
|
+
interface UploadEngineLayerConfig {
|
|
2126
2126
|
kvStore: Layer.Layer<BaseKvStoreService>;
|
|
2127
2127
|
eventEmitter: Layer.Layer<BaseEventEmitterService>;
|
|
2128
2128
|
dataStore: Layer.Layer<UploadFileDataStores, never, UploadFileKVStore>;
|
|
@@ -2136,7 +2136,7 @@ interface UploadServerLayerConfig {
|
|
|
2136
2136
|
* @property kvStore - Key-value store for flow job metadata
|
|
2137
2137
|
* @property eventEmitter - Event emitter for flow progress events
|
|
2138
2138
|
* @property flowProvider - Factory function for creating flows
|
|
2139
|
-
* @property
|
|
2139
|
+
* @property uploadEngine - Upload engine layer (used by flows for uploads)
|
|
2140
2140
|
*
|
|
2141
2141
|
* @example
|
|
2142
2142
|
* ```typescript
|
|
@@ -2146,7 +2146,7 @@ interface UploadServerLayerConfig {
|
|
|
2146
2146
|
* kvStore: redisKvStore,
|
|
2147
2147
|
* eventEmitter: webSocketEventEmitter,
|
|
2148
2148
|
* flowProvider: createFlowsEffect,
|
|
2149
|
-
*
|
|
2149
|
+
* uploadEngine: uploadEngineLayer,
|
|
2150
2150
|
* };
|
|
2151
2151
|
* ```
|
|
2152
2152
|
*/
|
|
@@ -2154,7 +2154,7 @@ interface FlowServerLayerConfig {
|
|
|
2154
2154
|
kvStore: Layer.Layer<BaseKvStoreService>;
|
|
2155
2155
|
eventEmitter: Layer.Layer<BaseEventEmitterService>;
|
|
2156
2156
|
flowProvider: Layer.Layer<FlowProvider>;
|
|
2157
|
-
|
|
2157
|
+
uploadEngine: Layer.Layer<UploadEngine$1>;
|
|
2158
2158
|
}
|
|
2159
2159
|
/**
|
|
2160
2160
|
* Creates the upload server layer with all dependencies composed.
|
|
@@ -2168,30 +2168,30 @@ interface FlowServerLayerConfig {
|
|
|
2168
2168
|
* - Optional custom ID generator
|
|
2169
2169
|
*
|
|
2170
2170
|
* @param config - Upload server layer configuration
|
|
2171
|
-
* @returns Effect Layer providing
|
|
2171
|
+
* @returns Effect Layer providing UploadEngine
|
|
2172
2172
|
*
|
|
2173
2173
|
* @example
|
|
2174
2174
|
* ```typescript
|
|
2175
|
-
* import {
|
|
2175
|
+
* import { createUploadEngineLayer } from "@uploadista/server";
|
|
2176
2176
|
* import { Layer } from "effect";
|
|
2177
2177
|
*
|
|
2178
|
-
* const
|
|
2178
|
+
* const uploadEngineLayer = createUploadEngineLayer({
|
|
2179
2179
|
* kvStore: redisKvStore,
|
|
2180
2180
|
* eventEmitter: webSocketEventEmitter,
|
|
2181
2181
|
* dataStore: s3DataStore,
|
|
2182
2182
|
* });
|
|
2183
2183
|
*
|
|
2184
2184
|
* // Use in application
|
|
2185
|
-
* const app = Layer.provide(appLogic,
|
|
2185
|
+
* const app = Layer.provide(appLogic, uploadEngineLayer);
|
|
2186
2186
|
* ```
|
|
2187
2187
|
*/
|
|
2188
|
-
declare const
|
|
2188
|
+
declare const createUploadEngineLayer: ({
|
|
2189
2189
|
kvStore,
|
|
2190
2190
|
eventEmitter,
|
|
2191
2191
|
dataStore,
|
|
2192
2192
|
bufferedDataStore,
|
|
2193
2193
|
generateId
|
|
2194
|
-
}:
|
|
2194
|
+
}: UploadEngineLayerConfig) => Layer.Layer<UploadEngine$1, never, never>;
|
|
2195
2195
|
/**
|
|
2196
2196
|
* Creates the flow server layer with all dependencies composed.
|
|
2197
2197
|
* This layer handles file processing workflows with multi-stage pipelines.
|
|
@@ -2214,19 +2214,176 @@ declare const createUploadServerLayer: ({
|
|
|
2214
2214
|
* kvStore: redisKvStore,
|
|
2215
2215
|
* eventEmitter: webSocketEventEmitter,
|
|
2216
2216
|
* flowProvider: createFlowsEffect,
|
|
2217
|
-
*
|
|
2217
|
+
* uploadEngine: uploadEngineLayer,
|
|
2218
2218
|
* });
|
|
2219
2219
|
*
|
|
2220
2220
|
* // Use in application
|
|
2221
2221
|
* const app = Layer.provide(appLogic, flowServerLayer);
|
|
2222
2222
|
* ```
|
|
2223
2223
|
*/
|
|
2224
|
-
declare const
|
|
2224
|
+
declare const createFlowEngineLayer: ({
|
|
2225
2225
|
kvStore,
|
|
2226
2226
|
eventEmitter,
|
|
2227
2227
|
flowProvider,
|
|
2228
|
-
|
|
2229
|
-
}: FlowServerLayerConfig) => Layer.Layer<_uploadista_core0.
|
|
2228
|
+
uploadEngine
|
|
2229
|
+
}: FlowServerLayerConfig) => Layer.Layer<_uploadista_core0.FlowEngine, never, never>;
|
|
2230
|
+
//#endregion
|
|
2231
|
+
//#region src/permissions/errors.d.ts
|
|
2232
|
+
/**
|
|
2233
|
+
* Authorization error - indicates the user lacks required permissions.
|
|
2234
|
+
* Returns HTTP 403 Forbidden status.
|
|
2235
|
+
*
|
|
2236
|
+
* @example
|
|
2237
|
+
* ```typescript
|
|
2238
|
+
* if (!hasPermission(permissions, "engine:metrics")) {
|
|
2239
|
+
* throw new AuthorizationError("engine:metrics");
|
|
2240
|
+
* }
|
|
2241
|
+
* ```
|
|
2242
|
+
*/
|
|
2243
|
+
declare class AuthorizationError extends AdapterError {
|
|
2244
|
+
/**
|
|
2245
|
+
* The permission that was required but not granted.
|
|
2246
|
+
*/
|
|
2247
|
+
readonly requiredPermission: string;
|
|
2248
|
+
constructor(requiredPermission: string, message?: string);
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Authentication required error - indicates no authentication context.
|
|
2252
|
+
* Returns HTTP 401 Unauthorized status.
|
|
2253
|
+
*
|
|
2254
|
+
* @example
|
|
2255
|
+
* ```typescript
|
|
2256
|
+
* if (!authContext) {
|
|
2257
|
+
* throw new AuthenticationRequiredError();
|
|
2258
|
+
* }
|
|
2259
|
+
* ```
|
|
2260
|
+
*/
|
|
2261
|
+
declare class AuthenticationRequiredError extends AdapterError {
|
|
2262
|
+
constructor(message?: string);
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Organization mismatch error - indicates accessing a resource from another organization.
|
|
2266
|
+
* Returns HTTP 403 Forbidden status.
|
|
2267
|
+
*
|
|
2268
|
+
* @example
|
|
2269
|
+
* ```typescript
|
|
2270
|
+
* if (resource.organizationId !== clientId) {
|
|
2271
|
+
* throw new OrganizationMismatchError();
|
|
2272
|
+
* }
|
|
2273
|
+
* ```
|
|
2274
|
+
*/
|
|
2275
|
+
declare class OrganizationMismatchError extends AdapterError {
|
|
2276
|
+
constructor(message?: string);
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* Quota exceeded error - indicates usage quota has been exceeded.
|
|
2280
|
+
* Returns HTTP 402 Payment Required status.
|
|
2281
|
+
*
|
|
2282
|
+
* @example
|
|
2283
|
+
* ```typescript
|
|
2284
|
+
* if (usage > quota) {
|
|
2285
|
+
* throw new QuotaExceededError("Storage quota exceeded");
|
|
2286
|
+
* }
|
|
2287
|
+
* ```
|
|
2288
|
+
*/
|
|
2289
|
+
declare class QuotaExceededError extends AdapterError {
|
|
2290
|
+
constructor(message?: string, code?: string);
|
|
2291
|
+
}
|
|
2292
|
+
/**
|
|
2293
|
+
* Creates a standardized error response body for AuthorizationError.
|
|
2294
|
+
* Includes the required permission in the response.
|
|
2295
|
+
*
|
|
2296
|
+
* @param error - The AuthorizationError to format
|
|
2297
|
+
* @returns Standardized error response body
|
|
2298
|
+
*/
|
|
2299
|
+
declare const createAuthorizationErrorResponseBody: (error: AuthorizationError) => {
|
|
2300
|
+
error: string;
|
|
2301
|
+
code: string;
|
|
2302
|
+
requiredPermission: string;
|
|
2303
|
+
timestamp: string;
|
|
2304
|
+
};
|
|
2305
|
+
//#endregion
|
|
2306
|
+
//#region src/permissions/matcher.d.ts
|
|
2307
|
+
/**
|
|
2308
|
+
* Permission Matching Logic
|
|
2309
|
+
*
|
|
2310
|
+
* Implements permission matching with support for:
|
|
2311
|
+
* - Exact match: `engine:health` matches `engine:health`
|
|
2312
|
+
* - Wildcard match: `engine:*` matches `engine:health`, `engine:metrics`, etc.
|
|
2313
|
+
* - Hierarchical match: `engine:dlq` implies `engine:dlq:read` and `engine:dlq:write`
|
|
2314
|
+
*/
|
|
2315
|
+
/**
|
|
2316
|
+
* Checks if a granted permission matches a required permission.
|
|
2317
|
+
*
|
|
2318
|
+
* @param granted - The permission that has been granted to the user
|
|
2319
|
+
* @param required - The permission that is required for the operation
|
|
2320
|
+
* @returns true if the granted permission satisfies the required permission
|
|
2321
|
+
*
|
|
2322
|
+
* @example
|
|
2323
|
+
* ```typescript
|
|
2324
|
+
* matchesPermission("engine:*", "engine:health") // true (wildcard)
|
|
2325
|
+
* matchesPermission("engine:health", "engine:health") // true (exact)
|
|
2326
|
+
* matchesPermission("engine:dlq", "engine:dlq:read") // true (hierarchical)
|
|
2327
|
+
* matchesPermission("flow:execute", "engine:health") // false
|
|
2328
|
+
* ```
|
|
2329
|
+
*/
|
|
2330
|
+
declare const matchesPermission: (granted: string, required: string) => boolean;
|
|
2331
|
+
/**
|
|
2332
|
+
* Checks if any of the granted permissions satisfy the required permission.
|
|
2333
|
+
*
|
|
2334
|
+
* @param grantedPermissions - Array of permissions granted to the user
|
|
2335
|
+
* @param required - The permission that is required for the operation
|
|
2336
|
+
* @returns true if any granted permission satisfies the required permission
|
|
2337
|
+
*
|
|
2338
|
+
* @example
|
|
2339
|
+
* ```typescript
|
|
2340
|
+
* hasPermission(["flow:*", "upload:create"], "flow:execute") // true
|
|
2341
|
+
* hasPermission(["upload:create"], "flow:execute") // false
|
|
2342
|
+
* ```
|
|
2343
|
+
*/
|
|
2344
|
+
declare const hasPermission: (grantedPermissions: readonly string[], required: string) => boolean;
|
|
2345
|
+
/**
|
|
2346
|
+
* Checks if any of the granted permissions satisfy any of the required permissions.
|
|
2347
|
+
*
|
|
2348
|
+
* @param grantedPermissions - Array of permissions granted to the user
|
|
2349
|
+
* @param requiredPermissions - Array of permissions, any of which would be sufficient
|
|
2350
|
+
* @returns true if any granted permission satisfies any required permission
|
|
2351
|
+
*
|
|
2352
|
+
* @example
|
|
2353
|
+
* ```typescript
|
|
2354
|
+
* hasAnyPermission(["upload:create"], ["flow:execute", "upload:create"]) // true
|
|
2355
|
+
* hasAnyPermission(["upload:read"], ["flow:execute", "upload:create"]) // false
|
|
2356
|
+
* ```
|
|
2357
|
+
*/
|
|
2358
|
+
declare const hasAnyPermission: (grantedPermissions: readonly string[], requiredPermissions: readonly string[]) => boolean;
|
|
2359
|
+
/**
|
|
2360
|
+
* Checks if all of the required permissions are satisfied.
|
|
2361
|
+
*
|
|
2362
|
+
* @param grantedPermissions - Array of permissions granted to the user
|
|
2363
|
+
* @param requiredPermissions - Array of permissions, all of which must be satisfied
|
|
2364
|
+
* @returns true if all required permissions are satisfied
|
|
2365
|
+
*
|
|
2366
|
+
* @example
|
|
2367
|
+
* ```typescript
|
|
2368
|
+
* hasAllPermissions(["flow:*", "upload:*"], ["flow:execute", "upload:create"]) // true
|
|
2369
|
+
* hasAllPermissions(["flow:execute"], ["flow:execute", "upload:create"]) // false
|
|
2370
|
+
* ```
|
|
2371
|
+
*/
|
|
2372
|
+
declare const hasAllPermissions: (grantedPermissions: readonly string[], requiredPermissions: readonly string[]) => boolean;
|
|
2373
|
+
/**
|
|
2374
|
+
* Expands a permission to include all implied permissions.
|
|
2375
|
+
* Useful for display or audit purposes.
|
|
2376
|
+
*
|
|
2377
|
+
* @param permission - The permission to expand
|
|
2378
|
+
* @returns Array of the permission and all implied permissions
|
|
2379
|
+
*
|
|
2380
|
+
* @example
|
|
2381
|
+
* ```typescript
|
|
2382
|
+
* expandPermission("engine:dlq") // ["engine:dlq", "engine:dlq:read", "engine:dlq:write"]
|
|
2383
|
+
* expandPermission("engine:health") // ["engine:health"]
|
|
2384
|
+
* ```
|
|
2385
|
+
*/
|
|
2386
|
+
declare const expandPermission: (permission: string) => string[];
|
|
2230
2387
|
//#endregion
|
|
2231
2388
|
//#region src/permissions/types.d.ts
|
|
2232
2389
|
/**
|
|
@@ -2360,163 +2517,6 @@ declare const PERMISSION_SETS: {
|
|
|
2360
2517
|
*/
|
|
2361
2518
|
declare const PERMISSION_HIERARCHY: Record<string, readonly string[]>;
|
|
2362
2519
|
//#endregion
|
|
2363
|
-
//#region src/permissions/matcher.d.ts
|
|
2364
|
-
/**
|
|
2365
|
-
* Permission Matching Logic
|
|
2366
|
-
*
|
|
2367
|
-
* Implements permission matching with support for:
|
|
2368
|
-
* - Exact match: `engine:health` matches `engine:health`
|
|
2369
|
-
* - Wildcard match: `engine:*` matches `engine:health`, `engine:metrics`, etc.
|
|
2370
|
-
* - Hierarchical match: `engine:dlq` implies `engine:dlq:read` and `engine:dlq:write`
|
|
2371
|
-
*/
|
|
2372
|
-
/**
|
|
2373
|
-
* Checks if a granted permission matches a required permission.
|
|
2374
|
-
*
|
|
2375
|
-
* @param granted - The permission that has been granted to the user
|
|
2376
|
-
* @param required - The permission that is required for the operation
|
|
2377
|
-
* @returns true if the granted permission satisfies the required permission
|
|
2378
|
-
*
|
|
2379
|
-
* @example
|
|
2380
|
-
* ```typescript
|
|
2381
|
-
* matchesPermission("engine:*", "engine:health") // true (wildcard)
|
|
2382
|
-
* matchesPermission("engine:health", "engine:health") // true (exact)
|
|
2383
|
-
* matchesPermission("engine:dlq", "engine:dlq:read") // true (hierarchical)
|
|
2384
|
-
* matchesPermission("flow:execute", "engine:health") // false
|
|
2385
|
-
* ```
|
|
2386
|
-
*/
|
|
2387
|
-
declare const matchesPermission: (granted: string, required: string) => boolean;
|
|
2388
|
-
/**
|
|
2389
|
-
* Checks if any of the granted permissions satisfy the required permission.
|
|
2390
|
-
*
|
|
2391
|
-
* @param grantedPermissions - Array of permissions granted to the user
|
|
2392
|
-
* @param required - The permission that is required for the operation
|
|
2393
|
-
* @returns true if any granted permission satisfies the required permission
|
|
2394
|
-
*
|
|
2395
|
-
* @example
|
|
2396
|
-
* ```typescript
|
|
2397
|
-
* hasPermission(["flow:*", "upload:create"], "flow:execute") // true
|
|
2398
|
-
* hasPermission(["upload:create"], "flow:execute") // false
|
|
2399
|
-
* ```
|
|
2400
|
-
*/
|
|
2401
|
-
declare const hasPermission: (grantedPermissions: readonly string[], required: string) => boolean;
|
|
2402
|
-
/**
|
|
2403
|
-
* Checks if any of the granted permissions satisfy any of the required permissions.
|
|
2404
|
-
*
|
|
2405
|
-
* @param grantedPermissions - Array of permissions granted to the user
|
|
2406
|
-
* @param requiredPermissions - Array of permissions, any of which would be sufficient
|
|
2407
|
-
* @returns true if any granted permission satisfies any required permission
|
|
2408
|
-
*
|
|
2409
|
-
* @example
|
|
2410
|
-
* ```typescript
|
|
2411
|
-
* hasAnyPermission(["upload:create"], ["flow:execute", "upload:create"]) // true
|
|
2412
|
-
* hasAnyPermission(["upload:read"], ["flow:execute", "upload:create"]) // false
|
|
2413
|
-
* ```
|
|
2414
|
-
*/
|
|
2415
|
-
declare const hasAnyPermission: (grantedPermissions: readonly string[], requiredPermissions: readonly string[]) => boolean;
|
|
2416
|
-
/**
|
|
2417
|
-
* Checks if all of the required permissions are satisfied.
|
|
2418
|
-
*
|
|
2419
|
-
* @param grantedPermissions - Array of permissions granted to the user
|
|
2420
|
-
* @param requiredPermissions - Array of permissions, all of which must be satisfied
|
|
2421
|
-
* @returns true if all required permissions are satisfied
|
|
2422
|
-
*
|
|
2423
|
-
* @example
|
|
2424
|
-
* ```typescript
|
|
2425
|
-
* hasAllPermissions(["flow:*", "upload:*"], ["flow:execute", "upload:create"]) // true
|
|
2426
|
-
* hasAllPermissions(["flow:execute"], ["flow:execute", "upload:create"]) // false
|
|
2427
|
-
* ```
|
|
2428
|
-
*/
|
|
2429
|
-
declare const hasAllPermissions: (grantedPermissions: readonly string[], requiredPermissions: readonly string[]) => boolean;
|
|
2430
|
-
/**
|
|
2431
|
-
* Expands a permission to include all implied permissions.
|
|
2432
|
-
* Useful for display or audit purposes.
|
|
2433
|
-
*
|
|
2434
|
-
* @param permission - The permission to expand
|
|
2435
|
-
* @returns Array of the permission and all implied permissions
|
|
2436
|
-
*
|
|
2437
|
-
* @example
|
|
2438
|
-
* ```typescript
|
|
2439
|
-
* expandPermission("engine:dlq") // ["engine:dlq", "engine:dlq:read", "engine:dlq:write"]
|
|
2440
|
-
* expandPermission("engine:health") // ["engine:health"]
|
|
2441
|
-
* ```
|
|
2442
|
-
*/
|
|
2443
|
-
declare const expandPermission: (permission: string) => string[];
|
|
2444
|
-
//#endregion
|
|
2445
|
-
//#region src/permissions/errors.d.ts
|
|
2446
|
-
/**
|
|
2447
|
-
* Authorization error - indicates the user lacks required permissions.
|
|
2448
|
-
* Returns HTTP 403 Forbidden status.
|
|
2449
|
-
*
|
|
2450
|
-
* @example
|
|
2451
|
-
* ```typescript
|
|
2452
|
-
* if (!hasPermission(permissions, "engine:metrics")) {
|
|
2453
|
-
* throw new AuthorizationError("engine:metrics");
|
|
2454
|
-
* }
|
|
2455
|
-
* ```
|
|
2456
|
-
*/
|
|
2457
|
-
declare class AuthorizationError extends AdapterError {
|
|
2458
|
-
/**
|
|
2459
|
-
* The permission that was required but not granted.
|
|
2460
|
-
*/
|
|
2461
|
-
readonly requiredPermission: string;
|
|
2462
|
-
constructor(requiredPermission: string, message?: string);
|
|
2463
|
-
}
|
|
2464
|
-
/**
|
|
2465
|
-
* Authentication required error - indicates no authentication context.
|
|
2466
|
-
* Returns HTTP 401 Unauthorized status.
|
|
2467
|
-
*
|
|
2468
|
-
* @example
|
|
2469
|
-
* ```typescript
|
|
2470
|
-
* if (!authContext) {
|
|
2471
|
-
* throw new AuthenticationRequiredError();
|
|
2472
|
-
* }
|
|
2473
|
-
* ```
|
|
2474
|
-
*/
|
|
2475
|
-
declare class AuthenticationRequiredError extends AdapterError {
|
|
2476
|
-
constructor(message?: string);
|
|
2477
|
-
}
|
|
2478
|
-
/**
|
|
2479
|
-
* Organization mismatch error - indicates accessing a resource from another organization.
|
|
2480
|
-
* Returns HTTP 403 Forbidden status.
|
|
2481
|
-
*
|
|
2482
|
-
* @example
|
|
2483
|
-
* ```typescript
|
|
2484
|
-
* if (resource.organizationId !== clientId) {
|
|
2485
|
-
* throw new OrganizationMismatchError();
|
|
2486
|
-
* }
|
|
2487
|
-
* ```
|
|
2488
|
-
*/
|
|
2489
|
-
declare class OrganizationMismatchError extends AdapterError {
|
|
2490
|
-
constructor(message?: string);
|
|
2491
|
-
}
|
|
2492
|
-
/**
|
|
2493
|
-
* Quota exceeded error - indicates usage quota has been exceeded.
|
|
2494
|
-
* Returns HTTP 402 Payment Required status.
|
|
2495
|
-
*
|
|
2496
|
-
* @example
|
|
2497
|
-
* ```typescript
|
|
2498
|
-
* if (usage > quota) {
|
|
2499
|
-
* throw new QuotaExceededError("Storage quota exceeded");
|
|
2500
|
-
* }
|
|
2501
|
-
* ```
|
|
2502
|
-
*/
|
|
2503
|
-
declare class QuotaExceededError extends AdapterError {
|
|
2504
|
-
constructor(message?: string, code?: string);
|
|
2505
|
-
}
|
|
2506
|
-
/**
|
|
2507
|
-
* Creates a standardized error response body for AuthorizationError.
|
|
2508
|
-
* Includes the required permission in the response.
|
|
2509
|
-
*
|
|
2510
|
-
* @param error - The AuthorizationError to format
|
|
2511
|
-
* @returns Standardized error response body
|
|
2512
|
-
*/
|
|
2513
|
-
declare const createAuthorizationErrorResponseBody: (error: AuthorizationError) => {
|
|
2514
|
-
error: string;
|
|
2515
|
-
code: string;
|
|
2516
|
-
requiredPermission: string;
|
|
2517
|
-
timestamp: string;
|
|
2518
|
-
};
|
|
2519
|
-
//#endregion
|
|
2520
2520
|
//#region src/plugins-typing.d.ts
|
|
2521
2521
|
/**
|
|
2522
2522
|
* @deprecated Use `ExtractLayerServices` from `@uploadista/core/flow/types` instead.
|
|
@@ -2544,7 +2544,7 @@ type FlowSuccess<TFlows extends (flowId: string, clientId: string | null) => Eff
|
|
|
2544
2544
|
/**
|
|
2545
2545
|
* @deprecated Use `ExtractFlowPluginRequirements` from `@uploadista/server/core/plugin-types` instead.
|
|
2546
2546
|
*
|
|
2547
|
-
* Extracts plugin requirements from a flow function, excluding
|
|
2547
|
+
* Extracts plugin requirements from a flow function, excluding UploadEngine.
|
|
2548
2548
|
*
|
|
2549
2549
|
* @example Migration
|
|
2550
2550
|
* ```typescript
|
|
@@ -2557,7 +2557,7 @@ type FlowSuccess<TFlows extends (flowId: string, clientId: string | null) => Eff
|
|
|
2557
2557
|
* type Requirements = ExtractFlowPluginRequirements<typeof myFlowFunction>;
|
|
2558
2558
|
* ```
|
|
2559
2559
|
*/
|
|
2560
|
-
type FlowRequirementsOf<TFlows extends (flowId: string, clientId: string | null) => Effect.Effect<unknown, unknown, unknown>> = FlowSuccess<TFlows> extends Flow<z$1.ZodSchema<unknown>, z$1.ZodSchema<unknown>, infer R> ? Exclude<R,
|
|
2560
|
+
type FlowRequirementsOf<TFlows extends (flowId: string, clientId: string | null) => Effect.Effect<unknown, unknown, unknown>> = FlowSuccess<TFlows> extends Flow<z$1.ZodSchema<unknown>, z$1.ZodSchema<unknown>, infer R> ? Exclude<R, UploadEngine> : never;
|
|
2561
2561
|
/**
|
|
2562
2562
|
* @deprecated Use `ExtractFlowPluginRequirements` from `@uploadista/server/core/plugin-types` instead.
|
|
2563
2563
|
*
|
|
@@ -2574,7 +2574,7 @@ type FlowRequirementsOf<TFlows extends (flowId: string, clientId: string | null)
|
|
|
2574
2574
|
* type Requirements = ExtractFlowPluginRequirements<typeof myFlowFunction>;
|
|
2575
2575
|
* ```
|
|
2576
2576
|
*/
|
|
2577
|
-
type RequiredPluginsOf<TFlows extends (flowId: string, clientId: string | null) => Effect.Effect<unknown, unknown, unknown>> = Exclude<FlowRequirementsOf<TFlows>,
|
|
2577
|
+
type RequiredPluginsOf<TFlows extends (flowId: string, clientId: string | null) => Effect.Effect<unknown, unknown, unknown>> = Exclude<FlowRequirementsOf<TFlows>, UploadEngine>;
|
|
2578
2578
|
/**
|
|
2579
2579
|
* @deprecated Use `ValidatePlugins` from `@uploadista/server/core/plugin-types` instead.
|
|
2580
2580
|
*
|
|
@@ -2759,5 +2759,5 @@ declare const UsageHookServiceLive: (config?: UsageHookConfig) => Layer.Layer<Us
|
|
|
2759
2759
|
*/
|
|
2760
2760
|
declare const NoUsageHookServiceLive: Layer.Layer<UsageHookService>;
|
|
2761
2761
|
//#endregion
|
|
2762
|
-
export { AdapterError, AuthCacheConfig, AuthCacheService, AuthCacheServiceLive, AuthContext, AuthContextService, AuthContextServiceLive, AuthContextServiceOptions, AuthCredentialsResponse, AuthFailedEvent, AuthResult, AuthenticationRequiredError, AuthorizationError, BadRequestError, BadRequestRequest, BadRequestResponse, BaseUsageMetadata, CancelFlowRequest, CancelFlowResponse, ConnectionEvent, CreateUploadRequest, CreateUploadResponse, DEFAULT_USAGE_HOOK_TIMEOUT, DlqCleanupRequest, DlqCleanupResponse, DlqDeleteRequest, DlqDeleteResponse, DlqGetRequest, DlqGetResponse, DlqListRequest, DlqListResponse, DlqResolveRequest, DlqResolveResponse, DlqRetryAllRequest, DlqRetryAllResponse, DlqRetryRequest, DlqRetryResponse, DlqStatsRequest, DlqStatsResponse, ENGINE_PERMISSIONS, EnginePermission, ErrorEvent, ExtractFlowPluginRequirements, ExtractServicesFromLayers, FLOW_PERMISSIONS, FlowEventMessage, FlowPermission, FlowRequirementsOf, FlowServerLayerConfig, FlowSuccess, FlowUsageContext, FlowUsageMetadata, FlowsFunction, GetCapabilitiesRequest, GetCapabilitiesResponse, GetFlowRequest, GetFlowResponse, GetJobStatusRequest, GetJobStatusResponse, GetUploadRequest, GetUploadResponse, HealthComponentsRequest, HealthComponentsResponse, HealthReadyRequest, HealthReadyResponse, HealthRequest, HealthResponse, InferFlowRequirements, InvalidPathEvent, KnownPluginLayer, LayerSuccessUnion, MethodNotAllowedRequest, MethodNotAllowedResponse, NoAuthCacheServiceLive, NoAuthContextServiceLive, NoUsageHookServiceLive, NotFoundError, NotFoundRequest, NotFoundResponse, OnFlowCompleteHook, OnFlowStartHook, OnUploadCompleteHook, OnUploadStartHook, OrganizationMismatchError, PERMISSIONS, PERMISSION_HIERARCHY, PERMISSION_SETS, PauseFlowRequest, PauseFlowResponse, Permission, PingEvent, PluginAssertion, PluginServices, PluginTuple, PluginValidationResult, QuotaExceededError, RequiredPluginsOf, ResumeFlowRequest, ResumeFlowResponse, RunFlowRequest, RunFlowResponse, RuntimePluginLayers, ServerAdapter, StandardRequest, StandardResponse, SubscribeFlowEvent, SubscribeUploadEvent, TypeSafeFlowFunction, TypeSafePluginConfig, TypeSafeServerConfig, UPLOAD_PERMISSIONS, UnsubscribeFlowEvent, UnsubscribeUploadEvent, UnsupportedContentTypeRequest, UnsupportedContentTypeResponse, UploadChunkRequest, UploadChunkResponse, UploadEventMessage, UploadPermission,
|
|
2762
|
+
export { AdapterError, AuthCacheConfig, AuthCacheService, AuthCacheServiceLive, AuthContext, AuthContextService, AuthContextServiceLive, AuthContextServiceOptions, AuthCredentialsResponse, AuthFailedEvent, AuthResult, AuthenticationRequiredError, AuthorizationError, BadRequestError, BadRequestRequest, BadRequestResponse, BaseUsageMetadata, CancelFlowRequest, CancelFlowResponse, ConnectionEvent, CreateUploadRequest, CreateUploadResponse, DEFAULT_USAGE_HOOK_TIMEOUT, DlqCleanupRequest, DlqCleanupResponse, DlqDeleteRequest, DlqDeleteResponse, DlqGetRequest, DlqGetResponse, DlqListRequest, DlqListResponse, DlqResolveRequest, DlqResolveResponse, DlqRetryAllRequest, DlqRetryAllResponse, DlqRetryRequest, DlqRetryResponse, DlqStatsRequest, DlqStatsResponse, ENGINE_PERMISSIONS, EnginePermission, ErrorEvent, ExtractFlowPluginRequirements, ExtractServicesFromLayers, FLOW_PERMISSIONS, FlowEventMessage, FlowPermission, FlowRequirementsOf, FlowServerLayerConfig, FlowSuccess, FlowUsageContext, FlowUsageMetadata, FlowsFunction, GetCapabilitiesRequest, GetCapabilitiesResponse, GetFlowRequest, GetFlowResponse, GetJobStatusRequest, GetJobStatusResponse, GetUploadRequest, GetUploadResponse, HealthComponentsRequest, HealthComponentsResponse, HealthReadyRequest, HealthReadyResponse, HealthRequest, HealthResponse, InferFlowRequirements, InvalidPathEvent, KnownPluginLayer, LayerSuccessUnion, MethodNotAllowedRequest, MethodNotAllowedResponse, NoAuthCacheServiceLive, NoAuthContextServiceLive, NoUsageHookServiceLive, NotFoundError, NotFoundRequest, NotFoundResponse, OnFlowCompleteHook, OnFlowStartHook, OnUploadCompleteHook, OnUploadStartHook, OrganizationMismatchError, PERMISSIONS, PERMISSION_HIERARCHY, PERMISSION_SETS, PauseFlowRequest, PauseFlowResponse, Permission, PingEvent, PluginAssertion, PluginServices, PluginTuple, PluginValidationResult, QuotaExceededError, RequiredPluginsOf, ResumeFlowRequest, ResumeFlowResponse, RunFlowRequest, RunFlowResponse, RuntimePluginLayers, ServerAdapter, StandardRequest, StandardResponse, SubscribeFlowEvent, SubscribeUploadEvent, TypeSafeFlowFunction, TypeSafePluginConfig, TypeSafeServerConfig, UPLOAD_PERMISSIONS, UnsubscribeFlowEvent, UnsubscribeUploadEvent, UnsupportedContentTypeRequest, UnsupportedContentTypeResponse, UploadChunkRequest, UploadChunkResponse, UploadEngineLayerConfig, UploadEventMessage, UploadPermission, UploadUsageContext, UploadUsageMetadata, UploadistaRequest, UploadistaResponse, UploadistaRoute, UploadistaRouteType, UploadistaServer, UploadistaServerConfig, UploadistaStandardResponse, UsageContext, UsageHookConfig, UsageHookResult, UsageHookService, UsageHookServiceLive, UsageHooks, ValidatePlugins, ValidationError, type WebSocketConnection, type WebSocketConnectionRequest, WebSocketEvent, WebSocketEventType, WebSocketHandler, WebSocketIncomingEvent, WebSocketOutgoingEvent, abortResult, continueResult, createAuthorizationErrorResponseBody, createErrorResponseBody, createFlowEngineLayer, createGenericErrorResponseBody, createTypeSafeServer, createUploadEngineLayer, createUploadistaErrorResponseBody, createUploadistaServer, defineFlow, defineSimpleFlow, expandPermission, extractFlowAndStorageId, extractJobAndNodeId, extractJobIdFromStatus, extractServiceIdentifiers, formatPluginValidationError, getAuthCredentials, getLastSegment, getRouteSegments, handleFlowError, handleWebSocketClose, handleWebSocketError, handleWebSocketMessage, handleWebSocketOpen, hasAllPermissions, hasAnyPermission, hasBasePath, hasPermission, matchesPermission, parseUrlSegments, validatePluginRequirements, validatePluginRequirementsEffect, validatePluginsOrThrow };
|
|
2763
2763
|
//# sourceMappingURL=index.d.cts.map
|