@camstack/core 0.1.1 → 0.1.2

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 (66) hide show
  1. package/dist/builtins/local-backup/index.d.mts +42 -0
  2. package/dist/builtins/local-backup/index.d.ts +42 -0
  3. package/dist/builtins/local-backup/index.js +188 -0
  4. package/dist/builtins/local-backup/index.js.map +1 -0
  5. package/dist/builtins/local-backup/index.mjs +11 -0
  6. package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.mts +2 -0
  7. package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +2 -0
  8. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +210 -0
  9. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js.map +1 -0
  10. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +10 -0
  11. package/dist/builtins/sqlite-storage/index.d.mts +4 -0
  12. package/dist/builtins/sqlite-storage/index.d.ts +4 -0
  13. package/dist/builtins/sqlite-storage/index.js +1025 -0
  14. package/dist/builtins/sqlite-storage/index.js.map +1 -0
  15. package/dist/builtins/sqlite-storage/index.mjs +31 -0
  16. package/dist/builtins/sqlite-storage/index.mjs.map +1 -0
  17. package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.mts +2 -0
  18. package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +2 -0
  19. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +317 -0
  20. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js.map +1 -0
  21. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +10 -0
  22. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs.map +1 -0
  23. package/dist/builtins/winston-logging/index.d.mts +30 -0
  24. package/dist/builtins/winston-logging/index.d.ts +30 -0
  25. package/dist/builtins/winston-logging/index.js +185 -0
  26. package/dist/builtins/winston-logging/index.js.map +1 -0
  27. package/dist/builtins/winston-logging/index.mjs +11 -0
  28. package/dist/builtins/winston-logging/index.mjs.map +1 -0
  29. package/dist/chunk-LQFPAEQF.mjs +147 -0
  30. package/dist/chunk-LQFPAEQF.mjs.map +1 -0
  31. package/dist/{chunk-LZOMFHX3.mjs → chunk-QEMJH3KY.mjs} +11 -1
  32. package/dist/chunk-QEMJH3KY.mjs.map +1 -0
  33. package/dist/chunk-R3DIIBBX.mjs +532 -0
  34. package/dist/chunk-R3DIIBBX.mjs.map +1 -0
  35. package/dist/chunk-SO4LROOT.mjs +150 -0
  36. package/dist/chunk-SO4LROOT.mjs.map +1 -0
  37. package/dist/chunk-SPA4JBKN.mjs +175 -0
  38. package/dist/chunk-SPA4JBKN.mjs.map +1 -0
  39. package/dist/chunk-YXNXYYHL.mjs +282 -0
  40. package/dist/chunk-YXNXYYHL.mjs.map +1 -0
  41. package/dist/dist-N7SR63RN.mjs +3515 -0
  42. package/dist/dist-N7SR63RN.mjs.map +1 -0
  43. package/dist/filesystem-storage.addon-C42r589X.d.mts +57 -0
  44. package/dist/filesystem-storage.addon-C42r589X.d.ts +57 -0
  45. package/dist/index.d.mts +281 -849
  46. package/dist/index.d.ts +281 -849
  47. package/dist/index.js +8351 -1942
  48. package/dist/index.js.map +1 -1
  49. package/dist/index.mjs +4086 -2164
  50. package/dist/index.mjs.map +1 -1
  51. package/dist/onnxruntime_binding-6Q6HXASN.node +0 -0
  52. package/dist/onnxruntime_binding-EKZT2NRK.node +0 -0
  53. package/dist/onnxruntime_binding-P6S7V3CI.node +0 -0
  54. package/dist/onnxruntime_binding-PJNNIIUO.node +0 -0
  55. package/dist/onnxruntime_binding-UN6SPTQK.node +0 -0
  56. package/dist/sql-schema-CKz78rId.d.mts +97 -0
  57. package/dist/sql-schema-CKz78rId.d.ts +97 -0
  58. package/dist/sqlite-settings.addon-DigoKwpZ.d.mts +70 -0
  59. package/dist/sqlite-settings.addon-DigoKwpZ.d.ts +70 -0
  60. package/dist/{storage-location-manager-F4YZMHGM.mjs → storage-location-manager-UQRGHTCA.mjs} +2 -2
  61. package/dist/storage-location-manager-UQRGHTCA.mjs.map +1 -0
  62. package/dist/{wrapper-NTBY5HOA.mjs → wrapper-Y55ADNM5.mjs} +2 -2
  63. package/package.json +64 -12
  64. /package/dist/{chunk-LZOMFHX3.mjs.map → builtins/local-backup/index.mjs.map} +0 -0
  65. /package/dist/{storage-location-manager-F4YZMHGM.mjs.map → builtins/sqlite-storage/filesystem-storage.addon.mjs.map} +0 -0
  66. /package/dist/{wrapper-NTBY5HOA.mjs.map → wrapper-Y55ADNM5.mjs.map} +0 -0
