@loopstack/common 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1 @@
1
1
  export * from './auth.constants';
2
- export * from './module.constants';
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth.constants"), exports);
18
- __exportStar(require("./module.constants"), exports);
@@ -1,16 +1,18 @@
1
1
  import { BlockOptions } from '../interfaces';
2
- export declare const BLOCK_METADATA_KEY = "block:metadata";
3
- export declare function BlockConfig(options: BlockOptions): ClassDecorator;
2
+ import { z } from 'zod';
3
+ export declare const BLOCK_METADATA_KEY: unique symbol;
4
4
  export declare const INPUT_METADATA_KEY: unique symbol;
5
5
  export declare const OUTPUT_METADATA_KEY: unique symbol;
6
- /**
7
- * Marks a property as an input parameter
8
- * Inputs can be read and written
9
- */
10
- export declare function Input(): (target: any, propertyKey: string) => void;
11
- /**
12
- * Marks a property/getter as an output value
13
- * Outputs are typically read-only (often getters)
14
- */
15
- export declare function Output(): (target: any, propertyKey: string) => void;
16
- export declare function getDecoratedProperties(metatype: any, metadataKey: symbol): string[];
6
+ export declare const TOOL_METADATA_KEY: unique symbol;
7
+ export declare const DOCUMENT_METADATA_KEY: unique symbol;
8
+ export declare const WORKFLOW_METADATA_KEY: unique symbol;
9
+ export declare const TEMPLATE_HELPER_METADATA_KEY: unique symbol;
10
+ export declare function WithArguments<T extends z.ZodType>(schema: T): ClassDecorator;
11
+ export declare function WithState<T extends z.ZodType>(schema: T): ClassDecorator;
12
+ export declare function BlockConfig(options: BlockOptions): ClassDecorator;
13
+ export declare function Tool(token?: any): PropertyDecorator & MethodDecorator;
14
+ export declare function Document(token?: any): PropertyDecorator & MethodDecorator;
15
+ export declare function Workflow(token?: any): PropertyDecorator & MethodDecorator;
16
+ export declare function Helper(): MethodDecorator;
17
+ export declare function Input(): PropertyDecorator;
18
+ export declare function Output(): PropertyDecorator;
@@ -1,55 +1,119 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OUTPUT_METADATA_KEY = exports.INPUT_METADATA_KEY = exports.BLOCK_METADATA_KEY = void 0;
3
+ exports.TEMPLATE_HELPER_METADATA_KEY = exports.WORKFLOW_METADATA_KEY = exports.DOCUMENT_METADATA_KEY = exports.TOOL_METADATA_KEY = exports.OUTPUT_METADATA_KEY = exports.INPUT_METADATA_KEY = exports.BLOCK_METADATA_KEY = void 0;
4
+ exports.WithArguments = WithArguments;
5
+ exports.WithState = WithState;
4
6
  exports.BlockConfig = BlockConfig;
7
+ exports.Tool = Tool;
8
+ exports.Document = Document;
9
+ exports.Workflow = Workflow;
10
+ exports.Helper = Helper;
5
11
  exports.Input = Input;
6
12
  exports.Output = Output;
7
- exports.getDecoratedProperties = getDecoratedProperties;
8
13
  const common_1 = require("@nestjs/common");
