@burdenoff/be-sdk 2026.1021.7 → 2026.1022.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AE4PRE4N.js → chunk-6HO5AJ3U.js} +278 -38
- package/dist/chunk-6HO5AJ3U.js.map +1 -0
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +1 -1
- package/dist/{index-BjtgcJxt.d.ts → index-CN4RA1PN.d.ts} +52 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server/index.d.ts +23 -3
- package/dist/server/index.js +146 -37
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AE4PRE4N.js.map +0 -1
|
@@ -64,6 +64,44 @@ interface DownloadedFile {
|
|
|
64
64
|
name: string;
|
|
65
65
|
size: number;
|
|
66
66
|
}
|
|
67
|
+
interface CreateUploadSessionInput {
|
|
68
|
+
fileName: string;
|
|
69
|
+
fileSize: number;
|
|
70
|
+
mimeType: string;
|
|
71
|
+
extension?: string;
|
|
72
|
+
sha256Hash?: string | null;
|
|
73
|
+
folderId?: string | null;
|
|
74
|
+
visibility?: FileVisibility;
|
|
75
|
+
}
|
|
76
|
+
interface UploadSessionPart {
|
|
77
|
+
partNumber: number;
|
|
78
|
+
url: string;
|
|
79
|
+
offset: number;
|
|
80
|
+
length: number;
|
|
81
|
+
}
|
|
82
|
+
interface UploadSessionTicket {
|
|
83
|
+
sessionId: string;
|
|
84
|
+
uploadType: 'DIRECT' | 'MULTIPART';
|
|
85
|
+
uploadUrl: string | null;
|
|
86
|
+
requiredHeaders: Record<string, string>;
|
|
87
|
+
parts: UploadSessionPart[];
|
|
88
|
+
partSize: number;
|
|
89
|
+
totalParts: number;
|
|
90
|
+
fileSize: number;
|
|
91
|
+
sha256Hash: string | null;
|
|
92
|
+
expiresAt: Date | null;
|
|
93
|
+
}
|
|
94
|
+
interface UploadedPart {
|
|
95
|
+
partNumber: number;
|
|
96
|
+
etag: string;
|
|
97
|
+
}
|
|
98
|
+
interface CompleteUploadSessionInput {
|
|
99
|
+
fileSize: number;
|
|
100
|
+
sha256Hash?: string | null;
|
|
101
|
+
description?: string | null;
|
|
102
|
+
folderId?: string | null;
|
|
103
|
+
parts?: readonly UploadedPart[];
|
|
104
|
+
}
|
|
67
105
|
interface DeleteFileOptions {
|
|
68
106
|
permanent?: boolean;
|
|
69
107
|
}
|
|
@@ -129,6 +167,9 @@ declare class FilesClient {
|
|
|
129
167
|
private clientPromise;
|
|
130
168
|
constructor(options?: FilesClientOptions);
|
|
131
169
|
uploadFile(input: UploadFileInput, actor: FileActor): Promise<StoredFile>;
|
|
170
|
+
createUploadSession(input: CreateUploadSessionInput, actor: FileActor): Promise<UploadSessionTicket>;
|
|
171
|
+
completeUploadSession(sessionId: string, input: CompleteUploadSessionInput, actor: FileActor): Promise<StoredFile>;
|
|
172
|
+
abortUploadSession(sessionId: string, actor: FileActor): Promise<boolean>;
|
|
132
173
|
getFile(fileId: string, actor: FileActor): Promise<FileMetadata | null>;
|
|
133
174
|
requireFile(fileId: string, actor: FileActor, options?: RequireFileOptions): Promise<FileMetadata>;
|
|
134
175
|
getDownloadUrl(fileId: string, actor: FileActor, options?: DownloadUrlOptions): Promise<string>;
|
|
@@ -142,6 +183,10 @@ declare class FilesClient {
|
|
|
142
183
|
deleteFile(fileId: string, actor: FileActor, options?: DeleteFileOptions): Promise<boolean>;
|
|
143
184
|
private putDirect;
|
|
144
185
|
private uploadParts;
|
|
186
|
+
private completeSession;
|
|
187
|
+
private assertMultipartPlan;
|
|
188
|
+
private partUrls;
|
|
189
|
+
private presignParts;
|
|
145
190
|
private abortQuietly;
|
|
146
191
|
private assertUsable;
|
|
147
192
|
private transfer;
|
|
@@ -163,6 +208,8 @@ interface FileReference {
|
|
|
163
208
|
declare function toFileReference(file: StoredFile | FileMetadata): FileReference;
|
|
164
209
|
declare function isFileReference(value: unknown): value is FileReference;
|
|
165
210
|
|
|
211
|
+
type index_CompleteUploadSessionInput = CompleteUploadSessionInput;
|
|
212
|
+
type index_CreateUploadSessionInput = CreateUploadSessionInput;
|
|
166
213
|
type index_DeleteFileOptions = DeleteFileOptions;
|
|
167
214
|
type index_DownloadFileOptions = DownloadFileOptions;
|
|
168
215
|
type index_DownloadUrlOptions = DownloadUrlOptions;
|
|
@@ -193,6 +240,9 @@ type index_RawFileMetadata = RawFileMetadata;
|
|
|
193
240
|
type index_RequireFileOptions = RequireFileOptions;
|
|
194
241
|
type index_StoredFile = StoredFile;
|
|
195
242
|
type index_UploadFileInput = UploadFileInput;
|
|
243
|
+
type index_UploadSessionPart = UploadSessionPart;
|
|
244
|
+
type index_UploadSessionTicket = UploadSessionTicket;
|
|
245
|
+
type index_UploadedPart = UploadedPart;
|
|
196
246
|
declare const index_clampDownloadUrlTtl: typeof clampDownloadUrlTtl;
|
|
197
247
|
declare const index_classifyFilesErrors: typeof classifyFilesErrors;
|
|
198
248
|
declare const index_fileExtensionOf: typeof fileExtensionOf;
|
|
@@ -202,7 +252,7 @@ declare const index_mapFileMetadata: typeof mapFileMetadata;
|
|
|
202
252
|
declare const index_toFileReference: typeof toFileReference;
|
|
203
253
|
declare const index_toFilesClientError: typeof toFilesClientError;
|
|
204
254
|
declare namespace index {
|
|
205
|
-
export { type index_DeleteFileOptions as DeleteFileOptions, type index_DownloadFileOptions as DownloadFileOptions, type index_DownloadUrlOptions as DownloadUrlOptions, type index_DownloadedFile as DownloadedFile, index_FILES_CLIENT_GRAPHQL_CODES as FILES_CLIENT_GRAPHQL_CODES, index_FILE_ACTOR_TYPES as FILE_ACTOR_TYPES, index_FILE_REFERENCE_KIND as FILE_REFERENCE_KIND, index_FILE_VISIBILITIES as FILE_VISIBILITIES, type index_FileActor as FileActor, type index_FileActorType as FileActorType, type index_FileBytes as FileBytes, type index_FileMetadata as FileMetadata, type index_FileReference as FileReference, type index_FileStatus as FileStatus, type index_FileUploadType as FileUploadType, type index_FileVisibility as FileVisibility, index_FilesClient as FilesClient, index_FilesClientError as FilesClientError, type index_FilesClientErrorCode as FilesClientErrorCode, type index_FilesClientOptions as FilesClientOptions, type index_FilesFetch as FilesFetch, type index_FilesTransport as FilesTransport, index_MAX_DOWNLOAD_URL_TTL_SECONDS as MAX_DOWNLOAD_URL_TTL_SECONDS, index_MIN_DOWNLOAD_URL_TTL_SECONDS as MIN_DOWNLOAD_URL_TTL_SECONDS, type index_RawFileMetadata as RawFileMetadata, type index_RequireFileOptions as RequireFileOptions, type index_StoredFile as StoredFile, type index_UploadFileInput as UploadFileInput, index_clampDownloadUrlTtl as clampDownloadUrlTtl, index_classifyFilesErrors as classifyFilesErrors, index_fileExtensionOf as fileExtensionOf, index_isFileReference as isFileReference, index_isFilesClientError as isFilesClientError, index_mapFileMetadata as mapFileMetadata, index_toFileReference as toFileReference, index_toFilesClientError as toFilesClientError };
|
|
255
|
+
export { type index_CompleteUploadSessionInput as CompleteUploadSessionInput, type index_CreateUploadSessionInput as CreateUploadSessionInput, type index_DeleteFileOptions as DeleteFileOptions, type index_DownloadFileOptions as DownloadFileOptions, type index_DownloadUrlOptions as DownloadUrlOptions, type index_DownloadedFile as DownloadedFile, index_FILES_CLIENT_GRAPHQL_CODES as FILES_CLIENT_GRAPHQL_CODES, index_FILE_ACTOR_TYPES as FILE_ACTOR_TYPES, index_FILE_REFERENCE_KIND as FILE_REFERENCE_KIND, index_FILE_VISIBILITIES as FILE_VISIBILITIES, type index_FileActor as FileActor, type index_FileActorType as FileActorType, type index_FileBytes as FileBytes, type index_FileMetadata as FileMetadata, type index_FileReference as FileReference, type index_FileStatus as FileStatus, type index_FileUploadType as FileUploadType, type index_FileVisibility as FileVisibility, index_FilesClient as FilesClient, index_FilesClientError as FilesClientError, type index_FilesClientErrorCode as FilesClientErrorCode, type index_FilesClientOptions as FilesClientOptions, type index_FilesFetch as FilesFetch, type index_FilesTransport as FilesTransport, index_MAX_DOWNLOAD_URL_TTL_SECONDS as MAX_DOWNLOAD_URL_TTL_SECONDS, index_MIN_DOWNLOAD_URL_TTL_SECONDS as MIN_DOWNLOAD_URL_TTL_SECONDS, type index_RawFileMetadata as RawFileMetadata, type index_RequireFileOptions as RequireFileOptions, type index_StoredFile as StoredFile, type index_UploadFileInput as UploadFileInput, type index_UploadSessionPart as UploadSessionPart, type index_UploadSessionTicket as UploadSessionTicket, type index_UploadedPart as UploadedPart, index_clampDownloadUrlTtl as clampDownloadUrlTtl, index_classifyFilesErrors as classifyFilesErrors, index_fileExtensionOf as fileExtensionOf, index_isFileReference as isFileReference, index_isFilesClientError as isFilesClientError, index_mapFileMetadata as mapFileMetadata, index_toFileReference as toFileReference, index_toFilesClientError as toFilesClientError };
|
|
206
256
|
}
|
|
207
257
|
|
|
208
|
-
export {
|
|
258
|
+
export { type UploadedPart as A, clampDownloadUrlTtl as B, type CompleteUploadSessionInput as C, type DeleteFileOptions as D, classifyFilesErrors as E, FILES_CLIENT_GRAPHQL_CODES as F, fileExtensionOf as G, isFileReference as H, isFilesClientError as I, mapFileMetadata as J, toFileReference as K, toFilesClientError as L, MAX_DOWNLOAD_URL_TTL_SECONDS as M, type RawFileMetadata as R, type StoredFile as S, type UploadFileInput as U, type CreateUploadSessionInput as a, type DownloadFileOptions as b, type DownloadUrlOptions as c, type DownloadedFile as d, FILE_ACTOR_TYPES as e, FILE_REFERENCE_KIND as f, FILE_VISIBILITIES as g, type FileActor as h, index as i, type FileActorType as j, type FileBytes as k, type FileMetadata as l, type FileReference as m, type FileStatus as n, type FileUploadType as o, type FileVisibility as p, FilesClient as q, FilesClientError as r, type FilesClientErrorCode as s, type FilesClientOptions as t, type FilesFetch as u, type FilesTransport as v, MIN_DOWNLOAD_URL_TTL_SECONDS as w, type RequireFileOptions as x, type UploadSessionPart as y, type UploadSessionTicket as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export { i as Lifecycle } from './index-CoMKgL-p.js';
|
|
|
21
21
|
export { BillingPlanTransport, PlanTier, RESOURCE_CAP_DEFAULTS, ResourceCap, ResourceCapDefaults, ResourceCapExceededError, ResourceCapsConfig, ResourceCapsModule, ResourceName, WorkspaceResourceCapScope, configureResourceCaps, getResourceCaps } from './resource-caps/index.js';
|
|
22
22
|
export { i as Sharing } from './index-kssw5ziY.js';
|
|
23
23
|
export { i as Tags } from './index-C_t30VyQ.js';
|
|
24
|
-
export { i as Files } from './index-
|
|
24
|
+
export { i as Files } from './index-CN4RA1PN.js';
|
|
25
25
|
export { i as AiCredits } from './index-DmxmEfAu.js';
|
|
26
26
|
export { i as Cache } from './index-Cx5I3ydM.js';
|
|
27
27
|
export { i as Middleware } from './index-DSOpj8DI.js';
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import './chunk-AWPNRV3L.js';
|
|
|
23
23
|
export { dataloader_exports as DataLoader } from './chunk-NUB5GQTU.js';
|
|
24
24
|
export { export_exports as Export } from './chunk-XJKVW34Q.js';
|
|
25
25
|
export { feature_flags_exports as FeatureFlags } from './chunk-UNASM5VJ.js';
|
|
26
|
-
export { files_exports as Files } from './chunk-
|
|
26
|
+
export { files_exports as Files } from './chunk-6HO5AJ3U.js';
|
|
27
27
|
export { gateway_exports as Gateway } from './chunk-QZG27OR7.js';
|
|
28
28
|
import './chunk-KCGJCY5U.js';
|
|
29
29
|
import { GatewayClient } from './chunk-UCNTCCV6.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WorkspaceSecret, I as IActor, J as JWTPayload, S as ServerDefinition, a as ServerInstance, b as ITenant, G as GraphQLContext, Y as YogaPlugin } from '../types-C-6m9NoG.js';
|
|
2
|
-
export { A as ActorProvenance, C as ConsentContext, E as ElysiaApp, c as IContextFilterInput, d as IOperationContext, e as IOrganization, f as IProduct, g as IProject, h as ITracking, i as IWorkspace, M as ModuleGraphConfig, P as PrismaClientConstructor,
|
|
1
|
+
import { W as WorkspaceSecret, I as IActor, J as JWTPayload, S as ServerDefinition, a as ServerInstance, R as RESTEndpoint, b as ITenant, G as GraphQLContext, Y as YogaPlugin } from '../types-C-6m9NoG.js';
|
|
2
|
+
export { A as ActorProvenance, C as ConsentContext, E as ElysiaApp, c as IContextFilterInput, d as IOperationContext, e as IOrganization, f as IProduct, g as IProject, h as ITracking, i as IWorkspace, M as ModuleGraphConfig, P as PrismaClientConstructor, j as ServerConfig, k as ServerI18nConfig, l as ServerInfo, V as VerifiedDelegationContext, m as WspaceGraphQLContext } from '../types-C-6m9NoG.js';
|
|
3
3
|
import * as jose from 'jose';
|
|
4
4
|
import { VerifyOptions } from 'jsonwebtoken';
|
|
5
5
|
import { I as I18n } from '../i18n-DrdPTann.js';
|
|
@@ -61,6 +61,26 @@ declare function tenantCheck(context: {
|
|
|
61
61
|
declare function createServer(definition: ServerDefinition): Promise<ServerInstance>;
|
|
62
62
|
declare function configureServerAuth(fetchWorkspaceSecret: FetchWorkspaceSecretFn): void;
|
|
63
63
|
|
|
64
|
+
type RawBodyResolution = {
|
|
65
|
+
kind: 'endpoint';
|
|
66
|
+
endpoint: RESTEndpoint;
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'method-not-allowed';
|
|
69
|
+
allowed: string[];
|
|
70
|
+
};
|
|
71
|
+
interface OrdinaryRoute {
|
|
72
|
+
method: string;
|
|
73
|
+
path: string;
|
|
74
|
+
}
|
|
75
|
+
interface RawBodyRouter {
|
|
76
|
+
readonly size: number;
|
|
77
|
+
hasPath(pathname: string): boolean;
|
|
78
|
+
resolve(pathname: string, method: string): RawBodyResolution | null;
|
|
79
|
+
}
|
|
80
|
+
declare function createRawBodyRouter(endpoints: readonly RESTEndpoint[], ordinaryRoutes?: () => readonly OrdinaryRoute[]): RawBodyRouter;
|
|
81
|
+
declare const MAX_IDLE_TIMEOUT_SECONDS = 255;
|
|
82
|
+
declare function extendRequestIdleTimeout(request: Request, seconds: number): boolean;
|
|
83
|
+
|
|
64
84
|
interface ContextBuilderOptions {
|
|
65
85
|
getDb: () => unknown;
|
|
66
86
|
defaultTenant?: ITenant;
|
|
@@ -194,4 +214,4 @@ declare function createHumanReadableErrorPlugin(options?: ErrorNormalizationOpti
|
|
|
194
214
|
declare function formatHttpError(error: unknown, options?: ErrorNormalizationOptions): HttpErrorResult;
|
|
195
215
|
declare function createHttpErrorResponse(error: unknown, options?: ErrorNormalizationOptions): Response;
|
|
196
216
|
|
|
197
|
-
export { type AuthConfig, type ContextBuilderOptions, type ErrorNormalizationOptions, type FetchWorkspaceSecretFn, GraphQLContext, type HttpErrorPayload, type HttpErrorResult, IActor, ITenant, JWTPayload, MUTATION_AUDIT_ACTIVITY_TYPE, MUTATION_AUDIT_RESOURCE_TYPE, type MutationAuditPluginOptions, type NormalizedErrorState, ServerDefinition, ServerInstance, type UserFacingErrorOptions, UserFacingGraphQLError, type WorkspaceGuardConfig, WorkspaceSecret, YogaPlugin, authCheck, buildContext, configureAuth, configureContext, configureDefaultAuth, configureServerAuth, createHttpErrorResponse, createHumanReadableErrorPlugin, createMutationAuditPlugin, createServer, createWorkspaceGuardPlugin, decodeJWT, fetchWorkspaceSecret, formatHttpError, generateSymmetricSecret, getContextOptions, getMutationFieldNames, normalizeError, normalizeExecutionResultErrors, normalizeGraphQLResponse, normalizeGraphQLResponsePayload, orgCheck, requireWorkspace, sanitizeAuditValue, tenantCheck, toUserFacingGraphQLError, verifyJWT, workspaceCheck };
|
|
217
|
+
export { type AuthConfig, type ContextBuilderOptions, type ErrorNormalizationOptions, type FetchWorkspaceSecretFn, GraphQLContext, type HttpErrorPayload, type HttpErrorResult, IActor, ITenant, JWTPayload, MAX_IDLE_TIMEOUT_SECONDS, MUTATION_AUDIT_ACTIVITY_TYPE, MUTATION_AUDIT_RESOURCE_TYPE, type MutationAuditPluginOptions, type NormalizedErrorState, type OrdinaryRoute, RESTEndpoint, type RawBodyResolution, type RawBodyRouter, ServerDefinition, ServerInstance, type UserFacingErrorOptions, UserFacingGraphQLError, type WorkspaceGuardConfig, WorkspaceSecret, YogaPlugin, authCheck, buildContext, configureAuth, configureContext, configureDefaultAuth, configureServerAuth, createHttpErrorResponse, createHumanReadableErrorPlugin, createMutationAuditPlugin, createRawBodyRouter, createServer, createWorkspaceGuardPlugin, decodeJWT, extendRequestIdleTimeout, fetchWorkspaceSecret, formatHttpError, generateSymmetricSecret, getContextOptions, getMutationFieldNames, normalizeError, normalizeExecutionResultErrors, normalizeGraphQLResponse, normalizeGraphQLResponsePayload, orgCheck, requireWorkspace, sanitizeAuditValue, tenantCheck, toUserFacingGraphQLError, verifyJWT, workspaceCheck };
|
package/dist/server/index.js
CHANGED
|
@@ -652,6 +652,127 @@ function createQuotaGaugeRefresher(opts) {
|
|
|
652
652
|
}
|
|
653
653
|
__name(createQuotaGaugeRefresher, "createQuotaGaugeRefresher");
|
|
654
654
|
|
|
655
|
+
// src/server/raw-body-routes.ts
|
|
656
|
+
var REGEX_SPECIAL = /[.*+?^${}()|[\]\\]/g;
|
|
657
|
+
function compile(path) {
|
|
658
|
+
if (!path.includes(":") && !path.includes("*")) return {
|
|
659
|
+
exact: path,
|
|
660
|
+
regex: null
|
|
661
|
+
};
|
|
662
|
+
const pattern = path.split("/").map((segment) => {
|
|
663
|
+
if (segment === "*") return ".*";
|
|
664
|
+
if (segment.startsWith(":")) return "[^/]+";
|
|
665
|
+
return segment.replace(REGEX_SPECIAL, "\\$&");
|
|
666
|
+
}).join("/");
|
|
667
|
+
return {
|
|
668
|
+
exact: null,
|
|
669
|
+
regex: new RegExp(`^${pattern}$`)
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
__name(compile, "compile");
|
|
673
|
+
function matches(route, pathname) {
|
|
674
|
+
return route.exact !== null ? route.exact === pathname : route.regex?.test(pathname) ?? false;
|
|
675
|
+
}
|
|
676
|
+
__name(matches, "matches");
|
|
677
|
+
function keyOf(route) {
|
|
678
|
+
return route.exact ?? route.regex?.source ?? "";
|
|
679
|
+
}
|
|
680
|
+
__name(keyOf, "keyOf");
|
|
681
|
+
var METHOD_ORDER = [
|
|
682
|
+
"GET",
|
|
683
|
+
"HEAD",
|
|
684
|
+
"POST",
|
|
685
|
+
"PUT",
|
|
686
|
+
"PATCH",
|
|
687
|
+
"DELETE",
|
|
688
|
+
"OPTIONS"
|
|
689
|
+
];
|
|
690
|
+
var rank = /* @__PURE__ */ __name((method) => {
|
|
691
|
+
const index = METHOD_ORDER.indexOf(method);
|
|
692
|
+
return index === -1 ? METHOD_ORDER.length : index;
|
|
693
|
+
}, "rank");
|
|
694
|
+
function createRawBodyRouter(endpoints, ordinaryRoutes = () => []) {
|
|
695
|
+
const routes = [];
|
|
696
|
+
for (const endpoint of endpoints.filter((ep) => ep.rawBody)) {
|
|
697
|
+
const method = endpoint.method.toUpperCase();
|
|
698
|
+
const compiled = compile(endpoint.path);
|
|
699
|
+
let route = routes.find((candidate) => keyOf(candidate) === keyOf(compiled));
|
|
700
|
+
if (!route) {
|
|
701
|
+
route = {
|
|
702
|
+
...compiled,
|
|
703
|
+
byMethod: /* @__PURE__ */ new Map()
|
|
704
|
+
};
|
|
705
|
+
routes.push(route);
|
|
706
|
+
}
|
|
707
|
+
if (!route.byMethod.has(method)) route.byMethod.set(method, endpoint);
|
|
708
|
+
}
|
|
709
|
+
const ordinaryMatchers = /* @__PURE__ */ new Map();
|
|
710
|
+
const ordinaryVerbsOn = /* @__PURE__ */ __name((pathname) => {
|
|
711
|
+
const verbs = /* @__PURE__ */ new Set();
|
|
712
|
+
for (const route of ordinaryRoutes()) {
|
|
713
|
+
let matcher = ordinaryMatchers.get(route.path);
|
|
714
|
+
if (!matcher) {
|
|
715
|
+
matcher = compile(route.path);
|
|
716
|
+
ordinaryMatchers.set(route.path, matcher);
|
|
717
|
+
}
|
|
718
|
+
if (matches(matcher, pathname)) verbs.add(route.method.toUpperCase());
|
|
719
|
+
}
|
|
720
|
+
return verbs;
|
|
721
|
+
}, "ordinaryVerbsOn");
|
|
722
|
+
return {
|
|
723
|
+
size: routes.length,
|
|
724
|
+
hasPath(pathname) {
|
|
725
|
+
return routes.some((route) => matches(route, pathname));
|
|
726
|
+
},
|
|
727
|
+
resolve(pathname, rawMethod) {
|
|
728
|
+
const method = rawMethod.toUpperCase();
|
|
729
|
+
const candidates = [
|
|
730
|
+
...routes.filter((route) => route.exact !== null && matches(route, pathname)),
|
|
731
|
+
...routes.filter((route) => route.exact === null && matches(route, pathname))
|
|
732
|
+
];
|
|
733
|
+
if (candidates.length === 0) return null;
|
|
734
|
+
for (const route of candidates) {
|
|
735
|
+
const endpoint = route.byMethod.get(method) ?? (method === "HEAD" ? route.byMethod.get("GET") : void 0);
|
|
736
|
+
if (endpoint) return {
|
|
737
|
+
kind: "endpoint",
|
|
738
|
+
endpoint
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
const ordinaryVerbs = ordinaryVerbsOn(pathname);
|
|
742
|
+
const servedElsewhere = ordinaryVerbs.has(method) || ordinaryVerbs.has("ALL") || method === "HEAD" && ordinaryVerbs.has("GET");
|
|
743
|
+
if (servedElsewhere) return null;
|
|
744
|
+
const allowed = new Set(ordinaryVerbs);
|
|
745
|
+
for (const route of candidates) for (const verb of route.byMethod.keys()) allowed.add(verb);
|
|
746
|
+
if (allowed.has("GET")) allowed.add("HEAD");
|
|
747
|
+
allowed.add("OPTIONS");
|
|
748
|
+
return {
|
|
749
|
+
kind: "method-not-allowed",
|
|
750
|
+
allowed: [
|
|
751
|
+
...allowed
|
|
752
|
+
].sort((a, b) => rank(a) - rank(b))
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
__name(createRawBodyRouter, "createRawBodyRouter");
|
|
758
|
+
var requestServers = /* @__PURE__ */ new WeakMap();
|
|
759
|
+
function canTimeout(server) {
|
|
760
|
+
return typeof server?.timeout === "function";
|
|
761
|
+
}
|
|
762
|
+
__name(canTimeout, "canTimeout");
|
|
763
|
+
function rememberRequestServer(request, server) {
|
|
764
|
+
if (canTimeout(server)) requestServers.set(request, server);
|
|
765
|
+
}
|
|
766
|
+
__name(rememberRequestServer, "rememberRequestServer");
|
|
767
|
+
var MAX_IDLE_TIMEOUT_SECONDS = 255;
|
|
768
|
+
function extendRequestIdleTimeout(request, seconds) {
|
|
769
|
+
const server = requestServers.get(request);
|
|
770
|
+
if (!server || !Number.isFinite(seconds) || seconds < 0) return false;
|
|
771
|
+
server.timeout(request, Math.min(Math.floor(seconds), MAX_IDLE_TIMEOUT_SECONDS));
|
|
772
|
+
return true;
|
|
773
|
+
}
|
|
774
|
+
__name(extendRequestIdleTimeout, "extendRequestIdleTimeout");
|
|
775
|
+
|
|
655
776
|
// src/server/readiness.ts
|
|
656
777
|
var READINESS_CACHE_MS = 1e3;
|
|
657
778
|
var READINESS_PROBE_TIMEOUT_MS = 2e3;
|
|
@@ -936,34 +1057,8 @@ async function createServer(definition) {
|
|
|
936
1057
|
"OPTIONS"
|
|
937
1058
|
]
|
|
938
1059
|
}));
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
ep.path,
|
|
942
|
-
ep
|
|
943
|
-
]));
|
|
944
|
-
const rawBodyMatchers = rawBodyEndpoints.map((endpoint) => {
|
|
945
|
-
const regexPattern = endpoint.path.replace(/:[^/]+/g, "[^/]+");
|
|
946
|
-
return {
|
|
947
|
-
endpoint,
|
|
948
|
-
regexPattern,
|
|
949
|
-
regex: new RegExp(`^${regexPattern}$`)
|
|
950
|
-
};
|
|
951
|
-
});
|
|
952
|
-
const matchRawBodyEndpoint = /* @__PURE__ */ __name((pathname) => {
|
|
953
|
-
const exactMatch = rawBodyPaths.get(pathname);
|
|
954
|
-
if (exactMatch) return exactMatch;
|
|
955
|
-
for (const { endpoint, regex, regexPattern } of rawBodyMatchers) {
|
|
956
|
-
const isMatch = regex.test(pathname);
|
|
957
|
-
logger.debug(`[Server] Checking ${pathname} against pattern ${endpoint.path} (regex: ${regexPattern}), match: ${isMatch}`);
|
|
958
|
-
if (isMatch) {
|
|
959
|
-
logger.debug(`[Server] Matched ${pathname} to pattern ${endpoint.path}`);
|
|
960
|
-
return endpoint;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
logger.debug(`[Server] No raw body endpoint match for ${pathname}, rawBodyEndpoints: ${rawBodyEndpoints.length}`);
|
|
964
|
-
return void 0;
|
|
965
|
-
}, "matchRawBodyEndpoint");
|
|
966
|
-
app.onRequest(async ({ request }) => {
|
|
1060
|
+
const rawBodyRouter = createRawBodyRouter(restEndpoints || [], () => app.routes);
|
|
1061
|
+
app.onRequest(async ({ request, server }) => {
|
|
967
1062
|
const url = new URL(request.url);
|
|
968
1063
|
const pathname = url.pathname;
|
|
969
1064
|
logger.debug(`[Server] onRequest: ${request.method} ${pathname}`);
|
|
@@ -981,9 +1076,7 @@ async function createServer(definition) {
|
|
|
981
1076
|
}
|
|
982
1077
|
return headers;
|
|
983
1078
|
}, "buildCorsHeaders");
|
|
984
|
-
|
|
985
|
-
if (rawBodyEndpoint) {
|
|
986
|
-
logger.debug(`[Server] Matched raw body endpoint: ${pathname} -> ${rawBodyEndpoint.path}`);
|
|
1079
|
+
if (!isHealthRoute && rawBodyRouter.size > 0 && rawBodyRouter.hasPath(pathname)) {
|
|
987
1080
|
const corsHeaders = buildCorsHeaders();
|
|
988
1081
|
if (request.method === "OPTIONS") {
|
|
989
1082
|
return new Response(null, {
|
|
@@ -991,9 +1084,25 @@ async function createServer(definition) {
|
|
|
991
1084
|
headers: corsHeaders
|
|
992
1085
|
});
|
|
993
1086
|
}
|
|
994
|
-
|
|
995
|
-
|
|
1087
|
+
const resolution = rawBodyRouter.resolve(pathname, request.method);
|
|
1088
|
+
if (!resolution) return void 0;
|
|
1089
|
+
if (resolution.kind === "method-not-allowed") {
|
|
1090
|
+
return new Response(JSON.stringify({
|
|
1091
|
+
error: `Method ${request.method} is not allowed`,
|
|
1092
|
+
allowed: resolution.allowed
|
|
1093
|
+
}), {
|
|
1094
|
+
status: 405,
|
|
1095
|
+
headers: {
|
|
1096
|
+
"Content-Type": "application/json",
|
|
1097
|
+
Allow: resolution.allowed.join(", "),
|
|
1098
|
+
...corsHeaders
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
996
1101
|
}
|
|
1102
|
+
const rawBodyEndpoint = resolution.endpoint;
|
|
1103
|
+
logger.debug(`[Server] Matched raw body endpoint: ${request.method} ${pathname} -> ${rawBodyEndpoint.path}`);
|
|
1104
|
+
rememberRequestServer(request, server);
|
|
1105
|
+
const isHead = request.method === "HEAD";
|
|
997
1106
|
try {
|
|
998
1107
|
const rawBody = await request.text();
|
|
999
1108
|
const context = await buildContext(request);
|
|
@@ -1003,7 +1112,7 @@ async function createServer(definition) {
|
|
|
1003
1112
|
for (const [key, value] of Object.entries(corsHeaders)) {
|
|
1004
1113
|
headers2.set(key, value);
|
|
1005
1114
|
}
|
|
1006
|
-
return new Response(result.body, {
|
|
1115
|
+
return new Response(isHead ? null : result.body, {
|
|
1007
1116
|
status: result.status,
|
|
1008
1117
|
statusText: result.statusText,
|
|
1009
1118
|
headers: headers2
|
|
@@ -1013,7 +1122,7 @@ async function createServer(definition) {
|
|
|
1013
1122
|
"Content-Type": "application/json",
|
|
1014
1123
|
...corsHeaders
|
|
1015
1124
|
});
|
|
1016
|
-
return new Response(JSON.stringify(result), {
|
|
1125
|
+
return new Response(isHead ? null : JSON.stringify(result), {
|
|
1017
1126
|
status: 200,
|
|
1018
1127
|
headers
|
|
1019
1128
|
});
|
|
@@ -1024,7 +1133,7 @@ async function createServer(definition) {
|
|
|
1024
1133
|
serviceName: config.serviceName,
|
|
1025
1134
|
environment: config.environment
|
|
1026
1135
|
});
|
|
1027
|
-
return new Response(JSON.stringify(formatted.body), {
|
|
1136
|
+
return new Response(isHead ? null : JSON.stringify(formatted.body), {
|
|
1028
1137
|
status: formatted.status,
|
|
1029
1138
|
headers: {
|
|
1030
1139
|
"Content-Type": "application/json",
|
|
@@ -1496,6 +1605,6 @@ function createMutationAuditPlugin(options) {
|
|
|
1496
1605
|
}
|
|
1497
1606
|
__name(createMutationAuditPlugin, "createMutationAuditPlugin");
|
|
1498
1607
|
|
|
1499
|
-
export { MUTATION_AUDIT_ACTIVITY_TYPE, MUTATION_AUDIT_RESOURCE_TYPE, authCheck, buildContext, configureAuth, configureContext, configureDefaultAuth, configureServerAuth, createMutationAuditPlugin, createServer, decodeJWT, fetchWorkspaceSecret, generateSymmetricSecret, getContextOptions, getMutationFieldNames, orgCheck, requireWorkspace, sanitizeAuditValue, tenantCheck, verifyJWT, workspaceCheck };
|
|
1608
|
+
export { MAX_IDLE_TIMEOUT_SECONDS, MUTATION_AUDIT_ACTIVITY_TYPE, MUTATION_AUDIT_RESOURCE_TYPE, authCheck, buildContext, configureAuth, configureContext, configureDefaultAuth, configureServerAuth, createMutationAuditPlugin, createRawBodyRouter, createServer, decodeJWT, extendRequestIdleTimeout, fetchWorkspaceSecret, generateSymmetricSecret, getContextOptions, getMutationFieldNames, orgCheck, requireWorkspace, sanitizeAuditValue, tenantCheck, verifyJWT, workspaceCheck };
|
|
1500
1609
|
//# sourceMappingURL=index.js.map
|
|
1501
1610
|
//# sourceMappingURL=index.js.map
|