@zudojs/api 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/api/constants.d.ts +18 -0
  5. package/dist/api/constants.d.ts.map +1 -0
  6. package/dist/api/constants.js +18 -0
  7. package/dist/api/constants.js.map +1 -0
  8. package/dist/api/context/context.type.d.ts +22 -0
  9. package/dist/api/context/context.type.d.ts.map +1 -0
  10. package/dist/api/context/context.type.js +25 -0
  11. package/dist/api/context/context.type.js.map +1 -0
  12. package/dist/api/context/contextKey.type.d.ts +28 -0
  13. package/dist/api/context/contextKey.type.d.ts.map +1 -0
  14. package/dist/api/context/contextKey.type.js +31 -0
  15. package/dist/api/context/contextKey.type.js.map +1 -0
  16. package/dist/api/errors/index.d.ts +10 -0
  17. package/dist/api/errors/index.d.ts.map +1 -0
  18. package/dist/api/errors/index.js +9 -0
  19. package/dist/api/errors/index.js.map +1 -0
  20. package/dist/api/executor/executor.core.d.ts +33 -0
  21. package/dist/api/executor/executor.core.d.ts.map +1 -0
  22. package/dist/api/executor/executor.core.js +62 -0
  23. package/dist/api/executor/executor.core.js.map +1 -0
  24. package/dist/api/executor/index.d.ts +3 -0
  25. package/dist/api/executor/index.d.ts.map +1 -0
  26. package/dist/api/executor/index.js +3 -0
  27. package/dist/api/executor/index.js.map +1 -0
  28. package/dist/api/handler/handler.type.d.ts +9 -0
  29. package/dist/api/handler/handler.type.d.ts.map +1 -0
  30. package/dist/api/handler/handler.type.js +2 -0
  31. package/dist/api/handler/handler.type.js.map +1 -0
  32. package/dist/api/interceptors/interceptor.type.d.ts +25 -0
  33. package/dist/api/interceptors/interceptor.type.d.ts.map +1 -0
  34. package/dist/api/interceptors/interceptor.type.js +11 -0
  35. package/dist/api/interceptors/interceptor.type.js.map +1 -0
  36. package/dist/api/operation/operation.type.d.ts +42 -0
  37. package/dist/api/operation/operation.type.d.ts.map +1 -0
  38. package/dist/api/operation/operation.type.js +12 -0
  39. package/dist/api/operation/operation.type.js.map +1 -0
  40. package/dist/api/registry/index.d.ts +2 -0
  41. package/dist/api/registry/index.d.ts.map +1 -0
  42. package/dist/api/registry/index.js +2 -0
  43. package/dist/api/registry/index.js.map +1 -0
  44. package/dist/api/registry/operationRegistry.core.d.ts +49 -0
  45. package/dist/api/registry/operationRegistry.core.d.ts.map +1 -0
  46. package/dist/api/registry/operationRegistry.core.js +80 -0
  47. package/dist/api/registry/operationRegistry.core.js.map +1 -0
  48. package/dist/api/result/apiResult.type.d.ts +36 -0
  49. package/dist/api/result/apiResult.type.d.ts.map +1 -0
  50. package/dist/api/result/apiResult.type.js +25 -0
  51. package/dist/api/result/apiResult.type.js.map +1 -0
  52. package/dist/index.d.ts +43 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +40 -0
  55. package/dist/index.js.map +1 -0
  56. package/package.json +53 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @zudojs/api/context-key
