@webpieces/core-util 0.4.957 → 0.4.959
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/package.json +1 -1
- package/src/http/ApiCallInfo.d.ts +71 -11
- package/src/http/ApiCallInfo.js +81 -7
- package/src/http/ApiCallInfo.js.map +1 -1
- package/src/http/ContextMgr.js +12 -2
- package/src/http/ContextMgr.js.map +1 -1
- package/src/http/DeletedAuthCompileAssertions.js +3 -1
- package/src/http/DeletedAuthCompileAssertions.js.map +1 -1
- package/src/http/DestinationTrust.d.ts +33 -4
- package/src/http/DestinationTrust.js +54 -11
- package/src/http/DestinationTrust.js.map +1 -1
- package/src/http/EndpointCompileAssertions.js +12 -6
- package/src/http/EndpointCompileAssertions.js.map +1 -1
- package/src/http/ExternalContextKeys.d.ts +31 -0
- package/src/http/ExternalContextKeys.js +77 -0
- package/src/http/ExternalContextKeys.js.map +1 -0
- package/src/http/HttpContract.d.ts +45 -7
- package/src/http/HttpContract.js +84 -6
- package/src/http/HttpContract.js.map +1 -1
- package/src/http/HttpEndpointOptions.d.ts +22 -3
- package/src/http/HttpEndpointOptions.js +8 -1
- package/src/http/HttpEndpointOptions.js.map +1 -1
- package/src/http/LogApiCall.d.ts +4 -1
- package/src/http/LogApiCall.js +7 -5
- package/src/http/LogApiCall.js.map +1 -1
- package/src/http/QueryParams.d.ts +47 -0
- package/src/http/QueryParams.js +89 -0
- package/src/http/QueryParams.js.map +1 -0
- package/src/http/RouteMetadata.d.ts +16 -2
- package/src/http/RouteMetadata.js +19 -3
- package/src/http/RouteMetadata.js.map +1 -1
- package/src/http/RouteMetadataFactory.d.ts +25 -0
- package/src/http/RouteMetadataFactory.js +97 -12
- package/src/http/RouteMetadataFactory.js.map +1 -1
- package/src/http/WpAuthApiKeyCompileAssertions.js +2 -2
- package/src/http/WpAuthApiKeyCompileAssertions.js.map +1 -1
- package/src/http/api-kind.d.ts +3 -2
- package/src/http/api-kind.js +5 -4
- package/src/http/api-kind.js.map +1 -1
- package/src/http/auth-mode.d.ts +8 -2
- package/src/http/auth-mode.js +11 -5
- package/src/http/auth-mode.js.map +1 -1
- package/src/http/decorators.d.ts +39 -21
- package/src/http/decorators.js +69 -37
- package/src/http/decorators.js.map +1 -1
- package/src/http/external-caller.d.ts +12 -17
- package/src/http/external-caller.js +12 -17
- package/src/http/external-caller.js.map +1 -1
- package/src/http/http-parameter-decorators.d.ts +17 -3
- package/src/http/http-parameter-decorators.js +27 -6
- package/src/http/http-parameter-decorators.js.map +1 -1
- package/src/index.d.ts +11 -7
- package/src/index.js +30 -12
- package/src/index.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/decorators.ts"],"names":[],"mappings":";;;AAqFA,0BAcC;AAwBD,4BAqBC;AAgFD,0BAUC;AAOD,kCAIC;AAqCD,oCAOC;AAID,wBAEC;AAID,kCAKC;AAGD,kCAEC;AASD,gCAEC;AAMD,oCAEC;AAOD,4CAEC;AAWD,0CAEC;AAID,sDAUC;AAMD,gDASC;AAID,oDAWC;AAiCD,8FAcC;AAOD,gCAEC;AAOD,8BAEC;AAeD,4FAeC;AAKD,8BAEC;AAMD,kCAEC;AAmBD,wEAuBC;AAOD,0EAkBC;AA3jBD,4BAA0B;AAC1B,iDAAoD;AACpD,uDAK2B;AAC3B,4FAA4F;AAC5F,2CAA8D;AAC9D,+DAO+B;AAC/B,iDAAuD;AACvD,mDAA2H;AAC3H,2EAA2E;AAI3E,6DAAsE;AAA7D,2GAAA,IAAI,OAAA;AAAE,uHAAA,gBAAgB,OAAA;AAAE,4GAAA,KAAK,OAAA;AAEtC,+CAA2C;AAAlC,mGAAA,GAAG,OAAA;AAAE,oGAAA,IAAI,OAAA;AAClB,yEAAkG;AAAzF,sHAAA,SAAS,OAAA;AAAE,uHAAA,UAAU,OAAA;AAAE,yIAAA,4BAA4B,OAAA;AAE5D;;;GAGG;AACU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ldMask';\nimport {\n DEFAULT_CALLER_KIND,\n ENDPOINT_CALLER_KEY,\n ExternalCaller,\n getEndpointCaller,\n} from './external-caller';\n// The TYPE layer these decorators attach — split out for file size only (see auth-mode.ts).\nimport { AuthMeta, AuthMethods, AuthMode } from './auth-mode';\nimport {\n EndpointOperation,\n EndpointOptions,\n ExternalEndpointOptions,\n READ,\n WRITE_IDEMPOTENT,\n WRITE,\n} from './HttpEndpointOptions';\nimport { GET, HttpMethod, POST } from './HttpContract';\nimport { AuthorizationDeclaration, AuthorizationType, AUTHORIZATION_METHODS_KEY, getAuthorization } from './authorization';\nimport { HTTP_PARAMETERS_METADATA_KEY } from './http-parameter-decorators';\n\nexport type { EndpointOptions, ExternalEndpointOptions } from './HttpEndpointOptions';\nexport type { EndpointOperation } from './HttpEndpointOptions';\nexport { READ, WRITE_IDEMPOTENT, WRITE } from './HttpEndpointOptions';\nexport type { HttpMethod } from './HttpContract';\nexport { GET, POST } from './HttpContract';\nexport { PathParam, QueryParam, getHttpParameterDeclarations } from './http-parameter-decorators';\n\n/**\n * Metadata keys for storing API routing information.\n * These keys are used by both server-side (routing) and client-side (client generation).\n */\nexport const METADATA_KEYS = {\n API_PATH: 'webpieces:api-path',\n ENDPOINTS: 'webpieces:endpoints',\n AUTH_META: 'webpieces:auth-meta',\n /** Method names carrying one of the canonical authorization decorators. */\n AUTH_METHODS: 'webpieces:auth-methods',\n /** 'rpc' (default, sync request/response) vs 'pubsub' (fire-and-forget cloud task). */\n API_KIND: 'webpieces:api-kind',\n /** Per-method Cloud Tasks queue-name override (set via @Queue). */\n QUEUE_OVERRIDE: 'webpieces:queue-override',\n /** Per-method @Endpoint options (e.g. formPost), parallel to ENDPOINTS. */\n ENDPOINT_OPTIONS: 'webpieces:endpoint-options',\n /** Per-method required HTTP method, parallel to ENDPOINTS. */\n ENDPOINT_HTTP_METHOD: 'webpieces:endpoint-http-method',\n /** Per-method required read/write semantics, parallel to ENDPOINTS. */\n ENDPOINT_OPERATION: 'webpieces:endpoint-operation',\n /** Per-method @Endpoint trigger kind (rpc | cloudtasks | cron | external), parallel to ENDPOINTS. */\n ENDPOINT_KIND: 'webpieces:endpoint-kind',\n /** Per-method declared external CALLER (only for kind 'external'), parallel to ENDPOINTS. */\n ENDPOINT_CALLER: ENDPOINT_CALLER_KEY,\n /** Per-method @MaskLog spec (which DTO fields the LogApiCall path masks). */\n MASK_LOG: 'webpieces:mask-log',\n /** Per-method opt-in metadata for publishing an RPC endpoint as an MCP tool. */\n MCP_TOOLS: 'webpieces:mcp-tools',\n /** Per-method PERMANENT exclusion from MCP, with the reason — see @InvalidEndpointForMcp. */\n MCP_INVALID: 'webpieces:mcp-invalid',\n /** Per-method request/response event metadata for a typed streaming endpoint. */\n STREAM_ENDPOINTS: 'webpieces:stream-endpoints',\n /** Per-method MCP-user authorization, intentionally separate from HTTP hop auth. */\n LOCAL_ONLY: 'webpieces:local-only',\n /** Per-method explicit path/query parameter declarations, keyed by parameter index. */\n HTTP_PARAMETERS: HTTP_PARAMETERS_METADATA_KEY,\n};\n\n/** Nominal backing keeps raw string literals out of endpoint declarations. */\nenum EndpointKindValue {\n RPC = 'rpc',\n CLOUDTASKS = 'cloudtasks',\n CRON = 'cron',\n EXTERNAL = 'external',\n}\n\n/** Short, statically importable decorator arguments. */\nexport const RPC = EndpointKindValue.RPC;\nexport const CLOUDTASKS = EndpointKindValue.CLOUDTASKS;\nexport const CRON = EndpointKindValue.CRON;\nexport const EXTERNAL = EndpointKindValue.EXTERNAL;\n\n/** Runtime trigger/delivery owner used by validation, architecture, and infrastructure tooling. */\nexport type EndpointKind = typeof RPC | typeof CLOUDTASKS | typeof CRON | typeof EXTERNAL;\n\n/** Class decorator that sets the shared base path for all endpoints. */\nexport function ApiPath(basePath: string): ClassDecorator {\n return (target: Function) => {\n if (Reflect.hasMetadata('webpieces:ipc-api-id', target)) {\n throw new Error(\n `Class ${target.name || 'Unknown'} cannot combine @ApiPath with @WpInternal.`,\n );\n }\n Reflect.defineMetadata(METADATA_KEYS.API_PATH, basePath, target);\n\n // Initialize endpoints map if not exists\n if (!Reflect.hasMetadata(METADATA_KEYS.ENDPOINTS, target)) {\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINTS, {}, target);\n }\n };\n}\n\n/**\n * Registers `@Endpoint(POST, path, WRITE, RPC)`. Method, operation, and trigger are required enum\n * values. Operation is independent of the HTTP verb. EXTERNAL additionally requires `calledBy`.\n * Each classification rides a parallel metadata map while ENDPOINTS remains method-name -> path.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function Endpoint(\n httpMethod: HttpMethod,\n path: string,\n operation: EndpointOperation,\n kind: typeof EXTERNAL,\n options: ExternalEndpointOptions,\n): MethodDecorator;\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function Endpoint(\n httpMethod: HttpMethod,\n path: string,\n operation: EndpointOperation,\n kind: Exclude<EndpointKind, typeof EXTERNAL>,\n options?: EndpointOptions,\n): MethodDecorator;\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function Endpoint(\n httpMethod: HttpMethod,\n path: string,\n operation: EndpointOperation,\n kind: EndpointKind,\n options: EndpointOptions = {},\n): MethodDecorator {\n validateEndpointClassification(httpMethod, operation, kind);\n // webpieces-disable no-any-unknown -- reflect-metadata decorator API requires any\n return (target: any, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => {\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n recordEndpointMetadata(\n metadataTarget,\n propertyKey as string,\n httpMethod,\n path,\n operation,\n kind,\n options,\n );\n };\n}\n\n// webpieces-disable no-function-outside-class -- runtime validation backs up nominal TS enums\nfunction validateEndpointClassification(\n httpMethod: HttpMethod,\n operation: EndpointOperation,\n kind: EndpointKind,\n): void {\n if (!isHttpMethod(httpMethod)) {\n throw new Error(\n `@Endpoint httpMethod must be GET or POST, received '${String(httpMethod)}'.`,\n );\n }\n if (!isEndpointOperation(operation)) {\n throw new Error(\n `@Endpoint operation must be READ, WRITE_IDEMPOTENT, or WRITE, received '${String(operation)}'.`,\n );\n }\n if (!isEndpointKind(kind)) {\n throw new Error(\n `@Endpoint trigger must be RPC, CLOUDTASKS, CRON, or EXTERNAL, received '${String(kind)}'.`,\n );\n }\n}\n\n// webpieces-disable no-function-outside-class -- one metadata write shared by the decorator overloads\nfunction recordEndpointMetadata(\n metadataTarget: Function,\n propertyKey: string,\n httpMethod: HttpMethod,\n path: string,\n operation: EndpointOperation,\n kind: EndpointKind,\n options: EndpointOptions,\n): void {\n const endpoints: Record<string, string> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINTS, metadataTarget) || {};\n\n endpoints[propertyKey] = path;\n\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINTS, endpoints, metadataTarget);\n\n const methods: Record<string, HttpMethod> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_HTTP_METHOD, metadataTarget) || {};\n methods[propertyKey] = httpMethod;\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_HTTP_METHOD, methods, metadataTarget);\n\n const operations: Record<string, EndpointOperation> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_OPERATION, metadataTarget) || {};\n operations[propertyKey] = operation;\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_OPERATION, operations, metadataTarget);\n\n const kinds: Record<string, EndpointKind> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_KIND, metadataTarget) || {};\n kinds[propertyKey] = kind;\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_KIND, kinds, metadataTarget);\n\n const opts: Record<string, EndpointOptions> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_OPTIONS, metadataTarget) || {};\n opts[propertyKey] = options;\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_OPTIONS, opts, metadataTarget);\n\n const declared = options as ExternalEndpointOptions;\n if (\n kind !== EXTERNAL ||\n typeof declared.calledBy !== 'string' ||\n declared.calledBy === ''\n )\n return;\n const callers: Record<string, ExternalCaller> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_CALLER, metadataTarget) || {};\n callers[propertyKey] = new ExternalCaller(\n declared.callerKind ?? DEFAULT_CALLER_KIND,\n declared.calledBy,\n );\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_CALLER, callers, metadataTarget);\n}\n\n/** Declares request/response DTO field names that API logging must mask at any depth. */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function MaskLog(fields: Record<string, MaskMode>): MethodDecorator {\n const spec = new MaskSpec(fields);\n // webpieces-disable no-any-unknown -- reflect-metadata decorator API requires any\n return (target: any, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => {\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n const specs: Record<string, MaskSpec> =\n Reflect.getMetadata(METADATA_KEYS.MASK_LOG, metadataTarget) || {};\n specs[propertyKey as string] = spec;\n Reflect.defineMetadata(METADATA_KEYS.MASK_LOG, specs, metadataTarget);\n };\n}\n\n/**\n * The @MaskLog spec for one method, or undefined if the method declared none (the common case — the\n * caller then logs the DTO verbatim on the plain JSON.stringify fast path).\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointOptions\nexport function getMaskSpec(apiClass: Function, methodName: string): MaskSpec | undefined {\n const specs: Record<string, MaskSpec> =\n Reflect.getMetadata(METADATA_KEYS.MASK_LOG, apiClass) || {};\n return specs[methodName];\n}\n\n/**\n * Shared implementation for every auth decorator. Authorization is deliberately\n * method-only: a class-level default is too easy to miss when reviewing one endpoint.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nfunction defineAuthMetadata(authMeta: AuthMeta): MethodDecorator {\n\n // webpieces-disable no-any-unknown -- reflect-metadata decorator API requires any\n return (target: any, propertyKey?: string | symbol, _descriptor?: PropertyDescriptor) => {\n if (propertyKey === undefined) {\n throw new Error(\n 'Authorization decorators are method-only; annotate every @Endpoint explicitly.',\n );\n }\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n if (Reflect.hasMetadata('webpieces:ipc-api-id', metadataTarget)) {\n throw new Error(\n `Internal API ${metadataTarget.name || 'Unknown'} cannot use HTTP authorization decorators.`,\n );\n }\n validateNoConflictingDecorators(metadataTarget, propertyKey as string);\n Reflect.defineMetadata(METADATA_KEYS.AUTH_META, authMeta, metadataTarget, propertyKey);\n const methods = new Set<string>(\n Reflect.getMetadata(METADATA_KEYS.AUTH_METHODS, metadataTarget) || [],\n );\n methods.add(propertyKey as string);\n Reflect.defineMetadata(METADATA_KEYS.AUTH_METHODS, [...methods], metadataTarget);\n };\n}\n\n/**\n * @WpAuthPublic(reason) - endpoint intentionally requires no authentication.\n * The non-empty reason makes anonymous exposure an explicit review decision.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function WpAuthPublic(reason: string): MethodDecorator {\n if (typeof reason !== 'string' || reason.trim() === '') {\n throw new Error(\n '@WpAuthPublic requires a non-empty reason explaining why anonymous access is required.',\n );\n }\n return defineAuthMetadata(new AuthMeta([{ kind: 'public' }], reason));\n}\n\n/** Protected network ingress: authenticate one declared credential, then authorize independently. */\n// webpieces-disable no-function-outside-class -- canonical method decorator factory\nexport function WpAuth(methods: AuthMethods): MethodDecorator {\n return defineAuthMetadata(new AuthMeta(methods, undefined));\n}\n\n/** Locality is independent of authentication and cannot prove a user or machine identity. */\n// webpieces-disable no-function-outside-class -- canonical method decorator factory\nexport function WpLocalOnly(): MethodDecorator {\n return (target: object, methodName: string | symbol) => {\n if (methodName === undefined) throw new Error('@WpLocalOnly is method-only.');\n Reflect.defineMetadata(METADATA_KEYS.LOCAL_ONLY, true, target.constructor, methodName);\n };\n}\n\n// webpieces-disable no-function-outside-class -- canonical metadata reader\nexport function isLocalOnly(apiClass: Function, methodName: string): boolean {\n return Reflect.getMetadata(METADATA_KEYS.LOCAL_ONLY, apiClass, methodName) === true;\n}\n\n// ============================================================\n// Helper functions\n// ============================================================\n\n/**\n * Get the base path from @ApiPath decorator.\n */\nexport function getApiPath(apiClass: Function): string | undefined {\n return Reflect.getMetadata(METADATA_KEYS.API_PATH, apiClass);\n}\n\n/**\n * Get all endpoints from @Endpoint decorators.\n * Returns a record of methodName -> endpoint path.\n */\nexport function getEndpoints(apiClass: Function): Record<string, string> | undefined {\n return Reflect.getMetadata(METADATA_KEYS.ENDPOINTS, apiClass);\n}\n\n/**\n * Every method's declared trigger kind, as `methodName -> kind`. Parallel to {@link getEndpoints}.\n * Empty for a class carrying no @Endpoint at all.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpoints\nexport function getEndpointKinds(apiClass: Function): Record<string, EndpointKind> {\n return Reflect.getMetadata(METADATA_KEYS.ENDPOINT_KIND, apiClass) || {};\n}\n\n/**\n * What triggers ONE method, or undefined when the method carries no @Endpoint.\n *\n * Defaults to nothing rather than to 'rpc': `kind` is a required argument, so a missing entry means\n * \"this is not an endpoint\", never \"an endpoint that forgot to say\". Silently defaulting here would\n * put an undeclared cron or webhook back into the graph as a normal rpc call — the exact blindness\n * the required argument exists to remove.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpoints\nexport function getEndpointKind(apiClass: Function, methodName: string): EndpointKind | undefined {\n return getEndpointKinds(apiClass)[methodName];\n}\n\n/** The required HTTP method for one endpoint. */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointKind\nexport function getEndpointHttpMethod(apiClass: Function, methodName: string): HttpMethod {\n const methods: Record<string, HttpMethod> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_HTTP_METHOD, apiClass) || {};\n const method = methods[methodName];\n if (!isHttpMethod(method)) {\n throw new Error(\n `@Endpoint ${apiClass.name || 'Unknown'}.${methodName} must declare GET or POST.`,\n );\n }\n return method;\n}\n\n/**\n * Get the @Endpoint options for one method (empty object if the method had no options).\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpoints\nexport function getEndpointOptions(apiClass: Function, methodName: string): EndpointOptions {\n const opts: Record<string, EndpointOptions> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_OPTIONS, apiClass) || {};\n const options = opts[methodName];\n if (!options && getEndpoints(apiClass)?.[methodName] === undefined) {\n // Preserve the historical helper behavior for a method that is not an endpoint at all.\n return {} as EndpointOptions;\n }\n return options ?? {};\n}\n\n/** Read one endpoint's required side-effect semantics. */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointOptions\nexport function getEndpointOperation(apiClass: Function, methodName: string): EndpointOperation {\n const operations: Record<string, EndpointOperation> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_OPERATION, apiClass) || {};\n const operation = operations[methodName];\n if (!isEndpointOperation(operation)) {\n throw new Error(\n `@Endpoint ${apiClass.name || 'Unknown'}.${methodName} must declare READ, ` +\n 'WRITE_IDEMPOTENT, or WRITE.',\n );\n }\n return operation;\n}\n\n// webpieces-disable no-function-outside-class -- runtime backstop for JavaScript and `as any` callers; webpieces-disable no-any-unknown -- untrusted runtime value is narrowed to an endpoint operation\nfunction isEndpointOperation(value: unknown): value is EndpointOperation {\n return (\n value === READ ||\n value === WRITE_IDEMPOTENT ||\n value === WRITE\n );\n}\n\n// webpieces-disable no-function-outside-class -- runtime backstop for JavaScript and `as any` callers; webpieces-disable no-any-unknown -- untrusted runtime value is narrowed to an HTTP method\nfunction isHttpMethod(value: unknown): value is HttpMethod {\n return value === GET || value === POST;\n}\n\n// webpieces-disable no-function-outside-class -- runtime backstop for JavaScript and `as any` callers; webpieces-disable no-any-unknown -- untrusted runtime value is narrowed to an endpoint kind\nfunction isEndpointKind(value: unknown): value is EndpointKind {\n return (\n value === RPC ||\n value === CLOUDTASKS ||\n value === CRON ||\n value === EXTERNAL\n );\n}\n\n/**\n * Fail-fast at wiring time when an `external` endpoint declared no caller. The {@link Endpoint}\n * overloads already make that a COMPILE error; this is the backstop for the ways TS is bypassed —\n * a JS caller, an `as any` options object, a hand-rolled Reflect.defineMetadata.\n * @throws Error naming the first external endpoint with no `calledBy`.\n */\n// webpieces-disable no-function-outside-class -- wiring-time assert, sibling of assertEveryEndpointHasAuthMode\nexport function assertEveryExternalEndpointDeclaresCaller(apiClass: Function): void {\n const kinds = getEndpointKinds(apiClass);\n for (const methodName of Object.keys(kinds)) {\n if (\n kinds[methodName] !== 'external' ||\n getEndpointCaller(apiClass, methodName) !== undefined\n )\n continue;\n throw new Error(\n `External endpoint '${methodName}' in ${apiClass.name || 'Unknown'} declares no caller. Say WHO ` +\n `posts to it: @Endpoint(POST, path, WRITE, EXTERNAL, { calledBy: '<vendor>' }) — the runtime architecture ` +\n `graph cannot name an inbound caller it was never told about.`,\n );\n }\n}\n\n/**\n * True when the method's @Endpoint declared `{ formPost: true }` — its body is\n * application/x-www-form-urlencoded (flat), not JSON.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpoints\nexport function isFormPost(apiClass: Function, methodName: string): boolean {\n return getEndpointOptions(apiClass, methodName).formPost === true;\n}\n\n/**\n * True when the method's @Endpoint declared `{ rawBody: true }` — the transport must retain the\n * verbatim bytes + absolute url for an {@link WebhookAuthCallback} hook to verify.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of isFormPost\nexport function isRawBody(apiClass: Function, methodName: string): boolean {\n return getEndpointOptions(apiClass, methodName).rawBody === true;\n}\n\n/**\n * Fail-fast at wiring time when an `webhook(...)` endpoint did not ask the transport to keep the\n * bytes it is supposed to verify. A hook with nothing to verify is a MISCONFIGURATION, and it must\n * surface at startup, naming the fix — not as a 401 in production on exactly the traffic the endpoint\n * exists for.\n *\n * This pairing is a runtime assert rather than a type because the two halves live on DIFFERENT\n * decorators (`webhook(...)` and `@Endpoint`), and no union over one decorator's argument can say\n * anything about the other's.\n *\n * @throws Error naming the first `webhook(...)` endpoint missing `{ rawBody: true }`.\n */\n// webpieces-disable no-function-outside-class -- wiring-time assert, sibling of assertEveryEndpointHasAuthMode\nexport function assertEveryWebhookEndpointRetainsRawBody(apiClass: Function): void {\n const endpoints = getEndpoints(apiClass) || {};\n for (const methodName of Object.keys(endpoints)) {\n if (\n !getAuthMeta(apiClass, methodName)?.methods.some((method: AuthMode) => method.kind === 'webhook') ||\n isRawBody(apiClass, methodName)\n )\n continue;\n throw new Error(\n `Endpoint '${methodName}' in ${apiClass.name || 'Unknown'} is webhook(...) but its @Endpoint ` +\n `does not declare { rawBody: true }. A webhook hook verifies a signature over the bytes and ` +\n `the url the SENDER transmitted, and without that option the transport parses the body and ` +\n `throws them away — leaving the hook nothing to check.`,\n );\n }\n}\n\n/**\n * Check if a class has @ApiPath decorator.\n */\nexport function isApiPath(apiClass: Function): boolean {\n return Reflect.hasMetadata(METADATA_KEYS.API_PATH, apiClass);\n}\n\n/**\n * Get method-level auth metadata. Class-level authorization is forbidden.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader paired with the decorator API\nexport function getAuthMeta(apiClass: Function, methodName: string): AuthMeta | undefined {\n return Reflect.getMetadata(METADATA_KEYS.AUTH_META, apiClass, methodName);\n}\n\n/**\n * The ONE prescription for \"this endpoint declares no auth\", shared by the two places that raise it\n * (here and http-routing's ApiRoutingFactory) because they had drifted into teaching different menus.\n * A message teaching an incomplete API is the same defect as an API with two spellings: whichever menu\n * the caller hits becomes the API they believe exists. It leads with the ROLE-GATED member on purpose —\n * the first thing offered should not be the widest grant.\n */\nexport const MISSING_AUTH_DECORATOR_FIX =\n \"Declare @WpAuth([jwt(), oidcSameProject() or oidcSvcs(['svc-a']), sharedSecret(key), webhook(name), apiKey('regime', [{in: 'header', key: MyKeys.API_KEY}])]) \" +\n \"or @WpAuthPublic('reason'), and exactly one @WpAuthorization on every endpoint. Add @WpLocalOnly() separately when locality is required.\";\n\n/**\n * Fail-fast at wiring time if any endpoint lacks an auth mode. Both the server\n * (ApiRoutingFactory) and the task/rpc clients call this so a missing auth\n * decorator is a startup error, never a silent open endpoint.\n * @throws Error naming the first endpoint with no auth decorator, via {@link MISSING_AUTH_DECORATOR_FIX}.\n */\nexport function assertEveryEndpointHasAuthMode(apiClass: Function): void {\n const apiName = apiClass.name || 'Unknown';\n const endpoints = getEndpoints(apiClass) || {};\n for (const methodName of Object.keys(endpoints)) {\n if (!getAuthMeta(apiClass, methodName)) {\n throw new Error(\n `Endpoint '${methodName}' in ${apiName} has no auth decorator. ` +\n MISSING_AUTH_DECORATOR_FIX,\n );\n }\n const policy = getAuthorization(apiClass, methodName);\n if (!policy) throw new Error(`Endpoint '${methodName}' in ${apiName} requires @WpAuthorization.`);\n AuthorizationDeclaration.validate(policy);\n const auth = getAuthMeta(apiClass, methodName)!;\n const isPublic = auth.methods.some((method: AuthMode) => method.kind === 'public');\n if (isPublic !== (policy.authType === AuthorizationType.ANONYMOUS)) {\n throw new Error(`Endpoint '${methodName}' must pair public authentication with ANONYMOUS authorization, or protected authentication with protected/CUSTOM authorization.`);\n }\n }\n const policyMethods: string[] = Reflect.getMetadata(AUTHORIZATION_METHODS_KEY, apiClass) ?? [];\n for (const methodName of policyMethods) {\n if (!(methodName in endpoints)) throw new Error(`Orphan @WpAuthorization on ${apiName}.${methodName}; declare @Endpoint.`);\n }\n}\n\n/**\n * Validate that a class/method doesn't have conflicting auth decorators.\n * @throws Error if multiple auth decorators are found on the same target.\n */\n// webpieces-disable no-function-outside-class -- shared decorator metadata validation\nexport function validateNoConflictingDecorators(\n apiClass: Function,\n methodName: string | undefined,\n): void {\n const existing = methodName\n ? Reflect.getMetadata(METADATA_KEYS.AUTH_META, apiClass, methodName)\n : Reflect.getMetadata(METADATA_KEYS.AUTH_META, apiClass);\n\n if (existing) {\n const targetName = apiClass.name || 'Unknown';\n const location = methodName\n ? `method '${methodName}' of ${targetName}`\n : `class ${targetName}`;\n throw new Error(\n `Conflicting auth decorator on ${location}. ` +\n `Exactly one @WpAuth([...]) or @WpAuthPublic('reason') is allowed per endpoint.`,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../../../pack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,IAAI,KAAK,CAAC,8BAA8B,OAAO,IAAI,UAAU,sBAAsB,CAAC,CAAC;IAC/H,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,sFAAsF;AACtF,SAAgB,+BAA+B,CAC3C,QAAkB,EAClB,UAA8B;IAE9B,MAAM,QAAQ,GAAG,UAAU;QACvB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,qBAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC;QACpE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,qBAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAE7D,IAAI,QAAQ,EAAE,CAAC;QACX,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,IAAI,SAAS,CAAC;QAC9C,MAAM,QAAQ,GAAG,UAAU;YACvB,CAAC,CAAC,WAAW,UAAU,QAAQ,UAAU,EAAE;YAC3C,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACX,iCAAiC,QAAQ,IAAI;YACzC,gFAAgF,CACvF,CAAC;IACN,CAAC;AACL,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { MaskSpec, MaskMode } from './LogFieldMask';\nimport {\n DEFAULT_CALLER_KIND,\n ENDPOINT_CALLER_KEY,\n ExternalCaller,\n getEndpointCaller,\n} from './external-caller';\n// The TYPE layer these decorators attach — split out for file size only (see auth-mode.ts).\nimport { AuthMeta, AuthMethods, AuthMode } from './auth-mode';\nimport {\n EndpointOperation,\n EndpointOptions,\n ExternalEndpointOptions,\n READ,\n WRITE_IDEMPOTENT,\n WRITE,\n} from './HttpEndpointOptions';\nimport { HTTP_METHODS, HttpMethod, isHttpMethod } from './HttpContract';\nimport { AuthorizationDeclaration, AuthorizationType, AUTHORIZATION_METHODS_KEY, getAuthorization } from './authorization';\nimport { HTTP_PARAMETERS_METADATA_KEY } from './http-parameter-decorators';\n\nexport type { EndpointOptions, ExternalEndpointOptions } from './HttpEndpointOptions';\nexport type { EndpointOperation } from './HttpEndpointOptions';\nexport { READ, WRITE_IDEMPOTENT, WRITE, NONE } from './HttpEndpointOptions';\nexport type { ResponseBodyKind } from './HttpEndpointOptions';\nexport type { HttpMethod } from './HttpContract';\nexport { GET, POST, PUT, PATCH, DELETE } from './HttpContract';\nexport { PathParam, QueryParam, QueryString, getHttpParameterDeclarations } from './http-parameter-decorators';\n\n/**\n * Metadata keys for storing API routing information.\n * These keys are used by both server-side (routing) and client-side (client generation).\n */\nexport const METADATA_KEYS = {\n API_PATH: 'webpieces:api-path',\n ENDPOINTS: 'webpieces:endpoints',\n AUTH_META: 'webpieces:auth-meta',\n /** Method names carrying one of the canonical authorization decorators. */\n AUTH_METHODS: 'webpieces:auth-methods',\n /** 'rpc' (default, sync request/response) vs 'pubsub' (fire-and-forget cloud task). */\n API_KIND: 'webpieces:api-kind',\n /** Per-method Cloud Tasks queue-name override (set via @Queue). */\n QUEUE_OVERRIDE: 'webpieces:queue-override',\n /** Per-method @Endpoint options (e.g. formPost), parallel to ENDPOINTS. */\n ENDPOINT_OPTIONS: 'webpieces:endpoint-options',\n /** Per-method required HTTP method, parallel to ENDPOINTS. */\n ENDPOINT_HTTP_METHOD: 'webpieces:endpoint-http-method',\n /** Per-method required read/write semantics, parallel to ENDPOINTS. */\n ENDPOINT_OPERATION: 'webpieces:endpoint-operation',\n /** Per-method @Endpoint trigger kind (rpc | cloudtasks | cron | external-inbound | external-outbound), parallel to ENDPOINTS. */\n ENDPOINT_KIND: 'webpieces:endpoint-kind',\n /** Per-method declared external CALLER (only for kind 'external-inbound'), parallel to ENDPOINTS. */\n ENDPOINT_CALLER: ENDPOINT_CALLER_KEY,\n /** Per-method @MaskLog spec (which DTO fields the LogApiCall path masks). */\n MASK_LOG: 'webpieces:mask-log',\n /** Per-method opt-in metadata for publishing an RPC endpoint as an MCP tool. */\n MCP_TOOLS: 'webpieces:mcp-tools',\n /** Per-method PERMANENT exclusion from MCP, with the reason — see @InvalidEndpointForMcp. */\n MCP_INVALID: 'webpieces:mcp-invalid',\n /** Per-method request/response event metadata for a typed streaming endpoint. */\n STREAM_ENDPOINTS: 'webpieces:stream-endpoints',\n /** Per-method MCP-user authorization, intentionally separate from HTTP hop auth. */\n LOCAL_ONLY: 'webpieces:local-only',\n /** Per-method explicit path/query parameter declarations, keyed by parameter index. */\n HTTP_PARAMETERS: HTTP_PARAMETERS_METADATA_KEY,\n};\n\n/** Nominal backing keeps raw string literals out of endpoint declarations. */\nenum EndpointKindValue {\n RPC = 'rpc',\n CLOUDTASKS = 'cloudtasks',\n CRON = 'cron',\n EXTERNAL_INBOUND = 'external-inbound',\n EXTERNAL_OUTBOUND = 'external-outbound',\n}\n\n/** Short, statically importable decorator arguments. */\nexport const RPC = EndpointKindValue.RPC;\nexport const CLOUDTASKS = EndpointKindValue.CLOUDTASKS;\nexport const CRON = EndpointKindValue.CRON;\n/**\n * An OUTSIDE system calls US (a vendor webhook, a push subscription). Requires `calledBy`, which names\n * that system on the runtime architecture graph.\n */\nexport const EXTERNAL_INBOUND = EndpointKindValue.EXTERNAL_INBOUND;\n/**\n * WE call an OUTSIDE system (a vendor API, a partner's webhook receiver). No server in this repo\n * implements it, every method of the contract must be this kind, and the client sends ONLY the\n * context keys listed with `@ExternalContextKeys(...)` and merges no response header into our context.\n */\nexport const EXTERNAL_OUTBOUND = EndpointKindValue.EXTERNAL_OUTBOUND;\n\n/** Runtime trigger/delivery owner used by validation, architecture, and infrastructure tooling. */\nexport type EndpointKind =\n | typeof RPC\n | typeof CLOUDTASKS\n | typeof CRON\n | typeof EXTERNAL_INBOUND\n | typeof EXTERNAL_OUTBOUND;\n\n/** Class decorator that sets the shared base path for all endpoints. */\nexport function ApiPath(basePath: string): ClassDecorator {\n return (target: Function) => {\n if (Reflect.hasMetadata('webpieces:ipc-api-id', target)) {\n throw new Error(\n `Class ${target.name || 'Unknown'} cannot combine @ApiPath with @WpInternal.`,\n );\n }\n Reflect.defineMetadata(METADATA_KEYS.API_PATH, basePath, target);\n\n // Initialize endpoints map if not exists\n if (!Reflect.hasMetadata(METADATA_KEYS.ENDPOINTS, target)) {\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINTS, {}, target);\n }\n };\n}\n\n/**\n * Registers `@Endpoint(POST, path, WRITE, RPC)`. Method, operation, and trigger are required enum\n * values. Operation is independent of the HTTP verb. EXTERNAL_INBOUND additionally requires `calledBy`.\n * Each classification rides a parallel metadata map while ENDPOINTS remains method-name -> path.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function Endpoint(\n httpMethod: HttpMethod,\n path: string,\n operation: EndpointOperation,\n kind: typeof EXTERNAL_INBOUND,\n options: ExternalEndpointOptions,\n): MethodDecorator;\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function Endpoint(\n httpMethod: HttpMethod,\n path: string,\n operation: EndpointOperation,\n kind: Exclude<EndpointKind, typeof EXTERNAL_INBOUND>,\n options?: EndpointOptions,\n): MethodDecorator;\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function Endpoint(\n httpMethod: HttpMethod,\n path: string,\n operation: EndpointOperation,\n kind: EndpointKind,\n options: EndpointOptions = {},\n): MethodDecorator {\n validateEndpointClassification(httpMethod, operation, kind);\n // webpieces-disable no-any-unknown -- reflect-metadata decorator API requires any\n return (target: any, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => {\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n recordEndpointMetadata(\n metadataTarget,\n propertyKey as string,\n httpMethod,\n path,\n operation,\n kind,\n options,\n );\n };\n}\n\n// webpieces-disable no-function-outside-class -- runtime validation backs up nominal TS enums\nfunction validateEndpointClassification(\n httpMethod: HttpMethod,\n operation: EndpointOperation,\n kind: EndpointKind,\n): void {\n if (!isHttpMethod(httpMethod)) {\n throw new Error(\n `@Endpoint httpMethod must be one of ${HTTP_METHODS.join(', ')}, received '${String(httpMethod)}'.`,\n );\n }\n if (!isEndpointOperation(operation)) {\n throw new Error(\n `@Endpoint operation must be READ, WRITE_IDEMPOTENT, or WRITE, received '${String(operation)}'.`,\n );\n }\n if (!isEndpointKind(kind)) {\n throw new Error(\n `@Endpoint trigger must be RPC, CLOUDTASKS, CRON, EXTERNAL_INBOUND, or EXTERNAL_OUTBOUND, received '${String(kind)}'.`,\n );\n }\n}\n\n// webpieces-disable no-function-outside-class -- one metadata write shared by the decorator overloads\nfunction recordEndpointMetadata(\n metadataTarget: Function,\n propertyKey: string,\n httpMethod: HttpMethod,\n path: string,\n operation: EndpointOperation,\n kind: EndpointKind,\n options: EndpointOptions,\n): void {\n const endpoints: Record<string, string> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINTS, metadataTarget) || {};\n\n endpoints[propertyKey] = path;\n\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINTS, endpoints, metadataTarget);\n\n const methods: Record<string, HttpMethod> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_HTTP_METHOD, metadataTarget) || {};\n methods[propertyKey] = httpMethod;\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_HTTP_METHOD, methods, metadataTarget);\n\n const operations: Record<string, EndpointOperation> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_OPERATION, metadataTarget) || {};\n operations[propertyKey] = operation;\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_OPERATION, operations, metadataTarget);\n\n const kinds: Record<string, EndpointKind> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_KIND, metadataTarget) || {};\n kinds[propertyKey] = kind;\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_KIND, kinds, metadataTarget);\n\n const opts: Record<string, EndpointOptions> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_OPTIONS, metadataTarget) || {};\n opts[propertyKey] = options;\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_OPTIONS, opts, metadataTarget);\n\n const declared = options as ExternalEndpointOptions;\n if (\n kind !== EXTERNAL_INBOUND ||\n typeof declared.calledBy !== 'string' ||\n declared.calledBy === ''\n )\n return;\n const callers: Record<string, ExternalCaller> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_CALLER, metadataTarget) || {};\n callers[propertyKey] = new ExternalCaller(\n declared.callerKind ?? DEFAULT_CALLER_KIND,\n declared.calledBy,\n );\n Reflect.defineMetadata(METADATA_KEYS.ENDPOINT_CALLER, callers, metadataTarget);\n}\n\n/** Declares request/response DTO field names that API logging must mask at any depth. */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function MaskLog(fields: Record<string, MaskMode>): MethodDecorator {\n const spec = new MaskSpec(fields);\n // webpieces-disable no-any-unknown -- reflect-metadata decorator API requires any\n return (target: any, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => {\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n const specs: Record<string, MaskSpec> =\n Reflect.getMetadata(METADATA_KEYS.MASK_LOG, metadataTarget) || {};\n specs[propertyKey as string] = spec;\n Reflect.defineMetadata(METADATA_KEYS.MASK_LOG, specs, metadataTarget);\n };\n}\n\n/**\n * The @MaskLog spec for one method, or undefined if the method declared none (the common case — the\n * caller then logs the DTO verbatim on the plain JSON.stringify fast path).\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointOptions\nexport function getMaskSpec(apiClass: Function, methodName: string): MaskSpec | undefined {\n const specs: Record<string, MaskSpec> =\n Reflect.getMetadata(METADATA_KEYS.MASK_LOG, apiClass) || {};\n return specs[methodName];\n}\n\n/**\n * Shared implementation for every auth decorator. Authorization is deliberately\n * method-only: a class-level default is too easy to miss when reviewing one endpoint.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nfunction defineAuthMetadata(authMeta: AuthMeta): MethodDecorator {\n\n // webpieces-disable no-any-unknown -- reflect-metadata decorator API requires any\n return (target: any, propertyKey?: string | symbol, _descriptor?: PropertyDescriptor) => {\n if (propertyKey === undefined) {\n throw new Error(\n 'Authorization decorators are method-only; annotate every @Endpoint explicitly.',\n );\n }\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n if (Reflect.hasMetadata('webpieces:ipc-api-id', metadataTarget)) {\n throw new Error(\n `Internal API ${metadataTarget.name || 'Unknown'} cannot use HTTP authorization decorators.`,\n );\n }\n validateNoConflictingDecorators(metadataTarget, propertyKey as string);\n Reflect.defineMetadata(METADATA_KEYS.AUTH_META, authMeta, metadataTarget, propertyKey);\n const methods = new Set<string>(\n Reflect.getMetadata(METADATA_KEYS.AUTH_METHODS, metadataTarget) || [],\n );\n methods.add(propertyKey as string);\n Reflect.defineMetadata(METADATA_KEYS.AUTH_METHODS, [...methods], metadataTarget);\n };\n}\n\n/**\n * @WpAuthPublic(reason) - endpoint intentionally requires no authentication.\n * The non-empty reason makes anonymous exposure an explicit review decision.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function WpAuthPublic(reason: string): MethodDecorator {\n if (typeof reason !== 'string' || reason.trim() === '') {\n throw new Error(\n '@WpAuthPublic requires a non-empty reason explaining why anonymous access is required.',\n );\n }\n return defineAuthMetadata(new AuthMeta([{ kind: 'public' }], reason));\n}\n\n/** Protected network ingress: authenticate one declared credential, then authorize independently. */\n// webpieces-disable no-function-outside-class -- canonical method decorator factory\nexport function WpAuth(methods: AuthMethods): MethodDecorator {\n return defineAuthMetadata(new AuthMeta(methods, undefined));\n}\n\n/** Locality is independent of authentication and cannot prove a user or machine identity. */\n// webpieces-disable no-function-outside-class -- canonical method decorator factory\nexport function WpLocalOnly(): MethodDecorator {\n return (target: object, methodName: string | symbol) => {\n if (methodName === undefined) throw new Error('@WpLocalOnly is method-only.');\n Reflect.defineMetadata(METADATA_KEYS.LOCAL_ONLY, true, target.constructor, methodName);\n };\n}\n\n// webpieces-disable no-function-outside-class -- canonical metadata reader\nexport function isLocalOnly(apiClass: Function, methodName: string): boolean {\n return Reflect.getMetadata(METADATA_KEYS.LOCAL_ONLY, apiClass, methodName) === true;\n}\n\n// ============================================================\n// Helper functions\n// ============================================================\n\n/**\n * Get the base path from @ApiPath decorator.\n */\nexport function getApiPath(apiClass: Function): string | undefined {\n return Reflect.getMetadata(METADATA_KEYS.API_PATH, apiClass);\n}\n\n/**\n * Get all endpoints from @Endpoint decorators.\n * Returns a record of methodName -> endpoint path.\n */\nexport function getEndpoints(apiClass: Function): Record<string, string> | undefined {\n return Reflect.getMetadata(METADATA_KEYS.ENDPOINTS, apiClass);\n}\n\n/**\n * Every method's declared trigger kind, as `methodName -> kind`. Parallel to {@link getEndpoints}.\n * Empty for a class carrying no @Endpoint at all.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpoints\nexport function getEndpointKinds(apiClass: Function): Record<string, EndpointKind> {\n return Reflect.getMetadata(METADATA_KEYS.ENDPOINT_KIND, apiClass) || {};\n}\n\n/**\n * What triggers ONE method, or undefined when the method carries no @Endpoint.\n *\n * Defaults to nothing rather than to 'rpc': `kind` is a required argument, so a missing entry means\n * \"this is not an endpoint\", never \"an endpoint that forgot to say\". Silently defaulting here would\n * put an undeclared cron or webhook back into the graph as a normal rpc call — the exact blindness\n * the required argument exists to remove.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpoints\nexport function getEndpointKind(apiClass: Function, methodName: string): EndpointKind | undefined {\n return getEndpointKinds(apiClass)[methodName];\n}\n\n/** The required HTTP method for one endpoint. */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointKind\nexport function getEndpointHttpMethod(apiClass: Function, methodName: string): HttpMethod {\n const methods: Record<string, HttpMethod> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_HTTP_METHOD, apiClass) || {};\n const method = methods[methodName];\n if (!isHttpMethod(method)) {\n throw new Error(\n `@Endpoint ${apiClass.name || 'Unknown'}.${methodName} must declare one of ${HTTP_METHODS.join(', ')}.`,\n );\n }\n return method;\n}\n\n/**\n * Get the @Endpoint options for one method (empty object if the method had no options).\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpoints\nexport function getEndpointOptions(apiClass: Function, methodName: string): EndpointOptions {\n const opts: Record<string, EndpointOptions> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_OPTIONS, apiClass) || {};\n const options = opts[methodName];\n if (!options && getEndpoints(apiClass)?.[methodName] === undefined) {\n // Preserve the historical helper behavior for a method that is not an endpoint at all.\n return {} as EndpointOptions;\n }\n return options ?? {};\n}\n\n/** Read one endpoint's required side-effect semantics. */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointOptions\nexport function getEndpointOperation(apiClass: Function, methodName: string): EndpointOperation {\n const operations: Record<string, EndpointOperation> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINT_OPERATION, apiClass) || {};\n const operation = operations[methodName];\n if (!isEndpointOperation(operation)) {\n throw new Error(\n `@Endpoint ${apiClass.name || 'Unknown'}.${methodName} must declare READ, ` +\n 'WRITE_IDEMPOTENT, or WRITE.',\n );\n }\n return operation;\n}\n\n// webpieces-disable no-function-outside-class -- runtime backstop for JavaScript and `as any` callers; webpieces-disable no-any-unknown -- untrusted runtime value is narrowed to an endpoint operation\nfunction isEndpointOperation(value: unknown): value is EndpointOperation {\n return (\n value === READ ||\n value === WRITE_IDEMPOTENT ||\n value === WRITE\n );\n}\n\n// webpieces-disable no-function-outside-class -- runtime backstop for JavaScript and `as any` callers; webpieces-disable no-any-unknown -- untrusted runtime value is narrowed to an endpoint kind\nfunction isEndpointKind(value: unknown): value is EndpointKind {\n return (\n value === RPC ||\n value === CLOUDTASKS ||\n value === CRON ||\n value === EXTERNAL_INBOUND ||\n value === EXTERNAL_OUTBOUND\n );\n}\n\n/**\n * Fail-fast at wiring time on the two EXTERNAL_* rules, called by `RouteMetadataFactory` for every\n * transport (server routes and every client). The {@link Endpoint} overloads already make a missing\n * `calledBy` a COMPILE error; this is the backstop for the ways TS is bypassed — a JS caller, an\n * `as any` options object, a hand-rolled Reflect.defineMetadata. The second rule cannot be a type:\n * \"every method of this class\" spans several decorators.\n *\n * @throws Error naming the first EXTERNAL_INBOUND endpoint with no `calledBy`, or the first method of\n * a contract that mixes EXTERNAL_OUTBOUND with any other kind.\n */\n// webpieces-disable no-function-outside-class -- wiring-time assert, sibling of assertEveryEndpointHasAuthMode\nexport function assertExternalEndpointKinds(apiClass: Function): void {\n const kinds = getEndpointKinds(apiClass);\n const apiName = apiClass.name || 'Unknown';\n const methods = Object.keys(kinds);\n const outbound = methods.filter((methodName: string) => kinds[methodName] === EXTERNAL_OUTBOUND);\n if (outbound.length > 0 && outbound.length !== methods.length) {\n const other = methods.find((methodName: string) => kinds[methodName] !== EXTERNAL_OUTBOUND)!;\n throw new Error(\n `${apiName} mixes EXTERNAL_OUTBOUND (${outbound[0]}) with ${String(kinds[other]).toUpperCase()} (${other}). ` +\n `An EXTERNAL_OUTBOUND contract is an outside system's API that no server in this repo implements, so ` +\n `EVERY method of it must be EXTERNAL_OUTBOUND; move the other methods to their own contract.`,\n );\n }\n for (const methodName of methods) {\n if (kinds[methodName] !== EXTERNAL_INBOUND || getEndpointCaller(apiClass, methodName) !== undefined)\n continue;\n throw new Error(\n `External endpoint '${methodName}' in ${apiName} declares no caller. Say WHO ` +\n `posts to it: @Endpoint(POST, path, WRITE, EXTERNAL_INBOUND, { calledBy: '<vendor>' }) — the runtime architecture ` +\n `graph cannot name an inbound caller it was never told about.`,\n );\n }\n}\n\n/** True when the contract is an outside system's API: every method is EXTERNAL_OUTBOUND. */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointKinds\nexport function isExternalOutboundApi(apiClass: Function): boolean {\n const kinds = Object.values(getEndpointKinds(apiClass));\n return kinds.length > 0 && kinds.every((kind: EndpointKind) => kind === EXTERNAL_OUTBOUND);\n}\n\n/**\n * True when the method's @Endpoint declared `{ formPost: true }` — its body is\n * application/x-www-form-urlencoded (flat), not JSON.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpoints\nexport function isFormPost(apiClass: Function, methodName: string): boolean {\n return getEndpointOptions(apiClass, methodName).formPost === true;\n}\n\n/**\n * True when the method's @Endpoint declared `{ rawBody: true }` — the transport must retain the\n * verbatim bytes + absolute url for a `VendorAuthHook.verify` to check.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of isFormPost\nexport function isRawBody(apiClass: Function, methodName: string): boolean {\n return getEndpointOptions(apiClass, methodName).rawBody === true;\n}\n\n/**\n * Fail-fast at wiring time when a SERVED `vendorAuth(...)` endpoint did not ask the transport to keep the\n * bytes it is supposed to verify. A hook with nothing to verify is a MISCONFIGURATION, and it must\n * surface at startup, naming the fix — not as a 401 in production on exactly the traffic the endpoint\n * exists for.\n *\n * This pairing is a runtime assert rather than a type because the two halves live on DIFFERENT\n * decorators (`vendorAuth(...)` and `@Endpoint`), and no union over one decorator's argument can say\n * anything about the other's.\n *\n * @throws Error naming the first `vendorAuth(...)` endpoint missing `{ rawBody: true }`.\n */\n// webpieces-disable no-function-outside-class -- wiring-time assert, sibling of assertEveryEndpointHasAuthMode\nexport function assertEveryVendorAuthEndpointRetainsRawBody(apiClass: Function): void {\n const endpoints = getEndpoints(apiClass) || {};\n for (const methodName of Object.keys(endpoints)) {\n if (\n !getAuthMeta(apiClass, methodName)?.methods.some((method: AuthMode) => method.kind === 'vendorAuth') ||\n isRawBody(apiClass, methodName)\n )\n continue;\n throw new Error(\n `Endpoint '${methodName}' in ${apiClass.name || 'Unknown'} is vendorAuth(...) but its @Endpoint ` +\n `does not declare { rawBody: true }. VendorAuthHook.verify checks a credential over the bytes and ` +\n `the url the SENDER transmitted, and without that option the transport parses the body and ` +\n `throws them away — leaving the hook nothing to check.`,\n );\n }\n}\n\n/**\n * Check if a class has @ApiPath decorator.\n */\nexport function isApiPath(apiClass: Function): boolean {\n return Reflect.hasMetadata(METADATA_KEYS.API_PATH, apiClass);\n}\n\n/**\n * Get method-level auth metadata. Class-level authorization is forbidden.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader paired with the decorator API\nexport function getAuthMeta(apiClass: Function, methodName: string): AuthMeta | undefined {\n return Reflect.getMetadata(METADATA_KEYS.AUTH_META, apiClass, methodName);\n}\n\n/**\n * The ONE prescription for \"this endpoint declares no auth\", shared by the two places that raise it\n * (here and http-routing's ApiRoutingFactory) because they had drifted into teaching different menus.\n * A message teaching an incomplete API is the same defect as an API with two spellings: whichever menu\n * the caller hits becomes the API they believe exists. It leads with the ROLE-GATED member on purpose —\n * the first thing offered should not be the widest grant.\n */\nexport const MISSING_AUTH_DECORATOR_FIX =\n \"Declare @WpAuth([jwt(), oidcSameProject() or oidcSvcs(['svc-a']), sharedSecret(key), vendorAuth(name), apiKey('regime', [{in: 'header', key: MyKeys.API_KEY}])]) \" +\n \"or @WpAuthPublic('reason'), and exactly one @WpAuthorization on every endpoint. Add @WpLocalOnly() separately when locality is required.\";\n\n/**\n * Fail-fast at wiring time if any endpoint lacks an auth mode. Both the server\n * (ApiRoutingFactory) and the task/rpc clients call this so a missing auth\n * decorator is a startup error, never a silent open endpoint.\n * @throws Error naming the first endpoint with no auth decorator, via {@link MISSING_AUTH_DECORATOR_FIX}.\n */\nexport function assertEveryEndpointHasAuthMode(apiClass: Function): void {\n const apiName = apiClass.name || 'Unknown';\n const endpoints = getEndpoints(apiClass) || {};\n for (const methodName of Object.keys(endpoints)) {\n if (!getAuthMeta(apiClass, methodName)) {\n throw new Error(\n `Endpoint '${methodName}' in ${apiName} has no auth decorator. ` +\n MISSING_AUTH_DECORATOR_FIX,\n );\n }\n const policy = getAuthorization(apiClass, methodName);\n if (!policy) throw new Error(`Endpoint '${methodName}' in ${apiName} requires @WpAuthorization.`);\n AuthorizationDeclaration.validate(policy);\n const auth = getAuthMeta(apiClass, methodName)!;\n const isPublic = auth.methods.some((method: AuthMode) => method.kind === 'public');\n if (isPublic !== (policy.authType === AuthorizationType.ANONYMOUS)) {\n throw new Error(`Endpoint '${methodName}' must pair public authentication with ANONYMOUS authorization, or protected authentication with protected/CUSTOM authorization.`);\n }\n }\n const policyMethods: string[] = Reflect.getMetadata(AUTHORIZATION_METHODS_KEY, apiClass) ?? [];\n for (const methodName of policyMethods) {\n if (!(methodName in endpoints)) throw new Error(`Orphan @WpAuthorization on ${apiName}.${methodName}; declare @Endpoint.`);\n }\n}\n\n/**\n * Validate that a class/method doesn't have conflicting auth decorators.\n * @throws Error if multiple auth decorators are found on the same target.\n */\n// webpieces-disable no-function-outside-class -- shared decorator metadata validation\nexport function validateNoConflictingDecorators(\n apiClass: Function,\n methodName: string | undefined,\n): void {\n const existing = methodName\n ? Reflect.getMetadata(METADATA_KEYS.AUTH_META, apiClass, methodName)\n : Reflect.getMetadata(METADATA_KEYS.AUTH_META, apiClass);\n\n if (existing) {\n const targetName = apiClass.name || 'Unknown';\n const location = methodName\n ? `method '${methodName}' of ${targetName}`\n : `class ${targetName}`;\n throw new Error(\n `Conflicting auth decorator on ${location}. ` +\n `Exactly one @WpAuth([...]) or @WpAuthPublic('reason') is allowed per endpoint.`,\n );\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* WHO calls us from outside — the vocabulary an `
|
|
2
|
+
* WHO calls us from outside — the vocabulary an `EXTERNAL_INBOUND` @Endpoint uses to name its caller.
|
|
3
3
|
*
|
|
4
4
|
* Deliberately the SAME `(kind, label)` vocabulary the runtime architecture graph already uses for
|
|
5
5
|
* OUTBOUND vendor seams (`@externalSystem saas twilio`). An inbound `saas twilio` and an outbound
|
|
@@ -10,24 +10,19 @@
|
|
|
10
10
|
* anything in that file, and decorators.ts is near its file-size limit. The dependency is strictly
|
|
11
11
|
* one-way (decorators.ts imports this; this imports only reflect-metadata), so no cycle is possible.
|
|
12
12
|
*
|
|
13
|
-
* ##
|
|
13
|
+
* ## `calledBy` is REQUIRED on every `EXTERNAL_INBOUND` endpoint
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* per endpoint migrates it:
|
|
15
|
+
* `@Endpoint(POST, path, WRITE, EXTERNAL_INBOUND, options)` does not compile without it. A lint rule
|
|
16
|
+
* can be ignored, a compile error cannot, and the alternative was a graph that names our own contract
|
|
17
|
+
* where the vendor belongs:
|
|
19
18
|
*
|
|
20
19
|
* ```ts
|
|
21
|
-
*
|
|
22
|
-
* @Endpoint(POST, '/inbound', WRITE, EXTERNAL, { formPost: true })
|
|
23
|
-
* // after
|
|
24
|
-
* @Endpoint(POST, '/inbound', WRITE, EXTERNAL, { formPost: true, calledBy: 'twilio' })
|
|
20
|
+
* @Endpoint(POST, '/inbound', WRITE, EXTERNAL_INBOUND, { formPost: true, calledBy: 'twilio' })
|
|
25
21
|
* // infrastructure rather than a vendor product:
|
|
26
|
-
* @Endpoint(POST, '/push', WRITE,
|
|
22
|
+
* @Endpoint(POST, '/push', WRITE, EXTERNAL_INBOUND, { calledBy: 'pubsub-push', callerKind: 'system' })
|
|
27
23
|
* ```
|
|
28
24
|
*
|
|
29
|
-
*
|
|
30
|
-
* stay optional there, and the ENDPOINTS path map every consumer iterates is untouched.
|
|
25
|
+
* `rpc` / `cloudtasks` / `cron` / `external-outbound` endpoints keep options optional.
|
|
31
26
|
*/
|
|
32
27
|
import 'reflect-metadata';
|
|
33
28
|
/**
|
|
@@ -42,7 +37,7 @@ export type ExternalSystemKind = (typeof EXTERNAL_SYSTEM_KINDS)[number];
|
|
|
42
37
|
/** True for a string that names one of {@link EXTERNAL_SYSTEM_KINDS}. */
|
|
43
38
|
export declare function isExternalSystemKind(value: string): value is ExternalSystemKind;
|
|
44
39
|
/**
|
|
45
|
-
* The declared caller of ONE `
|
|
40
|
+
* The declared caller of ONE `EXTERNAL_INBOUND` endpoint, normalized: `callerKind` defaulted, `calledBy`
|
|
46
41
|
* carried as the label.
|
|
47
42
|
*
|
|
48
43
|
* `label` is the node IDENTITY on the runtime graph, not merely display text — two endpoints
|
|
@@ -53,7 +48,7 @@ export declare class ExternalCaller {
|
|
|
53
48
|
readonly label: string;
|
|
54
49
|
constructor(kind: ExternalSystemKind, label: string);
|
|
55
50
|
}
|
|
56
|
-
/** The kind an `
|
|
51
|
+
/** The kind an `EXTERNAL_INBOUND` @Endpoint gets when it declares `calledBy` but no `callerKind`. */
|
|
57
52
|
export declare const DEFAULT_CALLER_KIND: ExternalSystemKind;
|
|
58
53
|
/**
|
|
59
54
|
* Metadata key of the per-method caller map, `methodName -> ExternalCaller`. Parallel to ENDPOINTS,
|
|
@@ -62,7 +57,7 @@ export declare const DEFAULT_CALLER_KIND: ExternalSystemKind;
|
|
|
62
57
|
*/
|
|
63
58
|
export declare const ENDPOINT_CALLER_KEY = "webpieces:endpoint-caller";
|
|
64
59
|
/**
|
|
65
|
-
* The DECLARED caller of one method, or undefined when it is not `
|
|
66
|
-
* bypassed TS — see `
|
|
60
|
+
* The DECLARED caller of one method, or undefined when it is not `EXTERNAL_INBOUND` (or is, but
|
|
61
|
+
* bypassed TS — see `assertExternalEndpointKinds`). Mirrors `getEndpointOptions`.
|
|
67
62
|
*/
|
|
68
63
|
export declare function getEndpointCaller(apiClass: Function, methodName: string): ExternalCaller | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* WHO calls us from outside — the vocabulary an `
|
|
3
|
+
* WHO calls us from outside — the vocabulary an `EXTERNAL_INBOUND` @Endpoint uses to name its caller.
|
|
4
4
|
*
|
|
5
5
|
* Deliberately the SAME `(kind, label)` vocabulary the runtime architecture graph already uses for
|
|
6
6
|
* OUTBOUND vendor seams (`@externalSystem saas twilio`). An inbound `saas twilio` and an outbound
|
|
@@ -11,24 +11,19 @@
|
|
|
11
11
|
* anything in that file, and decorators.ts is near its file-size limit. The dependency is strictly
|
|
12
12
|
* one-way (decorators.ts imports this; this imports only reflect-metadata), so no cycle is possible.
|
|
13
13
|
*
|
|
14
|
-
* ##
|
|
14
|
+
* ## `calledBy` is REQUIRED on every `EXTERNAL_INBOUND` endpoint
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* per endpoint migrates it:
|
|
16
|
+
* `@Endpoint(POST, path, WRITE, EXTERNAL_INBOUND, options)` does not compile without it. A lint rule
|
|
17
|
+
* can be ignored, a compile error cannot, and the alternative was a graph that names our own contract
|
|
18
|
+
* where the vendor belongs:
|
|
20
19
|
*
|
|
21
20
|
* ```ts
|
|
22
|
-
*
|
|
23
|
-
* @Endpoint(POST, '/inbound', WRITE, EXTERNAL, { formPost: true })
|
|
24
|
-
* // after
|
|
25
|
-
* @Endpoint(POST, '/inbound', WRITE, EXTERNAL, { formPost: true, calledBy: 'twilio' })
|
|
21
|
+
* @Endpoint(POST, '/inbound', WRITE, EXTERNAL_INBOUND, { formPost: true, calledBy: 'twilio' })
|
|
26
22
|
* // infrastructure rather than a vendor product:
|
|
27
|
-
* @Endpoint(POST, '/push', WRITE,
|
|
23
|
+
* @Endpoint(POST, '/push', WRITE, EXTERNAL_INBOUND, { calledBy: 'pubsub-push', callerKind: 'system' })
|
|
28
24
|
* ```
|
|
29
25
|
*
|
|
30
|
-
*
|
|
31
|
-
* stay optional there, and the ENDPOINTS path map every consumer iterates is untouched.
|
|
26
|
+
* `rpc` / `cloudtasks` / `cron` / `external-outbound` endpoints keep options optional.
|
|
32
27
|
*/
|
|
33
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
29
|
exports.ENDPOINT_CALLER_KEY = exports.DEFAULT_CALLER_KIND = exports.ExternalCaller = exports.EXTERNAL_SYSTEM_KINDS = void 0;
|
|
@@ -56,7 +51,7 @@ function isExternalSystemKind(value) {
|
|
|
56
51
|
return exports.EXTERNAL_SYSTEM_KINDS.includes(value);
|
|
57
52
|
}
|
|
58
53
|
/**
|
|
59
|
-
* The declared caller of ONE `
|
|
54
|
+
* The declared caller of ONE `EXTERNAL_INBOUND` endpoint, normalized: `callerKind` defaulted, `calledBy`
|
|
60
55
|
* carried as the label.
|
|
61
56
|
*
|
|
62
57
|
* `label` is the node IDENTITY on the runtime graph, not merely display text — two endpoints
|
|
@@ -71,7 +66,7 @@ class ExternalCaller {
|
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
exports.ExternalCaller = ExternalCaller;
|
|
74
|
-
/** The kind an `
|
|
69
|
+
/** The kind an `EXTERNAL_INBOUND` @Endpoint gets when it declares `calledBy` but no `callerKind`. */
|
|
75
70
|
exports.DEFAULT_CALLER_KIND = 'saas';
|
|
76
71
|
/**
|
|
77
72
|
* Metadata key of the per-method caller map, `methodName -> ExternalCaller`. Parallel to ENDPOINTS,
|
|
@@ -80,8 +75,8 @@ exports.DEFAULT_CALLER_KIND = 'saas';
|
|
|
80
75
|
*/
|
|
81
76
|
exports.ENDPOINT_CALLER_KEY = 'webpieces:endpoint-caller';
|
|
82
77
|
/**
|
|
83
|
-
* The DECLARED caller of one method, or undefined when it is not `
|
|
84
|
-
* bypassed TS — see `
|
|
78
|
+
* The DECLARED caller of one method, or undefined when it is not `EXTERNAL_INBOUND` (or is, but
|
|
79
|
+
* bypassed TS — see `assertExternalEndpointKinds`). Mirrors `getEndpointOptions`.
|
|
85
80
|
*/
|
|
86
81
|
// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointOptions
|
|
87
82
|
function getEndpointCaller(apiClass, methodName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-caller.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/external-caller.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"external-caller.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/external-caller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAwBH,oDAEC;AA+BD,8CAOC;AA9DD,4BAA0B;AAE1B;;;;;;GAMG;AACU,QAAA,qBAAqB,GAAG;IACjC,UAAU;IACV,OAAO;IACP,OAAO;IACP,SAAS;IACT,MAAM;IACN,QAAQ;CACF,CAAC;AAIX,yEAAyE;AACzE,sFAAsF;AACtF,SAAgB,oBAAoB,CAAC,KAAa;IAC9C,OAAQ,6BAA2C,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;GAMG;AACH,MAAa,cAAc;IAEH;IACA;IAFpB,YACoB,IAAwB,EACxB,KAAa;QADb,SAAI,GAAJ,IAAI,CAAoB;QACxB,UAAK,GAAL,KAAK,CAAQ;IAC9B,CAAC;CACP;AALD,wCAKC;AAED,qGAAqG;AACxF,QAAA,mBAAmB,GAAuB,MAAM,CAAC;AAE9D;;;;GAIG;AACU,QAAA,mBAAmB,GAAG,2BAA2B,CAAC;AAE/D;;;GAGG;AACH,wGAAwG;AACxG,SAAgB,iBAAiB,CAC7B,QAAkB,EAClB,UAAkB;IAElB,MAAM,OAAO,GACT,OAAO,CAAC,WAAW,CAAC,2BAAmB,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC7D,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/**\n * WHO calls us from outside — the vocabulary an `EXTERNAL_INBOUND` @Endpoint uses to name its caller.\n *\n * Deliberately the SAME `(kind, label)` vocabulary the runtime architecture graph already uses for\n * OUTBOUND vendor seams (`@externalSystem saas twilio`). An inbound `saas twilio` and an outbound\n * `saas twilio` are the same vendor, so sharing the vocabulary makes them share an IDENTITY and\n * converge on ONE node instead of drawing twilio twice, facing opposite directions.\n *\n * Its own module rather than a block in decorators.ts: this is a data model with no dependency on\n * anything in that file, and decorators.ts is near its file-size limit. The dependency is strictly\n * one-way (decorators.ts imports this; this imports only reflect-metadata), so no cycle is possible.\n *\n * ## `calledBy` is REQUIRED on every `EXTERNAL_INBOUND` endpoint\n *\n * `@Endpoint(POST, path, WRITE, EXTERNAL_INBOUND, options)` does not compile without it. A lint rule\n * can be ignored, a compile error cannot, and the alternative was a graph that names our own contract\n * where the vendor belongs:\n *\n * ```ts\n * @Endpoint(POST, '/inbound', WRITE, EXTERNAL_INBOUND, { formPost: true, calledBy: 'twilio' })\n * // infrastructure rather than a vendor product:\n * @Endpoint(POST, '/push', WRITE, EXTERNAL_INBOUND, { calledBy: 'pubsub-push', callerKind: 'system' })\n * ```\n *\n * `rpc` / `cloudtasks` / `cron` / `external-outbound` endpoints keep options optional.\n */\n\nimport 'reflect-metadata';\n\n/**\n * What KIND of system an external caller IS. Drives the shape the runtime graph draws it with, so a\n * push-subscription stops looking like a vendor SaaS.\n *\n * Most inbound webhooks are `saas` (Twilio, Gmail, Stripe). A GCP Pub/Sub push subscription is\n * `system` — it is infrastructure, not a vendor product.\n */\nexport const EXTERNAL_SYSTEM_KINDS = [\n 'database',\n 'cache',\n 'queue',\n 'storage',\n 'saas',\n 'system',\n] as const;\n\nexport type ExternalSystemKind = (typeof EXTERNAL_SYSTEM_KINDS)[number];\n\n/** True for a string that names one of {@link EXTERNAL_SYSTEM_KINDS}. */\n// webpieces-disable no-function-outside-class -- type guard beside the type it guards\nexport function isExternalSystemKind(value: string): value is ExternalSystemKind {\n return (EXTERNAL_SYSTEM_KINDS as readonly string[]).includes(value);\n}\n\n/**\n * The declared caller of ONE `EXTERNAL_INBOUND` endpoint, normalized: `callerKind` defaulted, `calledBy`\n * carried as the label.\n *\n * `label` is the node IDENTITY on the runtime graph, not merely display text — two endpoints\n * declaring `twilio` converge on one box with two arrows into it.\n */\nexport class ExternalCaller {\n constructor(\n public readonly kind: ExternalSystemKind,\n public readonly label: string,\n ) {}\n}\n\n/** The kind an `EXTERNAL_INBOUND` @Endpoint gets when it declares `calledBy` but no `callerKind`. */\nexport const DEFAULT_CALLER_KIND: ExternalSystemKind = 'saas';\n\n/**\n * Metadata key of the per-method caller map, `methodName -> ExternalCaller`. Parallel to ENDPOINTS,\n * exactly like ENDPOINT_KIND and ENDPOINT_OPTIONS, and re-exported as `METADATA_KEYS.ENDPOINT_CALLER`\n * — declared HERE so the reader below needs no import from decorators.ts (which would close a cycle).\n */\nexport const ENDPOINT_CALLER_KEY = 'webpieces:endpoint-caller';\n\n/**\n * The DECLARED caller of one method, or undefined when it is not `EXTERNAL_INBOUND` (or is, but\n * bypassed TS — see `assertExternalEndpointKinds`). Mirrors `getEndpointOptions`.\n */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader, sibling of getEndpointOptions\nexport function getEndpointCaller(\n apiClass: Function,\n methodName: string,\n): ExternalCaller | undefined {\n const callers: Record<string, ExternalCaller> =\n Reflect.getMetadata(ENDPOINT_CALLER_KEY, apiClass) || {};\n return callers[methodName];\n}\n"]}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { HttpParameterDeclaration } from './HttpContract';
|
|
2
|
+
import { HttpParameterDeclaration, HttpQueryItemType } from './HttpContract';
|
|
3
3
|
export declare const HTTP_PARAMETERS_METADATA_KEY = "webpieces:http-parameters";
|
|
4
4
|
/** Map one method argument to a `{placeholder}` in `@ApiPath + @Endpoint`. */
|
|
5
5
|
export declare function PathParam(wireName: string): ParameterDecorator;
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Map one method argument to an explicitly named query key. A LIST argument may name its item type,
|
|
8
|
+
* `@QueryParam('ids', Number) ids: number[]`, because design metadata erases `number[]` to `Array`;
|
|
9
|
+
* without it the items arrive as strings.
|
|
10
|
+
*/
|
|
11
|
+
export declare function QueryParam(wireName: string, itemType?: HttpQueryItemType): ParameterDecorator;
|
|
12
|
+
/**
|
|
13
|
+
* Map one `QueryParams` argument to the WHOLE query string — a free-form multimap:
|
|
14
|
+
* `@QueryString() query: QueryParams`. Allowed ONLY on an `EXTERNAL_OUTBOUND` contract (a vendor's
|
|
15
|
+
* query grammar is the vendor's); our own contracts use the typed {@link QueryParam}. At most one per
|
|
16
|
+
* method.
|
|
17
|
+
*
|
|
18
|
+
* Named `QueryString` rather than `QueryParams` because the argument's CLASS is `QueryParams`, and one
|
|
19
|
+
* module surface cannot export a decorator function and a class under the same name.
|
|
20
|
+
*/
|
|
21
|
+
export declare function QueryString(): ParameterDecorator;
|
|
8
22
|
/** Explicit path/query mappings for one endpoint, independent of JavaScript parameter names. */
|
|
9
23
|
export declare function getHttpParameterDeclarations(apiClass: Function, methodName: string): HttpParameterDeclaration[];
|
|
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HTTP_PARAMETERS_METADATA_KEY = void 0;
|
|
4
4
|
exports.PathParam = PathParam;
|
|
5
5
|
exports.QueryParam = QueryParam;
|
|
6
|
+
exports.QueryString = QueryString;
|
|
6
7
|
exports.getHttpParameterDeclarations = getHttpParameterDeclarations;
|
|
7
8
|
require("reflect-metadata");
|
|
8
9
|
const HttpContract_1 = require("./HttpContract");
|
|
9
10
|
exports.HTTP_PARAMETERS_METADATA_KEY = 'webpieces:http-parameters';
|
|
10
11
|
/** Shared implementation for explicit method-parameter wire mappings. */
|
|
11
12
|
// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope
|
|
12
|
-
function defineHttpParameter(source, wireName) {
|
|
13
|
-
if (typeof wireName !== 'string' || wireName.trim() === '') {
|
|
13
|
+
function defineHttpParameter(source, wireName, itemType) {
|
|
14
|
+
if (source !== 'query-map' && (typeof wireName !== 'string' || wireName.trim() === '')) {
|
|
14
15
|
throw new Error(`@${source === 'path' ? 'PathParam' : 'QueryParam'} requires a non-empty wire name.`);
|
|
15
16
|
}
|
|
16
17
|
return (
|
|
@@ -25,7 +26,10 @@ function defineHttpParameter(source, wireName) {
|
|
|
25
26
|
if (declarations.some((declaration) => declaration.index === parameterIndex)) {
|
|
26
27
|
throw new Error(`Argument ${parameterIndex} of ${metadataTarget.name}.${String(propertyKey)} already has an HTTP parameter decorator.`);
|
|
27
28
|
}
|
|
28
|
-
declarations.
|
|
29
|
+
if (source === 'query-map' && declarations.some((declaration) => declaration.source === 'query-map')) {
|
|
30
|
+
throw new Error(`${metadataTarget.name}.${String(propertyKey)} declares @QueryString() more than once; one QueryParams holds the whole query string.`);
|
|
31
|
+
}
|
|
32
|
+
declarations.push(new HttpContract_1.HttpParameterDeclaration(parameterIndex, source, wireName, itemType));
|
|
29
33
|
all[propertyKey] = declarations;
|
|
30
34
|
Reflect.defineMetadata(exports.HTTP_PARAMETERS_METADATA_KEY, all, metadataTarget);
|
|
31
35
|
};
|
|
@@ -35,10 +39,27 @@ function defineHttpParameter(source, wireName) {
|
|
|
35
39
|
function PathParam(wireName) {
|
|
36
40
|
return defineHttpParameter('path', wireName);
|
|
37
41
|
}
|
|
38
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Map one method argument to an explicitly named query key. A LIST argument may name its item type,
|
|
44
|
+
* `@QueryParam('ids', Number) ids: number[]`, because design metadata erases `number[]` to `Array`;
|
|
45
|
+
* without it the items arrive as strings.
|
|
46
|
+
*/
|
|
47
|
+
// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope
|
|
48
|
+
function QueryParam(wireName, itemType) {
|
|
49
|
+
return defineHttpParameter('query', wireName, itemType);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Map one `QueryParams` argument to the WHOLE query string — a free-form multimap:
|
|
53
|
+
* `@QueryString() query: QueryParams`. Allowed ONLY on an `EXTERNAL_OUTBOUND` contract (a vendor's
|
|
54
|
+
* query grammar is the vendor's); our own contracts use the typed {@link QueryParam}. At most one per
|
|
55
|
+
* method.
|
|
56
|
+
*
|
|
57
|
+
* Named `QueryString` rather than `QueryParams` because the argument's CLASS is `QueryParams`, and one
|
|
58
|
+
* module surface cannot export a decorator function and a class under the same name.
|
|
59
|
+
*/
|
|
39
60
|
// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope
|
|
40
|
-
function
|
|
41
|
-
return defineHttpParameter('query',
|
|
61
|
+
function QueryString() {
|
|
62
|
+
return defineHttpParameter('query-map', '');
|
|
42
63
|
}
|
|
43
64
|
/** Explicit path/query mappings for one endpoint, independent of JavaScript parameter names. */
|
|
44
65
|
// webpieces-disable no-function-outside-class -- reflect-metadata reader
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-parameter-decorators.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/http-parameter-decorators.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"http-parameter-decorators.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/http-parameter-decorators.ts"],"names":[],"mappings":";;;AAoDA,8BAEC;AAQD,gCAEC;AAYD,kCAEC;AAID,oEAOC;AAzFD,4BAA0B;AAC1B,iDAAkG;AAErF,QAAA,4BAA4B,GAAG,2BAA2B,CAAC;AAExE,yEAAyE;AACzE,2GAA2G;AAC3G,SAAS,mBAAmB,CACxB,MAA2B,EAC3B,QAAgB,EAChB,QAA4B;IAE5B,IAAI,MAAM,KAAK,WAAW,IAAI,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACrF,MAAM,IAAI,KAAK,CACX,IAAI,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,kCAAkC,CACvF,CAAC;IACN,CAAC;IACD,OAAO;IACH,4FAA4F;IAC5F,MAAW,EACX,WAAwC,EACxC,cAAsB,EAClB,EAAE;QACN,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,cAAc,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;QAClF,MAAM,GAAG,GACL,OAAO,CAAC,WAAW,CAAC,oCAA4B,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC;QAC5E,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,WAAqB,CAAC,IAAI,EAAE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,4BAA4B,CACxC,QAAkB,EAClB,UAAkB;IAElB,MAAM,GAAG,GACL,OAAO,CAAC,WAAW,CAAC,oCAA4B,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { HttpParameterDeclaration, HttpParameterSource, HttpQueryItemType } from './HttpContract';\n\nexport const HTTP_PARAMETERS_METADATA_KEY = 'webpieces:http-parameters';\n\n/** Shared implementation for explicit method-parameter wire mappings. */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nfunction defineHttpParameter(\n source: HttpParameterSource,\n wireName: string,\n itemType?: HttpQueryItemType,\n): ParameterDecorator {\n if (source !== 'query-map' && (typeof wireName !== 'string' || wireName.trim() === '')) {\n throw new Error(\n `@${source === 'path' ? 'PathParam' : 'QueryParam'} requires a non-empty wire name.`,\n );\n }\n return (\n // webpieces-disable no-any-unknown -- reflect-metadata parameter decorator API requires any\n target: any,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ): void => {\n if (propertyKey === undefined) {\n throw new Error('HTTP parameter decorators are method-only.');\n }\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n const all: Record<string, HttpParameterDeclaration[]> =\n Reflect.getMetadata(HTTP_PARAMETERS_METADATA_KEY, metadataTarget) || {};\n const declarations = [...(all[propertyKey as string] ?? [])];\n if (\n declarations.some(\n (declaration: HttpParameterDeclaration) => declaration.index === parameterIndex,\n )\n ) {\n throw new Error(\n `Argument ${parameterIndex} of ${metadataTarget.name}.${String(propertyKey)} already has an HTTP parameter decorator.`,\n );\n }\n if (source === 'query-map' && declarations.some((declaration: HttpParameterDeclaration) => declaration.source === 'query-map')) {\n throw new Error(\n `${metadataTarget.name}.${String(propertyKey)} declares @QueryString() more than once; one QueryParams holds the whole query string.`,\n );\n }\n declarations.push(new HttpParameterDeclaration(parameterIndex, source, wireName, itemType));\n all[propertyKey as string] = declarations;\n Reflect.defineMetadata(HTTP_PARAMETERS_METADATA_KEY, all, metadataTarget);\n };\n}\n\n/** Map one method argument to a `{placeholder}` in `@ApiPath + @Endpoint`. */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function PathParam(wireName: string): ParameterDecorator {\n return defineHttpParameter('path', wireName);\n}\n\n/**\n * Map one method argument to an explicitly named query key. A LIST argument may name its item type,\n * `@QueryParam('ids', Number) ids: number[]`, because design metadata erases `number[]` to `Array`;\n * without it the items arrive as strings.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function QueryParam(wireName: string, itemType?: HttpQueryItemType): ParameterDecorator {\n return defineHttpParameter('query', wireName, itemType);\n}\n\n/**\n * Map one `QueryParams` argument to the WHOLE query string — a free-form multimap:\n * `@QueryString() query: QueryParams`. Allowed ONLY on an `EXTERNAL_OUTBOUND` contract (a vendor's\n * query grammar is the vendor's); our own contracts use the typed {@link QueryParam}. At most one per\n * method.\n *\n * Named `QueryString` rather than `QueryParams` because the argument's CLASS is `QueryParams`, and one\n * module surface cannot export a decorator function and a class under the same name.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function QueryString(): ParameterDecorator {\n return defineHttpParameter('query-map', '');\n}\n\n/** Explicit path/query mappings for one endpoint, independent of JavaScript parameter names. */\n// webpieces-disable no-function-outside-class -- reflect-metadata reader\nexport function getHttpParameterDeclarations(\n apiClass: Function,\n methodName: string,\n): HttpParameterDeclaration[] {\n const all: Record<string, HttpParameterDeclaration[]> =\n Reflect.getMetadata(HTTP_PARAMETERS_METADATA_KEY, apiClass) || {};\n return [...(all[methodName] ?? [])];\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export { ConsoleLogger } from './logging/ConsoleLogger';
|
|
|
17
17
|
export { ConsoleLoggerFactory } from './logging/ConsoleLoggerFactory';
|
|
18
18
|
export { LogManager } from './logging/LogManager';
|
|
19
19
|
export { LogChunker, LogChunkerImpl, LogChunkInfo, MAX_GCP_LOG_BYTES, GCP_LOG_BUDGET_BYTES, } from './logging/LogChunker';
|
|
20
|
-
export { ApiPath, Endpoint, WpAuthPublic, WpAuth, MISSING_AUTH_DECORATOR_FIX, WpLocalOnly, isLocalOnly, MaskLog, getApiPath, getEndpoints, getEndpointHttpMethod, getEndpointOptions, getEndpointOperation, getEndpointKind, getEndpointKinds, getMaskSpec, isFormPost, isRawBody, isApiPath, getAuthMeta, assertEveryEndpointHasAuthMode,
|
|
21
|
-
export { PathParam, QueryParam, getHttpParameterDeclarations, } from './http/http-parameter-decorators';
|
|
20
|
+
export { ApiPath, Endpoint, WpAuthPublic, WpAuth, MISSING_AUTH_DECORATOR_FIX, WpLocalOnly, isLocalOnly, MaskLog, getApiPath, getEndpoints, getEndpointHttpMethod, getEndpointOptions, getEndpointOperation, getEndpointKind, getEndpointKinds, getMaskSpec, isFormPost, isRawBody, isApiPath, getAuthMeta, assertEveryEndpointHasAuthMode, assertExternalEndpointKinds, isExternalOutboundApi, assertEveryVendorAuthEndpointRetainsRawBody, validateNoConflictingDecorators, METADATA_KEYS, } from './http/decorators';
|
|
21
|
+
export { PathParam, QueryParam, QueryString, getHttpParameterDeclarations, } from './http/http-parameter-decorators';
|
|
22
|
+
export { QueryParams } from './http/QueryParams';
|
|
23
|
+
export type { QueryParamValue } from './http/QueryParams';
|
|
22
24
|
export { WpInt, WpMin, WpMax, NUMERIC_METADATA_KEYS } from './http/numeric-field-decorators';
|
|
23
25
|
export type { Integer } from './http/numeric-field-decorators';
|
|
24
26
|
export { ApiType, SVC_TO_SVC, EXTERNAL_CUSTOMER, MCP, API_TYPE_METADATA_KEY, DEFAULT_API_TYPES, getApiTypes, getApiTypeEndpointNames, assertApiTypeMatchesMcpTools, } from './http/api-type';
|
|
@@ -34,10 +36,12 @@ export { StreamErrorControl, StreamProtocolError, StreamDisconnectedError, } fro
|
|
|
34
36
|
export { BoundHttpRequest, HttpContractMapper, HttpParameterBinding, HttpParameterDeclaration, } from './http/HttpContract';
|
|
35
37
|
export { StreamCorrelation, StreamEnvelope, StreamingEndpointMetadata, StreamEventValidator, StreamTransportError, StreamWriter, StreamDirection, WpStream, getStreamingEndpoint, registerStreamingSchemas, } from './http/StreamingContract';
|
|
36
38
|
export type { RequestStream, ResponseStream, StreamEnvelopeKind } from './http/StreamingContract';
|
|
37
|
-
export type { EndpointResponseType, HttpMethod, HttpParameterSource, HttpParameterValueType, } from './http/HttpContract';
|
|
38
|
-
export { GET, POST } from './http/HttpContract';
|
|
39
|
+
export type { EndpointResponseType, HttpMethod, HttpParameterSource, HttpParameterValueType, HttpQueryItemType, } from './http/HttpContract';
|
|
40
|
+
export { GET, POST, PUT, PATCH, DELETE, HTTP_METHODS, verbCarriesBody, isHttpMethod, } from './http/HttpContract';
|
|
39
41
|
export type { EndpointKind, EndpointOperation, EndpointOptions, ExternalEndpointOptions, } from './http/decorators';
|
|
40
|
-
export { RPC, CLOUDTASKS, CRON,
|
|
42
|
+
export { RPC, CLOUDTASKS, CRON, EXTERNAL_INBOUND, EXTERNAL_OUTBOUND, READ, WRITE_IDEMPOTENT, WRITE, NONE, } from './http/decorators';
|
|
43
|
+
export { ExternalContextKeys, getExternalContextKeys, declaresExternalContextKeys, } from './http/ExternalContextKeys';
|
|
44
|
+
export type { ResponseBodyKind } from './http/decorators';
|
|
41
45
|
export { InvalidEndpointForMcp, InvalidEndpointForMcpMetadata, WpMcpTool, WpMcpToolHints, WpMcpToolMetadata, getInvalidEndpointsForMcp, getWpMcpTools, mcpHintsForOperation, } from './mcp/McpMetadata';
|
|
42
46
|
export type { WpMcpMethodDecorator } from './mcp/McpMetadata';
|
|
43
47
|
export { McpToolName } from './mcp/McpToolName';
|
|
@@ -46,7 +50,7 @@ export type { ApiJsonSchemaType, DtoValue } from './mcp/DtoSchema';
|
|
|
46
50
|
export { McpToolCatalogFile, McpToolCatalogError, McpToolDefinition, } from './mcp/McpToolCatalogFile';
|
|
47
51
|
export { GeneratedApiDocsLayout, GenerateLayoutProblem, GenerateOutputLookup, GenerateOutputTarget, } from './mcp/GeneratedApiDocsLayout';
|
|
48
52
|
export type { LayoutDependsOn, LayoutDependsOnObject, LayoutTarget, LayoutTargets, } from './mcp/GeneratedApiDocsLayout';
|
|
49
|
-
export { AuthMeta, AuthDeclaration, jwt, oidcSameProject, oidcSvcs, sharedSecret,
|
|
53
|
+
export { AuthMeta, AuthDeclaration, jwt, oidcSameProject, oidcSvcs, sharedSecret, vendorAuth, apiKey, } from './http/auth-mode';
|
|
50
54
|
export type { AuthMode, ApiKeyCredential, ApiKeyCredentials, AuthMethod, AuthMethods, OidcAuthMethod, OidcAuthMethods, OidcCallers, } from './http/auth-mode';
|
|
51
55
|
export { Rpc, PubSub, Queue, ENDPOINT_KINDS_BY_API_KIND, getApiKind, assertApiKind, assertPubSubConventions, getQueueName, } from './http/api-kind';
|
|
52
56
|
export type { ApiKind } from './http/api-kind';
|
|
@@ -91,7 +95,7 @@ export { LogApiCallImpl } from './http/LogApiCall';
|
|
|
91
95
|
export { LogApiCall, LogApiCallConfig } from './http/LogApiCall';
|
|
92
96
|
export { MaskSpec } from './http/LogFieldMask';
|
|
93
97
|
export type { MaskMode } from './http/LogFieldMask';
|
|
94
|
-
export { ApiCallInfo } from './http/ApiCallInfo';
|
|
98
|
+
export { ApiCallInfo, HttpCallFacts, HttpCallFactsHolder } from './http/ApiCallInfo';
|
|
95
99
|
export type { ApiCallDirection, ApiResult } from './http/ApiCallInfo';
|
|
96
100
|
export { ApiCallLogName, ApiCallLogNameImpl, LOG_API_CALL_LOGGER_NAME, } from './http/ApiCallLogName';
|
|
97
101
|
export { ApiMethodInfo } from './http/ApiMethodInfo';
|