@warlock.js/core 5.27.0 → 5.29.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/CHANGELOG.md +24 -0
- package/esm/cli/commands/openapi-generator.action.mjs +1 -1
- package/esm/cli/commands/openapi-generator.action.mjs.map +1 -1
- package/esm/cli/commands/postman-generator.action.mjs +47 -0
- package/esm/cli/commands/postman-generator.action.mjs.map +1 -0
- package/esm/cli/commands/postman-generator.command.mjs +43 -0
- package/esm/cli/commands/postman-generator.command.mjs.map +1 -0
- package/esm/cli/framework-cli-commands.mjs +2 -0
- package/esm/cli/framework-cli-commands.mjs.map +1 -1
- package/esm/container/development-app-modules.d.mts +31 -0
- package/esm/container/development-app-modules.d.mts.map +1 -0
- package/esm/container/index.d.mts +2 -0
- package/esm/container/index.d.mts.map +1 -1
- package/esm/container/index.mjs.map +1 -1
- package/esm/dev-server/app-module-registry.mjs +52 -0
- package/esm/dev-server/app-module-registry.mjs.map +1 -0
- package/esm/dev-server/files-orchestrator.mjs +13 -2
- package/esm/dev-server/files-orchestrator.mjs.map +1 -1
- package/esm/http/middleware/inject-request-context.d.mts.map +1 -1
- package/esm/http/middleware/inject-request-context.mjs +29 -3
- package/esm/http/middleware/inject-request-context.mjs.map +1 -1
- package/esm/http/request.d.mts +2 -2
- package/esm/http/request.d.mts.map +1 -1
- package/esm/index.d.mts +7 -2
- package/esm/index.mjs +5 -2
- package/esm/localization/parse-locale-dictionary.d.mts +6 -1
- package/esm/localization/parse-locale-dictionary.d.mts.map +1 -1
- package/esm/localization/parse-locale-dictionary.mjs +5 -1
- package/esm/localization/parse-locale-dictionary.mjs.map +1 -1
- package/esm/openapi/development-openapi-provider.d.mts +12 -1
- package/esm/openapi/development-openapi-provider.d.mts.map +1 -1
- package/esm/openapi/development-openapi-provider.mjs +15 -1
- package/esm/openapi/development-openapi-provider.mjs.map +1 -1
- package/esm/openapi/index.d.mts +5 -2
- package/esm/openapi/index.mjs +3 -1
- package/esm/openapi/postman/build-request-body.mjs +86 -0
- package/esm/openapi/postman/build-request-body.mjs.map +1 -0
- package/esm/openapi/postman/build-request-url.mjs +85 -0
- package/esm/openapi/postman/build-request-url.mjs.map +1 -0
- package/esm/openapi/postman/build-saved-responses.mjs +60 -0
- package/esm/openapi/postman/build-saved-responses.mjs.map +1 -0
- package/esm/openapi/postman/example-from-schema.d.mts +17 -0
- package/esm/openapi/postman/example-from-schema.d.mts.map +1 -0
- package/esm/openapi/postman/example-from-schema.mjs +92 -0
- package/esm/openapi/postman/example-from-schema.mjs.map +1 -0
- package/esm/openapi/postman/http-status-text.mjs +31 -0
- package/esm/openapi/postman/http-status-text.mjs.map +1 -0
- package/esm/openapi/postman/index.d.mts +3 -0
- package/esm/openapi/postman/openapi-to-postman-collection.d.mts +22 -0
- package/esm/openapi/postman/openapi-to-postman-collection.d.mts.map +1 -0
- package/esm/openapi/postman/openapi-to-postman-collection.mjs +109 -0
- package/esm/openapi/postman/openapi-to-postman-collection.mjs.map +1 -0
- package/esm/openapi/postman/postman-types.d.mts +119 -0
- package/esm/openapi/postman/postman-types.d.mts.map +1 -0
- package/esm/openapi/postman/resolve-operation-auth.mjs +51 -0
- package/esm/openapi/postman/resolve-operation-auth.mjs.map +1 -0
- package/esm/openapi/postman/schema-refs.d.mts +7 -0
- package/esm/openapi/postman/schema-refs.d.mts.map +1 -0
- package/esm/openapi/postman/schema-refs.mjs +41 -0
- package/esm/openapi/postman/schema-refs.mjs.map +1 -0
- package/esm/openapi/postman/uuid-v5.mjs +29 -0
- package/esm/openapi/postman/uuid-v5.mjs.map +1 -0
- package/esm/openapi/response-schemas.mjs +4 -1
- package/esm/openapi/response-schemas.mjs.map +1 -1
- package/esm/openapi/schema-registry.mjs +6 -0
- package/esm/openapi/schema-registry.mjs.map +1 -1
- package/esm/resource/index.d.mts +1 -0
- package/esm/resource/index.mjs +1 -0
- package/esm/resource/nullable-resource.d.mts +44 -0
- package/esm/resource/nullable-resource.d.mts.map +1 -0
- package/esm/resource/nullable-resource.mjs +38 -0
- package/esm/resource/nullable-resource.mjs.map +1 -0
- package/esm/resource/resource.d.mts.map +1 -1
- package/esm/resource/resource.mjs +24 -7
- package/esm/resource/resource.mjs.map +1 -1
- package/esm/resource/types.d.mts +10 -5
- package/esm/resource/types.d.mts.map +1 -1
- package/esm/restful/restful.d.mts +5 -5
- package/esm/restful/restful.d.mts.map +1 -1
- package/esm/router/response-schema-types.mjs +2 -0
- package/esm/router/response-schema-types.mjs.map +1 -1
- package/llms-full.txt +269 -241
- package/llms.txt +42 -42
- package/package.json +12 -12
- package/skills/README.md +39 -39
- package/skills/add-connector/SKILL.md +4 -4
- package/skills/benchmark-code/SKILL.md +3 -3
- package/skills/build-restful/SKILL.md +5 -5
- package/skills/build-url/SKILL.md +7 -7
- package/skills/configure-app/SKILL.md +7 -7
- package/skills/create-controller/SKILL.md +8 -8
- package/skills/create-module/SKILL.md +9 -9
- package/skills/define-resource/SKILL.md +4 -4
- package/skills/encrypt-data/SKILL.md +7 -7
- package/skills/generate-openapi/SKILL.md +33 -5
- package/skills/hash-password/SKILL.md +8 -8
- package/skills/health-checks/SKILL.md +6 -6
- package/skills/lower-stage3-decorators/SKILL.md +4 -4
- package/skills/process-image/SKILL.md +5 -5
- package/skills/register-route/SKILL.md +6 -6
- package/skills/request-memo/SKILL.md +4 -4
- package/skills/request-tracing/SKILL.md +6 -6
- package/skills/resolve-path/SKILL.md +6 -6
- package/skills/retry-operation/SKILL.md +4 -4
- package/skills/run-app/SKILL.md +11 -11
- package/skills/send-mail/SKILL.md +3 -3
- package/skills/send-response/SKILL.md +6 -6
- package/skills/store-file/SKILL.md +4 -4
- package/skills/test-http/SKILL.md +5 -5
- package/skills/test-service/SKILL.md +5 -5
- package/skills/update-packages/SKILL.md +6 -6
- package/skills/upload-file/SKILL.md +7 -7
- package/skills/use-app-context/SKILL.md +7 -7
- package/skills/use-localization/SKILL.md +6 -6
- package/skills/use-middleware/SKILL.md +6 -6
- package/skills/use-model-transformers/SKILL.md +6 -6
- package/skills/use-repository/SKILL.md +7 -7
- package/skills/use-request-locals/SKILL.md +4 -4
- package/skills/validate-input/SKILL.md +7 -7
- package/skills/warlock-conventions/SKILL.md +6 -6
- package/skills/warlock-doctor/SKILL.md +5 -5
- package/skills/warlock-routes/SKILL.md +6 -6
- package/skills/wire-socket/SKILL.md +4 -4
- package/skills/write-cli-command/SKILL.md +6 -6
- package/skills/write-middleware/SKILL.md +8 -8
- package/skills/write-seeder/SKILL.md +5 -5
- package/skills/write-use-case/SKILL.md +3 -3
package/esm/http/request.d.mts
CHANGED
|
@@ -385,14 +385,14 @@ declare class Request<RequestValidation = any> {
|
|
|
385
385
|
* @internal Framework orchestration — do not call from app code. Wired
|
|
386
386
|
* from the Fastify route handler in `router.scan()`.
|
|
387
387
|
*/
|
|
388
|
-
execute(): Promise<any[] |
|
|
388
|
+
execute(): Promise<any[] | Record<string, any> | Response>;
|
|
389
389
|
/**
|
|
390
390
|
* Iterate the collected middlewares in order; return the first short-circuit
|
|
391
391
|
* value or `undefined` when every middleware passes through.
|
|
392
392
|
*
|
|
393
393
|
* @internal Framework orchestration — do not call from app code.
|
|
394
394
|
*/
|
|
395
|
-
protected executeMiddleware(): Promise<any[] |
|
|
395
|
+
protected executeMiddleware(): Promise<any[] | Record<string, any> | Response | undefined>;
|
|
396
396
|
/**
|
|
397
397
|
* Gather the middleware list for the current route — today just the
|
|
398
398
|
* route-level array; future extraction may merge group + app-wide layers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.mts","names":[],"sources":["../../../../../../../core/src/http/request.ts"],"mappings":";;;;;;;;;;KAiCK,eAAA,iBAIU,mBAAA,mBAAsC,CAAA,0BAA2B,CAAA,WAAY,CAAA,GACvF,mBAAA,CAAoB,CAAA;AAAA,KAGpB,UAAA,SAAmB,eAAe;;KAG3B,iBAAA,IAAqB,OAAA,UAAiB,YAAA,GAAe,MAAM;AAAA,cAE1D,OAAA;EATwC;;;;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IAAA,CAAK,GAAA,WAAc,YAAA;;;;;EAUnB,KAAA,CAAM,IAAA,WAAe,YAAA;;;;MAOjB,MAAA;;;;;;;;;;;EAcJ,QAAA,CAAS,GAAA,UAAa,KAAA;;;;MAUlB,KAAA;;;;EAOJ,QAAA,CAAS,GAAA,UAAa,KAAA;;;;EAStB,GAAA;;;;EAOA,eAAA;;;;EAUA,iBAAA;;;;EAmBA,KAAA;;;;EAmBA,IAAA,CAAK,IAAA;;;;EAOL,KAAA,CAAM,IAAA;;;;EAWN,MAAA,CAAO,IAAA;;;;EAOP,IAAA,CAAK,GAAA,UAAa,YAAA;;;;EAqBlB,GAAA,CAAI,GAAA,UAAa,YAAA;;;;MAWb,OAAA;;;;EAOJ,MAAA,CAAO,GAAA,UAAa,YAAA;;;;EASpB,KAAA,CAAM,GAAA,UAAa,YAAA;;;;EASnB,MAAA,CAAO,GAAA,UAAa,YAAA;;;;;;;;;;MAehB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCJ,QAAA;;;;MAoCI,MAAA;;;;MAOA,GAAA;;;;MAOA,OAAA;;;;MAOA,SAAA;;;;MAOA,OAAA,gBAAuB,WAAA,CAAY,OAAA;;;;EAOvC,SAAA,CAAU,GAAA,EAAK,UAAA,EAAY,KAAA;AAAA"}
|
package/esm/index.d.mts
CHANGED
|
@@ -68,6 +68,7 @@ import { ModelResourceRegistry, Serialized, SerializedWire } from "./http/serial
|
|
|
68
68
|
import { LocalizedObject, getLocalized } from "./utils/get-localized.mjs";
|
|
69
69
|
import { ResourceFieldBuilder } from "./resource/resource-field-builder.mjs";
|
|
70
70
|
import { Resource, ResourceConstructor, ResourceContract } from "./resource/resource.mjs";
|
|
71
|
+
import { NULLABLE_RESOURCE, NullableResource, NullableResourceTarget, isNullableResource, nullable } from "./resource/nullable-resource.mjs";
|
|
71
72
|
import { BaseCastOutput, CastOutput, FieldOutput, ResourceArraySchema, ResourceCastType, ResourceFieldBuilderDateOutputOptions, ResourceFieldConfig, ResourceOutput, ResourceOutputOf, ResourceOutputValueCastType, ResourceSchema, ResourceSelfReference, ResponseBodyOutput, ResponseBodyValue, ResponseSchema, ResponseSchemaOutput } from "./resource/types.mjs";
|
|
72
73
|
import { GroupedRoutesOptions, HttpContext, Middleware, MiddlewareResponse, NamedApiRoute, NamedApiRoutesOptions, PartialPick, RequestControllerContract, RequestHandler, RequestHandlerType, RequestHandlerValidation, RequestMethod, ResourceMethod, RestfulMiddleware, Route, RouteOptions, RouteResource, RouterGroupCallback, RouterStacks } from "./router/types.mjs";
|
|
73
74
|
import { PositionalHandlerSuspect, clearPositionalHandlerSuspects, describePositionalHandlerSuspect, forgetPositionalHandlerSuspects, inspectHandlerSignature, listPositionalHandlerSuspects, looksLikePositionalHandler, reportPositionalHandlerSuspects } from "./router/positional-handler-diagnostics.mjs";
|
|
@@ -115,6 +116,7 @@ import { SocketConnector } from "./connectors/socket-connector.mjs";
|
|
|
115
116
|
import { StorageConnector } from "./connectors/storage.connector.mjs";
|
|
116
117
|
import { CLICommandAction, CLICommandOption, CLICommandOptions, CLICommandPreload, CLICommandSource, CommandActionData, ResolvedCLICommandOption } from "./commands/types.mjs";
|
|
117
118
|
import { CLICommand, command } from "./commands/cli-command.mjs";
|
|
119
|
+
import { DevelopmentAppModuleEntry, DevelopmentAppModules } from "./container/development-app-modules.mjs";
|
|
118
120
|
import { DevelopmentModelModuleEntry, DevelopmentModelModuleState, DevelopmentModelModules } from "./container/development-model-modules.mjs";
|
|
119
121
|
import { ContainerTypes, container } from "./container/index.mjs";
|
|
120
122
|
import { DatabaseLogModel } from "./database/models/database-log/database-log.mjs";
|
|
@@ -139,9 +141,12 @@ import { renderReactMail } from "./mail/react-mail.mjs";
|
|
|
139
141
|
import { sendMail } from "./mail/send-mail.mjs";
|
|
140
142
|
import { Mail } from "./mail/mail.mjs";
|
|
141
143
|
import { assertMailCount, assertMailSent, captureMail, clearTestMailbox, findMailsBySubject, findMailsTo, getLastMail, getMailboxSize, getTestMailbox, wasMailSentTo, wasMailSentWithSubject } from "./mail/test-mailbox.mjs";
|
|
144
|
+
import { PostmanAuth, PostmanAuthEntry, PostmanBody, PostmanCollection, PostmanCollectionOptions, PostmanFolder, PostmanFormParam, PostmanHeader, PostmanItem, PostmanOriginalRequest, PostmanQueryParam, PostmanRequest, PostmanRequestItem, PostmanResponse, PostmanUrl, PostmanVariable } from "./openapi/postman/postman-types.mjs";
|
|
142
145
|
import { AuthDescriptor, OpenApiBuildResult, OpenApiComponents, OpenApiContext, OpenApiDocument, OpenApiOperation, OpenApiParameter, OpenApiRequestBody, OpenApiResponse, OpenApiRouteInput, OpenApiSchema, OpenApiSecurityRequirement, OpenApiSecurityScheme, OpenApiValidationResponseConfig, WarningSink } from "./openapi/types.mjs";
|
|
143
|
-
import { getDevelopmentOpenApiDocument, registerDevelopmentOpenApiProvider } from "./openapi/development-openapi-provider.mjs";
|
|
146
|
+
import { DevelopmentPostmanResult, getDevelopmentOpenApiDocument, getDevelopmentPostmanCollection, registerDevelopmentOpenApiProvider } from "./openapi/development-openapi-provider.mjs";
|
|
144
147
|
import { OPENAPI_JSON_SCHEMA_DIALECT, buildOpenApiDocument } from "./openapi/build-openapi-document.mjs";
|
|
148
|
+
import { exampleFromSchema } from "./openapi/postman/example-from-schema.mjs";
|
|
149
|
+
import { DEFAULT_POSTMAN_BASE_URL, POSTMAN_COLLECTION_SCHEMA, openApiToPostmanCollection } from "./openapi/postman/openapi-to-postman-collection.mjs";
|
|
145
150
|
import { renderReact } from "./react/index.mjs";
|
|
146
151
|
import { RepositoryManager } from "./repositories/repository.manager.mjs";
|
|
147
152
|
import { RepositoryAdapterContract } from "./repositories/contracts/repository-adapter.contract.mjs";
|
|
@@ -186,7 +191,7 @@ import { WarlockConfigManager, isUnknownTsExtensionError, warlockConfigManager }
|
|
|
186
191
|
import { env } from "@mongez/dotenv";
|
|
187
192
|
import { colors } from "@mongez/copper";
|
|
188
193
|
export * from "@mongez/localization";
|
|
189
|
-
export { $registerUseCase, $unregisterUseCase, APP_ROLES, AccessConnector, AggregateExpressionInput, AggregateExpressions, AiConnector, AllRepositoryOptions, AppConfigurations, AppRole, Application, AuthDescriptor, BOOT_SIGNAL_ENV_KEY, BOOT_SIGNAL_VERSION, BadRequestError, BadSchemaUseCaseError, BaseCastOutput, BaseConnector, type BenchmarkChannel, type BenchmarkConfigurations, type BenchmarkErrorResult, type BenchmarkOptions, BenchmarkProfiler, type BenchmarkProfilerOptions, type BenchmarkResult, BenchmarkSnapshots, type BenchmarkSnapshotsOptions, type BenchmarkStats, type BenchmarkSuccessResult, BootContext, BootListener, BootSignal, BootSignalType, BootValidator, CLICommand, type CLICommandAction, type CLICommandOption, type CLICommandOptions, type CLICommandPreload, type CLICommandSource, CacheConnector, type CacheMiddlewareOptions, CachedRepositoryOptions, type CapturedMail, CascadeAdapter, CascadeQueryBuilder, CastOutput, ChunkCallback, ClosableServer, CloudDriver, CloudStorageDriverContract, CloudStorageDriverOptions, CloudStorageFileData, type CommandActionData, type ConcurrencyLimitOptions, ConfigKey, ConfigKeyRegistry, ConfigName, ConfigRegistry, ConfigSpecialHandlers, ConflictError, Connector, ConnectorBuildContext, ConnectorBuildContribution, ConnectorBuildGenerateResult, ConnectorEsbuildPatch, ConnectorLifecyclePhase, ConnectorName, ConnectorPriority, ConnectorsManager, ConsoleChannel, ContainerTypes, CookieJarUnavailableError, CookieOptions, CspConfig, CsrfOriginCheckReason, CsrfOriginVerdict, CursorPaginationOptions, CursorPaginationResult, DEFAULT_CSP_DIRECTIVES, DOSpacesDriver, DatabaseCacheDriver, type DatabaseCacheOptions, DatabaseConnector, DatabaseLog, DatabaseLogModel, DatabaseLogOptions, DecodedAccessToken, DefineResourceOptions, DeleteManyResult, DetectedImageFormat, type DevelopmentModelModuleEntry, type DevelopmentModelModuleState, type DevelopmentModelModules, EncryptionConfigurations, EncryptionPasswordConfigurations, Environment, EventSubscription, ExistsExceptCurrentIdRuleOptions, ExistsExceptCurrentUserRuleOptions, FastifyInstance, FieldOutput, FileNamingStrategy, FileValidationOptions, FileValidator, FileVisibility, FilterFunction, FilterOperator, FilterOptions, FilterRule, FilterRules, ForbiddenError, GenerateImageVariantsOptions, GeneratedImageDescriptor, GeneratedImageVariant, GroupByFields, GroupedRoutesOptions, HealthCheck, HealthStatus, HeraldConnector, HttpConfigurations, HttpConnector, HttpContext, HttpError, HttpErrorCodes, HttpReadyReport, HttpServerRebuiltListener, HttpTracingConfig, type IdempotencyOptions, Image, ImageFormat, ImageInput, ImageTransformCallback, ImageTransformConfig, ImageTransformOptions, ImageVariantDefinition, ImageVariantFit, ImageVariantOutputFormat, ImageVariantsConfigError, InvalidCspDirectiveError, type IpFilterOptions, ListOptions, LocalDriver, LocalStorageDriverOptions, LocaleDictionaryEntries, LocaleDictionaryError, LocalizedObject, LogConfigurations, LoggerConnector, MAIL_EVENTS, Mail, type MailAddress, type MailAttachment, type MailConfigurations, MailError, type MailErrorCode, type MailEvents, type MailMode, type MailOptions, type MailPriority, type MailResult, MailerConnector, type MailersConfig, type MaintenanceOptions, Middleware, MiddlewareResponse, MimeTypes, ModelResourceRegistry, NamedApiRoute, NamedApiRoutesOptions, NoopChannel, type NormalizedMail, NotAcceptableError, NotAllowedError, NotificationsConnector, OPENAPI_JSON_SCHEMA_DIALECT, OpenApiBuildResult, OpenApiComponents, OpenApiContext, OpenApiDocument, OpenApiOperation, OpenApiParameter, OpenApiRequestBody, OpenApiResponse, OpenApiRouteInput, OpenApiSchema, OpenApiSecurityRequirement, OpenApiSecurityScheme, OpenApiValidationResponseConfig, PaginationMode, PaginationResult, ParsedLocaleDictionary, PartialMiddleware, PartialPick, Path, PipeableReactStream, PipelineOptions, PortInUseError, PositionalHandlerSuspect, PrefixConfig, PrefixOptions, PresignedOptions, PresignedUploadOptions, PutDirectoryOptions, PutDirectoryResult, PutFromUrlOptions, PutOptions, QueryBuilderContract, Queue, R2Driver, R2StorageDriverOptions, type RateLimitOptions, RegisterConfiguredConnectorsOptions, RegisterResource, RegisteredUseCase, RepositoryAdapterContract, RepositoryConfigurations, RepositoryEvent, RepositoryManager, RepositoryOptions, RepositoryOptionsWithCursor, RepositoryOptionsWithPages, Request, RequestContextStore, RequestController, RequestControllerContract, RequestEvent, RequestHandler, RequestHandlerType, RequestHandlerValidation, RequestLocals, RequestLog, RequestMethod, RequestTranslator, type ResolvedCLICommandOption, ResolvedImageVariantsConfig, Resource, ResourceArraySchema, ResourceCastType, ResourceConstructor, ResourceContract, ResourceFieldBuilder, ResourceFieldBuilderDateOutputOptions, ResourceFieldConfig, ResourceMethod, ResourceNotFoundError, ResourceOutput, ResourceOutputOf, ResourceOutputValueCastType, ResourceSchema, ResourceSelfReference, Response, ResponseBodyOutput, ResponseBodyValue, ResponseEvent, ResponseSSEController, ResponseSchema, ResponseSchemaOutput, ResponseStatus, ResponseStreamController, Restful, RestfulMiddleware, ReturnedResponse, Route, RouteOptions, RouteRegistry, RouteResource, Router, RouterGroupCallback, RouterStacks, RuntimeStrategy, S3Driver, type SESConfigurations, type SMTPConfigurations, SafeFetchOptions, SafeFetchResult, SaveAsOptions, SaveMode, SaveOptions, ScopedStorage, ScopedStorageContract, SeedClock, SeedContext, SeedRecordRef, SeedResult, Seeder, SeederDependencyCycleError, SeederMetadata, SendBufferOptions, SendFileOptions, Serialized, SerializedWire, ServerError, ShutdownListener, SocketAdapterFactory, SocketConnector, SocketOptions, Storage, StorageCapabilityError, StorageConfigurations, StorageConnector, StorageCopyEventPayload, StorageDriverConfig, StorageDriverContextStore, StorageDriverContract, StorageDriverName, StorageDriverRegistry, StorageDriverType, StorageError, StorageErrorOptions, StorageEventHandler, StorageEventPayload, StorageEventType, StorageFile, StorageFileData, StorageFileInfo, StorageManagerContract, StorageNotInitializedError, StoragePutEventPayload, StreamReactResponseOptions, TemporaryTokenError, TemporaryTokenPayload, TemporaryTokenValidation, TracingContext, TracingContextSource, TracingHooks, TracingPhaseInfo, TracingRequestEndInfo, Track, TrackableModel, TypedAllRepositoryOptions, TypedRepositoryOptions, TypedRepositoryOptionsWithCursor, TypedRepositoryOptionsWithPages, UPDATE_MANY_BATCH_SIZE, UPLOADS_DEFAULTS, UnAuthorizedError, UniqueExceptCurrentIdRuleOptions, UniqueExceptCurrentUserRuleOptions, UnknownSeederDependencyError, UploadedFile, UploadedFileImageOptions, UploadedFileJson, UploadedFileQuery, UploadsConfigurations, UploadsImagesConfigurations, UseCase, UseCaseAfterMiddleware, UseCaseBeforeMiddleware, UseCaseBroadcastChannel, UseCaseBroadcastEvent, UseCaseBroadcastOption, UseCaseConfigurations, UseCaseContext, UseCaseErrorResult, UseCaseEventsCallbacksMap, UseCaseGuard, UseCaseHandler, UseCaseOnExecutingContext, UseCaseResult, UseCaseRuntimeOptions, UseCaseWithSchema, ValidationConfiguration, VariantOutputFormat, VariantSourceFormat, WarlockConfig, WarlockConfigManager, WarningSink, WatermarkConfig, WhereOperator, XMLable, addUseCaseHistory, anyMatch, app, appLog, appPath, applyCspHeader, assertConfiguredHttpPortIsFree, assertMailCount, assertMailSent, assertNoReservedConnectorNames, assertPortIsAvailable, assertSitesRequireWebRole, assertUniqueConnectorNames, assetsUrl, bootstrap, broadcastUseCaseResult, buildCspHeaderValue, buildIdempotencyCacheKey, buildOpenApiDocument, buildTracingContext, cachePath, captureMail, clearPositionalHandlerSuspects, clearTestMailbox, closeAllMailers, closeMailer, closeServerWithTimeout, colors, command, config, configPath, configSpecialHandlers, connectorsManager, container, createHttpApplication, createRequestStore, decrypt, defaultHttpConfigurations, defineConfig, defineResource, deriveTraceId, describePositionalHandlerSuspect, dispatchPhase, dispatchRequestEnd, dispatchRequestStart, displayEnvironmentMode, encrypt, ensureFatalIsVisible, env, environment, existsExceptCurrentIdRule, existsExceptCurrentUserRule, fetchLatestVersion, fileExtensionRule, fileRule, fileTypeRule, findMailsBySubject, findMailsTo, fireLifecycleEvent, forgetPositionalHandlerSuspects, generateImageVariants, generateMailId, getDefaultMailConfig, getDevelopmentOpenApiDocument, getHttpReadyReport, getHttpServer, getLastMail, getLocalized, getMailEventName, getMailMode, getMailboxSize, getMailer, getMailerConfig, getMimeType, getPoolStats, getPublicUrl, getRoles, getSites, getSocketServer, getTestMailbox, getUseCase, getUseCaseHistory, getUseCases, globalEventsCallbacksMap, globalUseCasesEvents, hasRole, hashBody, hashPassword, health, hmacHash, httpConfig, imageRule, increaseUseCaseFailedCalls, increaseUseCaseSuccessCalls, inspectHandlerSignature, ipMatches, isAllowedCsrfOrigin, isBootSignal, isDevelopmentMode, isNewerVersion, isPortAvailable, isPrivateOrReservedIp, isProductionMode, isTestMode, isTracingEnabled, isUnknownTsExtensionError, isValidIdempotencyKey, listPositionalHandlerSuspects, loadS3, logResponse, logsPath, looksLikePositionalHandler, mailEvents, matchesDerivedRouteName, measure, mergeCspDirectives, middleware, normalizeOrigin, normalizeRequestPath, normalizeRoutePath, notifyHttpServerRebuilt, onHttpServerRebuilt, originOf, ownOrigin, parseLocaleDictionary, parseRoles, parseSites, parseSize, parseTraceparentTraceId, paths, preflightConfiguredHttpPort, promiseAllObject, publicPath, publicUrl, registerAppConfig, registerConfiguredConnectors, registerDevelopmentOpenApiProvider, registerGroupedTranslationKeys, registerHttpPlugins, registerLocaleDictionary, registerTracingHooks, remedyLines, renderReact, renderReactMail, reportPositionalHandlerSuspects, requestContext, requestMemo, requiresDefaultCsrfGuard, resetHttpReadyReport, resetMailConfig, resetRolesCacheForTests, resetTracingConfigForTests, resolveCspConfig, resolveCsrfOriginVerdict, resolveMailConfig, resolveTracingConfig, resolveWithinRoot, rootPath, routeNameMethodSuffix, router, runDefaultCsrfGuard, runPipeline, safeFetchToBuffer, sanitizePath, seeder, sendBootSignal, sendMail, serializeCspDirectives, servesHttp, setBaseUrl, setConfig, setEnvironment, setHttpReadyReport, setLogConfigurations, setMailConfigurations, setMailMode, shouldPreflightHttpPort, sleep, sluggable, srcPath, startHttpServer, stopHttpApplication, storage, storageConfig, storageConfigurations, storageDriverContext, storagePath, streamReactResponse, t, tempPath, toJson, uniqueExceptCurrentIdRule, uniqueExceptCurrentUserRule, unregisterLocaleDictionary, uploadedFileController, uploadedFileMetadataSchema, uploadsConfig, uploadsPath, uploadsUrl, url, useCase, useComputedModel, useComputedSlug, useCurrentUser, useHashedPassword, useRequest, useRequestStore, validateCspConfigAtBoot, validateCspDirectives, verifyMailer, verifyPassword, warlockConfigManager, warlockPath, wasMailSentTo, wasMailSentWithSubject, wrapResponseInDataKey };
|
|
194
|
+
export { $registerUseCase, $unregisterUseCase, APP_ROLES, AccessConnector, AggregateExpressionInput, AggregateExpressions, AiConnector, AllRepositoryOptions, AppConfigurations, AppRole, Application, AuthDescriptor, BOOT_SIGNAL_ENV_KEY, BOOT_SIGNAL_VERSION, BadRequestError, BadSchemaUseCaseError, BaseCastOutput, BaseConnector, type BenchmarkChannel, type BenchmarkConfigurations, type BenchmarkErrorResult, type BenchmarkOptions, BenchmarkProfiler, type BenchmarkProfilerOptions, type BenchmarkResult, BenchmarkSnapshots, type BenchmarkSnapshotsOptions, type BenchmarkStats, type BenchmarkSuccessResult, BootContext, BootListener, BootSignal, BootSignalType, BootValidator, CLICommand, type CLICommandAction, type CLICommandOption, type CLICommandOptions, type CLICommandPreload, type CLICommandSource, CacheConnector, type CacheMiddlewareOptions, CachedRepositoryOptions, type CapturedMail, CascadeAdapter, CascadeQueryBuilder, CastOutput, ChunkCallback, ClosableServer, CloudDriver, CloudStorageDriverContract, CloudStorageDriverOptions, CloudStorageFileData, type CommandActionData, type ConcurrencyLimitOptions, ConfigKey, ConfigKeyRegistry, ConfigName, ConfigRegistry, ConfigSpecialHandlers, ConflictError, Connector, ConnectorBuildContext, ConnectorBuildContribution, ConnectorBuildGenerateResult, ConnectorEsbuildPatch, ConnectorLifecyclePhase, ConnectorName, ConnectorPriority, ConnectorsManager, ConsoleChannel, ContainerTypes, CookieJarUnavailableError, CookieOptions, CspConfig, CsrfOriginCheckReason, CsrfOriginVerdict, CursorPaginationOptions, CursorPaginationResult, DEFAULT_CSP_DIRECTIVES, DEFAULT_POSTMAN_BASE_URL, DOSpacesDriver, DatabaseCacheDriver, type DatabaseCacheOptions, DatabaseConnector, DatabaseLog, DatabaseLogModel, DatabaseLogOptions, DecodedAccessToken, DefineResourceOptions, DeleteManyResult, DetectedImageFormat, type DevelopmentAppModuleEntry, type DevelopmentAppModules, type DevelopmentModelModuleEntry, type DevelopmentModelModuleState, type DevelopmentModelModules, DevelopmentPostmanResult, EncryptionConfigurations, EncryptionPasswordConfigurations, Environment, EventSubscription, ExistsExceptCurrentIdRuleOptions, ExistsExceptCurrentUserRuleOptions, FastifyInstance, FieldOutput, FileNamingStrategy, FileValidationOptions, FileValidator, FileVisibility, FilterFunction, FilterOperator, FilterOptions, FilterRule, FilterRules, ForbiddenError, GenerateImageVariantsOptions, GeneratedImageDescriptor, GeneratedImageVariant, GroupByFields, GroupedRoutesOptions, HealthCheck, HealthStatus, HeraldConnector, HttpConfigurations, HttpConnector, HttpContext, HttpError, HttpErrorCodes, HttpReadyReport, HttpServerRebuiltListener, HttpTracingConfig, type IdempotencyOptions, Image, ImageFormat, ImageInput, ImageTransformCallback, ImageTransformConfig, ImageTransformOptions, ImageVariantDefinition, ImageVariantFit, ImageVariantOutputFormat, ImageVariantsConfigError, InvalidCspDirectiveError, type IpFilterOptions, ListOptions, LocalDriver, LocalStorageDriverOptions, LocaleDictionaryEntries, LocaleDictionaryError, LocalizedObject, LogConfigurations, LoggerConnector, MAIL_EVENTS, Mail, type MailAddress, type MailAttachment, type MailConfigurations, MailError, type MailErrorCode, type MailEvents, type MailMode, type MailOptions, type MailPriority, type MailResult, MailerConnector, type MailersConfig, type MaintenanceOptions, Middleware, MiddlewareResponse, MimeTypes, ModelResourceRegistry, NULLABLE_RESOURCE, NamedApiRoute, NamedApiRoutesOptions, NoopChannel, type NormalizedMail, NotAcceptableError, NotAllowedError, NotificationsConnector, NullableResource, NullableResourceTarget, OPENAPI_JSON_SCHEMA_DIALECT, OpenApiBuildResult, OpenApiComponents, OpenApiContext, OpenApiDocument, OpenApiOperation, OpenApiParameter, OpenApiRequestBody, OpenApiResponse, OpenApiRouteInput, OpenApiSchema, OpenApiSecurityRequirement, OpenApiSecurityScheme, OpenApiValidationResponseConfig, POSTMAN_COLLECTION_SCHEMA, PaginationMode, PaginationResult, ParsedLocaleDictionary, PartialMiddleware, PartialPick, Path, PipeableReactStream, PipelineOptions, PortInUseError, PositionalHandlerSuspect, PostmanAuth, PostmanAuthEntry, PostmanBody, PostmanCollection, PostmanCollectionOptions, PostmanFolder, PostmanFormParam, PostmanHeader, PostmanItem, PostmanOriginalRequest, PostmanQueryParam, PostmanRequest, PostmanRequestItem, PostmanResponse, PostmanUrl, PostmanVariable, PrefixConfig, PrefixOptions, PresignedOptions, PresignedUploadOptions, PutDirectoryOptions, PutDirectoryResult, PutFromUrlOptions, PutOptions, QueryBuilderContract, Queue, R2Driver, R2StorageDriverOptions, type RateLimitOptions, RegisterConfiguredConnectorsOptions, RegisterResource, RegisteredUseCase, RepositoryAdapterContract, RepositoryConfigurations, RepositoryEvent, RepositoryManager, RepositoryOptions, RepositoryOptionsWithCursor, RepositoryOptionsWithPages, Request, RequestContextStore, RequestController, RequestControllerContract, RequestEvent, RequestHandler, RequestHandlerType, RequestHandlerValidation, RequestLocals, RequestLog, RequestMethod, RequestTranslator, type ResolvedCLICommandOption, ResolvedImageVariantsConfig, Resource, ResourceArraySchema, ResourceCastType, ResourceConstructor, ResourceContract, ResourceFieldBuilder, ResourceFieldBuilderDateOutputOptions, ResourceFieldConfig, ResourceMethod, ResourceNotFoundError, ResourceOutput, ResourceOutputOf, ResourceOutputValueCastType, ResourceSchema, ResourceSelfReference, Response, ResponseBodyOutput, ResponseBodyValue, ResponseEvent, ResponseSSEController, ResponseSchema, ResponseSchemaOutput, ResponseStatus, ResponseStreamController, Restful, RestfulMiddleware, ReturnedResponse, Route, RouteOptions, RouteRegistry, RouteResource, Router, RouterGroupCallback, RouterStacks, RuntimeStrategy, S3Driver, type SESConfigurations, type SMTPConfigurations, SafeFetchOptions, SafeFetchResult, SaveAsOptions, SaveMode, SaveOptions, ScopedStorage, ScopedStorageContract, SeedClock, SeedContext, SeedRecordRef, SeedResult, Seeder, SeederDependencyCycleError, SeederMetadata, SendBufferOptions, SendFileOptions, Serialized, SerializedWire, ServerError, ShutdownListener, SocketAdapterFactory, SocketConnector, SocketOptions, Storage, StorageCapabilityError, StorageConfigurations, StorageConnector, StorageCopyEventPayload, StorageDriverConfig, StorageDriverContextStore, StorageDriverContract, StorageDriverName, StorageDriverRegistry, StorageDriverType, StorageError, StorageErrorOptions, StorageEventHandler, StorageEventPayload, StorageEventType, StorageFile, StorageFileData, StorageFileInfo, StorageManagerContract, StorageNotInitializedError, StoragePutEventPayload, StreamReactResponseOptions, TemporaryTokenError, TemporaryTokenPayload, TemporaryTokenValidation, TracingContext, TracingContextSource, TracingHooks, TracingPhaseInfo, TracingRequestEndInfo, Track, TrackableModel, TypedAllRepositoryOptions, TypedRepositoryOptions, TypedRepositoryOptionsWithCursor, TypedRepositoryOptionsWithPages, UPDATE_MANY_BATCH_SIZE, UPLOADS_DEFAULTS, UnAuthorizedError, UniqueExceptCurrentIdRuleOptions, UniqueExceptCurrentUserRuleOptions, UnknownSeederDependencyError, UploadedFile, UploadedFileImageOptions, UploadedFileJson, UploadedFileQuery, UploadsConfigurations, UploadsImagesConfigurations, UseCase, UseCaseAfterMiddleware, UseCaseBeforeMiddleware, UseCaseBroadcastChannel, UseCaseBroadcastEvent, UseCaseBroadcastOption, UseCaseConfigurations, UseCaseContext, UseCaseErrorResult, UseCaseEventsCallbacksMap, UseCaseGuard, UseCaseHandler, UseCaseOnExecutingContext, UseCaseResult, UseCaseRuntimeOptions, UseCaseWithSchema, ValidationConfiguration, VariantOutputFormat, VariantSourceFormat, WarlockConfig, WarlockConfigManager, WarningSink, WatermarkConfig, WhereOperator, XMLable, addUseCaseHistory, anyMatch, app, appLog, appPath, applyCspHeader, assertConfiguredHttpPortIsFree, assertMailCount, assertMailSent, assertNoReservedConnectorNames, assertPortIsAvailable, assertSitesRequireWebRole, assertUniqueConnectorNames, assetsUrl, bootstrap, broadcastUseCaseResult, buildCspHeaderValue, buildIdempotencyCacheKey, buildOpenApiDocument, buildTracingContext, cachePath, captureMail, clearPositionalHandlerSuspects, clearTestMailbox, closeAllMailers, closeMailer, closeServerWithTimeout, colors, command, config, configPath, configSpecialHandlers, connectorsManager, container, createHttpApplication, createRequestStore, decrypt, defaultHttpConfigurations, defineConfig, defineResource, deriveTraceId, describePositionalHandlerSuspect, dispatchPhase, dispatchRequestEnd, dispatchRequestStart, displayEnvironmentMode, encrypt, ensureFatalIsVisible, env, environment, exampleFromSchema, existsExceptCurrentIdRule, existsExceptCurrentUserRule, fetchLatestVersion, fileExtensionRule, fileRule, fileTypeRule, findMailsBySubject, findMailsTo, fireLifecycleEvent, forgetPositionalHandlerSuspects, generateImageVariants, generateMailId, getDefaultMailConfig, getDevelopmentOpenApiDocument, getDevelopmentPostmanCollection, getHttpReadyReport, getHttpServer, getLastMail, getLocalized, getMailEventName, getMailMode, getMailboxSize, getMailer, getMailerConfig, getMimeType, getPoolStats, getPublicUrl, getRoles, getSites, getSocketServer, getTestMailbox, getUseCase, getUseCaseHistory, getUseCases, globalEventsCallbacksMap, globalUseCasesEvents, hasRole, hashBody, hashPassword, health, hmacHash, httpConfig, imageRule, increaseUseCaseFailedCalls, increaseUseCaseSuccessCalls, inspectHandlerSignature, ipMatches, isAllowedCsrfOrigin, isBootSignal, isDevelopmentMode, isNewerVersion, isNullableResource, isPortAvailable, isPrivateOrReservedIp, isProductionMode, isTestMode, isTracingEnabled, isUnknownTsExtensionError, isValidIdempotencyKey, listPositionalHandlerSuspects, loadS3, logResponse, logsPath, looksLikePositionalHandler, mailEvents, matchesDerivedRouteName, measure, mergeCspDirectives, middleware, normalizeOrigin, normalizeRequestPath, normalizeRoutePath, notifyHttpServerRebuilt, nullable, onHttpServerRebuilt, openApiToPostmanCollection, originOf, ownOrigin, parseLocaleDictionary, parseRoles, parseSites, parseSize, parseTraceparentTraceId, paths, preflightConfiguredHttpPort, promiseAllObject, publicPath, publicUrl, registerAppConfig, registerConfiguredConnectors, registerDevelopmentOpenApiProvider, registerGroupedTranslationKeys, registerHttpPlugins, registerLocaleDictionary, registerTracingHooks, remedyLines, renderReact, renderReactMail, reportPositionalHandlerSuspects, requestContext, requestMemo, requiresDefaultCsrfGuard, resetHttpReadyReport, resetMailConfig, resetRolesCacheForTests, resetTracingConfigForTests, resolveCspConfig, resolveCsrfOriginVerdict, resolveMailConfig, resolveTracingConfig, resolveWithinRoot, rootPath, routeNameMethodSuffix, router, runDefaultCsrfGuard, runPipeline, safeFetchToBuffer, sanitizePath, seeder, sendBootSignal, sendMail, serializeCspDirectives, servesHttp, setBaseUrl, setConfig, setEnvironment, setHttpReadyReport, setLogConfigurations, setMailConfigurations, setMailMode, shouldPreflightHttpPort, sleep, sluggable, srcPath, startHttpServer, stopHttpApplication, storage, storageConfig, storageConfigurations, storageDriverContext, storagePath, streamReactResponse, t, tempPath, toJson, uniqueExceptCurrentIdRule, uniqueExceptCurrentUserRule, unregisterLocaleDictionary, uploadedFileController, uploadedFileMetadataSchema, uploadsConfig, uploadsPath, uploadsUrl, url, useCase, useComputedModel, useComputedSlug, useCurrentUser, useHashedPassword, useRequest, useRequestStore, validateCspConfigAtBoot, validateCspDirectives, verifyMailer, verifyPassword, warlockConfigManager, warlockPath, wasMailSentTo, wasMailSentWithSubject, wrapResponseInDataKey };
|
|
190
195
|
import "./config/types.mjs";
|
|
191
196
|
import "./http/request.mjs";
|
|
192
197
|
import "./http/serialized.mjs";
|
package/esm/index.mjs
CHANGED
|
@@ -150,7 +150,10 @@ import "./encryption/index.mjs";
|
|
|
150
150
|
import { LocaleDictionaryError, parseLocaleDictionary } from "./localization/parse-locale-dictionary.mjs";
|
|
151
151
|
import { registerGroupedTranslationKeys, registerLocaleDictionary, unregisterLocaleDictionary } from "./localization/register-locale-dictionary.mjs";
|
|
152
152
|
import "./localization/index.mjs";
|
|
153
|
-
import {
|
|
153
|
+
import { exampleFromSchema } from "./openapi/postman/example-from-schema.mjs";
|
|
154
|
+
import { DEFAULT_POSTMAN_BASE_URL, POSTMAN_COLLECTION_SCHEMA, openApiToPostmanCollection } from "./openapi/postman/openapi-to-postman-collection.mjs";
|
|
155
|
+
import { getDevelopmentOpenApiDocument, getDevelopmentPostmanCollection, registerDevelopmentOpenApiProvider } from "./openapi/development-openapi-provider.mjs";
|
|
156
|
+
import { NULLABLE_RESOURCE, isNullableResource, nullable } from "./resource/nullable-resource.mjs";
|
|
154
157
|
import { OPENAPI_JSON_SCHEMA_DIALECT, buildOpenApiDocument } from "./openapi/build-openapi-document.mjs";
|
|
155
158
|
import "./openapi/index.mjs";
|
|
156
159
|
import { CascadeQueryBuilder } from "./repositories/adapters/cascade/cascade-query-builder.mjs";
|
|
@@ -181,4 +184,4 @@ import { colors } from "@mongez/copper";
|
|
|
181
184
|
|
|
182
185
|
export * from "@mongez/localization"
|
|
183
186
|
|
|
184
|
-
export { $registerUseCase, $unregisterUseCase, APP_ROLES, AccessConnector, AiConnector, Application, BOOT_SIGNAL_ENV_KEY, BOOT_SIGNAL_VERSION, BadRequestError, BadSchemaUseCaseError, BaseConnector, BenchmarkProfiler, BenchmarkSnapshots, CLICommand, CacheConnector, CascadeAdapter, CascadeQueryBuilder, CloudDriver, ConfigSpecialHandlers, ConflictError, ConnectorLifecyclePhase, ConnectorPriority, ConnectorsManager, ConsoleChannel, CookieJarUnavailableError, DEFAULT_CSP_DIRECTIVES, DOSpacesDriver, DatabaseCacheDriver, DatabaseConnector, DatabaseLog, DatabaseLogModel, FileValidator, ForbiddenError, HeraldConnector, HttpConnector, HttpError, HttpErrorCodes, Image, ImageVariantsConfigError, InvalidCspDirectiveError, LocalDriver, LocaleDictionaryError, LoggerConnector, MAIL_EVENTS, Mail, MailError, MailerConnector, MimeTypes, NoopChannel, NotAcceptableError, NotAllowedError, NotificationsConnector, OPENAPI_JSON_SCHEMA_DIALECT, Path, PortInUseError, Queue, R2Driver, RegisterResource, RepositoryManager, Request, RequestController, RequestLog, Resource, ResourceFieldBuilder, ResourceNotFoundError, Response, ResponseStatus, Restful, RouteRegistry, Router, S3Driver, ScopedStorage, SeederDependencyCycleError, ServerError, SocketConnector, Storage, StorageCapabilityError, StorageConnector, StorageError, StorageFile, StorageNotInitializedError, UPDATE_MANY_BATCH_SIZE, UPLOADS_DEFAULTS, UnAuthorizedError, UnknownSeederDependencyError, UploadedFile, WarlockConfigManager, addUseCaseHistory, anyMatch, app, appLog, appPath, applyCspHeader, assertConfiguredHttpPortIsFree, assertMailCount, assertMailSent, assertNoReservedConnectorNames, assertPortIsAvailable, assertSitesRequireWebRole, assertUniqueConnectorNames, assetsUrl, bootstrap, broadcastUseCaseResult, buildCspHeaderValue, buildIdempotencyCacheKey, buildOpenApiDocument, buildTracingContext, cachePath, captureMail, clearPositionalHandlerSuspects, clearTestMailbox, closeAllMailers, closeMailer, closeServerWithTimeout, colors, command, config, configPath, configSpecialHandlers, connectorsManager, container, createHttpApplication, createRequestStore, decrypt, defaultHttpConfigurations, defineConfig, defineResource, deriveTraceId, describePositionalHandlerSuspect, dispatchPhase, dispatchRequestEnd, dispatchRequestStart, displayEnvironmentMode, encrypt, ensureFatalIsVisible, env, environment, existsExceptCurrentIdRule, existsExceptCurrentUserRule, fetchLatestVersion, fileExtensionRule, fileRule, fileTypeRule, findMailsBySubject, findMailsTo, fireLifecycleEvent, forgetPositionalHandlerSuspects, generateImageVariants, generateMailId, getDefaultMailConfig, getDevelopmentOpenApiDocument, getHttpReadyReport, getHttpServer, getLastMail, getLocalized, getMailEventName, getMailMode, getMailboxSize, getMailer, getMailerConfig, getMimeType, getPoolStats, getPublicUrl, getRoles, getSites, getSocketServer, getTestMailbox, getUseCase, getUseCaseHistory, getUseCases, globalEventsCallbacksMap, globalUseCasesEvents, hasRole, hashBody, hashPassword, health, hmacHash, httpConfig, imageRule, increaseUseCaseFailedCalls, increaseUseCaseSuccessCalls, inspectHandlerSignature, ipMatches, isAllowedCsrfOrigin, isBootSignal, isDevelopmentMode, isNewerVersion, isPortAvailable, isPrivateOrReservedIp, isProductionMode, isTestMode, isTracingEnabled, isUnknownTsExtensionError, isValidIdempotencyKey, listPositionalHandlerSuspects, loadS3, logResponse, logsPath, looksLikePositionalHandler, mailEvents, matchesDerivedRouteName, measure, mergeCspDirectives, middleware, normalizeOrigin, normalizeRequestPath, normalizeRoutePath, notifyHttpServerRebuilt, onHttpServerRebuilt, originOf, ownOrigin, parseLocaleDictionary, parseRoles, parseSites, parseSize, parseTraceparentTraceId, paths, preflightConfiguredHttpPort, promiseAllObject, publicPath, publicUrl, registerAppConfig, registerConfiguredConnectors, registerDevelopmentOpenApiProvider, registerGroupedTranslationKeys, registerHttpPlugins, registerLocaleDictionary, registerTracingHooks, remedyLines, renderReact, renderReactMail, reportPositionalHandlerSuspects, requestContext, requestMemo, requiresDefaultCsrfGuard, resetHttpReadyReport, resetMailConfig, resetRolesCacheForTests, resetTracingConfigForTests, resolveCspConfig, resolveCsrfOriginVerdict, resolveMailConfig, resolveTracingConfig, resolveWithinRoot, rootPath, routeNameMethodSuffix, router, runDefaultCsrfGuard, runPipeline, safeFetchToBuffer, sanitizePath, seeder, sendBootSignal, sendMail, serializeCspDirectives, servesHttp, setBaseUrl, setConfig, setEnvironment, setHttpReadyReport, setLogConfigurations, setMailConfigurations, setMailMode, shouldPreflightHttpPort, sleep, sluggable, srcPath, startHttpServer, stopHttpApplication, storage, storageConfig, storageConfigurations, storageDriverContext, storagePath, streamReactResponse, t, tempPath, toJson, uniqueExceptCurrentIdRule, uniqueExceptCurrentUserRule, unregisterLocaleDictionary, uploadedFileController, uploadedFileMetadataSchema, uploadsConfig, uploadsPath, uploadsUrl, url, useCase, useComputedModel, useComputedSlug, useCurrentUser, useHashedPassword, useRequest, useRequestStore, validateCspConfigAtBoot, validateCspDirectives, verifyMailer, verifyPassword, warlockConfigManager, warlockPath, wasMailSentTo, wasMailSentWithSubject, wrapResponseInDataKey };
|
|
187
|
+
export { $registerUseCase, $unregisterUseCase, APP_ROLES, AccessConnector, AiConnector, Application, BOOT_SIGNAL_ENV_KEY, BOOT_SIGNAL_VERSION, BadRequestError, BadSchemaUseCaseError, BaseConnector, BenchmarkProfiler, BenchmarkSnapshots, CLICommand, CacheConnector, CascadeAdapter, CascadeQueryBuilder, CloudDriver, ConfigSpecialHandlers, ConflictError, ConnectorLifecyclePhase, ConnectorPriority, ConnectorsManager, ConsoleChannel, CookieJarUnavailableError, DEFAULT_CSP_DIRECTIVES, DEFAULT_POSTMAN_BASE_URL, DOSpacesDriver, DatabaseCacheDriver, DatabaseConnector, DatabaseLog, DatabaseLogModel, FileValidator, ForbiddenError, HeraldConnector, HttpConnector, HttpError, HttpErrorCodes, Image, ImageVariantsConfigError, InvalidCspDirectiveError, LocalDriver, LocaleDictionaryError, LoggerConnector, MAIL_EVENTS, Mail, MailError, MailerConnector, MimeTypes, NULLABLE_RESOURCE, NoopChannel, NotAcceptableError, NotAllowedError, NotificationsConnector, OPENAPI_JSON_SCHEMA_DIALECT, POSTMAN_COLLECTION_SCHEMA, Path, PortInUseError, Queue, R2Driver, RegisterResource, RepositoryManager, Request, RequestController, RequestLog, Resource, ResourceFieldBuilder, ResourceNotFoundError, Response, ResponseStatus, Restful, RouteRegistry, Router, S3Driver, ScopedStorage, SeederDependencyCycleError, ServerError, SocketConnector, Storage, StorageCapabilityError, StorageConnector, StorageError, StorageFile, StorageNotInitializedError, UPDATE_MANY_BATCH_SIZE, UPLOADS_DEFAULTS, UnAuthorizedError, UnknownSeederDependencyError, UploadedFile, WarlockConfigManager, addUseCaseHistory, anyMatch, app, appLog, appPath, applyCspHeader, assertConfiguredHttpPortIsFree, assertMailCount, assertMailSent, assertNoReservedConnectorNames, assertPortIsAvailable, assertSitesRequireWebRole, assertUniqueConnectorNames, assetsUrl, bootstrap, broadcastUseCaseResult, buildCspHeaderValue, buildIdempotencyCacheKey, buildOpenApiDocument, buildTracingContext, cachePath, captureMail, clearPositionalHandlerSuspects, clearTestMailbox, closeAllMailers, closeMailer, closeServerWithTimeout, colors, command, config, configPath, configSpecialHandlers, connectorsManager, container, createHttpApplication, createRequestStore, decrypt, defaultHttpConfigurations, defineConfig, defineResource, deriveTraceId, describePositionalHandlerSuspect, dispatchPhase, dispatchRequestEnd, dispatchRequestStart, displayEnvironmentMode, encrypt, ensureFatalIsVisible, env, environment, exampleFromSchema, existsExceptCurrentIdRule, existsExceptCurrentUserRule, fetchLatestVersion, fileExtensionRule, fileRule, fileTypeRule, findMailsBySubject, findMailsTo, fireLifecycleEvent, forgetPositionalHandlerSuspects, generateImageVariants, generateMailId, getDefaultMailConfig, getDevelopmentOpenApiDocument, getDevelopmentPostmanCollection, getHttpReadyReport, getHttpServer, getLastMail, getLocalized, getMailEventName, getMailMode, getMailboxSize, getMailer, getMailerConfig, getMimeType, getPoolStats, getPublicUrl, getRoles, getSites, getSocketServer, getTestMailbox, getUseCase, getUseCaseHistory, getUseCases, globalEventsCallbacksMap, globalUseCasesEvents, hasRole, hashBody, hashPassword, health, hmacHash, httpConfig, imageRule, increaseUseCaseFailedCalls, increaseUseCaseSuccessCalls, inspectHandlerSignature, ipMatches, isAllowedCsrfOrigin, isBootSignal, isDevelopmentMode, isNewerVersion, isNullableResource, isPortAvailable, isPrivateOrReservedIp, isProductionMode, isTestMode, isTracingEnabled, isUnknownTsExtensionError, isValidIdempotencyKey, listPositionalHandlerSuspects, loadS3, logResponse, logsPath, looksLikePositionalHandler, mailEvents, matchesDerivedRouteName, measure, mergeCspDirectives, middleware, normalizeOrigin, normalizeRequestPath, normalizeRoutePath, notifyHttpServerRebuilt, nullable, onHttpServerRebuilt, openApiToPostmanCollection, originOf, ownOrigin, parseLocaleDictionary, parseRoles, parseSites, parseSize, parseTraceparentTraceId, paths, preflightConfiguredHttpPort, promiseAllObject, publicPath, publicUrl, registerAppConfig, registerConfiguredConnectors, registerDevelopmentOpenApiProvider, registerGroupedTranslationKeys, registerHttpPlugins, registerLocaleDictionary, registerTracingHooks, remedyLines, renderReact, renderReactMail, reportPositionalHandlerSuspects, requestContext, requestMemo, requiresDefaultCsrfGuard, resetHttpReadyReport, resetMailConfig, resetRolesCacheForTests, resetTracingConfigForTests, resolveCspConfig, resolveCsrfOriginVerdict, resolveMailConfig, resolveTracingConfig, resolveWithinRoot, rootPath, routeNameMethodSuffix, router, runDefaultCsrfGuard, runPipeline, safeFetchToBuffer, sanitizePath, seeder, sendBootSignal, sendMail, serializeCspDirectives, servesHttp, setBaseUrl, setConfig, setEnvironment, setHttpReadyReport, setLogConfigurations, setMailConfigurations, setMailMode, shouldPreflightHttpPort, sleep, sluggable, srcPath, startHttpServer, stopHttpApplication, storage, storageConfig, storageConfigurations, storageDriverContext, storagePath, streamReactResponse, t, tempPath, toJson, uniqueExceptCurrentIdRule, uniqueExceptCurrentUserRule, unregisterLocaleDictionary, uploadedFileController, uploadedFileMetadataSchema, uploadsConfig, uploadsPath, uploadsUrl, url, useCase, useComputedModel, useComputedSlug, useCurrentUser, useHashedPassword, useRequest, useRequestStore, validateCspConfigAtBoot, validateCspDirectives, verifyMailer, verifyPassword, warlockConfigManager, warlockPath, wasMailSentTo, wasMailSentWithSubject, wrapResponseInDataKey };
|
|
@@ -15,7 +15,12 @@ declare class LocaleDictionaryError extends Error {
|
|
|
15
15
|
declare function parseLocaleDictionary(input: {
|
|
16
16
|
sourceFile: string;
|
|
17
17
|
source: string;
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The group used when the file declares no `$group`. A function is called
|
|
20
|
+
* only in that case, so a namespace that cannot be derived (e.g. from a
|
|
21
|
+
* folder name) never fails a file that names its own `$group`.
|
|
22
|
+
*/
|
|
23
|
+
defaultNamespace: string | (() => string);
|
|
19
24
|
localeCodes?: readonly string[];
|
|
20
25
|
}): ParsedLocaleDictionary;
|
|
21
26
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-locale-dictionary.d.mts","names":[],"sources":["../../../../../../../core/src/localization/parse-locale-dictionary.ts"],"mappings":";KAAY,uBAAA,GAA0B,MAAM,SAAS,MAAA;AAAA,KAEzC,sBAAA;EACV,UAAA;EACA,KAAA;EACA,OAAA,EAAS,uBAAuB;AAAA;AAHlC;AAAA,cAca,qBAAA,SAA8B,KAAK;EAAA,SAE5B,UAAA;EAAA,SACA,GAAA;cADA,UAAA,UACA,GAAA,UAChB,MAAA;AAAA;;
|
|
1
|
+
{"version":3,"file":"parse-locale-dictionary.d.mts","names":[],"sources":["../../../../../../../core/src/localization/parse-locale-dictionary.ts"],"mappings":";KAAY,uBAAA,GAA0B,MAAM,SAAS,MAAA;AAAA,KAEzC,sBAAA;EACV,UAAA;EACA,KAAA;EACA,OAAA,EAAS,uBAAuB;AAAA;AAHlC;AAAA,cAca,qBAAA,SAA8B,KAAK;EAAA,SAE5B,UAAA;EAAA,SACA,GAAA;cADA,UAAA,UACA,GAAA,UAChB,MAAA;AAAA;;iBAsOY,qBAAA,CAAsB,KAAA;EACpC,UAAA;EACA,MAAA;EA5OW;;;;;EAkPX,gBAAA;EACA,WAAA;AAAA,IACE,sBAAsB"}
|
|
@@ -153,6 +153,10 @@ function explicitGroup(sourceFile, value) {
|
|
|
153
153
|
}
|
|
154
154
|
return value;
|
|
155
155
|
}
|
|
156
|
+
function defaultGroup(sourceFile, defaultNamespace) {
|
|
157
|
+
const namespace = typeof defaultNamespace === "function" ? defaultNamespace() : defaultNamespace;
|
|
158
|
+
return namespace === "" ? "" : explicitGroup(sourceFile, namespace);
|
|
159
|
+
}
|
|
156
160
|
function isObject(value) {
|
|
157
161
|
return value instanceof Map;
|
|
158
162
|
}
|
|
@@ -198,7 +202,7 @@ function parseLocaleDictionary(input) {
|
|
|
198
202
|
if (!isObject(parsed)) fail(sourceFile, "$", "root JSON value must be an object");
|
|
199
203
|
const groupValue = parsed.get("$group");
|
|
200
204
|
if (groupValue !== void 0 && typeof groupValue !== "string") fail(sourceFile, "$group", "'$group' must be a string");
|
|
201
|
-
const group = groupValue === void 0 ?
|
|
205
|
+
const group = groupValue === void 0 ? defaultGroup(sourceFile, defaultNamespace) : explicitGroup(sourceFile, groupValue);
|
|
202
206
|
const entries = Object.create(null);
|
|
203
207
|
const rootEntries = new Map(parsed);
|
|
204
208
|
rootEntries.delete("$group");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-locale-dictionary.mjs","names":[],"sources":["../../../../../../../core/src/localization/parse-locale-dictionary.ts"],"sourcesContent":["export type LocaleDictionaryEntries = Record<string, Record<string, string>>;\n\nexport type ParsedLocaleDictionary = {\n sourceFile: string;\n group: string;\n entries: LocaleDictionaryEntries;\n};\n\ntype JsonValue = string | number | boolean | null | JsonObject | JsonValue[];\ntype JsonObject = Map<string, JsonValue>;\n\nconst SEGMENT = /^[A-Za-z_][A-Za-z0-9_-]*$/;\nconst LOCALE_CODE = /^[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*$/;\nconst FORBIDDEN_SEGMENTS = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\n\n/** A source error that always names both the locale file and the offending JSON key. */\nexport class LocaleDictionaryError extends Error {\n public constructor(\n public readonly sourceFile: string,\n public readonly key: string,\n detail: string,\n ) {\n super(`Cannot parse route locales in \"${sourceFile}\" at \"${key}\": ${detail}.`);\n this.name = \"LocaleDictionaryError\";\n }\n}\n\nfunction fail(sourceFile: string, key: string, detail: string): never {\n throw new LocaleDictionaryError(sourceFile, key, detail);\n}\n\n/** A deliberately small JSON parser: unlike JSON.parse, it preserves duplicate property names. */\nclass StrictJsonParser {\n private offset = 0;\n\n public constructor(\n private readonly sourceFile: string,\n private readonly source: string,\n ) {}\n\n public parse(): JsonValue {\n if (this.source.charCodeAt(0) === 0xfeff) this.offset = 1;\n const value = this.value(\"$\");\n this.whitespace();\n if (this.offset !== this.source.length) this.invalid(\"$\", \"unexpected trailing JSON\");\n return value;\n }\n\n private value(key: string): JsonValue {\n this.whitespace();\n const character = this.source[this.offset];\n if (character === \"{\") return this.object(key);\n if (character === \"[\") return this.array(key);\n if (character === '\"') return this.string(key);\n if (this.source.startsWith(\"true\", this.offset)) return this.literal(\"true\", true);\n if (this.source.startsWith(\"false\", this.offset)) return this.literal(\"false\", false);\n if (this.source.startsWith(\"null\", this.offset)) return this.literal(\"null\", null);\n if (character === \"-\" || (character !== undefined && /[0-9]/.test(character)))\n return this.number(key);\n this.invalid(key, \"invalid JSON value\");\n }\n\n private object(key: string): JsonObject {\n this.offset++;\n this.whitespace();\n const object = new Map<string, JsonValue>();\n if (this.source[this.offset] === \"}\") {\n this.offset++;\n return object;\n }\n while (true) {\n this.whitespace();\n if (this.source[this.offset] !== '\"') this.invalid(key, \"object keys must be JSON strings\");\n const property = this.string(key);\n const propertyKey = `${key}.${property}`;\n if (object.has(property)) this.invalid(propertyKey, \"duplicate JSON property\");\n this.whitespace();\n if (this.source[this.offset] !== \":\")\n this.invalid(propertyKey, \"expected ':' after object key\");\n this.offset++;\n object.set(property, this.value(propertyKey));\n this.whitespace();\n const separator = this.source[this.offset];\n if (separator === \"}\") {\n this.offset++;\n return object;\n }\n if (separator !== \",\") this.invalid(key, \"expected ',' or '}' in object\");\n this.offset++;\n }\n }\n\n private array(key: string): JsonValue[] {\n this.offset++;\n this.whitespace();\n const values: JsonValue[] = [];\n if (this.source[this.offset] === \"]\") {\n this.offset++;\n return values;\n }\n while (true) {\n values.push(this.value(key));\n this.whitespace();\n const separator = this.source[this.offset];\n if (separator === \"]\") {\n this.offset++;\n return values;\n }\n if (separator !== \",\") this.invalid(key, \"expected ',' or ']' in array\");\n this.offset++;\n }\n }\n\n private string(key: string): string {\n const start = this.offset++;\n let escaped = false;\n while (this.offset < this.source.length) {\n const character = this.source[this.offset++];\n if (escaped) {\n escaped = false;\n continue;\n }\n if (character === \"\\\\\") {\n escaped = true;\n continue;\n }\n if (character === '\"') {\n try {\n return JSON.parse(this.source.slice(start, this.offset)) as string;\n } catch {\n this.invalid(key, \"invalid JSON string\");\n }\n }\n if (character !== undefined && character.charCodeAt(0) < 0x20)\n this.invalid(key, \"unescaped control character in JSON string\");\n }\n this.invalid(key, \"unterminated JSON string\");\n }\n\n private number(key: string): number {\n const match = /-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y;\n match.lastIndex = this.offset;\n const token = match.exec(this.source)?.[0];\n if (token === undefined) this.invalid(key, \"invalid JSON number\");\n this.offset += token.length;\n return Number(token);\n }\n\n private literal<T extends boolean | null>(written: string, value: T): T {\n this.offset += written.length;\n return value;\n }\n\n private whitespace(): void {\n while (this.offset < this.source.length) {\n const character = this.source[this.offset];\n if (character === undefined || !\" \\t\\n\\r\".includes(character)) return;\n this.offset++;\n }\n }\n\n private invalid(key: string, detail: string): never {\n fail(this.sourceFile, key, detail);\n }\n}\n\nfunction assertNamespaceSegment(sourceFile: string, segment: string, key: string): void {\n if (!SEGMENT.test(segment)) fail(sourceFile, key, \"segments must match [A-Za-z_][A-Za-z0-9_-]*\");\n if (FORBIDDEN_SEGMENTS.has(segment)) fail(sourceFile, key, \"segments cannot be reserved\");\n}\n\nfunction assertSegment(sourceFile: string, segment: string, key: string): void {\n if (segment.includes(\".\")) fail(sourceFile, key, \"JSON keys cannot contain '.'\");\n assertNamespaceSegment(sourceFile, segment, key);\n}\n\nfunction explicitGroup(sourceFile: string, value: string): string {\n if (value === \"\") fail(sourceFile, \"$group\", \"'$group' cannot be empty\");\n for (const segment of value.split(\".\")) {\n if (segment === \"\") fail(sourceFile, \"$group\", \"'$group' cannot contain empty segments\");\n assertNamespaceSegment(sourceFile, segment, \"$group\");\n }\n return value;\n}\n\nfunction isObject(value: JsonValue): value is JsonObject {\n return value instanceof Map;\n}\n\nfunction readLeaf(\n sourceFile: string,\n key: string,\n value: JsonObject,\n localeCodes: readonly string[] | undefined,\n): Record<string, string> {\n const locales = localeCodes === undefined ? undefined : new Set(localeCodes);\n const entry: Record<string, string> = Object.create(null) as Record<string, string>;\n for (const [locale, translation] of value) {\n if (!LOCALE_CODE.test(locale)) fail(sourceFile, `${key}.${locale}`, \"invalid locale code\");\n if (typeof translation !== \"string\")\n fail(sourceFile, `${key}.${locale}`, \"locale values must be strings\");\n if (locales !== undefined && !locales.has(locale))\n fail(sourceFile, `${key}.${locale}`, \"unknown locale code\");\n entry[locale] = translation;\n }\n if (localeCodes !== undefined)\n for (const locale of localeCodes)\n if (!(locale in entry)) fail(sourceFile, key, `missing locale code \"${locale}\"`);\n return entry;\n}\n\nfunction collectEntries(\n sourceFile: string,\n object: JsonObject,\n group: string,\n localeCodes: readonly string[] | undefined,\n entries: LocaleDictionaryEntries,\n nested: boolean,\n): void {\n if (nested && object.size === 0) fail(sourceFile, group, \"nested objects cannot be empty\");\n for (const [segment, value] of object) {\n const key = group === \"\" ? segment : `${group}.${segment}`;\n if (segment === \"$group\") fail(sourceFile, key, \"'$group' is only allowed at the root\");\n assertSegment(sourceFile, segment, key);\n if (!isObject(value)) fail(sourceFile, key, \"entries must be locale objects or nested objects\");\n if (value.has(\"$group\"))\n fail(sourceFile, `${key}.$group`, \"'$group' is only allowed at the root\");\n const values = [...value.values()];\n const hasString = values.some((item) => typeof item === \"string\");\n const allObjects = values.every(isObject);\n if (hasString) {\n if (!values.every((item) => typeof item === \"string\"))\n fail(sourceFile, key, \"cannot mix locale values with nested entries\");\n entries[key] = readLeaf(sourceFile, key, value, localeCodes);\n continue;\n }\n if (!allObjects) fail(sourceFile, key, \"cannot mix locale values with nested entries\");\n if (localeCodes !== undefined && [...value.keys()].some((child) => localeCodes.includes(child)))\n fail(sourceFile, key, \"cannot mix locale codes with nested entries\");\n collectEntries(sourceFile, value, key, localeCodes, entries, true);\n }\n}\n\n/** Parses one locale dictionary source without reading the filesystem or loading application code. */\nexport function parseLocaleDictionary(input: {\n sourceFile: string;\n source: string;\n defaultNamespace: string;\n localeCodes?: readonly string[];\n}): ParsedLocaleDictionary {\n const { sourceFile, source, defaultNamespace, localeCodes } = input;\n const parsed = new StrictJsonParser(sourceFile, source).parse();\n if (!isObject(parsed)) fail(sourceFile, \"$\", \"root JSON value must be an object\");\n const groupValue = parsed.get(\"$group\");\n if (groupValue !== undefined && typeof groupValue !== \"string\")\n fail(sourceFile, \"$group\", \"'$group' must be a string\");\n const group =\n groupValue === undefined\n ? defaultNamespace === \"\"\n ? \"\"\n : explicitGroup(sourceFile, defaultNamespace)\n : explicitGroup(sourceFile, groupValue);\n const entries: LocaleDictionaryEntries = Object.create(null) as LocaleDictionaryEntries;\n const rootEntries = new Map(parsed);\n rootEntries.delete(\"$group\");\n collectEntries(sourceFile, rootEntries, group, localeCodes, entries, false);\n return { sourceFile, group, entries };\n}\n"],"mappings":";AAWA,MAAM,UAAU;AAChB,MAAM,cAAc;AACpB,MAAM,qBAAqB,IAAI,IAAI;CAAC;CAAa;CAAa;AAAa,CAAC;;AAG5E,IAAa,wBAAb,cAA2C,MAAM;CAC/C,AAAO,YACL,AAAgB,YAChB,AAAgB,KAChB,QACA;EACA,MAAM,kCAAkC,WAAW,QAAQ,IAAI,KAAK,OAAO,EAAE;EAJ7D;EACA;EAIhB,KAAK,OAAO;CACd;AACF;AAEA,SAAS,KAAK,YAAoB,KAAa,QAAuB;CACpE,MAAM,IAAI,sBAAsB,YAAY,KAAK,MAAM;AACzD;;AAGA,IAAM,mBAAN,MAAuB;CAGrB,AAAO,YACL,AAAiB,YACjB,AAAiB,QACjB;EAFiB;EACA;gBAJF;CAKd;CAEH,AAAO,QAAmB;EACxB,IAAI,KAAK,OAAO,WAAW,CAAC,MAAM,OAAQ,KAAK,SAAS;EACxD,MAAM,QAAQ,KAAK,MAAM,GAAG;EAC5B,KAAK,WAAW;EAChB,IAAI,KAAK,WAAW,KAAK,OAAO,QAAQ,KAAK,QAAQ,KAAK,0BAA0B;EACpF,OAAO;CACT;CAEA,AAAQ,MAAM,KAAwB;EACpC,KAAK,WAAW;EAChB,MAAM,YAAY,KAAK,OAAO,KAAK;EACnC,IAAI,cAAc,KAAK,OAAO,KAAK,OAAO,GAAG;EAC7C,IAAI,c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kB,gBAAgB;CAC9D,MAAM,SAAS,IAAI,iBAAiB,YAAY,MAAM,CAAC,CAAC,MAAM;CAC9D,IAAI,CAAC,SAAS,MAAM,GAAG,KAAK,YAAY,KAAK,mCAAmC;CAChF,MAAM,aAAa,OAAO,IAAI,QAAQ;CACtC,IAAI,eAAe,UAAa,OAAO,eAAe,UACpD,KAAK,YAAY,UAAU,2BAA2B;CACxD,MAAM,QACJ,eAAe,SACX,qBAAqB,KACnB,KACA,cAAc,YAAY,gBAAgB,IAC5C,cAAc,YAAY,UAAU;CAC1C,MAAM,UAAmC,OAAO,OAAO,IAAI;CAC3D,MAAM,cAAc,IAAI,IAAI,MAAM;CAClC,YAAY,OAAO,QAAQ;CAC3B,eAAe,YAAY,aAAa,OAAO,aAAa,SAAS,KAAK;CAC1E,OAAO;EAAE;EAAY;EAAO;CAAQ;AACtC"}
|
|
1
|
+
{"version":3,"file":"parse-locale-dictionary.mjs","names":[],"sources":["../../../../../../../core/src/localization/parse-locale-dictionary.ts"],"sourcesContent":["export type LocaleDictionaryEntries = Record<string, Record<string, string>>;\n\nexport type ParsedLocaleDictionary = {\n sourceFile: string;\n group: string;\n entries: LocaleDictionaryEntries;\n};\n\ntype JsonValue = string | number | boolean | null | JsonObject | JsonValue[];\ntype JsonObject = Map<string, JsonValue>;\n\nconst SEGMENT = /^[A-Za-z_][A-Za-z0-9_-]*$/;\nconst LOCALE_CODE = /^[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*$/;\nconst FORBIDDEN_SEGMENTS = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\n\n/** A source error that always names both the locale file and the offending JSON key. */\nexport class LocaleDictionaryError extends Error {\n public constructor(\n public readonly sourceFile: string,\n public readonly key: string,\n detail: string,\n ) {\n super(`Cannot parse route locales in \"${sourceFile}\" at \"${key}\": ${detail}.`);\n this.name = \"LocaleDictionaryError\";\n }\n}\n\nfunction fail(sourceFile: string, key: string, detail: string): never {\n throw new LocaleDictionaryError(sourceFile, key, detail);\n}\n\n/** A deliberately small JSON parser: unlike JSON.parse, it preserves duplicate property names. */\nclass StrictJsonParser {\n private offset = 0;\n\n public constructor(\n private readonly sourceFile: string,\n private readonly source: string,\n ) {}\n\n public parse(): JsonValue {\n if (this.source.charCodeAt(0) === 0xfeff) this.offset = 1;\n const value = this.value(\"$\");\n this.whitespace();\n if (this.offset !== this.source.length) this.invalid(\"$\", \"unexpected trailing JSON\");\n return value;\n }\n\n private value(key: string): JsonValue {\n this.whitespace();\n const character = this.source[this.offset];\n if (character === \"{\") return this.object(key);\n if (character === \"[\") return this.array(key);\n if (character === '\"') return this.string(key);\n if (this.source.startsWith(\"true\", this.offset)) return this.literal(\"true\", true);\n if (this.source.startsWith(\"false\", this.offset)) return this.literal(\"false\", false);\n if (this.source.startsWith(\"null\", this.offset)) return this.literal(\"null\", null);\n if (character === \"-\" || (character !== undefined && /[0-9]/.test(character)))\n return this.number(key);\n this.invalid(key, \"invalid JSON value\");\n }\n\n private object(key: string): JsonObject {\n this.offset++;\n this.whitespace();\n const object = new Map<string, JsonValue>();\n if (this.source[this.offset] === \"}\") {\n this.offset++;\n return object;\n }\n while (true) {\n this.whitespace();\n if (this.source[this.offset] !== '\"') this.invalid(key, \"object keys must be JSON strings\");\n const property = this.string(key);\n const propertyKey = `${key}.${property}`;\n if (object.has(property)) this.invalid(propertyKey, \"duplicate JSON property\");\n this.whitespace();\n if (this.source[this.offset] !== \":\")\n this.invalid(propertyKey, \"expected ':' after object key\");\n this.offset++;\n object.set(property, this.value(propertyKey));\n this.whitespace();\n const separator = this.source[this.offset];\n if (separator === \"}\") {\n this.offset++;\n return object;\n }\n if (separator !== \",\") this.invalid(key, \"expected ',' or '}' in object\");\n this.offset++;\n }\n }\n\n private array(key: string): JsonValue[] {\n this.offset++;\n this.whitespace();\n const values: JsonValue[] = [];\n if (this.source[this.offset] === \"]\") {\n this.offset++;\n return values;\n }\n while (true) {\n values.push(this.value(key));\n this.whitespace();\n const separator = this.source[this.offset];\n if (separator === \"]\") {\n this.offset++;\n return values;\n }\n if (separator !== \",\") this.invalid(key, \"expected ',' or ']' in array\");\n this.offset++;\n }\n }\n\n private string(key: string): string {\n const start = this.offset++;\n let escaped = false;\n while (this.offset < this.source.length) {\n const character = this.source[this.offset++];\n if (escaped) {\n escaped = false;\n continue;\n }\n if (character === \"\\\\\") {\n escaped = true;\n continue;\n }\n if (character === '\"') {\n try {\n return JSON.parse(this.source.slice(start, this.offset)) as string;\n } catch {\n this.invalid(key, \"invalid JSON string\");\n }\n }\n if (character !== undefined && character.charCodeAt(0) < 0x20)\n this.invalid(key, \"unescaped control character in JSON string\");\n }\n this.invalid(key, \"unterminated JSON string\");\n }\n\n private number(key: string): number {\n const match = /-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y;\n match.lastIndex = this.offset;\n const token = match.exec(this.source)?.[0];\n if (token === undefined) this.invalid(key, \"invalid JSON number\");\n this.offset += token.length;\n return Number(token);\n }\n\n private literal<T extends boolean | null>(written: string, value: T): T {\n this.offset += written.length;\n return value;\n }\n\n private whitespace(): void {\n while (this.offset < this.source.length) {\n const character = this.source[this.offset];\n if (character === undefined || !\" \\t\\n\\r\".includes(character)) return;\n this.offset++;\n }\n }\n\n private invalid(key: string, detail: string): never {\n fail(this.sourceFile, key, detail);\n }\n}\n\nfunction assertNamespaceSegment(sourceFile: string, segment: string, key: string): void {\n if (!SEGMENT.test(segment)) fail(sourceFile, key, \"segments must match [A-Za-z_][A-Za-z0-9_-]*\");\n if (FORBIDDEN_SEGMENTS.has(segment)) fail(sourceFile, key, \"segments cannot be reserved\");\n}\n\nfunction assertSegment(sourceFile: string, segment: string, key: string): void {\n if (segment.includes(\".\")) fail(sourceFile, key, \"JSON keys cannot contain '.'\");\n assertNamespaceSegment(sourceFile, segment, key);\n}\n\nfunction explicitGroup(sourceFile: string, value: string): string {\n if (value === \"\") fail(sourceFile, \"$group\", \"'$group' cannot be empty\");\n for (const segment of value.split(\".\")) {\n if (segment === \"\") fail(sourceFile, \"$group\", \"'$group' cannot contain empty segments\");\n assertNamespaceSegment(sourceFile, segment, \"$group\");\n }\n return value;\n}\n\nfunction defaultGroup(sourceFile: string, defaultNamespace: string | (() => string)): string {\n const namespace = typeof defaultNamespace === \"function\" ? defaultNamespace() : defaultNamespace;\n\n return namespace === \"\" ? \"\" : explicitGroup(sourceFile, namespace);\n}\n\nfunction isObject(value: JsonValue): value is JsonObject {\n return value instanceof Map;\n}\n\nfunction readLeaf(\n sourceFile: string,\n key: string,\n value: JsonObject,\n localeCodes: readonly string[] | undefined,\n): Record<string, string> {\n const locales = localeCodes === undefined ? undefined : new Set(localeCodes);\n const entry: Record<string, string> = Object.create(null) as Record<string, string>;\n for (const [locale, translation] of value) {\n if (!LOCALE_CODE.test(locale)) fail(sourceFile, `${key}.${locale}`, \"invalid locale code\");\n if (typeof translation !== \"string\")\n fail(sourceFile, `${key}.${locale}`, \"locale values must be strings\");\n if (locales !== undefined && !locales.has(locale))\n fail(sourceFile, `${key}.${locale}`, \"unknown locale code\");\n entry[locale] = translation;\n }\n if (localeCodes !== undefined)\n for (const locale of localeCodes)\n if (!(locale in entry)) fail(sourceFile, key, `missing locale code \"${locale}\"`);\n return entry;\n}\n\nfunction collectEntries(\n sourceFile: string,\n object: JsonObject,\n group: string,\n localeCodes: readonly string[] | undefined,\n entries: LocaleDictionaryEntries,\n nested: boolean,\n): void {\n if (nested && object.size === 0) fail(sourceFile, group, \"nested objects cannot be empty\");\n for (const [segment, value] of object) {\n const key = group === \"\" ? segment : `${group}.${segment}`;\n if (segment === \"$group\") fail(sourceFile, key, \"'$group' is only allowed at the root\");\n assertSegment(sourceFile, segment, key);\n if (!isObject(value)) fail(sourceFile, key, \"entries must be locale objects or nested objects\");\n if (value.has(\"$group\"))\n fail(sourceFile, `${key}.$group`, \"'$group' is only allowed at the root\");\n const values = [...value.values()];\n const hasString = values.some((item) => typeof item === \"string\");\n const allObjects = values.every(isObject);\n if (hasString) {\n if (!values.every((item) => typeof item === \"string\"))\n fail(sourceFile, key, \"cannot mix locale values with nested entries\");\n entries[key] = readLeaf(sourceFile, key, value, localeCodes);\n continue;\n }\n if (!allObjects) fail(sourceFile, key, \"cannot mix locale values with nested entries\");\n if (localeCodes !== undefined && [...value.keys()].some((child) => localeCodes.includes(child)))\n fail(sourceFile, key, \"cannot mix locale codes with nested entries\");\n collectEntries(sourceFile, value, key, localeCodes, entries, true);\n }\n}\n\n/** Parses one locale dictionary source without reading the filesystem or loading application code. */\nexport function parseLocaleDictionary(input: {\n sourceFile: string;\n source: string;\n /**\n * The group used when the file declares no `$group`. A function is called\n * only in that case, so a namespace that cannot be derived (e.g. from a\n * folder name) never fails a file that names its own `$group`.\n */\n defaultNamespace: string | (() => string);\n localeCodes?: readonly string[];\n}): ParsedLocaleDictionary {\n const { sourceFile, source, defaultNamespace, localeCodes } = input;\n const parsed = new StrictJsonParser(sourceFile, source).parse();\n if (!isObject(parsed)) fail(sourceFile, \"$\", \"root JSON value must be an object\");\n const groupValue = parsed.get(\"$group\");\n if (groupValue !== undefined && typeof groupValue !== \"string\")\n fail(sourceFile, \"$group\", \"'$group' must be a string\");\n const group =\n groupValue === undefined\n ? defaultGroup(sourceFile, defaultNamespace)\n : explicitGroup(sourceFile, groupValue);\n const entries: LocaleDictionaryEntries = Object.create(null) as LocaleDictionaryEntries;\n const rootEntries = new Map(parsed);\n rootEntries.delete(\"$group\");\n collectEntries(sourceFile, rootEntries, group, localeCodes, entries, false);\n return { sourceFile, group, entries };\n}\n"],"mappings":";AAWA,MAAM,UAAU;AAChB,MAAM,cAAc;AACpB,MAAM,qBAAqB,IAAI,IAAI;CAAC;CAAa;CAAa;AAAa,CAAC;;AAG5E,IAAa,wBAAb,cAA2C,MAAM;CAC/C,AAAO,YACL,AAAgB,YAChB,AAAgB,KAChB,QACA;EACA,MAAM,kCAAkC,WAAW,QAAQ,IAAI,KAAK,OAAO,EAAE;EAJ7D;EACA;EAIhB,KAAK,OAAO;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-1,7 +1,12 @@
|
|
|
1
|
+
import { PostmanCollection, PostmanCollectionOptions } from "./postman/postman-types.mjs";
|
|
1
2
|
import { OpenApiBuildResult } from "./types.mjs";
|
|
2
3
|
|
|
3
4
|
//#region ../core/src/openapi/development-openapi-provider.d.ts
|
|
4
5
|
type DevelopmentOpenApiProvider = () => Promise<OpenApiBuildResult>;
|
|
6
|
+
type DevelopmentPostmanResult = {
|
|
7
|
+
collection: PostmanCollection;
|
|
8
|
+
warnings: string[];
|
|
9
|
+
};
|
|
5
10
|
/**
|
|
6
11
|
* Called by the dev server at startup. The builder lives under `dev-server/`, so the
|
|
7
12
|
* production entry never reaches it; this registry is the only thing the root exports.
|
|
@@ -12,6 +17,12 @@ declare function registerDevelopmentOpenApiProvider(build: DevelopmentOpenApiPro
|
|
|
12
17
|
* server's provider. Throws outside `warlock dev`, where no provider is registered.
|
|
13
18
|
*/
|
|
14
19
|
declare function getDevelopmentOpenApiDocument(): Promise<OpenApiBuildResult>;
|
|
20
|
+
/**
|
|
21
|
+
* The Postman collection (v2.1.0) for the routes registered in this process: the development
|
|
22
|
+
* OpenAPI document run through `openApiToPostmanCollection`, so both always agree. Throws
|
|
23
|
+
* outside `warlock dev`, like `getDevelopmentOpenApiDocument`.
|
|
24
|
+
*/
|
|
25
|
+
declare function getDevelopmentPostmanCollection(options?: PostmanCollectionOptions): Promise<DevelopmentPostmanResult>;
|
|
15
26
|
//#endregion
|
|
16
|
-
export { getDevelopmentOpenApiDocument, registerDevelopmentOpenApiProvider };
|
|
27
|
+
export { DevelopmentPostmanResult, getDevelopmentOpenApiDocument, getDevelopmentPostmanCollection, registerDevelopmentOpenApiProvider };
|
|
17
28
|
//# sourceMappingURL=development-openapi-provider.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"development-openapi-provider.d.mts","names":[],"sources":["../../../../../../../core/src/openapi/development-openapi-provider.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"development-openapi-provider.d.mts","names":[],"sources":["../../../../../../../core/src/openapi/development-openapi-provider.ts"],"mappings":";;;;KAIK,0BAAA,SAAmC,OAAO,CAAC,kBAAA;AAAA,KAEpC,wBAAA;EACV,UAAA,EAAY,iBAAiB;EAC7B,QAAA;AAAA;;AAJgE;AAElE;;iBAWgB,kCAAA,CAAmC,KAAiC,EAA1B,0BAA0B;;;;;iBAQ9D,6BAAA,IAAiC,OAAO,CAAC,kBAAA;AAjBrD;AASV;;;;AATU,iBAgCY,+BAAA,CACpB,OAAA,GAAS,wBAAA,GACR,OAAA,CAAQ,wBAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { openApiToPostmanCollection } from "./postman/openapi-to-postman-collection.mjs";
|
|
2
|
+
|
|
1
3
|
//#region ../core/src/openapi/development-openapi-provider.ts
|
|
2
4
|
let provider;
|
|
3
5
|
/**
|
|
@@ -15,7 +17,19 @@ async function getDevelopmentOpenApiDocument() {
|
|
|
15
17
|
if (!provider) throw new Error("No development OpenAPI provider is registered; the API docs are only available under `warlock dev`.");
|
|
16
18
|
return provider();
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The Postman collection (v2.1.0) for the routes registered in this process: the development
|
|
22
|
+
* OpenAPI document run through `openApiToPostmanCollection`, so both always agree. Throws
|
|
23
|
+
* outside `warlock dev`, like `getDevelopmentOpenApiDocument`.
|
|
24
|
+
*/
|
|
25
|
+
async function getDevelopmentPostmanCollection(options = {}) {
|
|
26
|
+
const { document, warnings } = await getDevelopmentOpenApiDocument();
|
|
27
|
+
return {
|
|
28
|
+
collection: openApiToPostmanCollection(document, options),
|
|
29
|
+
warnings
|
|
30
|
+
};
|
|
31
|
+
}
|
|
18
32
|
|
|
19
33
|
//#endregion
|
|
20
|
-
export { getDevelopmentOpenApiDocument, registerDevelopmentOpenApiProvider };
|
|
34
|
+
export { getDevelopmentOpenApiDocument, getDevelopmentPostmanCollection, registerDevelopmentOpenApiProvider };
|
|
21
35
|
//# sourceMappingURL=development-openapi-provider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"development-openapi-provider.mjs","names":[],"sources":["../../../../../../../core/src/openapi/development-openapi-provider.ts"],"sourcesContent":["import type { OpenApiBuildResult } from \"./types\";\n\ntype DevelopmentOpenApiProvider = () => Promise<OpenApiBuildResult>;\n\nlet provider: DevelopmentOpenApiProvider | undefined;\n\n/**\n * Called by the dev server at startup. The builder lives under `dev-server/`, so the\n * production entry never reaches it; this registry is the only thing the root exports.\n */\nexport function registerDevelopmentOpenApiProvider(build: DevelopmentOpenApiProvider): void {\n provider = build;\n}\n\n/**\n * The OpenAPI document for the routes registered in this process, built by the dev\n * server's provider. Throws outside `warlock dev`, where no provider is registered.\n */\nexport async function getDevelopmentOpenApiDocument(): Promise<OpenApiBuildResult> {\n if (!provider) {\n throw new Error(\n \"No development OpenAPI provider is registered; the API docs are only available under `warlock dev`.\",\n );\n }\n\n return provider();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"development-openapi-provider.mjs","names":[],"sources":["../../../../../../../core/src/openapi/development-openapi-provider.ts"],"sourcesContent":["import { openApiToPostmanCollection } from \"./postman/openapi-to-postman-collection\";\nimport type { PostmanCollection, PostmanCollectionOptions } from \"./postman/postman-types\";\nimport type { OpenApiBuildResult } from \"./types\";\n\ntype DevelopmentOpenApiProvider = () => Promise<OpenApiBuildResult>;\n\nexport type DevelopmentPostmanResult = {\n collection: PostmanCollection;\n warnings: string[];\n};\n\nlet provider: DevelopmentOpenApiProvider | undefined;\n\n/**\n * Called by the dev server at startup. The builder lives under `dev-server/`, so the\n * production entry never reaches it; this registry is the only thing the root exports.\n */\nexport function registerDevelopmentOpenApiProvider(build: DevelopmentOpenApiProvider): void {\n provider = build;\n}\n\n/**\n * The OpenAPI document for the routes registered in this process, built by the dev\n * server's provider. Throws outside `warlock dev`, where no provider is registered.\n */\nexport async function getDevelopmentOpenApiDocument(): Promise<OpenApiBuildResult> {\n if (!provider) {\n throw new Error(\n \"No development OpenAPI provider is registered; the API docs are only available under `warlock dev`.\",\n );\n }\n\n return provider();\n}\n\n/**\n * The Postman collection (v2.1.0) for the routes registered in this process: the development\n * OpenAPI document run through `openApiToPostmanCollection`, so both always agree. Throws\n * outside `warlock dev`, like `getDevelopmentOpenApiDocument`.\n */\nexport async function getDevelopmentPostmanCollection(\n options: PostmanCollectionOptions = {},\n): Promise<DevelopmentPostmanResult> {\n const { document, warnings } = await getDevelopmentOpenApiDocument();\n\n return { collection: openApiToPostmanCollection(document, options), warnings };\n}\n"],"mappings":";;;AAWA,IAAI;;;;;AAMJ,SAAgB,mCAAmC,OAAyC;CAC1F,WAAW;AACb;;;;;AAMA,eAAsB,gCAA6D;CACjF,IAAI,CAAC,UACH,MAAM,IAAI,MACR,qGACF;CAGF,OAAO,SAAS;AAClB;;;;;;AAOA,eAAsB,gCACpB,UAAoC,CAAC,GACF;CACnC,MAAM,EAAE,UAAU,aAAa,MAAM,8BAA8B;CAEnE,OAAO;EAAE,YAAY,2BAA2B,UAAU,OAAO;EAAG;CAAS;AAC/E"}
|
package/esm/openapi/index.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { PostmanAuth, PostmanAuthEntry, PostmanBody, PostmanCollection, PostmanCollectionOptions, PostmanFolder, PostmanFormParam, PostmanHeader, PostmanItem, PostmanOriginalRequest, PostmanQueryParam, PostmanRequest, PostmanRequestItem, PostmanResponse, PostmanUrl, PostmanVariable } from "./postman/postman-types.mjs";
|
|
1
2
|
import { AuthDescriptor, OpenApiBuildResult, OpenApiComponents, OpenApiContext, OpenApiDocument, OpenApiOperation, OpenApiParameter, OpenApiRequestBody, OpenApiResponse, OpenApiRouteInput, OpenApiSchema, OpenApiSecurityRequirement, OpenApiSecurityScheme, OpenApiValidationResponseConfig, WarningSink } from "./types.mjs";
|
|
2
|
-
import { getDevelopmentOpenApiDocument, registerDevelopmentOpenApiProvider } from "./development-openapi-provider.mjs";
|
|
3
|
-
import { OPENAPI_JSON_SCHEMA_DIALECT, buildOpenApiDocument } from "./build-openapi-document.mjs";
|
|
3
|
+
import { DevelopmentPostmanResult, getDevelopmentOpenApiDocument, getDevelopmentPostmanCollection, registerDevelopmentOpenApiProvider } from "./development-openapi-provider.mjs";
|
|
4
|
+
import { OPENAPI_JSON_SCHEMA_DIALECT, buildOpenApiDocument } from "./build-openapi-document.mjs";
|
|
5
|
+
import { exampleFromSchema } from "./postman/example-from-schema.mjs";
|
|
6
|
+
import { DEFAULT_POSTMAN_BASE_URL, POSTMAN_COLLECTION_SCHEMA, openApiToPostmanCollection } from "./postman/openapi-to-postman-collection.mjs";
|
package/esm/openapi/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { exampleFromSchema } from "./postman/example-from-schema.mjs";
|
|
2
|
+
import { DEFAULT_POSTMAN_BASE_URL, POSTMAN_COLLECTION_SCHEMA, openApiToPostmanCollection } from "./postman/openapi-to-postman-collection.mjs";
|
|
3
|
+
import { getDevelopmentOpenApiDocument, getDevelopmentPostmanCollection, registerDevelopmentOpenApiProvider } from "./development-openapi-provider.mjs";
|
|
2
4
|
import { OPENAPI_JSON_SCHEMA_DIALECT, buildOpenApiDocument } from "./build-openapi-document.mjs";
|
|
3
5
|
|
|
4
6
|
export { };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { isRecord, primaryType, resolveSchema } from "./schema-refs.mjs";
|
|
2
|
+
import { exampleFromSchema } from "./example-from-schema.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../core/src/openapi/postman/build-request-body.ts
|
|
5
|
+
const MULTIPART = "multipart/form-data";
|
|
6
|
+
const URL_ENCODED = "application/x-www-form-urlencoded";
|
|
7
|
+
function isJsonContentType(contentType) {
|
|
8
|
+
return contentType === "application/json" || contentType.endsWith("+json");
|
|
9
|
+
}
|
|
10
|
+
function stringifyValue(value) {
|
|
11
|
+
if (typeof value === "string") return value;
|
|
12
|
+
return isRecord(value) || Array.isArray(value) ? JSON.stringify(value) : String(value);
|
|
13
|
+
}
|
|
14
|
+
function isFileSchema(schema, components) {
|
|
15
|
+
const resolved = resolveSchema(schema, components);
|
|
16
|
+
if (resolved.format === "binary" || typeof resolved.contentMediaType === "string") return true;
|
|
17
|
+
return primaryType(resolved) === "array" && isRecord(resolved.items) ? isFileSchema(resolved.items, components) : false;
|
|
18
|
+
}
|
|
19
|
+
function formFields(schema, components) {
|
|
20
|
+
const resolved = resolveSchema(schema, components);
|
|
21
|
+
const properties = isRecord(resolved.properties) ? resolved.properties : {};
|
|
22
|
+
return Object.entries(properties).flatMap(([key, property]) => {
|
|
23
|
+
if (!isRecord(property)) return [];
|
|
24
|
+
const description = typeof property.description === "string" ? { description: property.description } : {};
|
|
25
|
+
if (isFileSchema(property, components)) return [{
|
|
26
|
+
key,
|
|
27
|
+
type: "file",
|
|
28
|
+
src: [],
|
|
29
|
+
...description
|
|
30
|
+
}];
|
|
31
|
+
return [{
|
|
32
|
+
key,
|
|
33
|
+
value: stringifyValue(exampleFromSchema(property, components)),
|
|
34
|
+
type: "text",
|
|
35
|
+
...description
|
|
36
|
+
}];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function pickContentType(contentTypes) {
|
|
40
|
+
return contentTypes.find(isJsonContentType) ?? contentTypes.find((contentType) => contentType === MULTIPART) ?? contentTypes.find((contentType) => contentType === URL_ENCODED) ?? contentTypes[0];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The Postman body of an operation's request body: JSON becomes a raw JSON example, multipart
|
|
44
|
+
* becomes `formdata` (binary properties as file rows), url-encoded becomes `urlencoded`.
|
|
45
|
+
*
|
|
46
|
+
* @returns `undefined` when the operation has no usable body.
|
|
47
|
+
*/
|
|
48
|
+
function buildRequestBody(requestBody, components) {
|
|
49
|
+
if (!requestBody) return;
|
|
50
|
+
const contentType = pickContentType(Object.keys(requestBody.content));
|
|
51
|
+
const schema = contentType !== void 0 ? requestBody.content[contentType]?.schema : void 0;
|
|
52
|
+
if (contentType === void 0 || schema === void 0) return;
|
|
53
|
+
if (contentType === MULTIPART) return { body: {
|
|
54
|
+
mode: "formdata",
|
|
55
|
+
formdata: formFields(schema, components)
|
|
56
|
+
} };
|
|
57
|
+
if (contentType === URL_ENCODED) return { body: {
|
|
58
|
+
mode: "urlencoded",
|
|
59
|
+
urlencoded: formFields(schema, components).flatMap((field) => field.type === "text" ? [{
|
|
60
|
+
key: field.key,
|
|
61
|
+
value: field.value,
|
|
62
|
+
type: "text"
|
|
63
|
+
}] : [])
|
|
64
|
+
} };
|
|
65
|
+
const example = exampleFromSchema(schema, components);
|
|
66
|
+
if (isJsonContentType(contentType)) return {
|
|
67
|
+
contentType,
|
|
68
|
+
body: {
|
|
69
|
+
mode: "raw",
|
|
70
|
+
raw: JSON.stringify(example, null, 2),
|
|
71
|
+
options: { raw: { language: "json" } }
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
contentType,
|
|
76
|
+
body: {
|
|
77
|
+
mode: "raw",
|
|
78
|
+
raw: typeof example === "string" ? example : "",
|
|
79
|
+
options: { raw: { language: "text" } }
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { buildRequestBody };
|
|
86
|
+
//# sourceMappingURL=build-request-body.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-request-body.mjs","names":[],"sources":["../../../../../../../../core/src/openapi/postman/build-request-body.ts"],"sourcesContent":["import type { OpenApiRequestBody, OpenApiSchema } from \"../types\";\nimport { exampleFromSchema } from \"./example-from-schema\";\nimport type { PostmanBody, PostmanFormParam } from \"./postman-types\";\nimport { isRecord, primaryType, resolveSchema, type SchemaComponents } from \"./schema-refs\";\n\nexport type RequestBodyParts = {\n body: PostmanBody;\n /** Set when the request needs an explicit `Content-Type` header; Postman adds the form ones itself. */\n contentType?: string;\n};\n\nconst MULTIPART = \"multipart/form-data\";\nconst URL_ENCODED = \"application/x-www-form-urlencoded\";\n\nfunction isJsonContentType(contentType: string): boolean {\n return contentType === \"application/json\" || contentType.endsWith(\"+json\");\n}\n\nfunction stringifyValue(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n\n return isRecord(value) || Array.isArray(value) ? JSON.stringify(value) : String(value);\n}\n\nfunction isFileSchema(schema: OpenApiSchema, components: SchemaComponents): boolean {\n const resolved = resolveSchema(schema, components);\n\n if (resolved.format === \"binary\" || typeof resolved.contentMediaType === \"string\") {\n return true;\n }\n\n return primaryType(resolved) === \"array\" && isRecord(resolved.items)\n ? isFileSchema(resolved.items, components)\n : false;\n}\n\nfunction formFields(schema: OpenApiSchema, components: SchemaComponents): PostmanFormParam[] {\n const resolved = resolveSchema(schema, components);\n const properties = isRecord(resolved.properties) ? resolved.properties : {};\n\n return Object.entries(properties).flatMap(([key, property]): PostmanFormParam[] => {\n if (!isRecord(property)) {\n return [];\n }\n\n const description = typeof property.description === \"string\" ? { description: property.description } : {};\n\n if (isFileSchema(property, components)) {\n return [{ key, type: \"file\", src: [], ...description }];\n }\n\n return [{ key, value: stringifyValue(exampleFromSchema(property, components)), type: \"text\", ...description }];\n });\n}\n\nfunction pickContentType(contentTypes: string[]): string | undefined {\n return (\n contentTypes.find(isJsonContentType) ??\n contentTypes.find((contentType) => contentType === MULTIPART) ??\n contentTypes.find((contentType) => contentType === URL_ENCODED) ??\n contentTypes[0]\n );\n}\n\n/**\n * The Postman body of an operation's request body: JSON becomes a raw JSON example, multipart\n * becomes `formdata` (binary properties as file rows), url-encoded becomes `urlencoded`.\n *\n * @returns `undefined` when the operation has no usable body.\n */\nexport function buildRequestBody(\n requestBody: OpenApiRequestBody | undefined,\n components: SchemaComponents,\n): RequestBodyParts | undefined {\n if (!requestBody) {\n return undefined;\n }\n\n const contentType = pickContentType(Object.keys(requestBody.content));\n const schema = contentType !== undefined ? requestBody.content[contentType]?.schema : undefined;\n\n if (contentType === undefined || schema === undefined) {\n return undefined;\n }\n\n if (contentType === MULTIPART) {\n return { body: { mode: \"formdata\", formdata: formFields(schema, components) } };\n }\n\n if (contentType === URL_ENCODED) {\n const urlencoded = formFields(schema, components).flatMap((field) =>\n field.type === \"text\" ? [{ key: field.key, value: field.value, type: \"text\" as const }] : [],\n );\n\n return { body: { mode: \"urlencoded\", urlencoded } };\n }\n\n const example = exampleFromSchema(schema, components);\n\n if (isJsonContentType(contentType)) {\n return {\n contentType,\n body: {\n mode: \"raw\",\n raw: JSON.stringify(example, null, 2),\n options: { raw: { language: \"json\" } },\n },\n };\n }\n\n return {\n contentType,\n body: {\n mode: \"raw\",\n raw: typeof example === \"string\" ? example : \"\",\n options: { raw: { language: \"text\" } },\n },\n };\n}\n"],"mappings":";;;;AAWA,MAAM,YAAY;AAClB,MAAM,cAAc;AAEpB,SAAS,kBAAkB,aAA8B;CACvD,OAAO,gBAAgB,sBAAsB,YAAY,SAAS,OAAO;AAC3E;AAEA,SAAS,eAAe,OAAwB;CAC9C,IAAI,OAAO,UAAU,UACnB,OAAO;CAGT,OAAO,SAAS,KAAK,KAAK,MAAM,QAAQ,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI,OAAO,KAAK;AACvF;AAEA,SAAS,aAAa,QAAuB,YAAuC;CAClF,MAAM,WAAW,cAAc,QAAQ,UAAU;CAEjD,IAAI,SAAS,WAAW,YAAY,OAAO,SAAS,qBAAqB,UACvE,OAAO;CAGT,OAAO,YAAY,QAAQ,MAAM,WAAW,SAAS,SAAS,KAAK,IAC/D,aAAa,SAAS,OAAO,UAAU,IACvC;AACN;AAEA,SAAS,WAAW,QAAuB,YAAkD;CAC3F,MAAM,WAAW,cAAc,QAAQ,UAAU;CACjD,MAAM,aAAa,SAAS,SAAS,UAAU,IAAI,SAAS,aAAa,CAAC;CAE1E,OAAO,OAAO,QAAQ,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,cAAkC;EACjF,IAAI,CAAC,SAAS,QAAQ,GACpB,OAAO,CAAC;EAGV,MA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F;CAGF,OAAO;EACL;EACA,MAAM;GACJ,MAAM;GACN,KAAK,OAAO,YAAY,WAAW,UAAU;GAC7C,SAAS,EAAE,KAAK,EAAE,UAAU,OAAO,EAAE;EACvC;CACF;AACF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isRecord, resolveSchema } from "./schema-refs.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../core/src/openapi/postman/build-request-url.ts
|
|
4
|
+
/** The Postman variable every request URL starts with. */
|
|
5
|
+
const BASE_URL_HOST = "{{baseUrl}}";
|
|
6
|
+
const PATH_TEMPLATE_PARAM = /\{([^}]+)\}/g;
|
|
7
|
+
function stringifyValue(value) {
|
|
8
|
+
if (typeof value === "string") return value;
|
|
9
|
+
return isRecord(value) || Array.isArray(value) ? JSON.stringify(value) : String(value);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Value a parameter starts with in Postman: its declared `example`, `default`, `const` or
|
|
13
|
+
* first `enum` value, otherwise empty so the caller fills it in.
|
|
14
|
+
*/
|
|
15
|
+
function parameterValue(schema, components) {
|
|
16
|
+
const resolved = resolveSchema(schema, components);
|
|
17
|
+
for (const key of [
|
|
18
|
+
"example",
|
|
19
|
+
"default",
|
|
20
|
+
"const"
|
|
21
|
+
]) if (key in resolved) return stringifyValue(resolved[key]);
|
|
22
|
+
if (Array.isArray(resolved.enum) && resolved.enum.length > 0) return stringifyValue(resolved.enum[0]);
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
25
|
+
function withDescription(row, parameter) {
|
|
26
|
+
return parameter.description ? {
|
|
27
|
+
...row,
|
|
28
|
+
description: parameter.description
|
|
29
|
+
} : row;
|
|
30
|
+
}
|
|
31
|
+
function queryRows(parameter, components) {
|
|
32
|
+
const disabled = parameter.required === true ? {} : { disabled: true };
|
|
33
|
+
const schema = resolveSchema(parameter.schema, components);
|
|
34
|
+
if (parameter.style === "deepObject" && isRecord(schema.properties)) return Object.entries(schema.properties).map(([property, propertySchema]) => ({
|
|
35
|
+
key: `${parameter.name}[${property}]`,
|
|
36
|
+
value: isRecord(propertySchema) ? parameterValue(propertySchema, components) : "",
|
|
37
|
+
...disabled
|
|
38
|
+
}));
|
|
39
|
+
return [{
|
|
40
|
+
key: parameter.name,
|
|
41
|
+
value: parameterValue(parameter.schema, components),
|
|
42
|
+
...parameter.description ? { description: parameter.description } : {},
|
|
43
|
+
...disabled
|
|
44
|
+
}];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Header rows for the `header` parameters of an operation. Optional ones start disabled.
|
|
48
|
+
*/
|
|
49
|
+
function buildHeaderParameters(parameters, components) {
|
|
50
|
+
return parameters.filter((parameter) => parameter.in === "header").map((parameter) => withDescription({
|
|
51
|
+
key: parameter.name,
|
|
52
|
+
value: parameterValue(parameter.schema, components),
|
|
53
|
+
...parameter.required === true ? {} : { disabled: true }
|
|
54
|
+
}, parameter));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The Postman URL of an operation: `{id}` templates become `:id` path variables, query
|
|
58
|
+
* parameters become rows (optional ones disabled, so `raw` carries only the enabled ones).
|
|
59
|
+
*/
|
|
60
|
+
function buildRequestUrl(path, parameters, components) {
|
|
61
|
+
const segments = path.split("/").filter((segment) => segment.length > 0).map((segment) => segment.replace(PATH_TEMPLATE_PARAM, ":$1"));
|
|
62
|
+
const variables = [...path.matchAll(PATH_TEMPLATE_PARAM)].flatMap((match) => {
|
|
63
|
+
const name = match[1];
|
|
64
|
+
if (name === void 0) return [];
|
|
65
|
+
const description = parameters.find((parameter) => parameter.in === "path" && parameter.name === name)?.description;
|
|
66
|
+
return [{
|
|
67
|
+
key: name,
|
|
68
|
+
value: "",
|
|
69
|
+
...description ? { description } : {}
|
|
70
|
+
}];
|
|
71
|
+
});
|
|
72
|
+
const query = parameters.filter((parameter) => parameter.in === "query").flatMap((parameter) => queryRows(parameter, components));
|
|
73
|
+
const search = query.filter((row) => row.disabled !== true).map((row) => `${row.key}=${row.value}`).join("&");
|
|
74
|
+
return {
|
|
75
|
+
raw: `${BASE_URL_HOST}/${segments.join("/")}${search ? `?${search}` : ""}`,
|
|
76
|
+
host: [BASE_URL_HOST],
|
|
77
|
+
path: segments,
|
|
78
|
+
...variables.length > 0 ? { variable: variables } : {},
|
|
79
|
+
...query.length > 0 ? { query } : {}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export { buildHeaderParameters, buildRequestUrl };
|
|
85
|
+
//# sourceMappingURL=build-request-url.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-request-url.mjs","names":[],"sources":["../../../../../../../../core/src/openapi/postman/build-request-url.ts"],"sourcesContent":["import type { OpenApiParameter, OpenApiSchema } from \"../types\";\nimport { isRecord, resolveSchema, type SchemaComponents } from \"./schema-refs\";\nimport type { PostmanHeader, PostmanQueryParam, PostmanUrl, PostmanVariable } from \"./postman-types\";\n\n/** The Postman variable every request URL starts with. */\nexport const BASE_URL_HOST = \"{{baseUrl}}\";\n\nconst PATH_TEMPLATE_PARAM = /\\{([^}]+)\\}/g;\n\nfunction stringifyValue(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n\n return isRecord(value) || Array.isArray(value) ? JSON.stringify(value) : String(value);\n}\n\n/**\n * Value a parameter starts with in Postman: its declared `example`, `default`, `const` or\n * first `enum` value, otherwise empty so the caller fills it in.\n */\nfunction parameterValue(schema: OpenApiSchema, components: SchemaComponents): string {\n const resolved = resolveSchema(schema, components);\n\n for (const key of [\"example\", \"default\", \"const\"]) {\n if (key in resolved) {\n return stringifyValue(resolved[key]);\n }\n }\n\n if (Array.isArray(resolved.enum) && resolved.enum.length > 0) {\n return stringifyValue(resolved.enum[0]);\n }\n\n return \"\";\n}\n\nfunction withDescription<T extends object>(row: T, parameter: OpenApiParameter): T & { description?: string } {\n return parameter.description ? { ...row, description: parameter.description } : row;\n}\n\nfunction queryRows(parameter: OpenApiParameter, components: SchemaComponents): PostmanQueryParam[] {\n const disabled = parameter.required === true ? {} : { disabled: true as const };\n const schema = resolveSchema(parameter.schema, components);\n\n if (parameter.style === \"deepObject\" && isRecord(schema.properties)) {\n return Object.entries(schema.properties).map(([property, propertySchema]) => ({\n key: `${parameter.name}[${property}]`,\n value: isRecord(propertySchema) ? parameterValue(propertySchema, components) : \"\",\n ...disabled,\n }));\n }\n\n return [\n {\n key: parameter.name,\n value: parameterValue(parameter.schema, components),\n ...(parameter.description ? { description: parameter.description } : {}),\n ...disabled,\n },\n ];\n}\n\n/**\n * Header rows for the `header` parameters of an operation. Optional ones start disabled.\n */\nexport function buildHeaderParameters(\n parameters: readonly OpenApiParameter[],\n components: SchemaComponents,\n): PostmanHeader[] {\n return parameters\n .filter((parameter) => parameter.in === \"header\")\n .map((parameter) =>\n withDescription(\n {\n key: parameter.name,\n value: parameterValue(parameter.schema, components),\n ...(parameter.required === true ? {} : { disabled: true as const }),\n },\n parameter,\n ),\n );\n}\n\n/**\n * The Postman URL of an operation: `{id}` templates become `:id` path variables, query\n * parameters become rows (optional ones disabled, so `raw` carries only the enabled ones).\n */\nexport function buildRequestUrl(\n path: string,\n parameters: readonly OpenApiParameter[],\n components: SchemaComponents,\n): PostmanUrl {\n const segments = path\n .split(\"/\")\n .filter((segment) => segment.length > 0)\n .map((segment) => segment.replace(PATH_TEMPLATE_PARAM, \":$1\"));\n\n const variables: PostmanVariable[] = [...path.matchAll(PATH_TEMPLATE_PARAM)].flatMap((match) => {\n const name = match[1];\n\n if (name === undefined) {\n return [];\n }\n\n const description = parameters.find((parameter) => parameter.in === \"path\" && parameter.name === name)\n ?.description;\n\n return [{ key: name, value: \"\", ...(description ? { description } : {}) }];\n });\n\n const query = parameters\n .filter((parameter) => parameter.in === \"query\")\n .flatMap((parameter) => queryRows(parameter, components));\n\n const search = query\n .filter((row) => row.disabled !== true)\n .map((row) => `${row.key}=${row.value}`)\n .join(\"&\");\n\n return {\n raw: `${BASE_URL_HOST}/${segments.join(\"/\")}${search ? `?${search}` : \"\"}`,\n host: [BASE_URL_HOST],\n path: segments,\n ...(variables.length > 0 ? { variable: variables } : {}),\n ...(query.length > 0 ? { query } : {}),\n };\n}\n"],"mappings":";;;;AAKA,MAAa,gBAAgB;AAE7B,MAAM,sBAAsB;AAE5B,SAAS,eAAe,OAAwB;CAC9C,IAAI,OAAO,UAAU,UACnB,OAAO;CAGT,OAAO,SAAS,KAAK,KAAK,MAAM,QAAQ,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI,OAAO,KAAK;AACvF;;;;;AAMA,SAAS,eAAe,QAAuB,YAAsC;CACnF,MAAM,WAAW,cAAc,QAAQ,UAAU;CAEjD,KAAK,MAAM,OAAO;EAAC;EAAW;EAAW;CAAO,GAC9C,IAAI,OAAO,UACT,OAAO,eAAe,SAAS,IAAI;CAIvC,IAAI,MAAM,QAAQ,SAAS,IAAI,KAAK,SAAS,KAAK,SAAS,GACzD,OAAO,eAAe,SAAS,KAAK,EAAE;CAGxC,OAAO;AACT;AAEA,SAAS,gBAAkC,KAAQ,WAA2D;CAC5G,OAAO,UAAU,cAAc;EAAE,GAAG;EAAK,aAAa,UAAU;CAAY,IAAI;AAClF;AAEA,SAAS,UAAU,WAA6B,YAAmD;CACjG,MAAM,WAAW,UAAU,aAAa,OAAO,CAAC,IAAI,EAAE,UAAU,KAAc;CAC9E,MAAM,SAAS,cAAc,UAAU,QAAQ,UAAU;CAEzD,IAAI,UAAU,UAAU,gBAAgB,SAAS,OAAO,UAAU,GAChE,OAAO,OAAO,QAAQ,OAAO,UAAU,CAAC,CAAC,KAAK,CAAC,UAAU,qBAAqB;EAC5E,KAAK,GAAG,UAAU,KAAK,GAAG,SAAS;EACnC,OAAO,SAAS,cAAc,IAAI,eAAe,gBAAgB,UAAU,IAAI;EAC/E,GAAG;CACL,EAAE;CAGJ,OAAO,CACL;EACE,KAAK,UAAU;EACf,OAAO,eAAe,UAAU,QAAQ,UAAU;EAClD,GAAI,UAAU,cAAc,EAAE,a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