@athosjs/pro 0.1.4-alpha

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 (94) hide show
  1. package/README.md +518 -0
  2. package/bootstrap.cjs +107 -0
  3. package/bootstrap.cjs.map +1 -0
  4. package/bootstrap.d.ts +8 -0
  5. package/bootstrap.d.ts.map +1 -0
  6. package/bootstrap.js +103 -0
  7. package/bootstrap.js.map +1 -0
  8. package/core/athos-application.cjs +362 -0
  9. package/core/athos-application.cjs.map +1 -0
  10. package/core/athos-application.d.ts +17 -0
  11. package/core/athos-application.d.ts.map +1 -0
  12. package/core/athos-application.js +357 -0
  13. package/core/athos-application.js.map +1 -0
  14. package/core/discovery.cjs +47 -0
  15. package/core/discovery.cjs.map +1 -0
  16. package/core/discovery.d.ts +6 -0
  17. package/core/discovery.d.ts.map +1 -0
  18. package/core/discovery.js +45 -0
  19. package/core/discovery.js.map +1 -0
  20. package/core/i18n.cjs +12 -0
  21. package/core/i18n.cjs.map +1 -0
  22. package/core/i18n.d.ts +4 -0
  23. package/core/i18n.d.ts.map +1 -0
  24. package/core/i18n.js +10 -0
  25. package/core/i18n.js.map +1 -0
  26. package/core/pipeline.cjs +251 -0
  27. package/core/pipeline.cjs.map +1 -0
  28. package/core/pipeline.d.ts +11 -0
  29. package/core/pipeline.d.ts.map +1 -0
  30. package/core/pipeline.js +246 -0
  31. package/core/pipeline.js.map +1 -0
  32. package/core/router-initializer.cjs +158 -0
  33. package/core/router-initializer.cjs.map +1 -0
  34. package/core/router-initializer.d.ts +26 -0
  35. package/core/router-initializer.d.ts.map +1 -0
  36. package/core/router-initializer.js +156 -0
  37. package/core/router-initializer.js.map +1 -0
  38. package/core/scanner.cjs +141 -0
  39. package/core/scanner.cjs.map +1 -0
  40. package/core/scanner.d.ts +7 -0
  41. package/core/scanner.d.ts.map +1 -0
  42. package/core/scanner.js +139 -0
  43. package/core/scanner.js.map +1 -0
  44. package/experimental.cjs +23 -0
  45. package/experimental.cjs.map +1 -0
  46. package/experimental.d.ts +9 -0
  47. package/experimental.d.ts.map +1 -0
  48. package/experimental.js +5 -0
  49. package/experimental.js.map +1 -0
  50. package/functions.cjs +67 -0
  51. package/functions.cjs.map +1 -0
  52. package/functions.d.ts +10 -0
  53. package/functions.d.ts.map +1 -0
  54. package/functions.js +62 -0
  55. package/functions.js.map +1 -0
  56. package/http-profile.cjs +48 -0
  57. package/http-profile.cjs.map +1 -0
  58. package/http-profile.d.ts +6 -0
  59. package/http-profile.d.ts.map +1 -0
  60. package/http-profile.js +44 -0
  61. package/http-profile.js.map +1 -0
  62. package/index.cjs +281 -0
  63. package/index.cjs.map +1 -0
  64. package/index.d.ts +23 -0
  65. package/index.d.ts.map +1 -0
  66. package/index.js +23 -0
  67. package/index.js.map +1 -0
  68. package/observability.cjs +191 -0
  69. package/observability.cjs.map +1 -0
  70. package/observability.d.ts +8 -0
  71. package/observability.d.ts.map +1 -0
  72. package/observability.js +188 -0
  73. package/observability.js.map +1 -0
  74. package/package.json +42 -0
  75. package/policies.cjs +30 -0
  76. package/policies.cjs.map +1 -0
  77. package/policies.d.ts +21 -0
  78. package/policies.d.ts.map +1 -0
  79. package/policies.js +27 -0
  80. package/policies.js.map +1 -0
  81. package/resilience.cjs +280 -0
  82. package/resilience.cjs.map +1 -0
  83. package/resilience.d.ts +6 -0
  84. package/resilience.d.ts.map +1 -0
  85. package/resilience.js +276 -0
  86. package/resilience.js.map +1 -0
  87. package/security.cjs +142 -0
  88. package/security.cjs.map +1 -0
  89. package/security.d.ts +11 -0
  90. package/security.d.ts.map +1 -0
  91. package/security.js +136 -0
  92. package/security.js.map +1 -0
  93. package/types.d.ts +3 -0
  94. package/types.d.ts.map +1 -0