9
- exports.BLOCK_METADATA_KEY = 'block:metadata';
14
+ const block_config_builder_1 = require("../utils/block-config.builder");
15
+ const zod_1 = require("zod");
16
+ exports.BLOCK_METADATA_KEY = Symbol('block');
17
+ exports.INPUT_METADATA_KEY = Symbol('input');
18
+ exports.OUTPUT_METADATA_KEY = Symbol('output');
19
+ exports.TOOL_METADATA_KEY = Symbol('tool');
20
+ exports.DOCUMENT_METADATA_KEY = Symbol('document');
21
+ exports.WORKFLOW_METADATA_KEY = Symbol('workflow');
22
+ exports.TEMPLATE_HELPER_METADATA_KEY = Symbol('templateHelper');
23
+ function WithArguments(schema) {
24
+ return (target) => {
25
+ target.argsSchema = schema;
26
+ };
27
+ }
28
+ function validateStateSchema(schema) {
29
+ const forbiddenKeys = ['args', 'metadata'];
30
+ if (schema instanceof zod_1.z.ZodObject) {
31
+ const shape = schema.shape;
32
+ const keys = Object.keys(shape);
33
+ for (const key of forbiddenKeys) {
34
+ if (keys.includes(key)) {
35
+ throw new Error(`State schema cannot contain '${key}' key`);
36
+ }
37
+ }
38
+ }
39
+ }
40
+ function WithState(schema) {
41
+ return (target) => {
42
+ validateStateSchema(schema);
43
+ target.stateSchema = schema;
44
+ };
45
+ }
46
+ function getTools(target) {
47
+ const keys = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target.prototype) || [];
48
+ return keys.map(key => String(key));
49
+ }
50
+ function getDocuments(target) {
51
+ const keys = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, target.prototype) || [];
52
+ return keys.map(key => String(key));
53
+ }
54
+ function getWorkflows(target) {
55
+ const keys = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target.prototype) || [];
56
+ return keys.map(key => String(key));
57
+ }
58
+ function getHelpers(target) {
59
+ const keys = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target.prototype) || [];
60
+ return keys.map(key => String(key));
61
+ }
10
62
  function BlockConfig(options) {
11
63
  return (target) => {
12
- const scope = options.scope ?? common_1.Scope.TRANSIENT;
13
- (0, common_1.Injectable)({ scope })(target);
64
+ target.blockConfig = (0, block_config_builder_1.buildConfig)(options);
65
+ target.blockTools = getTools(target);
66
+ target.blockDocuments = getDocuments(target);
67
+ target.blockWorkflows = getWorkflows(target);
68
+ target.blockHelpers = getHelpers(target);
14
69
  Reflect.defineMetadata(exports.BLOCK_METADATA_KEY, options, target);
15
- return target;
16
70
  };
17
71
  }