@@ -0,0 +1,30 @@
1
+ import { ILogDestination, LogEntry, LogFilter, ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';
2
+
3
+ interface WinstonConfig {
4
+ readonly level: string;
5
+ readonly retentionDays: number;
6
+ /** Resolved absolute path to the logs directory (replaces the old dataPath field). */
7
+ readonly logsDir: string;
8
+ }
9
+ declare class WinstonDestination implements ILogDestination {
10
+ private logger;
11
+ initialize(config?: WinstonConfig): Promise<void>;
12
+ write(entry: LogEntry): void;
13
+ query(_filter: LogFilter): Promise<readonly LogEntry[]>;
14
+ shutdown(): Promise<void>;
15
+ }
16
+
17
+ declare class WinstonLoggingAddon implements ICamstackAddon, IConfigurable {
18
+ readonly manifest: AddonManifest;
19
+ private destination;
20
+ private currentConfig;
21
+ initialize(context: AddonContext): Promise<void>;
22
+ shutdown(): Promise<void>;
23
+ getDestination(): WinstonDestination;
24
+ getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
25
+ getConfigSchema(): ConfigUISchema;
26
+ getConfig(): Record<string, unknown>;
27
+ onConfigChange(config: Record<string, unknown>): Promise<void>;
28
+ }
29
+
30
+ export { WinstonDestination, WinstonLoggingAddon, WinstonLoggingAddon as default };
@@ -0,0 +1,185 @@
1
+ "use strict";
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 __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/builtins/winston-logging/index.ts
31
+ var winston_logging_exports = {};
32
+ __export(winston_logging_exports, {
33
+ WinstonDestination: () => WinstonDestination,
34
+ WinstonLoggingAddon: () => WinstonLoggingAddon,
35
+ default: () => WinstonLoggingAddon
36
+ });
37
+ module.exports = __toCommonJS(winston_logging_exports);
38
+
39
+ // src/builtins/winston-logging/winston-destination.ts
40
+ var winston = __toESM(require("winston"));
41
+ var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"));
42
+ var path = __toESM(require("path"));
43
+ function formatScope(scope) {
44
+ if (scope.length === 0) return "";
45
+ const [first, ...rest] = scope;
46
+ const restFormatted = rest.map((s) => `[${s}]`).join("");
47
+ return `(${first})${restFormatted}`;
48
+ }
49
+ var WinstonDestination = class {
50
+ logger = null;
51
+ async initialize(config) {
52
+ const {
53
+ level = "info",
54
+ retentionDays = 30,
55
+ logsDir = path.join("camstack-data", "logs")
56
+ } = config ?? {};
57
+ const consoleFormat = winston.format.combine(
58
+ winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
59
+ winston.format.colorize(),
60
+ winston.format.printf(({ timestamp, level: lvl, message, scope }) => {
61
+ const scopeStr = scope ? ` ${scope}` : "";
62
+ return `${timestamp} [${lvl}]${scopeStr} - ${message}`;
63
+ })
64
+ );
65
+ const fileFormat = winston.format.combine(
66
+ winston.format.timestamp(),
67
+ winston.format.json()
68
+ );
69
+ this.logger = winston.createLogger({
70
+ level,
71
+ transports: [
72
+ new winston.transports.Console({
73
+ format: consoleFormat
74
+ }),
75
+ new import_winston_daily_rotate_file.default({
76
+ dirname: logsDir,
77
+ filename: "camstack-%DATE%.log",
78
+ datePattern: "YYYY-MM-DD",
79
+ maxFiles: `${retentionDays}d`,
80
+ format: fileFormat
81
+ })
82
+ ]
83
+ });
84
+ }
85
+ write(entry) {
86
+ if (!this.logger) return;
87
+ const scope = formatScope(entry.scope);
88
+ const meta = entry.meta ?? {};
89
+ this.logger.log({
90
+ level: entry.level,
91
+ message: entry.message,
92
+ scope,
93
+ timestamp: entry.timestamp.toISOString(),
94
+ ...meta
95
+ });
96
+ }
97
+ async query(_filter) {
98
+ return [];
99
+ }
100
+ async shutdown() {
101
+ if (!this.logger) return;
102
+ await new Promise((resolve) => {
103
+ this.logger.on("finish", resolve);
104
+ this.logger.end();
105
+ });
106
+ this.logger = null;
107
+ }
108
+ };
109
+
110
+ // src/builtins/winston-logging/winston-logging.addon.ts
111
+ var WinstonLoggingAddon = class {
112
+ manifest = {
113
+ id: "winston-logging",
114
+ name: "Winston Logging",
115
+ version: "1.0.0",
116
+ capabilities: ["log-destination"]
117
+ };
118
+ destination = null;
119
+ currentConfig = {
120
+ level: "info",
121
+ retentionDays: 30
122
+ };
123
+ async initialize(context) {
124
+ this.currentConfig = {
125
+ level: context.addonConfig.level ?? this.currentConfig.level,
126
+ retentionDays: context.addonConfig.retentionDays ?? this.currentConfig.retentionDays
127
+ };
128
+ const logsDir = context.locationPaths.logs;
129
+ this.destination = new WinstonDestination();
130
+ await this.destination.initialize({ ...this.currentConfig, logsDir });
131
+ context.logger.info("Winston logging initialized");
132
+ }
133
+ async shutdown() {
134
+ await this.destination?.shutdown();
135
+ }
136
+ getDestination() {
137
+ if (!this.destination) throw new Error("Winston not initialized");
138
+ return this.destination;
139
+ }
140
+ getCapabilityProvider(name) {
141
+ if (name === "log-destination" && this.destination) {
142
+ return this.destination;
143
+ }
144
+ return null;
145
+ }
146
+ getConfigSchema() {
147
+ return {
148
+ sections: [
149
+ {
150
+ id: "winston-retention",
151
+ title: "Log Retention",
152
+ description: "How long Winston keeps rotated log files on disk.",
153
+ columns: 1,
154
+ fields: [
155
+ {
156
+ type: "number",
157
+ key: "retentionDays",
158
+ label: "Retention (days)",
159
+ description: "Number of days to keep rotated log files before deletion",
160
+ min: 1,
161
+ max: 365,
162
+ step: 1,
163
+ unit: "days"
164
+ }
165
+ ]
166
+ }
167
+ ]
168
+ };
169
+ }
170
+ getConfig() {
171
+ return { ...this.currentConfig };
172
+ }
173
+ async onConfigChange(config) {
174
+ this.currentConfig = {
175
+ level: config.level ?? this.currentConfig.level,
176
+ retentionDays: config.retentionDays ?? this.currentConfig.retentionDays
177
+ };
178
+ }
179
+ };
180
+ // Annotate the CommonJS export names for ESM import in node:
181
+ 0 && (module.exports = {
182
+ WinstonDestination,
183
+ WinstonLoggingAddon
184
+ });
185
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/builtins/winston-logging/index.ts","../../../src/builtins/winston-logging/winston-destination.ts","../../../src/builtins/winston-logging/winston-logging.addon.ts"],"sourcesContent":["export { WinstonLoggingAddon } from './winston-logging.addon'\nexport { WinstonDestination } from './winston-destination'\nexport { WinstonLoggingAddon as default } from './winston-logging.addon'\n","import * as winston from 'winston'\nimport DailyRotateFile from 'winston-daily-rotate-file'\nimport * as path from 'node:path'\nimport type { ILogDestination, LogEntry, LogFilter } from '@camstack/types'\n\ninterface WinstonConfig {\n readonly level: string\n readonly retentionDays: number\n /** Resolved absolute path to the logs directory (replaces the old dataPath field). */\n readonly logsDir: string\n}\n\nfunction formatScope(scope: readonly string[]): string {\n if (scope.length === 0) return ''\n const [first, ...rest] = scope\n const restFormatted = rest.map((s) => `[${s}]`).join('')\n return `(${first})${restFormatted}`\n}\n\nexport class WinstonDestination implements ILogDestination {\n private logger: winston.Logger | null = null\n\n async initialize(config?: WinstonConfig): Promise<void> {\n const {\n level = 'info',\n retentionDays = 30,\n logsDir = path.join('camstack-data', 'logs'),\n } = config ?? {}\n\n const consoleFormat = winston.format.combine(\n winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),\n winston.format.colorize(),\n winston.format.printf(({ timestamp, level: lvl, message, scope }) => {\n const scopeStr = scope ? ` ${scope}` : ''\n return `${timestamp} [${lvl}]${scopeStr} - ${message}`\n }),\n )\n\n const fileFormat = winston.format.combine(\n winston.format.timestamp(),\n winston.format.json(),\n )\n\n this.logger = winston.createLogger({\n level,\n transports: [\n new winston.transports.Console({\n format: consoleFormat,\n }),\n new DailyRotateFile({\n dirname: logsDir,\n filename: 'camstack-%DATE%.log',\n datePattern: 'YYYY-MM-DD',\n maxFiles: `${retentionDays}d`,\n format: fileFormat,\n }),\n ],\n })\n }\n\n write(entry: LogEntry): void {\n if (!this.logger) return\n\n const scope = formatScope(entry.scope)\n const meta = entry.meta ?? {}\n\n this.logger.log({\n level: entry.level,\n message: entry.message,\n scope,\n timestamp: entry.timestamp.toISOString(),\n ...meta,\n })\n }\n\n async query(_filter: LogFilter): Promise<readonly LogEntry[]> {\n // File-based log querying is not implemented; use structured storage for log queries\n return []\n }\n\n async shutdown(): Promise<void> {\n if (!this.logger) return\n\n await new Promise<void>((resolve) => {\n this.logger!.on('finish', resolve)\n this.logger!.end()\n })\n this.logger = null\n }\n}\n","import type {\n ICamstackAddon,\n AddonManifest,\n AddonContext,\n IConfigurable,\n ConfigUISchema,\n CapabilityProviderMap,\n} from '@camstack/types'\nimport { WinstonDestination } from './winston-destination'\n\nexport class WinstonLoggingAddon implements ICamstackAddon, IConfigurable {\n readonly manifest: AddonManifest = {\n id: 'winston-logging',\n name: 'Winston Logging',\n version: '1.0.0',\n capabilities: ['log-destination'],\n }\n\n private destination: WinstonDestination | null = null\n private currentConfig = {\n level: 'info',\n retentionDays: 30,\n }\n\n async initialize(context: AddonContext): Promise<void> {\n this.currentConfig = {\n level: (context.addonConfig.level as string) ?? this.currentConfig.level,\n retentionDays: (context.addonConfig.retentionDays as number) ?? this.currentConfig.retentionDays,\n }\n const logsDir = context.locationPaths.logs\n this.destination = new WinstonDestination()\n await this.destination.initialize({ ...this.currentConfig, logsDir })\n context.logger.info('Winston logging initialized')\n }\n\n async shutdown(): Promise<void> {\n await this.destination?.shutdown()\n }\n\n getDestination(): WinstonDestination {\n if (!this.destination) throw new Error('Winston not initialized')\n return this.destination\n }\n\n getCapabilityProvider<K extends keyof CapabilityProviderMap>(\n name: K,\n ): CapabilityProviderMap[K] | null {\n if (name === 'log-destination' && this.destination) {\n return this.destination as unknown as CapabilityProviderMap[K]\n }\n return null\n }\n\n getConfigSchema(): ConfigUISchema {\n return {\n sections: [\n {\n id: 'winston-retention',\n title: 'Log Retention',\n description: 'How long Winston keeps rotated log files on disk.',\n columns: 1,\n fields: [\n {\n type: 'number',\n key: 'retentionDays',\n label: 'Retention (days)',\n description: 'Number of days to keep rotated log files before deletion',\n min: 1,\n max: 365,\n step: 1,\n unit: 'days',\n },\n ],\n },\n ],\n }\n }\n\n getConfig(): Record<string, unknown> {\n return { ...this.currentConfig }\n }\n\n async onConfigChange(config: Record<string, unknown>): Promise<void> {\n this.currentConfig = {\n level: (config.level as string) ?? this.currentConfig.level,\n retentionDays: (config.retentionDays as number) ?? this.currentConfig.retentionDays,\n }\n }\n}\n"],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AAA,EACnC;AAAA,EAEA,iBAAqC;AACnC,QAAI,CAAC,KAAK,YAAa,OAAM,IAAI,MAAM,yBAAyB;AAChE,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,sBACE,MACiC;AACjC,QAAI,SAAS,qBAAqB,KAAK,aAAa;AAClD,aAAO,KAAK;AAAA,IACd;AACA,WAAO;AAAA,EACT;AAAA,EAEA,kBAAkC;AAChC,WAAO;AAAA,MACL,UAAU;AAAA,QACR;AAAA,UACE,IAAI;AAAA,UACJ,OAAO;AAAA,UACP,aAAa;AAAA,UACb,SAAS;AAAA,UACT,QAAQ;AAAA,YACN;AAAA,cACE,MAAM;AAAA,cACN,KAAK;AAAA,cACL,OAAO;AAAA,cACP,aAAa;AAAA,cACb,KAAK;AAAA,cACL,KAAK;AAAA,cACL,MAAM;AAAA,cACN,MAAM;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAqC;AACnC,WAAO,EAAE,GAAG,KAAK,cAAc;AAAA,EACjC;AAAA,EAEA,MAAM,eAAe,QAAgD;AACnE,SAAK,gBAAgB;AAAA,MACnB,OAAQ,OAAO,SAAoB,KAAK,cAAc;AAAA,MACtD,eAAgB,OAAO,iBAA4B,KAAK,cAAc;AAAA,IACxE;AAAA,EACF;AACF;","names":["DailyRotateFile"]}
@@ -0,0 +1,11 @@
1
+ import {
2
+ WinstonDestination,
3
+ WinstonLoggingAddon
4
+ } from "../../chunk-LQFPAEQF.mjs";
5
+ import "../../chunk-QEMJH3KY.mjs";
6
+ export {
7
+ WinstonDestination,
8
+ WinstonLoggingAddon,
9
+ WinstonLoggingAddon as default
10
+ };
11
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,147 @@
1
+ // src/builtins/winston-logging/winston-destination.ts
2
+ import * as winston from "winston";
3
+ import DailyRotateFile from "winston-daily-rotate-file";
4
+ import * as path from "path";
5
+ function formatScope(scope) {
6
+ if (scope.length === 0) return "";
7
+ const [first, ...rest] = scope;
8
+ const restFormatted = rest.map((s) => `[${s}]`).join("");
9
+ return `(${first})${restFormatted}`;
10
+ }
11
+ var WinstonDestination = class {
12
+ logger = null;
13
+ async initialize(config) {
14
+ const {
15
+ level = "info",
16
+ retentionDays = 30,
17
+ logsDir = path.join("camstack-data", "logs")
18
+ } = config ?? {};
19
+ const consoleFormat = winston.format.combine(
20
+ winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
21
+ winston.format.colorize(),
22
+ winston.format.printf(({ timestamp, level: lvl, message, scope }) => {
23
+ const scopeStr = scope ? ` ${scope}` : "";
24
+ return `${timestamp} [${lvl}]${scopeStr} - ${message}`;
25
+ })
26
+ );
27
+ const fileFormat = winston.format.combine(
28
+ winston.format.timestamp(),
29
+ winston.format.json()
30
+ );
31
+ this.logger = winston.createLogger({
32
+ level,
33
+ transports: [
34
+ new winston.transports.Console({
35
+ format: consoleFormat
36
+ }),
37
+ new DailyRotateFile({
38
+ dirname: logsDir,
39
+ filename: "camstack-%DATE%.log",
40
+ datePattern: "YYYY-MM-DD",
41
+ maxFiles: `${retentionDays}d`,
42
+ format: fileFormat
43
+ })
44
+ ]
45
+ });
46
+ }
47
+ write(entry) {
48
+ if (!this.logger) return;
49
+ const scope = formatScope(entry.scope);
50
+ const meta = entry.meta ?? {};
51
+ this.logger.log({
52
+ level: entry.level,
53
+ message: entry.message,
54
+ scope,
55
+ timestamp: entry.timestamp.toISOString(),
56
+ ...meta
57
+ });
58
+ }
59
+ async query(_filter) {
60
+ return [];
61
+ }
62
+ async shutdown() {
63
+ if (!this.logger) return;
64
+ await new Promise((resolve) => {
65
+ this.logger.on("finish", resolve);
66
+ this.logger.end();
67
+ });
68
+ this.logger = null;
69
+ }
70
+ };
71
+
72
+ // src/builtins/winston-logging/winston-logging.addon.ts
73
+ var WinstonLoggingAddon = class {
74
+ manifest = {
75
+ id: "winston-logging",
76
+ name: "Winston Logging",
77
+ version: "1.0.0",
78
+ capabilities: ["log-destination"]
79
+ };
80
+ destination = null;
81
+ currentConfig = {
82
+ level: "info",
83
+ retentionDays: 30
84
+ };
85
+ async initialize(context) {
86
+ this.currentConfig = {
87
+ level: context.addonConfig.level ?? this.currentConfig.level,
88
+ retentionDays: context.addonConfig.retentionDays ?? this.currentConfig.retentionDays
89
+ };
90
+ const logsDir = context.locationPaths.logs;
91
+ this.destination = new WinstonDestination();
92
+ await this.destination.initialize({ ...this.currentConfig, logsDir });
93
+ context.logger.info("Winston logging initialized");
94
+ }
95
+ async shutdown() {
96
+ await this.destination?.shutdown();
97
+ }
98
+ getDestination() {
99
+ if (!this.destination) throw new Error("Winston not initialized");
100
+ return this.destination;
101
+ }
102
+ getCapabilityProvider(name) {
103
+ if (name === "log-destination" && this.destination) {
104
+ return this.destination;
105
+ }
106
+ return null;
107
+ }
108
+ getConfigSchema() {
109
+ return {
110
+ sections: [
111
+ {
112
+ id: "winston-retention",
113
+ title: "Log Retention",
114
+ description: "How long Winston keeps rotated log files on disk.",
115
+ columns: 1,
116
+ fields: [
117
+ {
118
+ type: "number",
119
+ key: "retentionDays",
120
+ label: "Retention (days)",
121
+ description: "Number of days to keep rotated log files before deletion",
122
+ min: 1,
123
+ max: 365,
124
+ step: 1,
125
+ unit: "days"
126
+ }
127
+ ]
128
+ }
129
+ ]
130
+ };
131
+ }
132
+ getConfig() {
133
+ return { ...this.currentConfig };
134
+ }
135
+ async onConfigChange(config) {
136
+ this.currentConfig = {
137
+ level: config.level ?? this.currentConfig.level,
138
+ retentionDays: config.retentionDays ?? this.currentConfig.retentionDays
139
+ };
140
+ }
141
+ };
142
+
143
+ export {
144
+ WinstonDestination,
145
+ WinstonLoggingAddon
146
+ };
147
+ //# sourceMappingURL=chunk-LQFPAEQF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/builtins/winston-logging/winston-destination.ts","../src/builtins/winston-logging/winston-logging.addon.ts"],"sourcesContent":["import * as winston from 'winston'\nimport DailyRotateFile from 'winston-daily-rotate-file'\nimport * as path from 'node:path'\nimport type { ILogDestination, LogEntry, LogFilter } from '@camstack/types'\n\ninterface WinstonConfig {\n readonly level: string\n readonly retentionDays: number\n /** Resolved absolute path to the logs directory (replaces the old dataPath field). */\n readonly logsDir: string\n}\n\nfunction formatScope(scope: readonly string[]): string {\n if (scope.length === 0) return ''\n const [first, ...rest] = scope\n const restFormatted = rest.map((s) => `[${s}]`).join('')\n return `(${first})${restFormatted}`\n}\n\nexport class WinstonDestination implements ILogDestination {\n private logger: winston.Logger | null = null\n\n async initialize(config?: WinstonConfig): Promise<void> {\n const {\n level = 'info',\n retentionDays = 30,\n logsDir = path.join('camstack-data', 'logs'),\n } = config ?? {}\n\n const consoleFormat = winston.format.combine(\n winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),\n winston.format.colorize(),\n winston.format.printf(({ timestamp, level: lvl, message, scope }) => {\n const scopeStr = scope ? ` ${scope}` : ''\n return `${timestamp} [${lvl}]${scopeStr} - ${message}`\n }),\n )\n\n const fileFormat = winston.format.combine(\n winston.format.timestamp(),\n winston.format.json(),\n )\n\n this.logger = winston.createLogger({\n level,\n transports: [\n new winston.transports.Console({\n format: consoleFormat,\n }),\n new DailyRotateFile({\n dirname: logsDir,\n filename: 'camstack-%DATE%.log',\n datePattern: 'YYYY-MM-DD',\n maxFiles: `${retentionDays}d`,\n format: fileFormat,\n }),\n ],\n })\n }\n\n write(entry: LogEntry): void {\n if (!this.logger) return\n\n const scope = formatScope(entry.scope)\n const meta = entry.meta ?? {}\n\n this.logger.log({\n level: entry.level,\n message: entry.message,\n scope,\n timestamp: entry.timestamp.toISOString(),\n ...meta,\n })\n }\n\n async query(_filter: LogFilter): Promise<readonly LogEntry[]> {\n // File-based log querying is not implemented; use structured storage for log queries\n return []\n }\n\n async shutdown(): Promise<void> {\n if (!this.logger) return\n\n await new Promise<void>((resolve) => {\n this.logger!.on('finish', resolve)\n this.logger!.end()\n })\n this.logger = null\n }\n}\n","import type {\n ICamstackAddon,\n AddonManifest,\n AddonContext,\n IConfigurable,\n ConfigUISchema,\n CapabilityProviderMap,\n} from '@camstack/types'\nimport { WinstonDestination } from './winston-destination'\n\nexport class WinstonLoggingAddon implements ICamstackAddon, IConfigurable {\n readonly manifest: AddonManifest = {\n id: 'winston-logging',\n name: 'Winston Logging',\n version: '1.0.0',\n capabilities: ['log-destination'],\n }\n\n private destination: WinstonDestination | null = null\n private currentConfig = {\n level: 'info',\n retentionDays: 30,\n }\n\n async initialize(context: AddonContext): Promise<void> {\n this.currentConfig = {\n level: (context.addonConfig.level as string) ?? this.currentConfig.level,\n retentionDays: (context.addonConfig.retentionDays as number) ?? this.currentConfig.retentionDays,\n }\n const logsDir = context.locationPaths.logs\n this.destination = new WinstonDestination()\n await this.destination.initialize({ ...this.currentConfig, logsDir })\n context.logger.info('Winston logging initialized')\n }\n\n async shutdown(): Promise<void> {\n await this.destination?.shutdown()\n }\n\n getDestination(): WinstonDestination {\n if (!this.destination) throw new Error('Winston not initialized')\n return this.destination\n }\n\n getCapabilityProvider<K extends keyof CapabilityProviderMap>(\n name: K,\n ): CapabilityProviderMap[K] | null {\n if (name === 'log-destination' && this.destination) {\n return this.destination as unknown as CapabilityProviderMap[K]\n }\n return null\n }\n\n getConfigSchema(): ConfigUISchema {\n return {\n sections: [\n {\n id: 'winston-retention',\n title: 'Log Retention',\n description: 'How long Winston keeps rotated log files on disk.',\n columns: 1,\n fields: [\n {\n type: 'number',\n key: 'retentionDays',\n label: 'Retention (days)',\n description: 'Number of days to keep rotated log files before deletion',\n min: 1,\n max: 365,\n step: 1,\n unit: 'days',\n },\n ],\n },\n ],\n }\n }\n\n getConfig(): Record<string, unknown> {\n return { ...this.currentConfig }\n }\n\n async onConfigChange(config: Record<string, unknown>): Promise<void> {\n this.currentConfig = {\n level: (config.level as string) ?? this.currentConfig.level,\n retentionDays: (config.retentionDays as number) ?? this.currentConfig.retention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AK,YAAa,OAAM,IAAI,MAAM,yBAAyB;AAChE,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,sBACE,MACiC;AACjC,QAAI,SAAS,qBAAqB,KAAK,aAAa;AAClD,aAAO,KAAK;AAAA,IACd;AACA,WAAO;AAAA,EACT;AAAA,EAEA,kBAAkC;AAChC,WAAO;AAAA,MACL,UAAU;AAAA,QACR;AAAA,UACE,IAAI;AAAA,UACJ,OAAO;AAAA,UACP,aAAa;AAAA,UACb,SAAS;AAAA,UACT,QAAQ;AAAA,YACN;AAAA,cACE,MAAM;AAAA,cACN,KAAK;AAAA,cACL,OAAO;AAAA,cACP,aAAa;AAAA,cACb,KAAK;AAAA,cACL,KAAK;AAAA,cACL,MAAM;AAAA,cACN,MAAM;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAqC;AACnC,WAAO,EAAE,GAAG,KAAK,cAAc;AAAA,EACjC;AAAA,EAEA,MAAM,eAAe,QAAgD;AACnE,SAAK,gBAAgB;AAAA,MACnB,OAAQ,OAAO,SAAoB,KAAK,cAAc;AAAA,MACtD,eAAgB,OAAO,iBAA4B,KAAK,cAAc;AAAA,IACxE;AAAA,EACF;AACF;","names":[]}
@@ -10,6 +10,14 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
10
10
  if (typeof require !== "undefined") return require.apply(this, arguments);
11
11
  throw Error('Dynamic require of "' + x + '" is not supported');
12
12
  });
13
+ var __glob = (map) => (path) => {
14
+ var fn = map[path];
15
+ if (fn) return fn();
16
+ throw new Error("Module not found in bundle: " + path);
17
+ };
18
+ var __esm = (fn, res) => function __init() {
19
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
20
+ };
13
21
  var __commonJS = (cb, mod) => function __require2() {
14
22
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
23
  };
@@ -32,7 +40,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
40
 
33
41
  export {
34
42
  __require,
43
+ __glob,
44
+ __esm,
35
45
  __commonJS,
36
46
  __toESM
37
47
  };
38
- //# sourceMappingURL=chunk-LZOMFHX3.mjs.map
48
+ //# sourceMappingURL=chunk-QEMJH3KY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}