@camstack/core 0.1.2 → 0.1.4

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 (41) hide show
  1. package/dist/builtins/local-backup/index.mjs +10 -3
  2. package/dist/builtins/local-backup/index.mjs.map +1 -1
  3. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +5 -3
  4. package/dist/builtins/sqlite-storage/index.js +197 -95
  5. package/dist/builtins/sqlite-storage/index.js.map +1 -1
  6. package/dist/builtins/sqlite-storage/index.mjs +26 -7
  7. package/dist/builtins/sqlite-storage/index.mjs.map +1 -1
  8. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +4 -2
  9. package/dist/builtins/winston-logging/index.mjs +10 -3
  10. package/dist/builtins/winston-logging/index.mjs.map +1 -1
  11. package/dist/{chunk-QEMJH3KY.mjs → chunk-4JEXNFZZ.mjs} +11 -2
  12. package/dist/chunk-4YD6WMO6.mjs +207 -0
  13. package/dist/{chunk-SPA4JBKN.mjs.map → chunk-4YD6WMO6.mjs.map} +1 -1
  14. package/dist/chunk-CHFIH4G6.mjs +314 -0
  15. package/dist/{chunk-YXNXYYHL.mjs.map → chunk-CHFIH4G6.mjs.map} +1 -1
  16. package/dist/chunk-EFQ25JFE.mjs +689 -0
  17. package/dist/chunk-EFQ25JFE.mjs.map +1 -0
  18. package/dist/chunk-GBWW3JU4.mjs +180 -0
  19. package/dist/{chunk-SO4LROOT.mjs.map → chunk-GBWW3JU4.mjs.map} +1 -1
  20. package/dist/chunk-XSLBW5C2.mjs +177 -0
  21. package/dist/{chunk-LQFPAEQF.mjs.map → chunk-XSLBW5C2.mjs.map} +1 -1
  22. package/dist/index.js +14872 -11586
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +16119 -5933
  25. package/dist/index.mjs.map +1 -1
  26. package/package.json +2 -1
  27. package/dist/chunk-2F3XZYRW.mjs +0 -89
  28. package/dist/chunk-2F3XZYRW.mjs.map +0 -1
  29. package/dist/chunk-LQFPAEQF.mjs +0 -147
  30. package/dist/chunk-R3DIIBBX.mjs +0 -532
  31. package/dist/chunk-R3DIIBBX.mjs.map +0 -1
  32. package/dist/chunk-SO4LROOT.mjs +0 -150
  33. package/dist/chunk-SPA4JBKN.mjs +0 -175
  34. package/dist/chunk-YXNXYYHL.mjs +0 -282
  35. package/dist/dist-N7SR63RN.mjs +0 -3515
  36. package/dist/dist-N7SR63RN.mjs.map +0 -1
  37. package/dist/storage-location-manager-UQRGHTCA.mjs +0 -8
  38. package/dist/storage-location-manager-UQRGHTCA.mjs.map +0 -1
  39. package/dist/wrapper-Y55ADNM5.mjs +0 -3652
  40. package/dist/wrapper-Y55ADNM5.mjs.map +0 -1
  41. /package/dist/{chunk-QEMJH3KY.mjs.map → chunk-4JEXNFZZ.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",
@@ -26,6 +26,7 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "camstack": {
29
+ "displayName": "CamStack Core",
29
30
  "addons": [
30
31
  {
31
32
  "id": "filesystem-storage",
@@ -1,89 +0,0 @@
1
- // src/storage/storage-location-manager.ts
2
- import { join as join2, isAbsolute as isAbsolute2 } from "path";
3
-
4
- // src/storage/fs-storage-backend.ts
5
- import { existsSync, mkdirSync, accessSync, constants } from "fs";
6
- import { join, resolve, isAbsolute } from "path";
7
- var FsStorageBackend = class {
8
- type = "local";
9
- basePath;
10
- constructor(basePath) {
11
- this.basePath = resolve(basePath);
12
- }
13
- resolve(subpath) {
14
- if (isAbsolute(subpath)) return subpath;
15
- return join(this.basePath, subpath);
16
- }
17
- isAvailable() {
18
- try {
19
- if (!existsSync(this.basePath)) return false;
20
- accessSync(this.basePath, constants.W_OK);
21
- return true;
22
- } catch {
23
- return false;
24
- }
25
- }
26
- async initialize() {
27
- mkdirSync(this.basePath, { recursive: true });
28
- }
29
- };
30
-
31
- // src/storage/storage-location-manager.ts
32
- var StorageLocationManager = class {
33
- backends = /* @__PURE__ */ new Map();
34
- dataPath;
35
- constructor(dataPath) {
36
- this.dataPath = dataPath;
37
- }
38
- /** Initialize all locations with default paths */
39
- async initializeDefaults() {
40
- const defaults = {
41
- data: join2(this.dataPath, "db"),
42
- media: join2(this.dataPath, "media"),
43
- recordings: join2(this.dataPath, "recordings"),
44
- models: join2(this.dataPath, "models"),
45
- cache: "/tmp/camstack-cache",
46
- logs: join2(this.dataPath, "logs")
47
- };
48
- for (const [name, path] of Object.entries(defaults)) {
49
- const backend = new FsStorageBackend(path);
50
- await backend.initialize();
51
- this.backends.set(name, backend);
52
- }
53
- }
54
- /** Override a specific location's backend path */
55
- async setLocationPath(name, basePath) {
56
- const resolved = isAbsolute2(basePath) ? basePath : join2(this.dataPath, basePath);
57
- const backend = new FsStorageBackend(resolved);
58
- await backend.initialize();
59
- this.backends.set(name, backend);
60
- }
61
- /** Get the backend for a location */
62
- getBackend(name) {
63
- const backend = this.backends.get(name);
64
- if (!backend) throw new Error(`Storage location "${name}" not initialized`);
65
- return backend;
66
- }
67
- /** Resolve a path within a location */
68
- resolve(location, subpath) {
69
- return this.getBackend(location).resolve(subpath);
70
- }
71
- /** Check if all locations are available */
72
- getStatus() {
73
- return Array.from(this.backends.entries()).map(([name, backend]) => ({
74
- name,
75
- available: backend.isAvailable(),
76
- path: backend.basePath
77
- }));
78
- }
79
- /** All location names */
80
- getLocationNames() {
81
- return Array.from(this.backends.keys());
82
- }
83
- };
84
-
85
- export {
86
- FsStorageBackend,
87
- StorageLocationManager
88
- };
89
- //# sourceMappingURL=chunk-2F3XZYRW.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/storage/storage-location-manager.ts","../src/storage/fs-storage-backend.ts"],"sourcesContent":["import { join, isAbsolute } from 'node:path'\nimport { FsStorageBackend, type IStorageBackend } from './fs-storage-backend.js'\n\nexport type StorageLocationName = 'data' | 'media' | 'recordings' | 'models' | 'cache' | 'logs'\n\nexport class StorageLocationManager {\n private readonly backends: Map<StorageLocationName, IStorageBackend> = new Map()\n private readonly dataPath: string\n\n constructor(dataPath: string) {\n this.dataPath = dataPath\n }\n\n /** Initialize all locations with default paths */\n async initializeDefaults(): Promise<void> {\n const defaults: Record<StorageLocationName, string> = {\n data: join(this.dataPath, 'db'),\n media: join(this.dataPath, 'media'),\n recordings: join(this.dataPath, 'recordings'),\n models: join(this.dataPath, 'models'),\n cache: '/tmp/camstack-cache',\n logs: join(this.dataPath, 'logs'),\n }\n\n for (const [name, path] of Object.entries(defaults)) {\n const backend = new FsStorageBackend(path)\n await backend.initialize()\n this.backends.set(name as StorageLocationName, backend)\n }\n }\n\n /** Override a specific location's backend path */\n async setLocationPath(name: StorageLocationName, basePath: string): Promise<void> {\n const resolved = isAbsolute(basePath) ? basePath : join(this.dataPath, basePath)\n const backend = new FsStorageBackend(resolved)\n await backend.initialize()\n this.backends.set(name, backend)\n }\n\n /** Get the backend for a location */\n getBackend(name: StorageLocationName): IStorageBackend {\n const backend = this.backends.get(name)\n if (!backend) throw new Error(`Storage location \"${name}\" not initialized`)\n return backend\n }\n\n /** Resolve a path within a location */\n resolve(location: StorageLocationName, subpath: string): string {\n return this.getBackend(location).resolve(subpath)\n }\n\n /** Check if all locations are available */\n getStatus(): Array<{ name: StorageLocationName; available: boolean; path: string }> {\n return Array.from(this.backends.entries()).map(([name, backend]) => ({\n name,\n available: backend.isAvailable(),\n path: backend.basePath,\n }))\n }\n\n /** All location names */\n getLocationNames(): StorageLocationName[] {\n return Array.from(this.backends.keys())\n }\n}\n","import { existsSync, mkdirSync, accessSync, constants } from 'node:fs'\nimport { join, resolve, isAbsolute } from 'node:path'\n\nexport interface IStorageBackend {\n /** Backend type identifier */\n readonly type: string\n /** Base path of this backend */\n readonly basePath: string\n /** Resolve a subpath to an absolute path */\n resolve(subpath: string): string\n /** Check if the backend path exists and is writable */\n isAvailable(): boolean\n /** Ensure base directory exists (mkdir -p equivalent) */\n initialize(): Promise<void>\n}\n\nexport class FsStorageBackend implements IStorageBackend {\n readonly type = 'local'\n readonly basePath: string\n\n constructor(basePath: string) {\n this.basePath = resolve(basePath)\n }\n\n resolve(subpath: string): string {\n if (isAbsolute(subpath)) return subpath\n return join(this.basePath, subpath)\n }\n\n isAvailable(): boolean {\n try {\n if (!existsSync(this.basePath)) return false\n accessSync(this.basePath, constants.W_OK)\n return true\n } catch {\n return false\n }\n }\n\n async initialize(): Promise<void> {\n mkdirSync(this.basePath, { recursive: true })\n }\n}\n"],"mappings":";AAAA,SAAS,QAAAA,OAAM,cAAAC,mBAAkB;;;ACAjC,SAAS,YAAY,WAAW,YAAY,iBAAiB;AAC7D,SAAS,MAAM,SAAS,kBAAkB;AAenC,IAAM,mBAAN,MAAkD;AAAA,EAC9C,OAAO;AAAA,EACP;AAAA,EAET,YAAY,UAAkB;AAC5B,SAAK,WAAW,QAAQ,QAAQ;AAAA,EAClC;AAAA,EAEA,QAAQ,SAAyB;AAC/B,QAAI,WAAW,OAAO,EAAG,QAAO;AAChC,WAAO,KAAK,KAAK,UAAU,OAAO;AAAA,EACpC;AAAA,EAEA,cAAuB;AACrB,QAAI;AACF,UAAI,CAAC,WAAW,KAAK,QAAQ,EAAG,QAAO;AACvC,iBAAW,KAAK,UAAU,UAAU,IAAI;AACxC,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,aAA4B;AAChC,cAAU,KAAK,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EAC9C;AACF;;;ADrCO,IAAM,yBAAN,MAA6B;AAAA,EACjB,WAAsD,oBAAI,IAAI;AAAA,EAC9D;AAAA,EAEjB,YAAY,UAAkB;AAC5B,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA,EAGA,MAAM,qBAAoC;AACxC,UAAM,WAA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A,EACxC;AACF;","names":["join","isAbsolute","join","isAbsolute"]}
@@ -1,147 +0,0 @@
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