18
- exports.INPUT_METADATA_KEY = Symbol('input');
19
- exports.OUTPUT_METADATA_KEY = Symbol('output');
20
- /**
21
- * Marks a property as an input parameter
22
- * Inputs can be read and written
23
- */
72
+ function Tool(token) {
73
+ return (target, propertyKey) => {
74
+ const type = token ?? Reflect.getMetadata('design:type', target, propertyKey);
75
+ if (type) {
76
+ (0, common_1.Inject)(type)(target, propertyKey);
77
+ }
78
+ const existingTools = Reflect.getMetadata(exports.TOOL_METADATA_KEY, target) || [];
79
+ Reflect.defineMetadata(exports.TOOL_METADATA_KEY, [...existingTools, propertyKey], target);
80
+ };
81
+ }
82
+ function Document(token) {
83
+ return (target, propertyKey) => {
84
+ const type = token ?? Reflect.getMetadata('design:type', target, propertyKey);
85
+ if (type) {
86
+ (0, common_1.Inject)(type)(target, propertyKey);
87
+ }
88
+ const existingTools = Reflect.getMetadata(exports.DOCUMENT_METADATA_KEY, target) || [];
89
+ Reflect.defineMetadata(exports.DOCUMENT_METADATA_KEY, [...existingTools, propertyKey], target);
90
+ };
91
+ }
92
+ function Workflow(token) {
93
+ return (target, propertyKey) => {
94
+ const type = token ?? Reflect.getMetadata('design:type', target, propertyKey);
95
+ if (type) {
96
+ (0, common_1.Inject)(type)(target, propertyKey);
97
+ }
98
+ const existingWorkflows = Reflect.getMetadata(exports.WORKFLOW_METADATA_KEY, target) || [];
99
+ Reflect.defineMetadata(exports.WORKFLOW_METADATA_KEY, [...existingWorkflows, propertyKey], target);
100
+ };
101
+ }
102
+ function Helper() {
103
+ return (target, propertyKey) => {
104
+ const existing = Reflect.getMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, target) || [];
105
+ Reflect.defineMetadata(exports.TEMPLATE_HELPER_METADATA_KEY, [...existing, propertyKey], target);
106
+ };
107
+ }
24
108
  function Input() {
25
- return function (target, propertyKey) {
26
- const constructor = target.constructor;
27
- const existingInputs = Reflect.getOwnMetadata(exports.INPUT_METADATA_KEY, constructor) || [];
28
- const newInputs = [...existingInputs, propertyKey];
29
- Reflect.defineMetadata(exports.INPUT_METADATA_KEY, newInputs, constructor);
109
+ return (target, propertyKey) => {
110
+ const existingInputs = Reflect.getMetadata(exports.INPUT_METADATA_KEY, target) || [];
111
+ Reflect.defineMetadata(exports.INPUT_METADATA_KEY, [...existingInputs, propertyKey], target);
30
112
  };
31
113
  }
32
- /**
33
- * Marks a property/getter as an output value
34
- * Outputs are typically read-only (often getters)
35
- */
36
114
  function Output() {
37
- return function (target, propertyKey) {
38
- const constructor = target.constructor;
39
- const existingOutputs = Reflect.getOwnMetadata(exports.OUTPUT_METADATA_KEY, constructor) || [];
40
- const newOutputs = [...existingOutputs, propertyKey];
41
- Reflect.defineMetadata(exports.OUTPUT_METADATA_KEY, newOutputs, constructor);
42
- };
43
- }
44
- function getDecoratedProperties(metatype, metadataKey) {
45
- const properties = new Set();
46
- let current = metatype;
47
- while (current && current !== Object && current !== Function.prototype) {
48
- const metadata = Reflect.getOwnMetadata(metadataKey, current);
49
- if (metadata && Array.isArray(metadata)) {
50
- metadata.forEach(prop => properties.add(prop));
51
- }
52
- current = Object.getPrototypeOf(current);
53
- }
54
- return Array.from(properties);
115
+ return (target, propertyKey) => {
116
+ const existingOutputs = Reflect.getMetadata(exports.OUTPUT_METADATA_KEY, target) || [];
117
+ Reflect.defineMetadata(exports.OUTPUT_METADATA_KEY, [...existingOutputs, propertyKey], target);
118
+ };
55
119
  }
@@ -1,5 +1,2 @@
1
- import { Type } from '@nestjs/common';
2
- export declare const CAPABILITY_METADATA = "is_capability";
3
- export declare const MODULE_FACTORY_CLASS = "module_factory_class";
4
- export declare function Capability(): (target: any) => void;
5
- export declare function ModuleFactory(factoryClass: Type<any>): (target: any) => void;
1
+ export declare const FACTORY_MODULE = "FACTORY_MODULE";
2
+ export declare function CapabilityFactory(moduleClass: string): (target: any) => any;
@@ -1,19 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MODULE_FACTORY_CLASS = exports.CAPABILITY_METADATA = void 0;
4
- exports.Capability = Capability;
5
- exports.ModuleFactory = ModuleFactory;
3
+ exports.FACTORY_MODULE = void 0;
4
+ exports.CapabilityFactory = CapabilityFactory;
6
5
  const common_1 = require("@nestjs/common");
7
- exports.CAPABILITY_METADATA = 'is_capability';
8
- exports.MODULE_FACTORY_CLASS = 'module_factory_class';
9
- function Capability() {
6
+ exports.FACTORY_MODULE = 'FACTORY_MODULE';
7
+ function CapabilityFactory(moduleClass) {
10
8
  return (target) => {
11
9
  (0, common_1.Injectable)()(target);
12
- Reflect.defineMetadata(exports.CAPABILITY_METADATA, true, target);
13
- };
14
- }
15
- function ModuleFactory(factoryClass) {
16
- return (target) => {
17
- Reflect.defineMetadata(exports.MODULE_FACTORY_CLASS, factoryClass, target);
10
+ Reflect.defineMetadata(exports.FACTORY_MODULE, moduleClass, target);
11
+ return target;
18
12
  };
19
13
  }
@@ -4,7 +4,7 @@ import type { JSONSchemaConfigType } from '@loopstack/contracts/types';
4
4
  export declare class DocumentEntity<T = any> {
5
5
  id: string;
6
6
  messageId: string;
7
- configKey: string;
7
+ blockName: string;
8
8
  workspaceId: string;
9
9
  pipelineId: string;
10
10
  content: T | null;
@@ -16,7 +16,7 @@ const utils_1 = require("../utils");
16
16
  let DocumentEntity = class DocumentEntity {
17
17
  id;
18
18
  messageId;
19
- configKey;
19
+ blockName;
20
20
  workspaceId;
21
21
  pipelineId;
22
22
  content;
@@ -51,10 +51,10 @@ __decorate([
51
51
  __metadata("design:type", String)
52
52
  ], DocumentEntity.prototype, "messageId", void 0);
53
53
  __decorate([
54
- (0, typeorm_1.Column)({ type: 'varchar', name: 'config_key' }),
54
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'block_name' }),
55
55
  (0, typeorm_1.Index)(),
56
56
  __metadata("design:type", String)
57
- ], DocumentEntity.prototype, "configKey", void 0);
57
+ ], DocumentEntity.prototype, "blockName", void 0);
58
58
  __decorate([
59
59
  (0, typeorm_1.Column)({ name: 'workspace_id' }),
60
60
  (0, typeorm_1.Index)(),
@@ -5,7 +5,7 @@ import { z } from 'zod';
5
5
  import type { JSONSchemaConfigType } from '@loopstack/contracts/types';
6
6
  export declare class PipelineEntity {
7
7
  id: string;
8
- configKey: string;
8
+ blockName: string;
9
9
  title: string | null;
10
10
  run: number;
11
11
  labels: string[];
@@ -17,7 +17,7 @@ const enums_1 = require("../enums");
17
17
  const utils_1 = require("../utils");
18
18
  let PipelineEntity = class PipelineEntity {
19
19
  id;
20
- configKey;
20
+ blockName;
21
21
  title;
22
22
  run;
23
23
  labels;
@@ -41,10 +41,10 @@ __decorate([
41
41
  __metadata("design:type", String)
42
42
  ], PipelineEntity.prototype, "id", void 0);
43
43
  __decorate([
44
- (0, typeorm_1.Column)({ type: 'varchar', name: 'config_key' }),
44
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'block_name' }),
45
45
  (0, typeorm_1.Index)(),
46
46
  __metadata("design:type", String)
47
- ], PipelineEntity.prototype, "configKey", void 0);
47
+ ], PipelineEntity.prototype, "blockName", void 0);
48
48
  __decorate([
49
49
  (0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
50
50
  __metadata("design:type", Object)
@@ -3,10 +3,10 @@ import { NamespaceEntity } from './namespace.entity';
3
3
  import { WorkflowState } from '../enums';
4
4
  import { TransitionResultLookup } from '../interfaces';
5
5
  import { z } from 'zod';
6
- import type { HistoryTransition, JSONSchemaConfigType, UiFormType, WorkflowTransitionType } from '@loopstack/contracts/types';
6
+ import type { JSONSchemaConfigType, UiFormType, WorkflowTransitionType } from '@loopstack/contracts/types';
7
7
  export declare class WorkflowEntity {
8
8
  id: string;
9
- configKey: string;
9
+ blockName: string;
10
10
  title: string;
11
11
  index: string;
12
12
  progress: number;
@@ -19,7 +19,7 @@ export declare class WorkflowEntity {
19
19
  transitionResults: TransitionResultLookup | null;
20
20
  inputData: Record<string, any>;
21
21
  availableTransitions: WorkflowTransitionType[] | null;
22
- history: HistoryTransition[] | null;
22
+ history: any[] | null;
23
23
  schema: JSONSchemaConfigType | null;
24
24
  error: z.ZodError | null;
25
25
  ui: UiFormType | null;
@@ -17,7 +17,7 @@ const enums_1 = require("../enums");
17
17
  const utils_1 = require("../utils");
18
18
  let WorkflowEntity = class WorkflowEntity {
19
19
  id;
20
- configKey;
20
+ blockName;
21
21
  title;
22
22
  index;
23
23
  progress;
@@ -30,7 +30,7 @@ let WorkflowEntity = class WorkflowEntity {
30
30
  transitionResults;
31
31
  inputData;
32
32
  availableTransitions;
33
- history;
33
+ history; //todo should be WorkflowMementoDto[]
34
34
  schema;
35
35
  error;
36
36
  ui;
@@ -49,10 +49,10 @@ __decorate([
49
49
  __metadata("design:type", String)
50
50
  ], WorkflowEntity.prototype, "id", void 0);
51
51
  __decorate([
52
- (0, typeorm_1.Column)({ type: 'varchar', name: 'config_key' }),
52
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'block_name' }),
53
53
  (0, typeorm_1.Index)(),
54
54
  __metadata("design:type", String)
55
- ], WorkflowEntity.prototype, "configKey", void 0);
55
+ ], WorkflowEntity.prototype, "blockName", void 0);
56
56
  __decorate([
57
57
  (0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
58
58
  __metadata("design:type", String)
@@ -2,7 +2,7 @@ import { PipelineEntity } from './pipeline.entity';
2
2
  export declare class WorkspaceEntity {
3
3
  id: string;
4
4
  title: string;
5
- configKey: string;
5
+ blockName: string;
6
6
  createdAt: Date;
7
7
  updatedAt: Date;
8
8
  pipelines: PipelineEntity[];
@@ -16,7 +16,7 @@ const pipeline_entity_1 = require("./pipeline.entity");
16
16
  let WorkspaceEntity = class WorkspaceEntity {
17
17
  id;
18
18
  title;
19
- configKey;
19
+ blockName;
20
20
  createdAt;
21
21
  updatedAt;
22
22
  pipelines;
@@ -32,10 +32,10 @@ __decorate([
32
32
  __metadata("design:type", String)
33
33
  ], WorkspaceEntity.prototype, "title", void 0);
34
34
  __decorate([
35
- (0, typeorm_1.Column)({ type: 'varchar', name: 'config_key' }),
35
+ (0, typeorm_1.Column)({ type: 'varchar', name: 'block_name' }),
36
36
  (0, typeorm_1.Index)(),
37
37
  __metadata("design:type", String)
38
- ], WorkspaceEntity.prototype, "configKey", void 0);
38
+ ], WorkspaceEntity.prototype, "blockName", void 0);
39
39
  __decorate([
40
40
  (0, typeorm_2.CreateDateColumn)({ name: 'created_at' }),
41
41
  __metadata("design:type", Date)
@@ -1,22 +1,6 @@
1
- import { z } from 'zod';
2
- import { Scope, Type } from '@nestjs/common';
3
- import type { BlockConfigType, JSONSchemaConfigType } from '@loopstack/contracts/types';
1
+ import type { BlockConfigType } from '@loopstack/contracts/types';
4
2
  export interface BlockOptions {
5
- scope?: Scope;
6
- imports?: any[];
3
+ type?: string;
7
4
  config?: Partial<BlockConfigType>;
8
5
  configFile?: string;
9
- documentationFile?: string;
10
- properties?: z.ZodType;
11
- configSchema?: z.ZodType;
12
- }
13
- export interface BlockMetadata {
14
- imports: Type<any>[];
15
- config: BlockConfigType;
16
- configFile?: string;
17
- properties?: z.ZodType;
18
- propertiesSchema?: JSONSchemaConfigType;
19
- configSchema?: z.ZodType;
20
- inputProperties: string[];
21
- outputProperties: string[];
22
6
  }
@@ -3,9 +3,9 @@ export interface ToolSideEffects {
3
3
  setTransitionPlace?: string;
4
4
  addWorkflowDocuments?: DocumentEntity[];
5
5
  }
6
- export type HandlerCallResult = {
6
+ export type ToolResult<TData = any> = {
7
7
  type?: 'text' | 'image' | 'file';
8
- data?: any;
8
+ data?: TData;
9
9
  error?: string;
10
10
  effects?: ToolSideEffects;
11
11
  };
@@ -1,6 +1,6 @@
1
- import { HandlerCallResult } from './handler.interface';
1
+ import { ToolResult } from './handler.interface';
2
2
  export type StepResultLookup = Record<string, any>;
3
- export type ToolResultLookup = Record<string, HandlerCallResult>;
3
+ export type ToolResultLookup = Record<string, ToolResult>;
4
4
  export type TransitionResultLookup = Record<string, {
5
5
  toolResults: ToolResultLookup;
6
6
  }>;
@@ -0,0 +1,8 @@
1
+ import { Reflector } from '@nestjs/core';
2
+ import { BlockOptions } from '../interfaces';
3
+ export declare class BlockConfigService {
4
+ private reflector;
5
+ constructor(reflector: Reflector);
6
+ getMetadata(): BlockOptions;
7
+ getConfig(target: object | Function): void;
8
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var _a;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.BlockConfigService = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const core_1 = require("@nestjs/core");
16
+ const decorators_1 = require("../decorators");
17
+ let BlockConfigService = class BlockConfigService {
18
+ reflector;
19
+ constructor(reflector) {
20
+ this.reflector = reflector;
21
+ }
22
+ getMetadata() {
23
+ return this.reflector.get(decorators_1.BLOCK_METADATA_KEY, this.constructor);
24
+ }
25
+ getConfig(target) {
26
+ const constructor = typeof target === 'function' ? target : target.constructor;
27
+ const metadata = this.getMetadata();
28
+ }
29
+ };
30
+ exports.BlockConfigService = BlockConfigService;
31
+ exports.BlockConfigService = BlockConfigService = __decorate([
32
+ (0, common_1.Injectable)(),
33
+ __metadata("design:paramtypes", [typeof (_a = typeof core_1.Reflector !== "undefined" && core_1.Reflector) === "function" ? _a : Object])
34
+ ], BlockConfigService);
@@ -0,0 +1,3 @@
1
+ import { BlockConfigType } from '@loopstack/contracts/types';
2
+ import { BlockOptions } from '../interfaces';
3
+ export declare function buildConfig(options: BlockOptions, type?: string): BlockConfigType;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildConfig = buildConfig;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const yaml_1 = require("yaml");
10
+ function buildConfig(options, type) {
11
+ const baseConfig = {
12
+ ...options.config,
13
+ };
14
+ if (options.configFile) {
15
+ const configSource = loadConfigFile(options.configFile);
16
+ if (!configSource) {
17
+ throw new Error(`Could not load config source ${options.configFile}`);
18
+ }
19
+ Object.assign(baseConfig, configSource.config);
20
+ }
21
+ if (type) {
22
+ baseConfig.type = type;
23
+ }
24
+ return {
25
+ type: baseConfig.type ?? 'undefined',
26
+ description: baseConfig.description ?? '',
27
+ ...baseConfig,
28
+ };
29
+ }
30
+ function loadConfigFile(filePath) {
31
+ const raw = fs_1.default.readFileSync(filePath, 'utf8');
32
+ const config = (0, yaml_1.parse)(raw);
33
+ return {
34
+ path: filePath,
35
+ relativePath: path_1.default.basename(filePath),
36
+ raw,
37
+ config,
38
+ };
39
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@loopstack/common",
3
3
  "displayName": "Loopstack Common Module",
4
4
  "description": "A collection of utils and dtos shared between nestjs modules",
5
- "version": "0.14.0",
5
+ "version": "0.15.1",
6
6
  "license": "BSL",
7
7
  "author": {
8
8
  "name": "Jakob Klippel",
@@ -28,10 +28,11 @@
28
28
  "typescript": "^5.7.3"
29
29
  },
30
30
  "dependencies": {
31
- "@loopstack/contracts": "^0.14.0",
31
+ "@loopstack/contracts": "^0.15.0",
32
32
  "fast-json-stable-stringify": "^2.1.0",
33
33
  "murmurhash": "^2.0.1",
34
34
  "reflect-metadata": "^0.2.2",
35
+ "yaml": "^2.8.1",
35
36
  "zod": "^3.25.76"
36
37
  }
37
38
  }