@kopai/app 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 Kopai Authors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # @kopai/app
2
+
3
+ Local OpenTelemetry backend with an http/json Otel collector, Otel data storage and API to query the data.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npx @kopai/app start
9
+ ```
10
+
11
+ Starts two servers:
12
+
13
+ - **API server** on port 8000 (query traces, logs, metrics)
14
+ - **OTEL collector** on port 4318 (receives OTLP/HTTP data)
15
+
16
+ ## Kopai App server usage
17
+
18
+ ```bash
19
+ npx @kopai/app <command>
20
+ ```
21
+
22
+ ### Commands
23
+
24
+ | Command | Description |
25
+ | ------- | ----------------- |
26
+ | `start` | Start the server |
27
+ | `help` | Show help message |
28
+
29
+ ### Options
30
+
31
+ | Option | Description |
32
+ | --------------- | ----------------- |
33
+ | `-h, --help` | Show help message |
34
+ | `-v, --version` | Show version |
35
+
36
+ ### Global Install (optional)
37
+
38
+ ```bash
39
+ npm install -g @kopai/app
40
+ kopai-server start
41
+ ```
42
+
43
+ ## Environment Variables
44
+
45
+ | Variable | Default | Description |
46
+ | --------------------- | ----------- | ---------------------------- |
47
+ | `SQLITE_DB_FILE_PATH` | `:memory:` | Path to SQLite database file |
48
+ | `PORT` | `8000` | API server port |
49
+ | `HOST` | `localhost` | Host to bind |
50
+
51
+ ### Examples
52
+
53
+ ```bash
54
+ # [In-memory](https://www.sqlite.org/inmemorydb.html) database (default)
55
+ npx @kopai/app start
56
+
57
+ # Persistent database [sqlite db path](https://nodejs.org/api/sqlite.html)
58
+ SQLITE_DB_FILE_PATH=./data.db npx @kopai/app start
59
+
60
+ # Custom port
61
+ PORT=3000 npx @kopai/app start
62
+ ```
63
+
64
+ ## Endpoints
65
+
66
+ - **OTEL Collector** - `localhost:4318` - [OTLP/HTTP endpoints](https://opentelemetry.io/docs/specs/otlp/#otlphttp-request)
67
+ - **API Server** - `localhost:8000` - see [/documentation](http://localhost:8000/documentation) for available endpoints
68
+
69
+ ## Sending Telemetry
70
+
71
+ Your application needs an [OpenTelemetry SDK](https://opentelemetry.io/docs/languages/) for your language.
72
+
73
+ Configure it to export OTLP/HTTP data to `http://localhost:4318`:
74
+
75
+ ```bash
76
+ export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
77
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
78
+ ```
79
+
80
+ See [OTLP Exporter Configuration](https://opentelemetry.io/docs/specs/otel/protocol/exporter/#example-1) for more details.
81
+
82
+ ## Example Workflow
83
+
84
+ ### 1. Start Kopai
85
+
86
+ ```bash
87
+ npx @kopai/app start
88
+ ```
89
+
90
+ ### 2. Run your instrumented app
91
+
92
+ ```bash
93
+ export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
94
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
95
+ export OTEL_SERVICE_NAME=my-app
96
+
97
+ node my-app.js
98
+ ```
99
+
100
+ ### 3. Query your telemetry data
101
+
102
+ **Search traces:**
103
+
104
+ ```bash
105
+ curl -X POST http://localhost:8000/signals/traces/search \
106
+ -H "Content-Type: application/json" \
107
+ -d '{"serviceName": "my-app"}'
108
+ ```
109
+
110
+ **Get a specific trace:**
111
+
112
+ ```bash
113
+ curl http://localhost:8000/signals/traces/<traceId>
114
+ ```
115
+
116
+ **Search logs:**
117
+
118
+ ```bash
119
+ curl -X POST http://localhost:8000/signals/logs/search \
120
+ -H "Content-Type: application/json" \
121
+ -d '{"serviceName": "my-app"}'
122
+ ```
123
+
124
+ **Discover available metrics:**
125
+
126
+ ```bash
127
+ curl http://localhost:8000/signals/metrics/discover
128
+ ```
129
+
130
+ **Search metrics:**
131
+
132
+ ```bash
133
+ curl -X POST http://localhost:8000/signals/metrics/search \
134
+ -H "Content-Type: application/json" \
135
+ -d '{"metricName": "http.server.duration"}'
136
+ ```
137
+
138
+ ### Query telemetry data using @kopai/cli (recommended)
139
+
140
+ [@kopai/cli](https://github.com/kopai-app/kopai-mono/tree/main/packages/cli) provides a simpler interface for querying data. It's also better suited for LLM agents.
141
+
142
+ ```bash
143
+ # Search traces
144
+ npx @kopai/cli traces search --service my-app
145
+
146
+ # Get a specific trace
147
+ npx @kopai/cli traces get <traceId>
148
+
149
+ # Search logs
150
+ npx @kopai/cli logs search --service my-app
151
+
152
+ # Discover metrics
153
+ npx @kopai/cli metrics discover
154
+
155
+ # Search metrics
156
+ npx @kopai/cli metrics search --type Gauge --name http.server.duration
157
+ ```
158
+
159
+ See [@kopai/cli README](https://github.com/kopai-app/kopai-mono/tree/main/packages/cli) for all available options.
package/dist/cli.cjs ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ const require_config = require('./config-Bf8VglYn.cjs');
3
+ let node_util = require("node:util");
4
+ let node_module = require("node:module");
5
+
6
+ //#region src/version.ts
7
+ const pkg = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("../package.json");
8
+ const version = pkg.version;
9
+
10
+ //#endregion
11
+ //#region src/cli.ts
12
+ const { values, positionals } = (0, node_util.parseArgs)({
13
+ allowPositionals: true,
14
+ options: {
15
+ help: {
16
+ type: "boolean",
17
+ short: "h"
18
+ },
19
+ version: {
20
+ type: "boolean",
21
+ short: "v"
22
+ }
23
+ }
24
+ });
25
+ const command = positionals[0];
26
+ function showHelp() {
27
+ console.log(`
28
+ @kopai/app v${version} - OpenTelemetry collector and API server
29
+
30
+ Usage: npx @kopai/app <command>
31
+
32
+ Commands:
33
+ start Start the server
34
+ help Show this help message
35
+
36
+ Options:
37
+ -h, --help Show this help message
38
+ -v, --version Show version
39
+
40
+ Environment:
41
+ SQLITE_DB_FILE_PATH Path to SQLite database (default: :memory:)
42
+ PORT API server port (default: 8000)
43
+ HOST Host to bind (default: localhost)
44
+ `);
45
+ }
46
+ if (values.version) {
47
+ console.log(version);
48
+ process.exit(0);
49
+ }
50
+ if (values.help || command === "help" || !command) {
51
+ showHelp();
52
+ process.exit(0);
53
+ }
54
+ if (command === "start") Promise.resolve().then(() => require("./server-Bci2-vxj.cjs"));
55
+ else {
56
+ console.error(`Unknown command: ${command}`);
57
+ showHelp();
58
+ process.exit(1);
59
+ }
60
+
61
+ //#endregion
62
+ exports.version = version;
package/dist/cli.d.cts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.mjs ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ import { parseArgs } from "node:util";
4
+
5
+ //#region src/version.ts
6
+ const pkg = createRequire(import.meta.url)("../package.json");
7
+ const version = pkg.version;
8
+
9
+ //#endregion
10
+ //#region src/cli.ts
11
+ const { values, positionals } = parseArgs({
12
+ allowPositionals: true,
13
+ options: {
14
+ help: {
15
+ type: "boolean",
16
+ short: "h"
17
+ },
18
+ version: {
19
+ type: "boolean",
20
+ short: "v"
21
+ }
22
+ }
23
+ });
24
+ const command = positionals[0];
25
+ function showHelp() {
26
+ console.log(`
27
+ @kopai/app v${version} - OpenTelemetry collector and API server
28
+
29
+ Usage: npx @kopai/app <command>
30
+
31
+ Commands:
32
+ start Start the server
33
+ help Show this help message
34
+
35
+ Options:
36
+ -h, --help Show this help message
37
+ -v, --version Show version
38
+
39
+ Environment:
40
+ SQLITE_DB_FILE_PATH Path to SQLite database (default: :memory:)
41
+ PORT API server port (default: 8000)
42
+ HOST Host to bind (default: localhost)
43
+ `);
44
+ }
45
+ if (values.version) {
46
+ console.log(version);
47
+ process.exit(0);
48
+ }
49
+ if (values.help || command === "help" || !command) {
50
+ showHelp();
51
+ process.exit(0);
52
+ }
53
+ if (command === "start") import("./server-DZHgJbDT.mjs");
54
+ else {
55
+ console.error(`Unknown command: ${command}`);
56
+ showHelp();
57
+ process.exit(1);
58
+ }
59
+
60
+ //#endregion
61
+ export { version as t };
62
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","names":[],"sources":["../src/version.ts","../src/cli.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\");\n\nexport const version: string = pkg.version;\n","#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { version } from \"./version.js\";\n\nconst { values, positionals } = parseArgs({\n allowPositionals: true,\n options: {\n help: { type: \"boolean\", short: \"h\" },\n version: { type: \"boolean\", short: \"v\" },\n },\n});\n\nconst command = positionals[0];\n\nfunction showHelp() {\n console.log(`\n@kopai/app v${version} - OpenTelemetry collector and API server\n\nUsage: npx @kopai/app <command>\n\nCommands:\n start Start the server\n help Show this help message\n\nOptions:\n -h, --help Show this help message\n -v, --version Show version\n\nEnvironment:\n SQLITE_DB_FILE_PATH Path to SQLite database (default: :memory:)\n PORT API server port (default: 8000)\n HOST Host to bind (default: localhost)\n`);\n}\n\nif (values.version) {\n console.log(version);\n process.exit(0);\n}\n\nif (values.help || command === \"help\" || !command) {\n showHelp();\n process.exit(0);\n}\n\nif (command === \"start\") {\n import(\"./server.js\");\n} else {\n console.error(`Unknown command: ${command}`);\n showHelp();\n process.exit(1);\n}\n"],"mappings":";;;;;AAGA,MAAM,MADU,cAAc,OAAO,KAAK,IAAI,CAC1B,kBAAkB;AAEtC,MAAa,UAAkB,IAAI;;;;ACDnC,MAAM,EAAE,QAAQ,gBAAgB,UAAU;CACxC,kBAAkB;CAClB,SAAS;EACP,MAAM;GAAE,MAAM;GAAW,OAAO;GAAK;EACrC,SAAS;GAAE,MAAM;GAAW,OAAO;GAAK;EACzC;CACF,CAAC;AAEF,MAAM,UAAU,YAAY;AAE5B,SAAS,WAAW;AAClB,SAAQ,IAAI;cACA,QAAQ;;;;;;;;;;;;;;;;EAgBpB;;AAGF,IAAI,OAAO,SAAS;AAClB,SAAQ,IAAI,QAAQ;AACpB,SAAQ,KAAK,EAAE;;AAGjB,IAAI,OAAO,QAAQ,YAAY,UAAU,CAAC,SAAS;AACjD,WAAU;AACV,SAAQ,KAAK,EAAE;;AAGjB,IAAI,YAAY,QACd,QAAO;KACF;AACL,SAAQ,MAAM,oBAAoB,UAAU;AAC5C,WAAU;AACV,SAAQ,KAAK,EAAE"}
@@ -0,0 +1,53 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ let zod = require("zod");
29
+ zod = __toESM(zod);
30
+
31
+ //#region src/config.ts
32
+ const DEFAULT_PORT = 8e3;
33
+ const envSchema = zod.default.object({
34
+ NODE_ENV: zod.default.string().optional(),
35
+ HOST: zod.default.string().optional(),
36
+ SQLITE_DB_FILE_PATH: zod.default.string().default(":memory:"),
37
+ PORT: zod.default.string().optional().transform((val) => val ? parseInt(val, 10) : DEFAULT_PORT)
38
+ });
39
+ const env = envSchema.parse(process.env);
40
+
41
+ //#endregion
42
+ Object.defineProperty(exports, '__toESM', {
43
+ enumerable: true,
44
+ get: function () {
45
+ return __toESM;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, 'env', {
49
+ enumerable: true,
50
+ get: function () {
51
+ return env;
52
+ }
53
+ });
@@ -0,0 +1,15 @@
1
+ import z from "zod";
2
+
3
+ //#region src/config.ts
4
+ const DEFAULT_PORT = 8e3;
5
+ const envSchema = z.object({
6
+ NODE_ENV: z.string().optional(),
7
+ HOST: z.string().optional(),
8
+ SQLITE_DB_FILE_PATH: z.string().default(":memory:"),
9
+ PORT: z.string().optional().transform((val) => val ? parseInt(val, 10) : DEFAULT_PORT)
10
+ });
11
+ const env = envSchema.parse(process.env);
12
+
13
+ //#endregion
14
+ export { env as t };
15
+ //# sourceMappingURL=config-CJN47Wnk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-CJN47Wnk.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import z from \"zod\";\n\nconst DEFAULT_PORT = 8000;\n\nconst envSchema = z.object({\n NODE_ENV: z.string().optional(),\n HOST: z.string().optional(),\n SQLITE_DB_FILE_PATH: z.string().default(\":memory:\"),\n PORT: z\n .string()\n .optional()\n .transform((val) => (val ? parseInt(val, 10) : DEFAULT_PORT)),\n});\n\nexport const env = envSchema.parse(process.env);\n"],"mappings":";;;AAEA,MAAM,eAAe;AAErB,MAAM,YAAY,EAAE,OAAO;CACzB,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,qBAAqB,EAAE,QAAQ,CAAC,QAAQ,WAAW;CACnD,MAAM,EACH,QAAQ,CACR,UAAU,CACV,WAAW,QAAS,MAAM,SAAS,KAAK,GAAG,GAAG,aAAc;CAChE,CAAC;AAEF,MAAa,MAAM,UAAU,MAAM,QAAQ,IAAI"}
package/dist/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ const require_config = require('./config-Bf8VglYn.cjs');
2
+
3
+ exports.env = require_config.env;
@@ -0,0 +1,10 @@
1
+ //#region src/config.d.ts
2
+ declare const env: {
3
+ SQLITE_DB_FILE_PATH: string;
4
+ PORT: number;
5
+ NODE_ENV?: string | undefined;
6
+ HOST?: string | undefined;
7
+ };
8
+ //#endregion
9
+ export { env };
10
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";cAca,GAAA"}
@@ -0,0 +1,10 @@
1
+ //#region src/config.d.ts
2
+ declare const env: {
3
+ SQLITE_DB_FILE_PATH: string;
4
+ PORT: number;
5
+ NODE_ENV?: string | undefined;
6
+ HOST?: string | undefined;
7
+ };
8
+ //#endregion
9
+ export { env };
10
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";cAca,GAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { t as env } from "./config-CJN47Wnk.mjs";
2
+
3
+ export { env };
@@ -0,0 +1,120 @@
1
+ const require_config = require('./config-Bf8VglYn.cjs');
2
+ const require_cli = require('./cli.cjs');
3
+ let fastify = require("fastify");
4
+ fastify = require_config.__toESM(fastify);
5
+ let fastify_type_provider_zod = require("fastify-type-provider-zod");
6
+ let _fastify_swagger = require("@fastify/swagger");
7
+ _fastify_swagger = require_config.__toESM(_fastify_swagger);
8
+ let _fastify_swagger_ui = require("@fastify/swagger-ui");
9
+ _fastify_swagger_ui = require_config.__toESM(_fastify_swagger_ui);
10
+ let close_with_grace = require("close-with-grace");
11
+ close_with_grace = require_config.__toESM(close_with_grace);
12
+ let _kopai_api = require("@kopai/api");
13
+ require("@kopai/core");
14
+ let _kopai_collector = require("@kopai/collector");
15
+ let _kopai_sqlite_datasource = require("@kopai/sqlite-datasource");
16
+
17
+ //#region src/routes/index.ts
18
+ const apiRoutes = async function(fastify, opts) {
19
+ fastify.register(_kopai_api.signalsRoutes, { readTelemetryDatasource: opts.readTelemetryDatasource });
20
+ };
21
+
22
+ //#endregion
23
+ //#region src/collector/index.ts
24
+ const otelCollectorRoutes = async function(fastify, opts) {
25
+ fastify.register(_kopai_collector.collectorRoutes, opts);
26
+ };
27
+
28
+ //#endregion
29
+ //#region src/server.ts
30
+ const apiServer = (0, fastify.default)({ logger: true });
31
+ apiServer.setValidatorCompiler(fastify_type_provider_zod.validatorCompiler);
32
+ apiServer.setSerializerCompiler(fastify_type_provider_zod.serializerCompiler);
33
+ apiServer.register(_fastify_swagger.default, {
34
+ openapi: {
35
+ info: {
36
+ title: "Kopai App",
37
+ description: "Kopai App documentation",
38
+ version: require_cli.version
39
+ },
40
+ servers: []
41
+ },
42
+ transform: fastify_type_provider_zod.jsonSchemaTransform,
43
+ transformObject: fastify_type_provider_zod.jsonSchemaTransformObject
44
+ });
45
+ apiServer.register(_fastify_swagger_ui.default, {
46
+ routePrefix: "/documentation",
47
+ logo: {
48
+ type: "image/svg+xml",
49
+ content: Buffer.from("PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAgNDAiIGZpbGw9Im5vbmUiPjx0ZXh0IHg9IjAiIHk9IjI4IiBmb250LWZhbWlseT0iU3BhY2UgR3JvdGVzaywgc3lzdGVtLXVpLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjI0IiBmb250LXdlaWdodD0iNzAwIiBmaWxsPSIjZmFmYWZhIj5Lb3BhaTwvdGV4dD48L3N2Zz4K", "base64"),
50
+ href: "/documentation",
51
+ target: "_blank"
52
+ },
53
+ theme: { favicon: [{
54
+ filename: "favicon.svg",
55
+ rel: "icon",
56
+ sizes: "32x32",
57
+ type: "image/svg+xml",
58
+ content: Buffer.from("PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSI+PHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNCIgZmlsbD0iIzBhMGEwYSIvPjx0ZXh0IHg9IjQiIHk9IjIzIiBmb250LWZhbWlseT0ic3lzdGVtLXVpLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE4IiBmb250LXdlaWdodD0iNzAwIiBmaWxsPSIjZmFmYWZhIj5LPC90ZXh0Pjwvc3ZnPgo=", "base64")
59
+ }] }
60
+ });
61
+ const sqliteDatabase = (0, _kopai_sqlite_datasource.initializeDatabase)(require_config.env.SQLITE_DB_FILE_PATH);
62
+ apiServer.after(() => {
63
+ const telemetryDatasource = new _kopai_sqlite_datasource.NodeSqliteTelemetryDatasource(sqliteDatabase);
64
+ apiServer.register(apiRoutes, { readTelemetryDatasource: telemetryDatasource });
65
+ });
66
+ const collectorServer = (0, fastify.default)({ logger: true });
67
+ collectorServer.setValidatorCompiler(fastify_type_provider_zod.validatorCompiler);
68
+ collectorServer.setSerializerCompiler(fastify_type_provider_zod.serializerCompiler);
69
+ collectorServer.after(async () => {
70
+ const telemetryDatasource = new _kopai_sqlite_datasource.NodeSqliteTelemetryDatasource(sqliteDatabase);
71
+ collectorServer.register(otelCollectorRoutes, { telemetryDatasource });
72
+ });
73
+ async function run() {
74
+ console.log(`@kopai/app v${require_cli.version}`);
75
+ await apiServer.ready();
76
+ const host = require_config.env.HOST || "localhost";
77
+ const port = require_config.env.PORT;
78
+ const STANDARD_OTEL_HTTP_COLLECTOR_PORT = 4318;
79
+ apiServer.listen({
80
+ port,
81
+ host,
82
+ listenTextResolver(address) {
83
+ return `API server listening at ${address}`;
84
+ }
85
+ }, (err, address) => {
86
+ if (err) {
87
+ console.error(err);
88
+ process.exit(1);
89
+ }
90
+ apiServer.log.info(`API server documentation available at ${address}/documentation`);
91
+ });
92
+ await collectorServer.ready();
93
+ collectorServer.listen({
94
+ port: STANDARD_OTEL_HTTP_COLLECTOR_PORT,
95
+ host,
96
+ listenTextResolver(address) {
97
+ return `OTEL collector server listening at ${address}:${STANDARD_OTEL_HTTP_COLLECTOR_PORT}`;
98
+ }
99
+ }, (err) => {
100
+ if (err) {
101
+ console.error(err);
102
+ process.exit(1);
103
+ }
104
+ });
105
+ }
106
+ run();
107
+ (0, close_with_grace.default)(async ({ signal, err }) => {
108
+ if (err) {
109
+ collectorServer.log.fatal({ err }, "Closing OTEL collector server with error");
110
+ apiServer.log.fatal({ err }, "Closing API server with error");
111
+ } else {
112
+ collectorServer.log.info(`Received signal ${signal}, closing OTEL collector server`);
113
+ apiServer.log.info(`Received signal ${signal}, closing API server`);
114
+ }
115
+ await collectorServer.close();
116
+ sqliteDatabase?.close();
117
+ await apiServer.close();
118
+ });
119
+
120
+ //#endregion
@@ -0,0 +1,118 @@
1
+ import { t as env } from "./config-CJN47Wnk.mjs";
2
+ import { t as version } from "./cli.mjs";
3
+ import fastify from "fastify";
4
+ import { jsonSchemaTransform, jsonSchemaTransformObject, serializerCompiler, validatorCompiler } from "fastify-type-provider-zod";
5
+ import fastifySwagger from "@fastify/swagger";
6
+ import fastifySwaggerUI from "@fastify/swagger-ui";
7
+ import closeWithGrace from "close-with-grace";
8
+ import { signalsRoutes } from "@kopai/api";
9
+ import "@kopai/core";
10
+ import { collectorRoutes } from "@kopai/collector";
11
+ import { NodeSqliteTelemetryDatasource, initializeDatabase } from "@kopai/sqlite-datasource";
12
+
13
+ //#region src/routes/index.ts
14
+ const apiRoutes = async function(fastify, opts) {
15
+ fastify.register(signalsRoutes, { readTelemetryDatasource: opts.readTelemetryDatasource });
16
+ };
17
+
18
+ //#endregion
19
+ //#region src/collector/index.ts
20
+ const otelCollectorRoutes = async function(fastify, opts) {
21
+ fastify.register(collectorRoutes, opts);
22
+ };
23
+
24
+ //#endregion
25
+ //#region src/server.ts
26
+ const apiServer = fastify({ logger: true });
27
+ apiServer.setValidatorCompiler(validatorCompiler);
28
+ apiServer.setSerializerCompiler(serializerCompiler);
29
+ apiServer.register(fastifySwagger, {
30
+ openapi: {
31
+ info: {
32
+ title: "Kopai App",
33
+ description: "Kopai App documentation",
34
+ version
35
+ },
36
+ servers: []
37
+ },
38
+ transform: jsonSchemaTransform,
39
+ transformObject: jsonSchemaTransformObject
40
+ });
41
+ apiServer.register(fastifySwaggerUI, {
42
+ routePrefix: "/documentation",
43
+ logo: {
44
+ type: "image/svg+xml",
45
+ content: Buffer.from("PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAgNDAiIGZpbGw9Im5vbmUiPjx0ZXh0IHg9IjAiIHk9IjI4IiBmb250LWZhbWlseT0iU3BhY2UgR3JvdGVzaywgc3lzdGVtLXVpLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjI0IiBmb250LXdlaWdodD0iNzAwIiBmaWxsPSIjZmFmYWZhIj5Lb3BhaTwvdGV4dD48L3N2Zz4K", "base64"),
46
+ href: "/documentation",
47
+ target: "_blank"
48
+ },
49
+ theme: { favicon: [{
50
+ filename: "favicon.svg",
51
+ rel: "icon",
52
+ sizes: "32x32",
53
+ type: "image/svg+xml",
54
+ content: Buffer.from("PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSI+PHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNCIgZmlsbD0iIzBhMGEwYSIvPjx0ZXh0IHg9IjQiIHk9IjIzIiBmb250LWZhbWlseT0ic3lzdGVtLXVpLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE4IiBmb250LXdlaWdodD0iNzAwIiBmaWxsPSIjZmFmYWZhIj5LPC90ZXh0Pjwvc3ZnPgo=", "base64")
55
+ }] }
56
+ });
57
+ const sqliteDatabase = initializeDatabase(env.SQLITE_DB_FILE_PATH);
58
+ apiServer.after(() => {
59
+ const telemetryDatasource = new NodeSqliteTelemetryDatasource(sqliteDatabase);
60
+ apiServer.register(apiRoutes, { readTelemetryDatasource: telemetryDatasource });
61
+ });
62
+ const collectorServer = fastify({ logger: true });
63
+ collectorServer.setValidatorCompiler(validatorCompiler);
64
+ collectorServer.setSerializerCompiler(serializerCompiler);
65
+ collectorServer.after(async () => {
66
+ const telemetryDatasource = new NodeSqliteTelemetryDatasource(sqliteDatabase);
67
+ collectorServer.register(otelCollectorRoutes, { telemetryDatasource });
68
+ });
69
+ async function run() {
70
+ console.log(`@kopai/app v${version}`);
71
+ await apiServer.ready();
72
+ const host = env.HOST || "localhost";
73
+ const port = env.PORT;
74
+ const STANDARD_OTEL_HTTP_COLLECTOR_PORT = 4318;
75
+ apiServer.listen({
76
+ port,
77
+ host,
78
+ listenTextResolver(address) {
79
+ return `API server listening at ${address}`;
80
+ }
81
+ }, (err, address) => {
82
+ if (err) {
83
+ console.error(err);
84
+ process.exit(1);
85
+ }
86
+ apiServer.log.info(`API server documentation available at ${address}/documentation`);
87
+ });
88
+ await collectorServer.ready();
89
+ collectorServer.listen({
90
+ port: STANDARD_OTEL_HTTP_COLLECTOR_PORT,
91
+ host,
92
+ listenTextResolver(address) {
93
+ return `OTEL collector server listening at ${address}:${STANDARD_OTEL_HTTP_COLLECTOR_PORT}`;
94
+ }
95
+ }, (err) => {
96
+ if (err) {
97
+ console.error(err);
98
+ process.exit(1);
99
+ }
100
+ });
101
+ }
102
+ run();
103
+ closeWithGrace(async ({ signal, err }) => {
104
+ if (err) {
105
+ collectorServer.log.fatal({ err }, "Closing OTEL collector server with error");
106
+ apiServer.log.fatal({ err }, "Closing API server with error");
107
+ } else {
108
+ collectorServer.log.info(`Received signal ${signal}, closing OTEL collector server`);
109
+ apiServer.log.info(`Received signal ${signal}, closing API server`);
110
+ }
111
+ await collectorServer.close();
112
+ sqliteDatabase?.close();
113
+ await apiServer.close();
114
+ });
115
+
116
+ //#endregion
117
+ export { };
118
+ //# sourceMappingURL=server-DZHgJbDT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-DZHgJbDT.mjs","names":[],"sources":["../src/routes/index.ts","../src/collector/index.ts","../src/server.ts"],"sourcesContent":["import type { FastifyPluginAsyncZod } from \"fastify-type-provider-zod\";\nimport { signalsRoutes } from \"@kopai/api\";\nimport { type datasource } from \"@kopai/core\";\n\nexport const apiRoutes: FastifyPluginAsyncZod<{\n readTelemetryDatasource: datasource.ReadTelemetryDatasource;\n}> = async function (fastify, opts) {\n fastify.register(signalsRoutes, {\n readTelemetryDatasource: opts.readTelemetryDatasource,\n });\n};\n","import type { FastifyPluginAsyncZod } from \"fastify-type-provider-zod\";\nimport { collectorRoutes } from \"@kopai/collector\";\nimport type { datasource } from \"@kopai/core\";\n\nexport const otelCollectorRoutes: FastifyPluginAsyncZod<{\n telemetryDatasource: datasource.WriteTelemetryDatasource;\n}> = async function (fastify, opts) {\n fastify.register(collectorRoutes, opts);\n};\n","import fastify from \"fastify\";\nimport {\n jsonSchemaTransformObject,\n jsonSchemaTransform,\n serializerCompiler,\n validatorCompiler,\n} from \"fastify-type-provider-zod\";\nimport fastifySwagger from \"@fastify/swagger\";\nimport fastifySwaggerUI from \"@fastify/swagger-ui\";\nimport closeWithGrace from \"close-with-grace\";\n\nimport { env } from \"./config.js\";\nimport { version } from \"./version.js\";\nimport { apiRoutes } from \"./routes/index.js\";\nimport { otelCollectorRoutes } from \"./collector/index.js\";\nimport {\n initializeDatabase,\n NodeSqliteTelemetryDatasource,\n} from \"@kopai/sqlite-datasource\";\n\nconst apiServer = fastify({\n logger: true,\n});\n\n// Add schema validator and serializer\napiServer.setValidatorCompiler(validatorCompiler);\napiServer.setSerializerCompiler(serializerCompiler);\n\napiServer.register(fastifySwagger, {\n openapi: {\n info: {\n title: \"Kopai App\",\n description: \"Kopai App documentation\",\n version,\n },\n servers: [],\n },\n transform: jsonSchemaTransform,\n transformObject: jsonSchemaTransformObject,\n});\n\napiServer.register(fastifySwaggerUI, {\n routePrefix: \"/documentation\",\n logo: {\n type: \"image/svg+xml\",\n content: Buffer.from(\n \"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAgNDAiIGZpbGw9Im5vbmUiPjx0ZXh0IHg9IjAiIHk9IjI4IiBmb250LWZhbWlseT0iU3BhY2UgR3JvdGVzaywgc3lzdGVtLXVpLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjI0IiBmb250LXdlaWdodD0iNzAwIiBmaWxsPSIjZmFmYWZhIj5Lb3BhaTwvdGV4dD48L3N2Zz4K\",\n \"base64\"\n ),\n href: \"/documentation\",\n target: \"_blank\",\n },\n theme: {\n favicon: [\n {\n filename: \"favicon.svg\",\n rel: \"icon\",\n sizes: \"32x32\",\n type: \"image/svg+xml\",\n content: Buffer.from(\n \"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSI+PHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNCIgZmlsbD0iIzBhMGEwYSIvPjx0ZXh0IHg9IjQiIHk9IjIzIiBmb250LWZhbWlseT0ic3lzdGVtLXVpLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE4IiBmb250LXdlaWdodD0iNzAwIiBmaWxsPSIjZmFmYWZhIj5LPC90ZXh0Pjwvc3ZnPgo=\",\n \"base64\"\n ),\n },\n ],\n },\n});\n\nconst sqliteDatabase = initializeDatabase(env.SQLITE_DB_FILE_PATH);\n\napiServer.after(() => {\n const telemetryDatasource = new NodeSqliteTelemetryDatasource(sqliteDatabase);\n apiServer.register(apiRoutes, {\n readTelemetryDatasource: telemetryDatasource,\n });\n});\n\nconst collectorServer = fastify({\n logger: true,\n});\n\ncollectorServer.setValidatorCompiler(validatorCompiler);\ncollectorServer.setSerializerCompiler(serializerCompiler);\n\ncollectorServer.after(async () => {\n const telemetryDatasource = new NodeSqliteTelemetryDatasource(sqliteDatabase);\n collectorServer.register(otelCollectorRoutes, {\n telemetryDatasource,\n });\n});\n\nasync function run() {\n console.log(`@kopai/app v${version}`);\n\n await apiServer.ready();\n\n const host = env.HOST || \"localhost\";\n const port = env.PORT;\n const STANDARD_OTEL_HTTP_COLLECTOR_PORT = 4318;\n\n apiServer.listen(\n {\n port,\n host,\n listenTextResolver(address) {\n return `API server listening at ${address}`;\n },\n },\n (err, address) => {\n if (err) {\n console.error(err);\n process.exit(1);\n }\n apiServer.log.info(\n `API server documentation available at ${address}/documentation`\n );\n }\n );\n\n await collectorServer.ready();\n\n collectorServer.listen(\n {\n port: STANDARD_OTEL_HTTP_COLLECTOR_PORT,\n host,\n listenTextResolver(address) {\n return `OTEL collector server listening at ${address}:${STANDARD_OTEL_HTTP_COLLECTOR_PORT}`;\n },\n },\n (err) => {\n if (err) {\n console.error(err);\n process.exit(1);\n }\n }\n );\n}\n\nrun();\n\ncloseWithGrace(async ({ signal, err }) => {\n if (err) {\n collectorServer.log.fatal(\n { err },\n \"Closing OTEL collector server with error\"\n );\n apiServer.log.fatal({ err }, \"Closing API server with error\");\n } else {\n collectorServer.log.info(\n `Received signal ${signal}, closing OTEL collector server`\n );\n apiServer.log.info(`Received signal ${signal}, closing API server`);\n }\n\n await collectorServer.close();\n sqliteDatabase?.close();\n await apiServer.close();\n});\n"],"mappings":";;;;;;;;;;;;;AAIA,MAAa,YAER,eAAgB,SAAS,MAAM;AAClC,SAAQ,SAAS,eAAe,EAC9B,yBAAyB,KAAK,yBAC/B,CAAC;;;;;ACLJ,MAAa,sBAER,eAAgB,SAAS,MAAM;AAClC,SAAQ,SAAS,iBAAiB,KAAK;;;;;ACazC,MAAM,YAAY,QAAQ,EACxB,QAAQ,MACT,CAAC;AAGF,UAAU,qBAAqB,kBAAkB;AACjD,UAAU,sBAAsB,mBAAmB;AAEnD,UAAU,SAAS,gBAAgB;CACjC,SAAS;EACP,MAAM;GACJ,OAAO;GACP,aAAa;GACb;GACD;EACD,SAAS,EAAE;EACZ;CACD,WAAW;CACX,iBAAiB;CAClB,CAAC;AAEF,UAAU,SAAS,kBAAkB;CACnC,aAAa;CACb,MAAM;EACJ,MAAM;EACN,SAAS,OAAO,KACd,4RACA,SACD;EACD,MAAM;EACN,QAAQ;EACT;CACD,OAAO,EACL,SAAS,CACP;EACE,UAAU;EACV,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS,OAAO,KACd,wUACA,SACD;EACF,CACF,EACF;CACF,CAAC;AAEF,MAAM,iBAAiB,mBAAmB,IAAI,oBAAoB;AAElE,UAAU,YAAY;CACpB,MAAM,sBAAsB,IAAI,8BAA8B,eAAe;AAC7E,WAAU,SAAS,WAAW,EAC5B,yBAAyB,qBAC1B,CAAC;EACF;AAEF,MAAM,kBAAkB,QAAQ,EAC9B,QAAQ,MACT,CAAC;AAEF,gBAAgB,qBAAqB,kBAAkB;AACvD,gBAAgB,sBAAsB,mBAAmB;AAEzD,gBAAgB,MAAM,YAAY;CAChC,MAAM,sBAAsB,IAAI,8BAA8B,eAAe;AAC7E,iBAAgB,SAAS,qBAAqB,EAC5C,qBACD,CAAC;EACF;AAEF,eAAe,MAAM;AACnB,SAAQ,IAAI,eAAe,UAAU;AAErC,OAAM,UAAU,OAAO;CAEvB,MAAM,OAAO,IAAI,QAAQ;CACzB,MAAM,OAAO,IAAI;CACjB,MAAM,oCAAoC;AAE1C,WAAU,OACR;EACE;EACA;EACA,mBAAmB,SAAS;AAC1B,UAAO,2BAA2B;;EAErC,GACA,KAAK,YAAY;AAChB,MAAI,KAAK;AACP,WAAQ,MAAM,IAAI;AAClB,WAAQ,KAAK,EAAE;;AAEjB,YAAU,IAAI,KACZ,yCAAyC,QAAQ,gBAClD;GAEJ;AAED,OAAM,gBAAgB,OAAO;AAE7B,iBAAgB,OACd;EACE,MAAM;EACN;EACA,mBAAmB,SAAS;AAC1B,UAAO,sCAAsC,QAAQ,GAAG;;EAE3D,GACA,QAAQ;AACP,MAAI,KAAK;AACP,WAAQ,MAAM,IAAI;AAClB,WAAQ,KAAK,EAAE;;GAGpB;;AAGH,KAAK;AAEL,eAAe,OAAO,EAAE,QAAQ,UAAU;AACxC,KAAI,KAAK;AACP,kBAAgB,IAAI,MAClB,EAAE,KAAK,EACP,2CACD;AACD,YAAU,IAAI,MAAM,EAAE,KAAK,EAAE,gCAAgC;QACxD;AACL,kBAAgB,IAAI,KAClB,mBAAmB,OAAO,iCAC3B;AACD,YAAU,IAAI,KAAK,mBAAmB,OAAO,sBAAsB;;AAGrE,OAAM,gBAAgB,OAAO;AAC7B,iBAAgB,OAAO;AACvB,OAAM,UAAU,OAAO;EACvB"}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@kopai/app",
3
+ "version": "0.0.0",
4
+ "description": "Local OpenTelemetry backend for testing instrumentation - no Docker, no config, just npx",
5
+ "keywords": [
6
+ "opentelemetry",
7
+ "otlp",
8
+ "tracing",
9
+ "metrics",
10
+ "logs",
11
+ "observability",
12
+ "collector",
13
+ "local",
14
+ "testing",
15
+ "development",
16
+ "instrumentation"
17
+ ],
18
+ "license": "Apache-2.0",
19
+ "author": "Vladimir Adamic",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/kopai-app/kopai-mono.git",
23
+ "directory": "packages/app"
24
+ },
25
+ "homepage": "https://github.com/kopai-app/kopai-mono/tree/main/packages/app#readme",
26
+ "bugs": {
27
+ "url": "https://github.com/kopai-app/kopai-mono/issues"
28
+ },
29
+ "engines": {
30
+ "node": ">=20"
31
+ },
32
+ "type": "module",
33
+ "main": "./dist/index.cjs",
34
+ "module": "./dist/index.mjs",
35
+ "types": "./dist/index.d.ts",
36
+ "bin": {
37
+ "kopai-server": "./dist/cli.mjs"
38
+ },
39
+ "exports": {
40
+ ".": {
41
+ "types": "./dist/index.d.mts",
42
+ "import": "./dist/index.mjs",
43
+ "require": "./dist/index.cjs"
44
+ }
45
+ },
46
+ "files": [
47
+ "dist"
48
+ ],
49
+ "dependencies": {
50
+ "@fastify/swagger": "^9.6.1",
51
+ "@fastify/swagger-ui": "^5.2.4",
52
+ "close-with-grace": "^2.4.0",
53
+ "fastify": "^5.7.2",
54
+ "fastify-type-provider-zod": "^6.1.0",
55
+ "zod": "^4.3.6",
56
+ "@kopai/sqlite-datasource": "0.0.0",
57
+ "@kopai/collector": "0.0.0",
58
+ "@kopai/core": "0.0.0",
59
+ "@kopai/api": "0.0.0"
60
+ },
61
+ "devDependencies": {
62
+ "nodemon": "^3.1.11",
63
+ "tsdown": "^0.20.1",
64
+ "typescript": "^5.9.3",
65
+ "@kopai/tsconfig": "0.0.0"
66
+ },
67
+ "scripts": {
68
+ "build": "tsdown",
69
+ "dev": "tsdown --watch",
70
+ "lint": "eslint src",
71
+ "type-check": "tsc --noEmit",
72
+ "start": "node ./dist/cli.mjs start",
73
+ "start:dev": "nodemon --watch ./dist --watch '../*/dist' --env-file=.env ./dist/cli.mjs start"
74
+ }
75
+ }