3
+ *
4
+ * Typed context keys for the API context system.
5
+ *
6
+ * Context keys allow type-safe storage and retrieval of values
7
+ * from the API context without creating a god object.
8
+ */
9
+ /**
10
+ * A typed key for storing and retrieving values from the API context.
11
+ */
12
+ export interface APIContextKey<T> {
13
+ readonly name: string;
14
+ readonly type: T;
15
+ }
16
+ /**
17
+ * Creates a typed context key.
18
+ */
19
+ export declare function createContextKey<T>(name: string): APIContextKey<T>;
20
+ /**
21
+ * Well-known context keys for common cross-cutting concerns.
22
+ */
23
+ export declare const RequestIdContextKey: APIContextKey<string>;
24
+ export declare const CorrelationIdContextKey: APIContextKey<string>;
25
+ export declare const TenantIdContextKey: APIContextKey<string>;
26
+ export declare const UserIdContextKey: APIContextKey<string>;
27
+ export declare const StartTimeContextKey: APIContextKey<number>;
28
+ //# sourceMappingURL=contextKey.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextKey.type.d.ts","sourceRoot":"","sources":["../../../src/api/context/contextKey.type.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAKlE;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,uBACuB,CAAC;AAExD,eAAO,MAAM,uBAAuB,uBACuB,CAAC;AAE5D,eAAO,MAAM,kBAAkB,uBACuB,CAAC;AAEvD,eAAO,MAAM,gBAAgB,uBACuB,CAAC;AAErD,eAAO,MAAM,mBAAmB,uBACuB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @zudojs/api/context-key
3
+ *
4
+ * Typed context keys for the API context system.
5
+ *
6
+ * Context keys allow type-safe storage and retrieval of values
7
+ * from the API context without creating a god object.
8
+ */
9
+ /**
10
+ * Creates a typed context key.
11
+ */
12
+ export function createContextKey(name) {
13
+ return Object.freeze({
14
+ name,
15
+ type: undefined,
16
+ });
17
+ }
18
+ /**
19
+ * Well-known context keys for common cross-cutting concerns.
20
+ */
21
+ export const RequestIdContextKey =
22
+ /* #__PURE__ */ createContextKey("requestId");
23
+ export const CorrelationIdContextKey =
24
+ /* #__PURE__ */ createContextKey("correlationId");
25
+ export const TenantIdContextKey =
26
+ /* #__PURE__ */ createContextKey("tenantId");
27
+ export const UserIdContextKey =
28
+ /* #__PURE__ */ createContextKey("userId");
29
+ export const StartTimeContextKey =
30
+ /* #__PURE__ */ createContextKey("startTime");
31
+ //# sourceMappingURL=contextKey.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextKey.type.js","sourceRoot":"","sources":["../../../src/api/context/contextKey.type.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAI,IAAY;IAC9C,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI;QACJ,IAAI,EAAE,SAAyB;KAChC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB;AAC9B,eAAe,CAAC,gBAAgB,CAAS,WAAW,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,uBAAuB;AAClC,eAAe,CAAC,gBAAgB,CAAS,eAAe,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB;AAC7B,eAAe,CAAC,gBAAgB,CAAS,UAAU,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,gBAAgB;AAC3B,eAAe,CAAC,gBAAgB,CAAS,QAAQ,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,mBAAmB;AAC9B,eAAe,CAAC,gBAAgB,CAAS,WAAW,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @zudojs/api/errors
3
+ *
4
+ * API-specific error classes for the Zudojs framework.
5
+ *
6
+ * Re-exported from @zudojs/errors for convenience.
7
+ */
8
+ export { APIError, APIValidationError, APIAuthenticationError, APIAuthorizationError, APINotFoundError, APIConflictError, APIRateLimitError, APITimeoutError, APIUnavailableError, APIInternalError, APIVersionError, APIOperationNotFoundError, APIDuplicateOperationError, APIIdempotencyError, createAPIError, isAPIError, } from "@zudojs/errors";
9
+ export type { APIErrorOptions } from "@zudojs/errors";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,cAAc,EACd,UAAU,GACX,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @zudojs/api/errors
3
+ *
4
+ * API-specific error classes for the Zudojs framework.
5
+ *
6
+ * Re-exported from @zudojs/errors for convenience.
7
+ */
8
+ export { APIError, APIValidationError, APIAuthenticationError, APIAuthorizationError, APINotFoundError, APIConflictError, APIRateLimitError, APITimeoutError, APIUnavailableError, APIInternalError, APIVersionError, APIOperationNotFoundError, APIDuplicateOperationError, APIIdempotencyError, createAPIError, isAPIError, } from "@zudojs/errors";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,cAAc,EACd,UAAU,GACX,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { APIContext } from "../context/context.type.js";
2
+ import type { APIResult } from "../result/apiResult.type.js";
3
+ import type { APIOperation } from "../operation/operation.type.js";
4
+ import type { APIInterceptor } from "../interceptors/interceptor.type.js";
5
+ /**
6
+ * Execution context passed through the interceptor pipeline.
7
+ */
8
+ export interface APIExecutionContext<TInput = unknown, TOutput = unknown> {
9
+ readonly operation: APIOperation<TInput, TOutput>;
10
+ readonly input: TInput;
11
+ readonly context: APIContext;
12
+ readonly result?: APIResult<TOutput>;
13
+ }
14
+ /**
15
+ * Error normalizer for converting unknown errors into Error instances.
16
+ */
17
+ export declare function normalizeAPIError(error: unknown, operationName?: string): Error;
18
+ /**
19
+ * Executes an API operation through its interceptor pipeline.
20
+ */
21
+ export declare class APIExecutor {
22
+ private readonly interceptors;
23
+ constructor(interceptors?: readonly APIInterceptor[]);
24
+ /**
25
+ * Executes an operation with the given input and context.
26
+ */
27
+ execute<TInput = unknown, TOutput = unknown>(operation: APIOperation<TInput, TOutput>, input: TInput, context: APIContext): Promise<APIResult<TOutput>>;
28
+ /**
29
+ * Runs the interceptor pipeline.
30
+ */
31
+ private runPipeline;
32
+ }
33
+ //# sourceMappingURL=executor.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.core.d.ts","sourceRoot":"","sources":["../../../src/api/executor/executor.core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACtE,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,MAAM,GACrB,KAAK,CAOP;AAED;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;IAEzD,YAAY,YAAY,GAAE,SAAS,cAAc,EAAO,EAEvD;IAED;;OAEG;IACG,OAAO,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC/C,SAAS,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAoB7B;IAED;;OAEG;YACW,WAAW;CAyB1B"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Error normalizer for converting unknown errors into Error instances.
3
+ */
4
+ export function normalizeAPIError(error, operationName) {
5
+ if (error instanceof Error) {
6
+ return error;
7
+ }
8
+ return new Error(`Unexpected non-error thrown in operation "${operationName}": ${String(error)}`);
9
+ }
10
+ /**
11
+ * Executes an API operation through its interceptor pipeline.
12
+ */
13
+ export class APIExecutor {
14
+ interceptors;
15
+ constructor(interceptors = []) {
16
+ this.interceptors = Object.freeze([...interceptors]);
17
+ }
18
+ /**
19
+ * Executes an operation with the given input and context.
20
+ */
21
+ async execute(operation, input, context) {
22
+ const executionContext = {
23
+ operation,
24
+ input,
25
+ context,
26
+ };
27
+ const executeNext = async () => {
28
+ try {
29
+ const output = await operation.handler(input, context);
30
+ return { ok: true, data: output };
31
+ }
32
+ catch (error) {
33
+ return {
34
+ ok: false,
35
+ error: normalizeAPIError(error, operation.name),
36
+ };
37
+ }
38
+ };
39
+ return this.runPipeline(executionContext, executeNext);
40
+ }
41
+ /**
42
+ * Runs the interceptor pipeline.
43
+ */
44
+ async runPipeline(context, next) {
45
+ const interceptors = this.interceptors;
46
+ let index = 0;
47
+ const runNext = async () => {
48
+ if (index >= interceptors.length) {
49
+ return next();
50
+ }
51
+ const interceptor = interceptors[index];
52
+ index += 1;
53
+ if (!interceptor) {
54
+ return next();
55
+ }
56
+ return interceptor.intercept(context, runNext);
57
+ };
58
+ const result = await runNext();
59
+ return result;
60
+ }
61
+ }
62
+ //# sourceMappingURL=executor.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.core.js","sourceRoot":"","sources":["../../../src/api/executor/executor.core.ts"],"names":[],"mappings":"AAqBA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAc,EACd,aAAsB;IAEtB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,KAAK,CACd,6CAA6C,aAAa,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,CAChF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,WAAW;IACL,YAAY,CAA4B;IAEzD,YAAY,YAAY,GAA8B,EAAE;QACtD,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,SAAwC,EACxC,KAAa,EACb,OAAmB;QAEnB,MAAM,gBAAgB,GAAyC;YAC7D,SAAS;YACT,KAAK;YACL,OAAO;SACR,CAAC;QAEF,MAAM,WAAW,GAAG,KAAK,IAAiC,EAAE;YAC1D,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBACvD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAwB,CAAC;YAC1D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,EAAE,EAAE,KAAK;oBACT,KAAK,EAAE,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC;iBAC1B,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW,CACvB,OAA6C,EAC7C,IAAuC;QAEvC,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACvC,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,MAAM,OAAO,GAAG,KAAK,IAAiC,EAAE;YACtD,IAAI,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;gBACjC,OAAO,IAAI,EAAE,CAAC;YAChB,CAAC;YAED,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YACxC,KAAK,IAAI,CAAC,CAAC;YAEX,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO,IAAI,EAAE,CAAC;YAChB,CAAC;YAED,OAAO,WAAW,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,OAAO,EAAE,CAAC;QAC/B,OAAO,MAA4B,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { APIExecutor } from "./executor.core.js";
2
+ export { normalizeAPIError } from "./executor.core.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { APIExecutor } from "./executor.core.js";
2
+ export { normalizeAPIError } from "./executor.core.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { APIContext } from "../context/context.type.js";
2
+ /**
3
+ * Handler for an API operation.
4
+ *
5
+ * Receives validated input and the execution context,
6
+ * and returns the operation output.
7
+ */
8
+ export type APIHandler<TInput = unknown, TOutput = unknown> = (input: TInput, context: APIContext) => Promise<TOutput>;
9
+ //# sourceMappingURL=handler.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.type.d.ts","sourceRoot":"","sources":["../../../src/api/handler/handler.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,UAAU,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,CAC5D,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,UAAU,KAChB,OAAO,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=handler.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.type.js","sourceRoot":"","sources":["../../../src/api/handler/handler.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import type { APIContext } from "../context/context.type.js";
2
+ import type { APIResult } from "../result/apiResult.type.js";
3
+ import type { APIOperation } from "../operation/operation.type.js";
4
+ /**
5
+ * Execution context passed through the interceptor pipeline.
6
+ */
7
+ export interface APIExecutionContext<TInput = unknown, TOutput = unknown> {
8
+ readonly operation: APIOperation<TInput, TOutput>;
9
+ readonly input: TInput;
10
+ readonly context: APIContext;
11
+ readonly result?: APIResult<TOutput>;
12
+ }
13
+ /**
14
+ * Interceptor that wraps operation execution.
15
+ *
16
+ * Interceptors form a pipeline around the handler execution.
17
+ */
18
+ export interface APIInterceptor {
19
+ intercept<TInput = unknown, TOutput = unknown>(context: APIExecutionContext<TInput, TOutput>, next: () => Promise<APIResult<TOutput>>): Promise<APIResult<TOutput>>;
20
+ }
21
+ /**
22
+ * Creates a no-op interceptor.
23
+ */
24
+ export declare function createNoopInterceptor(): APIInterceptor;
25
+ //# sourceMappingURL=interceptor.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interceptor.type.d.ts","sourceRoot":"","sources":["../../../src/api/interceptors/interceptor.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACtE,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC3C,OAAO,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,IAAI,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GACtC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,cAAc,CAMtD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Creates a no-op interceptor.
3
+ */
4
+ export function createNoopInterceptor() {
5
+ return {
6
+ async intercept(_context, next) {
7
+ return next();
8
+ },
9
+ };
10
+ }
11
+ //# sourceMappingURL=interceptor.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interceptor.type.js","sourceRoot":"","sources":["../../../src/api/interceptors/interceptor.type.ts"],"names":[],"mappings":"AA+BA;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI;YAC5B,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { APIHandler } from "../handler/handler.type.js";
2
+ /**
3
+ * Metadata for an API operation.
4
+ */
5
+ export interface APIOperationMetadata {
6
+ readonly description?: string;
7
+ readonly tags?: readonly string[];
8
+ readonly deprecated?: boolean;
9
+ readonly version?: string;
10
+ readonly timeout?: number;
11
+ readonly idempotent?: boolean;
12
+ }
13
+ /**
14
+ * Core API operation contract.
15
+ *
16
+ * Operations are transport-independent and define the public
17
+ * surface of application capabilities.
18
+ */
19
+ export interface APIOperation<TInput = unknown, TOutput = unknown> {
20
+ readonly name: string;
21
+ readonly input?: unknown;
22
+ readonly output?: unknown;
23
+ readonly handler: APIHandler<TInput, TOutput>;
24
+ readonly metadata?: APIOperationMetadata;
25
+ readonly timeout?: number;
26
+ }
27
+ /**
28
+ * Options for defining an API operation.
29
+ */
30
+ export interface DefineOperationOptions<TInput = unknown, TOutput = unknown> {
31
+ readonly name: string;
32
+ readonly input?: unknown;
33
+ readonly output?: unknown;
34
+ readonly handler: APIHandler<TInput, TOutput>;
35
+ readonly metadata?: APIOperationMetadata;
36
+ readonly timeout?: number;
37
+ }
38
+ /**
39
+ * Creates a new API operation definition.
40
+ */
41
+ export declare function defineOperation<TInput = unknown, TOutput = unknown>(options: DefineOperationOptions<TInput, TOutput>): APIOperation<TInput, TOutput>;
42
+ //# sourceMappingURL=operation.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.type.d.ts","sourceRoot":"","sources":["../../../src/api/operation/operation.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAI7D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAElC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAE9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAE1B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAEzC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAE1B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAEzC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EACjE,OAAO,EAAE,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/C,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAQ/B"}
@@ -0,0 +1,12 @@
1
+ import { DEFAULT_OPERATION_TIMEOUT } from "../constants.js";
2
+ /**
3
+ * Creates a new API operation definition.
4
+ */
5
+ export function defineOperation(options) {
6
+ const operation = {
7
+ ...options,
8
+ timeout: options.timeout ?? options.metadata?.timeout ?? DEFAULT_OPERATION_TIMEOUT,
9
+ };
10
+ return Object.freeze(operation);
11
+ }
12
+ //# sourceMappingURL=operation.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.type.js","sourceRoot":"","sources":["../../../src/api/operation/operation.type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAwD5D;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAgD;IAEhD,MAAM,SAAS,GAAkC;QAC/C,GAAG,OAAO;QACV,OAAO,EACL,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,OAAO,IAAI,yBAAyB;KAC5E,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { APIOperationRegistry } from "./operationRegistry.core.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { APIOperationRegistry } from "./operationRegistry.core.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { APIOperation } from "../operation/operation.type.js";
2
+ /**
3
+ * Registry for API operations.
4
+ *
5
+ * Enforces uniqueness and provides O(1) lookup by operation name.
6
+ */
7
+ export declare class APIOperationRegistry {
8
+ private readonly operations;
9
+ private frozen;
10
+ /**
11
+ * Registers an operation.
12
+ *
13
+ * @throws {APIDuplicateOperationError} if an operation with the same name is already registered.
14
+ */
15
+ register(operation: APIOperation): void;
16
+ /**
17
+ * Retrieves an operation by name.
18
+ */
19
+ get(name: string): APIOperation | undefined;
20
+ /**
21
+ * Determines whether an operation is registered.
22
+ */
23
+ has(name: string): boolean;
24
+ /**
25
+ * Retrieves an operation by name or throws.
26
+ */
27
+ require(name: string): APIOperation;
28
+ /**
29
+ * Returns all registered operations.
30
+ */
31
+ getAll(): readonly APIOperation[];
32
+ /**
33
+ * Finds operations by tag.
34
+ */
35
+ findByTag(tag: string): readonly APIOperation[];
36
+ /**
37
+ * Unregisters an operation.
38
+ */
39
+ unregister(name: string): boolean;
40
+ /**
41
+ * Prevents further mutation of the registry.
42
+ */
43
+ freeze(): void;
44
+ /**
45
+ * Determines whether the registry is frozen.
46
+ */
47
+ isFrozen(): boolean;
48
+ }
49
+ //# sourceMappingURL=operationRegistry.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operationRegistry.core.d.ts","sourceRoot":"","sources":["../../../src/api/registry/operationRegistry.core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;;;GAIG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAE9D,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI,CAWtC;IAED;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAE1C;IAED;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzB;IAED;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAMlC;IAED;;OAEG;IACH,MAAM,IAAI,SAAS,YAAY,EAAE,CAEhC;IAED;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,YAAY,EAAE,CAI9C;IAED;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKhC;IAED;;OAEG;IACH,MAAM,IAAI,IAAI,CAEb;IAED;;OAEG;IACH,QAAQ,IAAI,OAAO,CAElB;CACF"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Registry for API operations.
3
+ *
4
+ * Enforces uniqueness and provides O(1) lookup by operation name.
5
+ */
6
+ export class APIOperationRegistry {
7
+ operations = new Map();
8
+ frozen = false;
9
+ /**
10
+ * Registers an operation.
11
+ *
12
+ * @throws {APIDuplicateOperationError} if an operation with the same name is already registered.
13
+ */
14
+ register(operation) {
15
+ if (this.frozen) {
16
+ throw new Error("Cannot register operations on a frozen registry.");
17
+ }
18
+ const existing = this.operations.get(operation.name);
19
+ if (existing !== undefined) {
20
+ throw new Error(`Operation "${operation.name}" is already registered.`);
21
+ }
22
+ this.operations.set(operation.name, Object.freeze(operation));
23
+ }
24
+ /**
25
+ * Retrieves an operation by name.
26
+ */
27
+ get(name) {
28
+ return this.operations.get(name);
29
+ }
30
+ /**
31
+ * Determines whether an operation is registered.
32
+ */
33
+ has(name) {
34
+ return this.operations.has(name);
35
+ }
36
+ /**
37
+ * Retrieves an operation by name or throws.
38
+ */
39
+ require(name) {
40
+ const operation = this.get(name);
41
+ if (operation === undefined) {
42
+ throw new Error(`Operation "${name}" is not registered.`);
43
+ }
44
+ return operation;
45
+ }
46
+ /**
47
+ * Returns all registered operations.
48
+ */
49
+ getAll() {
50
+ return Array.from(this.operations.values());
51
+ }
52
+ /**
53
+ * Finds operations by tag.
54
+ */
55
+ findByTag(tag) {
56
+ return this.getAll().filter((operation) => operation.metadata?.tags?.includes(tag));
57
+ }
58
+ /**
59
+ * Unregisters an operation.
60
+ */
61
+ unregister(name) {
62
+ if (this.frozen) {
63
+ throw new Error("Cannot unregister operations on a frozen registry.");
64
+ }
65
+ return this.operations.delete(name);
66
+ }
67
+ /**
68
+ * Prevents further mutation of the registry.
69
+ */
70
+ freeze() {
71
+ this.frozen = true;
72
+ }
73
+ /**
74
+ * Determines whether the registry is frozen.
75
+ */
76
+ isFrozen() {
77
+ return this.frozen;
78
+ }
79
+ }
80
+ //# sourceMappingURL=operationRegistry.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operationRegistry.core.js","sourceRoot":"","sources":["../../../src/api/registry/operationRegistry.core.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACd,UAAU,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEtD,MAAM,GAAG,KAAK,CAAC;IAEvB;;;;OAIG;IACH,QAAQ,CAAC,SAAuB;QAC9B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,cAAc,SAAS,CAAC,IAAI,0BAA0B,CAAC,CAAC;QAC1E,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAY;QAClB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,sBAAsB,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CACxC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CACxC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAY;QACrB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import type { APIError } from "../errors/index.js";
2
+ /**
3
+ * Success result from an API operation.
4
+ */
5
+ export interface APISuccess<T> {
6
+ readonly ok: true;
7
+ readonly data: T;
8
+ }
9
+ /**
10
+ * Failure result from an API operation.
11
+ */
12
+ export interface APIFailure {
13
+ readonly ok: false;
14
+ readonly error: APIError;
15
+ }
16
+ /**
17
+ * Discriminated result type for API operations.
18
+ */
19
+ export type APIResult<T> = APISuccess<T> | APIFailure;
20
+ /**
21
+ * Creates a successful API result.
22
+ */
23
+ export declare function apiSuccess<T>(data: T): APISuccess<T>;
24
+ /**
25
+ * Creates a failed API result.
26
+ */
27
+ export declare function apiFailure(error: APIError): APIFailure;
28
+ /**
29
+ * Determines whether an API result is successful.
30
+ */
31
+ export declare function isApiSuccess<T>(result: APIResult<T>): result is APISuccess<T>;
32
+ /**
33
+ * Determines whether an API result is a failure.
34
+ */
35
+ export declare function isApiFailure<T>(result: APIResult<T>): result is APIFailure;
36
+ //# sourceMappingURL=apiResult.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiResult.type.d.ts","sourceRoot":"","sources":["../../../src/api/result/apiResult.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;AAEtD;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAEpD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,CAEtD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,CAE7E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,UAAU,CAE1E"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Creates a successful API result.
3
+ */
4
+ export function apiSuccess(data) {
5
+ return Object.freeze({ ok: true, data });
6
+ }
7
+ /**
8
+ * Creates a failed API result.
9
+ */
10
+ export function apiFailure(error) {
11
+ return Object.freeze({ ok: false, error });
12
+ }
13
+ /**
14
+ * Determines whether an API result is successful.
15
+ */
16
+ export function isApiSuccess(result) {
17
+ return result.ok === true;
18
+ }
19
+ /**
20
+ * Determines whether an API result is a failure.
21
+ */
22
+ export function isApiFailure(result) {
23
+ return result.ok === false;
24
+ }
25
+ //# sourceMappingURL=apiResult.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiResult.type.js","sourceRoot":"","sources":["../../../src/api/result/apiResult.type.ts"],"names":[],"mappings":"AAuBA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAI,IAAO;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAe;IACxC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAI,MAAoB;IAClD,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAI,MAAoB;IAClD,OAAO,MAAM,CAAC,EAAE,KAAK,KAAK,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @zudojs/api
3
+ *
4
+ * Application-facing API layer for the Zudojs framework.
5
+ *
6
+ * Provides transport-agnostic operation definitions, execution context,
7
+ * interceptors, policies, and result types.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { defineOperation, APIOperationRegistry, APIExecutor } from "@zudojs/api";
12
+ *
13
+ * const getUser = defineOperation({
14
+ * name: "users.get",
15
+ * input: GetUserSchema,
16
+ * output: UserSchema,
17
+ * handler: async (input, context) => {
18
+ * return userService.findById(input.id);
19
+ * },
20
+ * });
21
+ *
22
+ * const registry = new APIOperationRegistry();
23
+ * registry.register(getUser);
24
+ *
25
+ * const executor = new APIExecutor();
26
+ * const result = await executor.execute(getUser, { id: "123" }, context);
27
+ * ```
28
+ */
29
+ export type { APISuccess, APIFailure, APIResult, } from "./api/result/apiResult.type.js";
30
+ export { apiSuccess, apiFailure, isApiSuccess, isApiFailure, } from "./api/result/apiResult.type.js";
31
+ export type { APIErrorOptions } from "./api/errors/index.js";
32
+ export { APIError, APIValidationError, APIAuthenticationError, APIAuthorizationError, APINotFoundError, APIConflictError, APIRateLimitError, APITimeoutError, APIUnavailableError, APIInternalError, APIVersionError, APIOperationNotFoundError, APIDuplicateOperationError, APIIdempotencyError, createAPIError, isAPIError, } from "./api/errors/index.js";
33
+ export { DEFAULT_OPERATION_TIMEOUT, MAX_INTERCEPTORS, MAX_POLICIES, } from "./api/constants.js";
34
+ export type { APIContext, APIContextKey } from "./api/context/context.type.js";
35
+ export { createAPIContext, RequestIdContextKey, CorrelationIdContextKey, TenantIdContextKey, UserIdContextKey, StartTimeContextKey, } from "./api/context/context.type.js";
36
+ export type { APIHandler } from "./api/handler/handler.type.js";
37
+ export type { APIOperation, APIOperationMetadata, DefineOperationOptions, } from "./api/operation/operation.type.js";
38
+ export { defineOperation } from "./api/operation/operation.type.js";
39
+ export { APIOperationRegistry } from "./api/registry/index.js";
40
+ export type { APIInterceptor, APIExecutionContext, } from "./api/interceptors/interceptor.type.js";
41
+ export { createNoopInterceptor } from "./api/interceptors/interceptor.type.js";
42
+ export { APIExecutor, normalizeAPIError } from "./api/executor/index.js";
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,YAAY,EACV,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,gCAAgC,CAAC;AAGxC,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,cAAc,EACd,UAAU,GACX,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AAGvC,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAG/D,YAAY,EACV,cAAc,EACd,mBAAmB,GACpB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}