@@ -0,0 +1,139 @@
1
+ import { existsSync, statSync, readdirSync } from 'node:fs';
2
+ import { ATHOS_ERROR_CODES } from '@athosjs/constants';
3
+ import { createAthosError } from '@athosjs/core';
4
+ import { defineMetadata } from '@athosjs/metadata';
5
+ import { Platform } from '@athosjs/runtime/platform';
6
+ import { relative, resolve, dirname } from 'node:path';
7
+
8
+ const DISCOVERY_SOURCE_FILE_METADATA_KEY = Symbol.for("athos:discovery:source-file");
9
+ class FileScanner {
10
+ static async scanAndLoad(baseDir, includeDirectories = [
11
+ "src",
12
+ "app"
13
+ ], options) {
14
+ const absoluteBaseDir = Platform.path.resolve(FileScanner.#normalizeDiscoveryRoot(baseDir));
15
+ const roots = FileScanner.#resolveDiscoveryRoots(absoluteBaseDir, includeDirectories);
16
+ const files = roots.flatMap((root)=>FileScanner.#walk(root));
17
+ const modules = [];
18
+ const errors = [];
19
+ for (const file of files){
20
+ if (FileScanner.#isLoadable(file)) {
21
+ const resolved = FileScanner.#resolveCompiledFile(file, absoluteBaseDir);
22
+ try {
23
+ const moduleExports = await import(Platform.url.pathToFileURL(resolved).href);
24
+ FileScanner.#annotateDiscoveredModuleExports(moduleExports, file);
25
+ modules.push(moduleExports);
26
+ } catch (error) {
27
+ const cause = error instanceof Error ? error.message : String(error);
28
+ if (options?.ignoreDiscoveryErrors) {
29
+ errors.push({
30
+ file,
31
+ cause
32
+ });
33
+ } else {
34
+ throw createAthosError(ATHOS_ERROR_CODES.MODULE_INVALID, `Failed to load discovered file: ${file}. ${cause}`, {
35
+ details: {
36
+ file,
37
+ cause
38
+ }
39
+ });
40
+ }
41
+ }
42
+ }
43
+ }
44
+ if (errors.length > 0) {
45
+ console.warn(`[athos/discovery] ${errors.length} file(s) failed to load but were ignored:`);
46
+ for (const { file, cause } of errors){
47
+ console.warn(` - ${file}: ${cause}`);
48
+ }
49
+ }
50
+ return modules;
51
+ }
52
+ static #resolveCompiledFile(file, baseDir) {
53
+ const ext = Platform.path.extname(file);
54
+ if (ext !== ".ts") {
55
+ return file;
56
+ }
57
+ const projectRoot = FileScanner.#findProjectRoot(file);
58
+ if (!projectRoot) {
59
+ return file;
60
+ }
61
+ const distDir = Platform.path.join(projectRoot, "dist");
62
+ if (!existsSync(distDir)) {
63
+ return file;
64
+ }
65
+ const relativePath = relative(baseDir, file);
66
+ const compiledJs = Platform.path.join(distDir, relativePath).replace(/\.ts$/u, ".js");
67
+ if (existsSync(compiledJs)) return compiledJs;
68
+ return file;
69
+ }
70
+ static #resolveDiscoveryRoots(baseDir, includeDirectories) {
71
+ const configuredRoots = includeDirectories.map((directory)=>Platform.path.resolve(baseDir, directory)).filter((directory)=>{
72
+ try {
73
+ return statSync(directory).isDirectory();
74
+ } catch {
75
+ return false;
76
+ }
77
+ });
78
+ return configuredRoots.length === 0 ? [] : configuredRoots;
79
+ }
80
+ static #walk(dir) {
81
+ const results = [];
82
+ const skipDirs = [
83
+ "node_modules",
84
+ ".git",
85
+ "build",
86
+ ".athos"
87
+ ];
88
+ let list;
89
+ try {
90
+ list = readdirSync(dir);
91
+ } catch (error) {
92
+ throw createAthosError(ATHOS_ERROR_CODES.MODULE_INVALID, `Failed to scan discovery directory ${dir}.`, {
93
+ details: {
94
+ directory: dir,
95
+ cause: error instanceof Error ? error.message : String(error)
96
+ }
97
+ });
98
+ }
99
+ for (const file of list){
100
+ if (skipDirs.includes(file)) continue;
101
+ const path = Platform.path.join(dir, file);
102
+ const stat = statSync(path);
103
+ if (stat?.isDirectory()) {
104
+ results.push(...FileScanner.#walk(path));
105
+ } else {
106
+ results.push(path);
107
+ }
108
+ }
109
+ return results;
110
+ }
111
+ static #isLoadable(file) {
112
+ const ext = Platform.path.extname(file);
113
+ return (ext === ".ts" || ext === ".js" || ext === "" || ext === ".mjs") && !file.endsWith(".d.ts") && !file.includes(".test.") && !file.includes(".spec.") && !file.includes("/scripts/") && !file.includes("/examples/");
114
+ }
115
+ static #findProjectRoot(dir) {
116
+ let current = resolve(dir);
117
+ while(true){
118
+ if (existsSync(Platform.path.join(current, "package.json"))) return current;
119
+ const parent = dirname(current);
120
+ if (parent === current) return undefined;
121
+ current = parent;
122
+ }
123
+ }
124
+ static #annotateDiscoveredModuleExports(moduleExports, file) {
125
+ for (const value of Object.values(moduleExports)){
126
+ if (typeof value === "function") {
127
+ defineMetadata(value, DISCOVERY_SOURCE_FILE_METADATA_KEY, file);
128
+ }
129
+ }
130
+ }
131
+ static #normalizeDiscoveryRoot(root) {
132
+ if (root instanceof URL) return Platform.url.fileURLToPath(root);
133
+ if (root.startsWith("file://")) return Platform.url.fileURLToPath(root);
134
+ return root;
135
+ }
136
+ }
137
+
138
+ export { FileScanner };
139
+ //# sourceMappingURL=scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.js","sources":["../../../../packages/pro/src/core/scanner.ts"],"sourcesContent":["import { readdirSync, statSync, existsSync } from \"node:fs\";\nimport { ATHOS_ERROR_CODES } from \"@athosjs/constants\";\nimport { createAthosError } from \"@athosjs/core\";\nimport { defineMetadata } from \"@athosjs/metadata\";\nimport { Platform } from \"@athosjs/runtime/platform\";\nimport { resolve, dirname, relative } from \"node:path\";\n\nconst DISCOVERY_SOURCE_FILE_METADATA_KEY = Symbol.for(\"athos:discovery:source-file\");\n\nexport class FileScanner {\n\tstatic async scanAndLoad(\n\t\tbaseDir: string | URL,\n\t\tincludeDirectories: readonly string[] = [\"src\", \"app\"],\n\t\toptions?: { ignoreDiscoveryErrors?: boolean },\n\t): Promise<readonly Record<string, unknown>[]> {\n\t\tconst absoluteBaseDir = Platform.path.resolve(FileScanner.#normalizeDiscoveryRoot(baseDir));\n\t\tconst roots = FileScanner.#resolveDiscoveryRoots(absoluteBaseDir, includeDirectories);\n\t\tconst files = roots.flatMap((root) => FileScanner.#walk(root));\n\t\tconst modules: Record<string, unknown>[] = [];\n\t\tconst errors: Array<{ file: string; cause: string }> = [];\n\n\t\tfor (const file of files) {\n\t\t\tif (FileScanner.#isLoadable(file)) {\n\t\t\t\tconst resolved = FileScanner.#resolveCompiledFile(file, absoluteBaseDir);\n\t\t\t\ttry {\n\t\t\t\t\tconst moduleExports = await import(Platform.url.pathToFileURL(resolved).href);\n\t\t\t\t\tFileScanner.#annotateDiscoveredModuleExports(moduleExports, file);\n\t\t\t\t\tmodules.push(moduleExports);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst cause = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tif (options?.ignoreDiscoveryErrors) {\n\t\t\t\t\t\terrors.push({ file, cause });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow createAthosError(\n\t\t\t\t\t\t\tATHOS_ERROR_CODES.MODULE_INVALID,\n\t\t\t\t\t\t\t`Failed to load discovered file: ${file}. ${cause}`,\n\t\t\t\t\t\t\t{ details: { file, cause } },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\tconsole.warn(`[athos/discovery] ${errors.length} file(s) failed to load but were ignored:`);\n\t\t\tfor (const { file, cause } of errors) {\n\t\t\t\tconsole.warn(` - ${file}: ${cause}`);\n\t\t\t}\n\t\t}\n\n\t\treturn modules;\n\t}\n\n\tstatic #resolveCompiledFile(file: string, baseDir: string): string {\n\t\tconst ext = Platform.path.extname(file);\n\t\tif (ext !== \".ts\") {\n\t\t return file;\n\t\t}\n\n\t\tconst projectRoot = FileScanner.#findProjectRoot(file);\n\t\tif (!projectRoot) {\n\t\t return file;\n\t\t}\n\n\t\tconst distDir = Platform.path.join(projectRoot, \"dist\");\n if (!existsSync(distDir)) {\n return file;\n\t\t}\n\n\t\tconst relativePath = relative(baseDir, file);\n\t\tconst compiledJs = Platform.path.join(distDir, relativePath).replace(/\\.ts$/u, \".js\");\n\n\t\tif (existsSync(compiledJs)) return compiledJs;\n\t\treturn file;\n\t}\n\n\tstatic #resolveDiscoveryRoots(baseDir: string, includeDirectories: readonly string[]): string[] {\n\t\tconst configuredRoots = includeDirectories\n\t\t\t.map((directory) => Platform.path.resolve(baseDir, directory))\n\t\t\t.filter((directory) => {\n\t\t\t\ttry { return statSync(directory).isDirectory(); } catch { return false; }\n\t\t\t});\n\n\t\treturn configuredRoots.length === 0 ? [] : configuredRoots;\n\t}\n\n\tstatic #walk(dir: string): string[] {\n\t\tconst results: string[] = [];\n\t\tconst skipDirs = [\"node_modules\", \".git\", \"build\", \".athos\"];\n\n\t\tlet list: string[];\n\t\ttry {\n\t\t\tlist = readdirSync(dir);\n\t\t} catch (error) {\n\t\t\tthrow createAthosError(ATHOS_ERROR_CODES.MODULE_INVALID, `Failed to scan discovery directory ${dir}.`, {\n\t\t\t\tdetails: { directory: dir, cause: error instanceof Error ? error.message : String(error) },\n\t\t\t});\n\t\t}\n\n\t\tfor (const file of list) {\n\t\t\tif (skipDirs.includes(file)) continue;\n\n\t\t\tconst path = Platform.path.join(dir, file);\n\t\t\tconst stat = statSync(path);\n\n\t\t\tif (stat?.isDirectory()) {\n\t\t\t\tresults.push(...FileScanner.#walk(path));\n\t\t\t} else {\n\t\t\t\tresults.push(path);\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\tstatic #isLoadable(file: string): boolean {\n\t\tconst ext = Platform.path.extname(file);\n\t\treturn (\n\t\t\t(ext === \".ts\" || ext === \".js\" || ext === \"\" || ext === \".mjs\") &&\n\t\t\t!file.endsWith(\".d.ts\") &&\n\t\t\t!file.includes(\".test.\") &&\n\t\t\t!file.includes(\".spec.\") &&\n\t\t\t!file.includes(\"/scripts/\") &&\n\t\t\t!file.includes(\"/examples/\")\n\t\t);\n\t}\n\n\tstatic #findProjectRoot(dir: string): string | undefined {\n\t\tlet current = resolve(dir);\n\t\twhile (true) {\n\t\t\tif (existsSync(Platform.path.join(current, \"package.json\"))) return current;\n\t\t\tconst parent = dirname(current);\n\t\t\tif (parent === current) return undefined;\n\t\t\tcurrent = parent;\n\t\t}\n\t}\n\n\tstatic #annotateDiscoveredModuleExports(moduleExports: Record<string, unknown>, file: string): void {\n\t\tfor (const value of Object.values(moduleExports)) {\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tdefineMetadata(value, DISCOVERY_SOURCE_FILE_METADATA_KEY, file);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic #normalizeDiscoveryRoot(root: string | URL): string {\n\t\tif (root instanceof URL) return Platform.url.fileURLToPath(root);\n\t\tif (root.startsWith(\"file://\")) return Platform.url.fileURLToPath(root);\n\t\treturn root;\n\t}\n}\n"],"names":["DISCOVERY_SOURCE_FILE_METADATA_KEY","Symbol","for","FileScanner","scanAndLoad","baseDir","includeDirectories","options","absoluteBaseDir","Platform","path","resolve","roots","files","flatMap","root","modules","errors","file","resolved","moduleExports","url","pathToFileURL","href","push","error","cause","Error","message","String","ignoreDiscoveryErrors","createAthosError","ATHOS_ERROR_CODES","MODULE_INVALID","details","length","console","warn","ext","extname","projectRoot","distDir","join","existsSync","relativePath","relative","compiledJs","replace","configuredRoots","map","directory","filter","statSync","isDirectory","dir","results","skipDirs","list","readdirSync","includes","stat","endsWith","current","parent","dirname","undefined","value","Object","values","defineMetadata","URL","fileURLToPath","startsWith"],"mappings":";;;;;;;AAOA,MAAMA,kCAAAA,GAAqCC,MAAAA,CAAOC,GAAG,CAAC,6BAAA,CAAA;AAE/C,MAAMC,WAAAA,CAAAA;IACZ,aAAaC,WAAAA,CACZC,OAAqB,EACrBC,kBAAAA,GAAwC;AAAC,QAAA,KAAA;AAAO,QAAA;AAAM,KAAA,EACtDC,OAA6C,EACC;QAC9C,MAAMC,eAAAA,GAAkBC,SAASC,IAAI,CAACC,OAAO,CAACR,WAAAA,CAAY,uBAAuB,CAACE,OAAAA,CAAAA,CAAAA;AAClF,QAAA,MAAMO,KAAAA,GAAQT,WAAAA,CAAY,sBAAsB,CAACK,eAAAA,EAAiBF,kBAAAA,CAAAA;QAClE,MAAMO,KAAAA,GAAQD,MAAME,OAAO,CAAC,CAACC,IAAAA,GAASZ,WAAAA,CAAY,KAAK,CAACY,IAAAA,CAAAA,CAAAA;AACxD,QAAA,MAAMC,UAAqC,EAAE;AAC7C,QAAA,MAAMC,SAAiD,EAAE;QAEzD,KAAK,MAAMC,QAAQL,KAAAA,CAAO;AACzB,YAAA,IAAIV,WAAAA,CAAY,WAAW,CAACe,IAAA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AAO8C,UAAU,UAAA,EAAY;AAChCG,gBAAAA,cAAAA,CAAeH,OAAOlE,kCAAAA,EAAoCkB,IAAAA,CAAAA;AAC3D,YAAA;AACD,QAAA;AACD,IAAA;IAEA,OAAO,uBAAuB,CAACH,IAAkB,EAAA;AAChD,QAAA,IAAIA,gBAAgBuD,GAAAA,EAAK,OAAO7D,SAASY,GAAG,CAACkD,aAAa,CAACxD,IAAAA,CAAAA;QAC3D,IAAIA,IAAAA,CAAKyD,UAAU,CAAC,SAAA,CAAA,EAAY,OAAO/D,QAAAA,CAASY,GAAG,CAACkD,aAAa,CAACxD,IAAAA,CAAAA;QAClE,OAAOA,IAAAA;AACR,IAAA;AACD;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var httpProfile = require('./http-profile.cjs');
4
+ var observability = require('./observability.cjs');
5
+ var resilience = require('./resilience.cjs');
6
+ var security = require('./security.cjs');
7
+
8
+
9
+
10
+ exports.createDefaultProHttpProfile = httpProfile.createDefaultProHttpProfile;
11
+ exports.createProductionProHttpProfile = httpProfile.createProductionProHttpProfile;
12
+ exports.resolveProHttpProfile = httpProfile.resolveProHttpProfile;
13
+ exports.attachProObservability = observability.attachProObservability;
14
+ exports.createProObservabilityHooks = observability.createProObservabilityHooks;
15
+ exports.createCircuitBreaker = resilience.createCircuitBreaker;
16
+ exports.createConcurrencyLimiter = resilience.createConcurrencyLimiter;
17
+ exports.createResilientExecutor = resilience.createResilientExecutor;
18
+ exports.createAuthenticationFailureResponse = security.createAuthenticationFailureResponse;
19
+ exports.createAuthorizationFailureResponse = security.createAuthorizationFailureResponse;
20
+ exports.createProAuthenticationMiddleware = security.createProAuthenticationMiddleware;
21
+ exports.createProAuthorizationMiddleware = security.createProAuthorizationMiddleware;
22
+ exports.formatWwwAuthenticateHeader = security.formatWwwAuthenticateHeader;
23
+ //# sourceMappingURL=experimental.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experimental.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,9 @@
1
+ export type { ProHttpProfile, ProHttpProfileName } from "./http-profile";
2
+ export { createDefaultProHttpProfile, createProductionProHttpProfile, resolveProHttpProfile, } from "./http-profile";
3
+ export type { ProObservabilityOptions } from "./observability";
4
+ export { attachProObservability, createProObservabilityHooks } from "./observability";
5
+ export type { CircuitBreaker, CircuitBreakerOptions, ConcurrencyLimiter, ConcurrencyLimiterOptions, ResilientExecutor, ResilientExecutorOptions, } from "./resilience";
6
+ export { createCircuitBreaker, createConcurrencyLimiter, createResilientExecutor, } from "./resilience";
7
+ export type { ProAuthenticationMiddlewareOptions, ProAuthorizationMiddlewareOptions, } from "./security";
8
+ export { createAuthenticationFailureResponse, createAuthorizationFailureResponse, createProAuthenticationMiddleware, createProAuthorizationMiddleware, formatWwwAuthenticateHeader, } from "./security";
9
+ //# sourceMappingURL=experimental.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experimental.d.ts","sourceRoot":"","sources":["../../../../../../packages/pro/src/experimental.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EACN,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,GACrB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AACtF,YAAY,EACX,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,cAAc,CAAC;AACtB,YAAY,EACX,kCAAkC,EAClC,iCAAiC,GACjC,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,mCAAmC,EACnC,kCAAkC,EAClC,iCAAiC,EACjC,gCAAgC,EAChC,2BAA2B,GAC3B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { createDefaultProHttpProfile, createProductionProHttpProfile, resolveProHttpProfile } from './http-profile.js';
2
+ export { attachProObservability, createProObservabilityHooks } from './observability.js';
3
+ export { createCircuitBreaker, createConcurrencyLimiter, createResilientExecutor } from './resilience.js';
4
+ export { createAuthenticationFailureResponse, createAuthorizationFailureResponse, createProAuthenticationMiddleware, createProAuthorizationMiddleware, formatWwwAuthenticateHeader } from './security.js';
5
+ //# sourceMappingURL=experimental.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experimental.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
package/functions.cjs ADDED
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var core = require('@athosjs/core');
4
+ var di = require('@athosjs/di');
5
+ var module$1 = require('@athosjs/module');
6
+ var observability = require('@athosjs/observability');
7
+
8
+ class ProApplication {
9
+ static createBuilder(options) {
10
+ const builder = core.createApplicationBuilder(options);
11
+ const container = options.container ?? di.createContainer(...options.providers ?? []);
12
+ if (options.logger) {
13
+ builder.provide(observability.ATHOS_LOGGER_TOKEN, options.logger);
14
+ }
15
+ if (options.telemetrySink) {
16
+ builder.provide(observability.ATHOS_TELEMETRY_SINK_TOKEN, options.telemetrySink);
17
+ }
18
+ if (!builder.capabilities.has("http-server")) {
19
+ builder.capability("http-server", {
20
+ provider: "pro"
21
+ }, "pro");
22
+ }
23
+ container.attach(builder, options.containerAttach);
24
+ return {
25
+ builder,
26
+ container
27
+ };
28
+ }
29
+ static async createSetup(options) {
30
+ const { builder, container } = ProApplication.createBuilder(options);
31
+ const modules = await module$1.installModules(builder, {
32
+ manifests: [
33
+ ...options.manifests ?? []
34
+ ],
35
+ ...options.plugins ? {
36
+ plugins: options.plugins
37
+ } : {}
38
+ });
39
+ return {
40
+ builder: builder,
41
+ container: container,
42
+ modules: modules
43
+ };
44
+ }
45
+ static async create(options) {
46
+ const container = options.container ?? di.AthosContainer.getRootInstance(...options.providers ?? []);
47
+ const setup = await ProApplication.createSetup({
48
+ ...options,
49
+ container: container
50
+ });
51
+ const kernel = setup.builder.build();
52
+ kernel.container = setup.container;
53
+ return {
54
+ ...setup,
55
+ kernel: kernel
56
+ };
57
+ }
58
+ }
59
+ const createProApplicationBuilder = ProApplication.createBuilder;
60
+ const createProApplicationSetup = ProApplication.createSetup;
61
+ const createProApplication = ProApplication.create;
62
+
63
+ exports.ProApplication = ProApplication;
64
+ exports.createProApplication = createProApplication;
65
+ exports.createProApplicationBuilder = createProApplicationBuilder;
66
+ exports.createProApplicationSetup = createProApplicationSetup;
67
+ //# sourceMappingURL=functions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.cjs","sources":["../../../packages/pro/src/functions.ts"],"sourcesContent":["import { createApplicationBuilder } from \"@athosjs/core\";\nimport { type ContainerAttachOptions, createContainer, AthosContainer, type HavenProvider } from \"@athosjs/di\";\nimport { installModules } from \"@athosjs/module\";\nimport {\n\ttype ExecutionTelemetrySink,\n\tATHOS_LOGGER_TOKEN,\n\tATHOS_TELEMETRY_SINK_TOKEN,\n\ttype AthosLogger,\n} from \"@athosjs/observability\";\nimport type {\n\tProApplicationBuilderOptions,\n\tProApplicationBuilderResult,\n\tProApplicationResult,\n\tProApplicationSetupOptions,\n\tProApplicationSetupResult,\n} from \"./types\";\n\nexport class ProApplication {\n\tstatic createBuilder(options: ProApplicationBuilderOptions): ProApplicationBuilderResult {\n\t\tconst builder = createApplicationBuilder(options as any);\n\t\tconst container =\n\t\t\t(options.container as AthosContainer | undefined) ??\n\t\t\tcreateContainer(...((options.providers ?? []) as HavenProvider[]));\n\n\t\tif (options.logger) {\n\t\t\tbuilder.provide(ATHOS_LOGGER_TOKEN, options.logger as AthosLogger);\n\t\t}\n\n\t\tif (options.telemetrySink) {\n\t\t\tbuilder.provide(ATHOS_TELEMETRY_SINK_TOKEN, options.telemetrySink as ExecutionTelemetrySink);\n\t\t}\n\n\t\tif (!builder.capabilities.has(\"http-server\")) {\n\t\t\tbuilder.capability(\"http-server\", { provider: \"pro\" }, \"pro\");\n\t\t}\n\n\t\t(container as AthosContainer).attach(builder as any, options.containerAttach as ContainerAttachOptions | undefined);\n\n\t\treturn {\n\t\t\tbuilder,\n\t\t\tcontainer,\n\t\t};\n\t}\n\n\tstatic async createSetup(options: ProApplicationSetupOptions): Promise<ProApplicationSetupResult> {\n\t\tconst { builder, container } = ProApplication.createBuilder(options);\n\t\tconst modules = await installModules(builder as any, {\n\t\t\tmanifests: [...((options.manifests ?? []) as any)],\n\t\t\t...((options as any).plugins ? { plugins: (options as any).plugins } : {}),\n\t\t});\n\n\t\treturn {\n\t\t\tbuilder: builder as any,\n\t\t\tcontainer: container as any,\n\t\t\tmodules: modules as any,\n\t\t};\n\t}\n\n\tstatic async create(options: ProApplicationSetupOptions): Promise<ProApplicationResult> {\n\t\tconst container = (options.container as AthosContainer | undefined) ?? AthosContainer.getRootInstance(\n\t\t\t...((options.providers ?? []) as HavenProvider[]),\n\t\t);\n\t\tconst setup = await ProApplication.createSetup({\n\t\t\t...options,\n\t\t\tcontainer: container as AthosContainer,\n\t\t} as ProApplicationSetupOptions);\n\t\tconst kernel = (setup.builder as any).build();\n\t\t(kernel as any).container = setup.container;\n\n\t\treturn {\n\t\t\t...(setup as any),\n\t\t\tkernel: kernel as any,\n\t\t} as ProApplicationResult;\n\t}\n}\n\nexport const createProApplicationBuilder = ProApplication.createBuilder;\nexport const createProApplicationSetup = ProApplication.createSetup;\nexport const createProApplication = ProApplication.create;\n"],"names":["ProApplication","createBuilder","options","builder","createApplicationBuilder","container","createContainer","providers","logger","provide","ATHOS_LOGGER_TOKEN","telemetrySink","ATHOS_TELEMETRY_SINK_TOKEN","capabilities","has","capability","provider","attach","containerAttach","createSetup","modules","installModules","manifests","plugins","create","AthosContainer","getRootInstance","setup","kernel","build","createProApplicationBuilder","createProApplicationS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;AAAQ,aAAA,GAAI;AACxE,SAAA,CAAA;QAEA,OAAO;YACNpB,OAAAA,EAASA,OAAAA;YACTE,SAAAA,EAAWA,SAAAA;YACXe,OAAAA,EAASA;AACV,SAAA;AACD,IAAA;IAEA,aAAaI,MAAAA,CAAOtB,OAAmC,EAAiC;QACvF,MAAMG,SAAAA,GAAY,OAACH,CAAQG,SAAS,IAAmCoB,iBAAAA,CAAeC,eAAe,CAAA,GAC/FxB,OAAAA,CAAQK,SAAS,IAAI,EAAE,CAAA;AAE7B,QAAA,MAAMoB,KAAAA,GAAQ,MAAM3B,cAAAA,CAAemB,WAAW,CAAC;AAC9C,YAAA,GAAGjB,OAAO;YACVG,SAAAA,EAAWA;AACZ,SAAA,CAAA;AACA,QAAA,MAAMuB,MAAAA,GAAUD,KAAAA,CAAMxB,OAAO,CAAS0B,KAAK,EAAA;QAC1CD,MAAAA,CAAevB,SAAS,GAAGsB,KAAAA,CAAMtB,SAAS;QAE3C,OAAO;AACN,YAAA,GAAIsB,KAAK;YACTC,MAAAA,EAAQA;AACT,SAAA;AACD,IAAA;AACD;AAEO,MAAME,2BAAAA,GAA8B9B,cAAAA,CAAeC;AACnD,MAAM8B,yBAAAA,GAA4B/B,cAAAA,CAAemB;AACjD,MAAMa,oBAAAA,GAAuBhC,cAAAA,CAAewB;;;;;;;"}
package/functions.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { ProApplicationBuilderOptions, ProApplicationBuilderResult, ProApplicationResult, ProApplicationSetupOptions, ProApplicationSetupResult } from "./types";
2
+ export declare class ProApplication {
3
+ static createBuilder(options: ProApplicationBuilderOptions): ProApplicationBuilderResult;
4
+ static createSetup(options: ProApplicationSetupOptions): Promise<ProApplicationSetupResult>;
5
+ static create(options: ProApplicationSetupOptions): Promise<ProApplicationResult>;
6
+ }
7
+ export declare const createProApplicationBuilder: typeof ProApplication.createBuilder;
8
+ export declare const createProApplicationSetup: typeof ProApplication.createSetup;
9
+ export declare const createProApplication: typeof ProApplication.create;
10
+ //# sourceMappingURL=functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../../../../packages/pro/src/functions.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,MAAM,SAAS,CAAC;AAEjB,qBAAa,cAAc;IAC1B,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,4BAA4B,GAAG,2BAA2B;WA0B3E,WAAW,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC;WAcpF,MAAM,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAgBvF;AAED,eAAO,MAAM,2BAA2B,qCAA+B,CAAC;AACxE,eAAO,MAAM,yBAAyB,mCAA6B,CAAC;AACpE,eAAO,MAAM,oBAAoB,8BAAwB,CAAC"}
package/functions.js ADDED
@@ -0,0 +1,62 @@
1
+ import { createApplicationBuilder } from '@athosjs/core';
2
+ import { createContainer, AthosContainer } from '@athosjs/di';
3
+ import { installModules } from '@athosjs/module';
4
+ import { ATHOS_LOGGER_TOKEN, ATHOS_TELEMETRY_SINK_TOKEN } from '@athosjs/observability';
5
+
6
+ class ProApplication {
7
+ static createBuilder(options) {
8
+ const builder = createApplicationBuilder(options);
9
+ const container = options.container ?? createContainer(...options.providers ?? []);
10
+ if (options.logger) {
11
+ builder.provide(ATHOS_LOGGER_TOKEN, options.logger);
12
+ }
13
+ if (options.telemetrySink) {
14
+ builder.provide(ATHOS_TELEMETRY_SINK_TOKEN, options.telemetrySink);
15
+ }
16
+ if (!builder.capabilities.has("http-server")) {
17
+ builder.capability("http-server", {
18
+ provider: "pro"
19
+ }, "pro");
20
+ }
21
+ container.attach(builder, options.containerAttach);
22
+ return {
23
+ builder,
24
+ container
25
+ };
26
+ }
27
+ static async createSetup(options) {
28
+ const { builder, container } = ProApplication.createBuilder(options);
29
+ const modules = await installModules(builder, {
30
+ manifests: [
31
+ ...options.manifests ?? []
32
+ ],
33
+ ...options.plugins ? {
34
+ plugins: options.plugins
35
+ } : {}
36
+ });
37
+ return {
38
+ builder: builder,
39
+ container: container,
40
+ modules: modules
41
+ };
42
+ }
43
+ static async create(options) {
44
+ const container = options.container ?? AthosContainer.getRootInstance(...options.providers ?? []);
45
+ const setup = await ProApplication.createSetup({
46
+ ...options,
47
+ container: container
48
+ });
49
+ const kernel = setup.builder.build();
50
+ kernel.container = setup.container;
51
+ return {
52
+ ...setup,
53
+ kernel: kernel
54
+ };
55
+ }
56
+ }
57
+ const createProApplicationBuilder = ProApplication.createBuilder;
58
+ const createProApplicationSetup = ProApplication.createSetup;
59
+ const createProApplication = ProApplication.create;
60
+
61
+ export { ProApplication, createProApplication, createProApplicationBuilder, createProApplicationSetup };
62
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sources":["../../../packages/pro/src/functions.ts"],"sourcesContent":["import { createApplicationBuilder } from \"@athosjs/core\";\nimport { type ContainerAttachOptions, createContainer, AthosContainer, type HavenProvider } from \"@athosjs/di\";\nimport { installModules } from \"@athosjs/module\";\nimport {\n\ttype ExecutionTelemetrySink,\n\tATHOS_LOGGER_TOKEN,\n\tATHOS_TELEMETRY_SINK_TOKEN,\n\ttype AthosLogger,\n} from \"@athosjs/observability\";\nimport type {\n\tProApplicationBuilderOptions,\n\tProApplicationBuilderResult,\n\tProApplicationResult,\n\tProApplicationSetupOptions,\n\tProApplicationSetupResult,\n} from \"./types\";\n\nexport class ProApplication {\n\tstatic createBuilder(options: ProApplicationBuilderOptions): ProApplicationBuilderResult {\n\t\tconst builder = createApplicationBuilder(options as any);\n\t\tconst container =\n\t\t\t(options.container as AthosContainer | undefined) ??\n\t\t\tcreateContainer(...((options.providers ?? []) as HavenProvider[]));\n\n\t\tif (options.logger) {\n\t\t\tbuilder.provide(ATHOS_LOGGER_TOKEN, options.logger as AthosLogger);\n\t\t}\n\n\t\tif (options.telemetrySink) {\n\t\t\tbuilder.provide(ATHOS_TELEMETRY_SINK_TOKEN, options.telemetrySink as ExecutionTelemetrySink);\n\t\t}\n\n\t\tif (!builder.capabilities.has(\"http-server\")) {\n\t\t\tbuilder.capability(\"http-server\", { provider: \"pro\" }, \"pro\");\n\t\t}\n\n\t\t(container as AthosContainer).attach(builder as any, options.containerAttach as ContainerAttachOptions | undefined);\n\n\t\treturn {\n\t\t\tbuilder,\n\t\t\tcontainer,\n\t\t};\n\t}\n\n\tstatic async createSetup(options: ProApplicationSetupOptions): Promise<ProApplicationSetupResult> {\n\t\tconst { builder, container } = ProApplication.createBuilder(options);\n\t\tconst modules = await installModules(builder as any, {\n\t\t\tmanifests: [...((options.manifests ?? []) as any)],\n\t\t\t...((options as any).plugins ? { plugins: (options as any).plugins } : {}),\n\t\t});\n\n\t\treturn {\n\t\t\tbuilder: builder as any,\n\t\t\tcontainer: container as any,\n\t\t\tmodules: modules as any,\n\t\t};\n\t}\n\n\tstatic async create(options: ProApplicationSetupOptions): Promise<ProApplicationResult> {\n\t\tconst container = (options.container as AthosContainer | undefined) ?? AthosContainer.getRootInstance(\n\t\t\t...((options.providers ?? []) as HavenProvider[]),\n\t\t);\n\t\tconst setup = await ProApplication.createSetup({\n\t\t\t...options,\n\t\t\tcontainer: container as AthosContainer,\n\t\t} as ProApplicationSetupOptions);\n\t\tconst kernel = (setup.builder as any).build();\n\t\t(kernel as any).container = setup.container;\n\n\t\treturn {\n\t\t\t...(setup as any),\n\t\t\tkernel: kernel as any,\n\t\t} as ProApplicationResult;\n\t}\n}\n\nexport const createProApplicationBuilder = ProApplication.createBuilder;\nexport const createProApplicationSetup = ProApplication.createSetup;\nexport const createProApplication = ProApplication.create;\n"],"names":["ProApplication","createBuilder","options","builder","createApplicationBuilder","container","createContainer","providers","logger","provide","ATHOS_LOGGER_TOKEN","telemetrySink","ATHOS_TELEMETRY_SINK_TOKEN","capabilities","has","capability","provider","attach","containerAttach","createSetup","modules","installModules","manifests","plugins","create","AthosContainer","getRootInstance","setup","kernel","build","createProApplicationBuilder","createProApplicationSetup","createProApplication"],"mappings":";;;;;AAiBO,MAAMA,cAAAA,CAAAA;IACZ,OAAOC,aAAAA,CAAcC,OAAqC,EAA+B;AACxF,QAAA,MAAMC,UAAUC,wBAAAA,CAAyBF,OAAAA,CAAAA;QACzC,MAAMG,SAAAA,GACL,OAACH,CAAQG,SAAS,IAClBC,eAAAA,CAAAA,GAAqBJ,OAAAA,CAAQK,SAAS,IAAI,EAAE,CAAA;QAE7C,IAAIL,OAAAA,CAAQM,MAAM,EAAE;AACnBL,YAAAA,OAAAA,CAAQM,OAAO,CAACC,kBAAAA,EAAoBR,OAAAA,CAAQM,MAAM,CAAA;AACnD,QAAA;QAEA,IAAIN,OAAAA,CAAQS,aAAa,EAAE;AAC1BR,YAAAA,OAAAA,CAAQM,OAAO,CAACG,0BAAAA,EAA4BV,OAAAA,CAAQS,aAAa,CAAA;AAClE,QAAA;AAEA,QAAA,IAAI,CAACR,OAAAA,CAAQU,YAAY,CAACC,GAAG,CAAC,aAAA,CAAA,EAAgB;YAC7CX,OAAAA,CAAQY,UAAU,CAAC,aAAA,EAAe;gBAAEC,QAAAA,EAAU;aAAM,EAAG,KAAA,CAAA;AACxD,QAAA;AAECX,QAAAA,SAAAA,CAA6BY,MAAM,CAACd,OAAAA,EAAgBD,OAAAA,CAAQgB,eAAe,CAAA;QAE5E,OAAO;AACNf,YAAAA,OAAAA;AACAE,YAAAA;AACD,SAAA;AACD,IAAA;IAEA,aAAac,WAAAA,CAAYjB,OAAmC,EAAsC;QACjG,MAAM,EAAEC,OAAO,EAAEE,SAAS,EAAE,GAAGL,cAAAA,CAAeC,aAAa,CAACC,OAAAA,CAAAA;QAC5D,MAAMkB,OAAAA,GAAU,MAAMC,cAAAA,CAAelB,OAAAA,EAAgB;YACpDmB,SAAAA,EAAW;mBAAMpB,OAAAA,CAAQoB,SAAS,IAAI;AAAY,aAAA;YAClD,GAAKpB,OAAAA,CAAgBqB,OAAO,GAAG;gBAAEA,OAAAA,EAAUrB,QAAgBqB;AAAQ,aAAA,GAAI;AACxE,SAAA,CAAA;QAEA,OAAO;YACNpB,OAAAA,EAASA,OAAAA;YACTE,SAAAA,EAAWA,SAAAA;YACXe,OAAAA,EAASA;AACV,SAAA;AACD,IAAA;IAEA,aAAaI,MAAAA,CAAOtB,OAAmC,EAAiC;QACvF,MAAMG,SAAAA,GAAY,OAACH,CAAQG,SAAS,IAAmCoB,cAAAA,CAAeC,eAAe,CAAA,GAC/FxB,OAAAA,CAAQK,SAAS,IAAI,EAAE,CAAA;AAE7B,QAAA,MAAMoB,KAAAA,GAAQ,MAAM3B,cAAAA,CAAemB,WAAW,CAAC;AAC9C,YAAA,GAAGjB,OAAO;YACVG,SAAAA,EAAWA;AACZ,SAAA,CAAA;AACA,QAAA,MAAMuB,MAAAA,GAAUD,KAAAA,CAAMxB,OAAO,CAAS0B,KAAK,EAAA;QAC1CD,MAAAA,CAAevB,SAAS,GAAGsB,KAAAA,CAAMtB,SAAS;QAE3C,OAAO;AACN,YAAA,GAAIsB,KAAK;YACTC,MAAAA,EAAQA;AACT,SAAA;AACD,IAAA;AACD;AAEO,MAAME,2BAAAA,GAA8B9B,cAAAA,CAAeC;AACnD,MAAM8B,yBAAAA,GAA4B/B,cAAAA,CAAemB;AACjD,MAAMa,oBAAAA,GAAuBhC,cAAAA,CAAewB;;;;"}
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ function createDefaultProHttpProfile(overrides = {}) {
4
+ return {
5
+ name: "default",
6
+ ...overrides.router ? {
7
+ router: overrides.router
8
+ } : {},
9
+ observability: {
10
+ enabled: false,
11
+ ...overrides.observability ?? {}
12
+ }
13
+ };
14
+ }
15
+ function createProductionProHttpProfile(overrides = {}) {
16
+ return {
17
+ name: "production",
18
+ router: {
19
+ matchCacheSize: 256,
20
+ ...overrides.router ?? {}
21
+ },
22
+ observability: {
23
+ enabled: false,
24
+ logRequests: "errors",
25
+ sampleRate: 0.1,
26
+ alwaysSampleErrors: true,
27
+ maxPendingTelemetryEvents: 2048,
28
+ ...overrides.observability ?? {}
29
+ }
30
+ };
31
+ }
32
+ function resolveProHttpProfile(profile) {
33
+ if (!profile || profile === "default") {
34
+ return createDefaultProHttpProfile();
35
+ }
36
+ if (profile === "production") {
37
+ return createProductionProHttpProfile();
38
+ }
39
+ if (profile.name === "production") {
40
+ return createProductionProHttpProfile(profile);
41
+ }
42
+ return createDefaultProHttpProfile(profile);
43
+ }
44
+
45
+ exports.createDefaultProHttpProfile = createDefaultProHttpProfile;
46
+ exports.createProductionProHttpProfile = createProductionProHttpProfile;
47
+ exports.resolveProHttpProfile = resolveProHttpProfile;
48
+ //# sourceMappingURL=http-profile.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-profile.cjs","sources":["../../../packages/pro/src/http-profile.ts"],"sourcesContent":["import type { ProHttpProfile, ProHttpProfileName } from \"@athosjs/types/pro\";\n\nexport type { ProHttpProfile, ProHttpProfileName };\n\nexport function createDefaultProHttpProfile(overrides: Partial<ProHttpProfile> = {}): ProHttpProfile {\n\treturn {\n\t\tname: \"default\",\n\t\t...(overrides.router ? { router: overrides.router } : {}),\n\t\tobservability: {\n\t\t\tenabled: false,\n\t\t\t...(overrides.observability ?? {}),\n\t\t},\n\t};\n}\n\nexport function createProductionProHttpProfile(overrides: Partial<ProHttpProfile> = {}): ProHttpProfile {\n\treturn {\n\t\tname: \"production\",\n\t\trouter: {\n\t\t\tmatchCacheSize: 256,\n\t\t\t...((overrides.router ?? {}) as Record<string, unknown>),\n\t\t},\n\t\tobservability: {\n\t\t\tenabled: false,\n\t\t\tlogRequests: \"errors\",\n\t\t\tsampleRate: 0.1,\n\t\t\talwaysSampleErrors: true,\n\t\t\tmaxPendingTelemetryEvents: 2048,\n\t\t\t...(overrides.observability ?? {}),\n\t\t},\n\t};\n}\n\nexport function resolveProHttpProfile(profile?: ProHttpProfileName | ProHttpProfile | undefined): ProHttpProfile {\n\tif (!profile || profile === \"default\") {\n\t\treturn createDefaultProHttpProfile();\n\t}\n\n\tif (profile === \"production\") {\n\t\treturn createProductionProHttpProfile();\n\t}\n\n\tif (profile.name === \"production\") {\n\t\treturn createProductionProHttpProfile(profile);\n\t}\n\n\treturn createDefaultProHttpProfile(profile);\n}\n"],"names":["createDefaultProHttpProfile","overrides","name","router","observability","enabled","createProductionProHttpProfile","matchCacheSize","logRequests","sampleRate","alwaysSampleErrors","maxPendingTelemetryEvents","resolveProHttpProfile","profile"],"mappings":";;AAIO,SAASA,2BAAAA,CAA4BC,SAAAA,GAAqC,EAAE,EAAA;IAClF,OAAO;QACNC,IAAAA,EAAM,SAAA;QACN,GAAID,SAAAA,CAAUE,MAAM,GAAG;AAAEA,YAAAA,MAAAA,EAAQF,UAAUE;AAAO,SAAA,GAAI,EAAE;QACxDC,aAAAA,EAAe;YACdC,OAAAA,EAAS,KAAA;AACT,YAAA,GAAIJ,SAAAA,CAAUG,aAAa,IAAI;AAChC;AACD,KAAA;AACD;AAEO,SAASE,8BAAAA,CAA+BL,SAAAA,GAAqC,EAAE,EAAA;IACrF,OAAO;QACNC,IAAAA,EAAM,YAAA;QACNC,MAAAA,EAAQ;YACPI,cAAAA,EAAgB,GAAA;AAChB,YAAA,GAAKN,SAAAA,CAAUE,MAAM,IAAI;AAC1B,SAAA;QACAC,aAAAA,EAAe;YACdC,OAAAA,EAAS,KAAA;YACTG,WAAAA,EAAa,QAAA;YACbC,UAAAA,EAAY,GAAA;YACZC,kBAAAA,EAAoB,IAAA;YACpBC,yBAAAA,EAA2B,IAAA;AAC3B,YAAA,GAAIV,SAAAA,CAAUG,aAAa,IAAI;AAChC;AACD,KAAA;AACD;AAEO,SAASQ,sBAAsBC,OAAyD,EAAA;IAC9F,IAAI,CAACA,OAAAA,IAAWA,OAAAA,KAAY,SAAA,EAAW;QACtC,OAAOb,2BAAAA,EAAAA;AACR,IAAA;AAEA,IAAA,IAAIa,YAAY,YAAA,EAAc;QAC7B,OAAOP,8BAAAA,EAAAA;AACR,IAAA;IAEA,IAAIO,OAAAA,CAAQX,IAAI,KAAK,YAAA,EAAc;AAClC,QAAA,OAAOI,8BAAAA,CAA+BO,OAAAA,CAAAA;AACvC,IAAA;AAEA,IAAA,OAAOb,2BAAAA,CAA4Ba,OAAAA,CAAAA;AACpC;;;;;;"}
@@ -0,0 +1,6 @@
1
+ import type { ProHttpProfile, ProHttpProfileName } from "@athosjs/types/pro";
2
+ export type { ProHttpProfile, ProHttpProfileName };
3
+ export declare function createDefaultProHttpProfile(overrides?: Partial<ProHttpProfile>): ProHttpProfile;
4
+ export declare function createProductionProHttpProfile(overrides?: Partial<ProHttpProfile>): ProHttpProfile;
5
+ export declare function resolveProHttpProfile(profile?: ProHttpProfileName | ProHttpProfile | undefined): ProHttpProfile;
6
+ //# sourceMappingURL=http-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-profile.d.ts","sourceRoot":"","sources":["../../../../../../packages/pro/src/http-profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;AAEnD,wBAAgB,2BAA2B,CAAC,SAAS,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,cAAc,CASnG;AAED,wBAAgB,8BAA8B,CAAC,SAAS,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,cAAc,CAgBtG;AAED,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,GAAG,SAAS,GAAG,cAAc,CAc/G"}
@@ -0,0 +1,44 @@
1
+ function createDefaultProHttpProfile(overrides = {}) {
2
+ return {
3
+ name: "default",
4
+ ...overrides.router ? {
5
+ router: overrides.router
6
+ } : {},
7
+ observability: {
8
+ enabled: false,
9
+ ...overrides.observability ?? {}
10
+ }
11
+ };
12
+ }
13
+ function createProductionProHttpProfile(overrides = {}) {
14
+ return {
15
+ name: "production",
16
+ router: {
17
+ matchCacheSize: 256,
18
+ ...overrides.router ?? {}
19
+ },
20
+ observability: {
21
+ enabled: false,
22
+ logRequests: "errors",
23
+ sampleRate: 0.1,
24
+ alwaysSampleErrors: true,
25
+ maxPendingTelemetryEvents: 2048,
26
+ ...overrides.observability ?? {}
27
+ }
28
+ };
29
+ }
30
+ function resolveProHttpProfile(profile) {
31
+ if (!profile || profile === "default") {
32
+ return createDefaultProHttpProfile();
33
+ }
34
+ if (profile === "production") {
35
+ return createProductionProHttpProfile();
36
+ }
37
+ if (profile.name === "production") {
38
+ return createProductionProHttpProfile(profile);
39
+ }
40
+ return createDefaultProHttpProfile(profile);
41
+ }
42
+
43
+ export { createDefaultProHttpProfile, createProductionProHttpProfile, resolveProHttpProfile };
44
+ //# sourceMappingURL=http-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-profile.js","sources":["../../../packages/pro/src/http-profile.ts"],"sourcesContent":["import type { ProHttpProfile, ProHttpProfileName } from \"@athosjs/types/pro\";\n\nexport type { ProHttpProfile, ProHttpProfileName };\n\nexport function createDefaultProHttpProfile(overrides: Partial<ProHttpProfile> = {}): ProHttpProfile {\n\treturn {\n\t\tname: \"default\",\n\t\t...(overrides.router ? { router: overrides.router } : {}),\n\t\tobservability: {\n\t\t\tenabled: false,\n\t\t\t...(overrides.observability ?? {}),\n\t\t},\n\t};\n}\n\nexport function createProductionProHttpProfile(overrides: Partial<ProHttpProfile> = {}): ProHttpProfile {\n\treturn {\n\t\tname: \"production\",\n\t\trouter: {\n\t\t\tmatchCacheSize: 256,\n\t\t\t...((overrides.router ?? {}) as Record<string, unknown>),\n\t\t},\n\t\tobservability: {\n\t\t\tenabled: false,\n\t\t\tlogRequests: \"errors\",\n\t\t\tsampleRate: 0.1,\n\t\t\talwaysSampleErrors: true,\n\t\t\tmaxPendingTelemetryEvents: 2048,\n\t\t\t...(overrides.observability ?? {}),\n\t\t},\n\t};\n}\n\nexport function resolveProHttpProfile(profile?: ProHttpProfileName | ProHttpProfile | undefined): ProHttpProfile {\n\tif (!profile || profile === \"default\") {\n\t\treturn createDefaultProHttpProfile();\n\t}\n\n\tif (profile === \"production\") {\n\t\treturn createProductionProHttpProfile();\n\t}\n\n\tif (profile.name === \"production\") {\n\t\treturn createProductionProHttpProfile(profile);\n\t}\n\n\treturn createDefaultProHttpProfile(profile);\n}\n"],"names":["createDefaultProHttpProfile","overrides","name","router","observability","enabled","createProductionProHttpProfile","matchCacheSize","logRequests","sampleRate","alwaysSampleErrors","maxPendingTelemetryEvents","resolveProHttpProfile","profile"],"mappings":"AAIO,SAASA,2BAAAA,CAA4BC,SAAAA,GAAqC,EAAE,EAAA;IAClF,OAAO;QACNC,IAAAA,EAAM,SAAA;QACN,GAAID,SAAAA,CAAUE,MAAM,GAAG;AAAEA,YAAAA,MAAAA,EAAQF,UAAUE;AAAO,SAAA,GAAI,EAAE;QACxDC,aAAAA,EAAe;YACdC,OAAAA,EAAS,KAAA;AACT,YAAA,GAAIJ,SAAAA,CAAUG,aAAa,IAAI;AAChC;AACD,KAAA;AACD;AAEO,SAASE,8BAAAA,CAA+BL,SAAAA,GAAqC,EAAE,EAAA;IACrF,OAAO;QACNC,IAAAA,EAAM,YAAA;QACNC,MAAAA,EAAQ;YACPI,cAAAA,EAAgB,GAAA;AAChB,YAAA,GAAKN,SAAAA,CAAUE,MAAM,IAAI;AAC1B,SAAA;QACAC,aAAAA,EAAe;YACdC,OAAAA,EAAS,KAAA;YACTG,WAAAA,EAAa,QAAA;YACbC,UAAAA,EAAY,GAAA;YACZC,kBAAAA,EAAoB,IAAA;YACpBC,yBAAAA,EAA2B,IAAA;AAC3B,YAAA,GAAIV,SAAAA,CAAUG,aAAa,IAAI;AAChC;AACD,KAAA;AACD;AAEO,SAASQ,sBAAsBC,OAAyD,EAAA;IAC9F,IAAI,CAACA,OAAAA,IAAWA,OAAAA,KAAY,SAAA,EAAW;QACtC,OAAOb,2BAAAA,EAAAA;AACR,IAAA;AAEA,IAAA,IAAIa,YAAY,YAAA,EAAc;QAC7B,OAAOP,8BAAAA,EAAAA;AACR,IAAA;IAEA,IAAIO,OAAAA,CAAQX,IAAI,KAAK,YAAA,EAAc;AAClC,QAAA,OAAOI,8BAAAA,CAA+BO,OAAAA,CAAAA;AACvC,IAAA;AAEA,IAAA,OAAOb,2BAAAA,CAA4Ba,OAAAA,CAAAA;AACpC;;;;"}