@tstdl/base 0.93.61 → 0.93.64
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/ai/genkit/helpers.d.ts +10 -0
- package/ai/genkit/helpers.js +14 -0
- package/ai/genkit/index.d.ts +2 -0
- package/ai/genkit/index.js +2 -0
- package/ai/genkit/module.d.ts +35 -0
- package/ai/genkit/module.js +56 -0
- package/ai/index.d.ts +1 -0
- package/ai/index.js +1 -0
- package/ai/prompts/format.d.ts +15 -0
- package/ai/prompts/format.js +17 -0
- package/ai/prompts/index.d.ts +3 -0
- package/ai/prompts/index.js +3 -0
- package/ai/prompts/instructions-formatter.d.ts +25 -0
- package/ai/prompts/instructions-formatter.js +166 -0
- package/ai/prompts/instructions.d.ts +3 -0
- package/ai/prompts/instructions.js +8 -0
- package/document-management/api/document-management.api.d.ts +8 -8
- package/document-management/models/document-assignment-scope.model.d.ts +3 -4
- package/document-management/models/document-assignment-scope.model.js +5 -9
- package/document-management/models/document-assignment-task.model.d.ts +3 -4
- package/document-management/models/document-assignment-task.model.js +4 -8
- package/document-management/models/document-category.model.d.ts +3 -4
- package/document-management/models/document-category.model.js +4 -8
- package/document-management/models/document-collection-assignment.model.d.ts +2 -3
- package/document-management/models/document-collection-assignment.model.js +4 -9
- package/document-management/models/document-collection.model.d.ts +3 -4
- package/document-management/models/document-collection.model.js +4 -8
- package/document-management/models/document-property-value.model.d.ts +3 -4
- package/document-management/models/document-property-value.model.js +5 -9
- package/document-management/models/document-property.model.d.ts +3 -4
- package/document-management/models/document-property.model.js +3 -7
- package/document-management/models/document-request-collection-assignment.model.d.ts +3 -4
- package/document-management/models/document-request-collection-assignment.model.js +5 -9
- package/document-management/models/document-request-template.d.ts +2 -3
- package/document-management/models/document-request-template.js +4 -9
- package/document-management/models/document-request.model.d.ts +3 -4
- package/document-management/models/document-request.model.js +5 -9
- package/document-management/models/document-requests-template.d.ts +2 -3
- package/document-management/models/document-requests-template.js +2 -7
- package/document-management/models/document-tag-assignment.model.d.ts +3 -4
- package/document-management/models/document-tag-assignment.model.js +5 -9
- package/document-management/models/document-tag.model.d.ts +3 -4
- package/document-management/models/document-tag.model.js +3 -7
- package/document-management/models/document-type-property.model.d.ts +2 -3
- package/document-management/models/document-type-property.model.js +4 -9
- package/document-management/models/document-type-validation.model.d.ts +2 -3
- package/document-management/models/document-type-validation.model.js +4 -9
- package/document-management/models/document-type.model.d.ts +3 -4
- package/document-management/models/document-type.model.js +4 -8
- package/document-management/models/document-validation-definition.model.d.ts +3 -4
- package/document-management/models/document-validation-definition.model.js +3 -7
- package/document-management/models/document-validation-execution-related-document.model.d.ts +3 -4
- package/document-management/models/document-validation-execution-related-document.model.js +5 -9
- package/document-management/models/document-validation-execution.model.d.ts +3 -4
- package/document-management/models/document-validation-execution.model.js +5 -9
- package/document-management/models/document-workflow.model.d.ts +3 -4
- package/document-management/models/document-workflow.model.js +4 -8
- package/document-management/models/document.model.d.ts +3 -4
- package/document-management/models/document.model.js +4 -8
- package/document-management/server/drizzle/0001_lyrical_wong.sql +123 -0
- package/document-management/server/drizzle/meta/0001_snapshot.json +2728 -0
- package/document-management/server/drizzle/meta/_journal.json +7 -0
- package/document-management/server/services/document-category-type.service.d.ts +6 -6
- package/document-management/server/services/document-category-type.service.js +6 -6
- package/document-management/server/services/document-file.service.d.ts +2 -0
- package/document-management/server/services/document-file.service.js +10 -9
- package/document-management/server/services/document-management-ai.service.d.ts +1 -0
- package/document-management/server/services/document-management-ai.service.js +268 -135
- package/document-management/server/services/document-management.service.d.ts +2 -2
- package/document-management/server/services/document-property.service.d.ts +4 -4
- package/document-management/server/services/document-property.service.js +3 -3
- package/document-management/server/services/document-request.service.d.ts +2 -2
- package/document-management/server/services/document-request.service.js +1 -1
- package/document-management/server/services/document-tag.service.d.ts +1 -1
- package/document-management/server/services/document-tag.service.js +2 -2
- package/document-management/server/services/document-validation.service.js +6 -6
- package/document-management/server/services/document.service.js +2 -7
- package/document-management/service-models/document-management.view-model.d.ts +1 -1
- package/document-management/service-models/document-management.view-model.js +1 -1
- package/document-management/service-models/document.service-model.d.ts +4 -4
- package/document-management/service-models/enriched/enriched-document-category.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document-type.view.d.ts +1 -1
- package/examples/document-management/main.js +6 -0
- package/json-path/json-path.js +1 -1
- package/orm/decorators.d.ts +18 -7
- package/orm/decorators.js +10 -2
- package/orm/entity.d.ts +2 -2
- package/orm/entity.js +2 -0
- package/orm/server/drizzle/schema-converter.d.ts +3 -3
- package/orm/server/drizzle/schema-converter.js +22 -5
- package/orm/server/repository.js +4 -6
- package/package.json +11 -7
- package/pdf/utils.js +1 -1
- package/schema/converters/zod-converter.d.ts +1 -1
- package/schema/converters/zod-converter.js +2 -13
- package/schema/converters/zod-v3-converter.d.ts +3 -3
- package/utils/file-reader.d.ts +0 -1
- package/utils/file-reader.js +4 -7
- package/utils/object/object.d.ts +4 -2
- package/utils/object/object.js +30 -21
- package/utils/stream/from-promise.js +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GenerateOptions, z } from 'genkit';
|
|
2
|
+
import type { SchemaTestable } from '../../schema/index.js';
|
|
3
|
+
import type { TypedOmit } from '../../types/types.js';
|
|
4
|
+
export type TstdlGenkitGenerationOptions<T, O extends z.ZodTypeAny> = TypedOmit<GenerateOptions<z.ZodType<NoInfer<T>>, O>, 'output'> & {
|
|
5
|
+
output?: TypedOmit<NonNullable<GenerateOptions['output']>, 'schema'> & {
|
|
6
|
+
schema?: SchemaTestable<T>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare function convertToGenkitSchema<T>(schema: SchemaTestable<T>): z.ZodType<T>;
|
|
10
|
+
export declare function genkitGenerationOptions<T, O extends z.ZodTypeAny>(options: TstdlGenkitGenerationOptions<T, O>): GenerateOptions<z.ZodType<T>, z.ZodType<O>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { convertToZodV3Schema } from '../../schema/converters/zod-v3-converter.js';
|
|
2
|
+
import { isDefined } from '../../utils/type-guards.js';
|
|
3
|
+
export function convertToGenkitSchema(schema) {
|
|
4
|
+
return convertToZodV3Schema(schema); // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
5
|
+
}
|
|
6
|
+
export function genkitGenerationOptions(options) {
|
|
7
|
+
return {
|
|
8
|
+
...options,
|
|
9
|
+
output: {
|
|
10
|
+
...options.output,
|
|
11
|
+
schema: isDefined(options.output?.schema) ? convertToGenkitSchema(options.output.schema) : undefined,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { vertexAI } from '@genkit-ai/google-genai';
|
|
2
|
+
import { type Genkit, type GenkitOptions } from 'genkit';
|
|
3
|
+
/**
|
|
4
|
+
* Options for configuring the AI Module.
|
|
5
|
+
*/
|
|
6
|
+
export declare class GenkitModuleOptions {
|
|
7
|
+
/** Gemini API specific options. */
|
|
8
|
+
gemini?: {
|
|
9
|
+
/** Gemini API key */
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
};
|
|
12
|
+
/** Vertex AI specific options. If provided, the service will use Vertex AI endpoints. */
|
|
13
|
+
vertex?: {
|
|
14
|
+
/** Google Cloud API key */
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
/** Google Cloud projectId */
|
|
17
|
+
projectId: string;
|
|
18
|
+
/** Google Cloud region */
|
|
19
|
+
location: string;
|
|
20
|
+
/** Path to the Google Cloud credentials file */
|
|
21
|
+
keyFile?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Plugins to register automatically */
|
|
24
|
+
plugins?: GenkitOptions['plugins'];
|
|
25
|
+
/** Default Genkit options */
|
|
26
|
+
options?: Omit<GenkitOptions, 'plugins'>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Configures the {@link AiService}.
|
|
30
|
+
* @param options The configuration options for the AI services.
|
|
31
|
+
*/
|
|
32
|
+
export declare function configureGenkit(options: GenkitModuleOptions): void;
|
|
33
|
+
export declare function injectGenkit(options?: GenkitOptions): Genkit;
|
|
34
|
+
declare const _injectModel: typeof vertexAI.model;
|
|
35
|
+
export { _injectModel as injectModel };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { googleAI, vertexAI } from '@genkit-ai/google-genai';
|
|
2
|
+
import { genkit } from 'genkit';
|
|
3
|
+
import { inject } from '../../injector/inject.js';
|
|
4
|
+
import { Injector } from '../../injector/injector.js';
|
|
5
|
+
import { isDefined, isNotNull } from '../../utils/type-guards.js';
|
|
6
|
+
/**
|
|
7
|
+
* Options for configuring the AI Module.
|
|
8
|
+
*/
|
|
9
|
+
export class GenkitModuleOptions {
|
|
10
|
+
/** Gemini API specific options. */
|
|
11
|
+
gemini;
|
|
12
|
+
/** Vertex AI specific options. If provided, the service will use Vertex AI endpoints. */
|
|
13
|
+
vertex;
|
|
14
|
+
/** Plugins to register automatically */
|
|
15
|
+
plugins;
|
|
16
|
+
/** Default Genkit options */
|
|
17
|
+
options;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configures the {@link AiService}.
|
|
21
|
+
* @param options The configuration options for the AI services.
|
|
22
|
+
*/
|
|
23
|
+
export function configureGenkit(options) {
|
|
24
|
+
Injector.register(GenkitModuleOptions, { useValue: options });
|
|
25
|
+
}
|
|
26
|
+
export function injectGenkit(options) {
|
|
27
|
+
const { vertex, gemini, ...moduleOptions } = inject(GenkitModuleOptions, undefined, { optional: true }) ?? {};
|
|
28
|
+
const vertexPlugin = isDefined(vertex)
|
|
29
|
+
? vertexAI({
|
|
30
|
+
apiKey: vertex.apiKey,
|
|
31
|
+
location: vertex.location,
|
|
32
|
+
projectId: vertex.projectId,
|
|
33
|
+
googleAuth: isDefined(vertex.keyFile) ? { keyFile: vertex.keyFile } : undefined,
|
|
34
|
+
})
|
|
35
|
+
: null;
|
|
36
|
+
const geminiPlugin = isDefined(gemini)
|
|
37
|
+
? googleAI({ apiKey: gemini.apiKey })
|
|
38
|
+
: null;
|
|
39
|
+
return genkit({
|
|
40
|
+
...moduleOptions.options,
|
|
41
|
+
...options,
|
|
42
|
+
plugins: [
|
|
43
|
+
geminiPlugin,
|
|
44
|
+
vertexPlugin,
|
|
45
|
+
...(moduleOptions.plugins ?? []),
|
|
46
|
+
...(options?.plugins ?? []),
|
|
47
|
+
].filter(isNotNull),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function injectModel(...args) {
|
|
51
|
+
const moduleOptions = inject(GenkitModuleOptions, undefined, { optional: true }) ?? {};
|
|
52
|
+
const provider = isDefined(moduleOptions.vertex) ? vertexAI : googleAI;
|
|
53
|
+
return provider.model(...args);
|
|
54
|
+
}
|
|
55
|
+
const _injectModel = injectModel;
|
|
56
|
+
export { _injectModel as injectModel };
|
package/ai/index.d.ts
CHANGED
package/ai/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Json } from '../../types/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Formats objects and arrays for AI context. Requires values to be primitive types (or arrays of primitive types).
|
|
4
|
+
* Nesting of arrays is only supported one level deep and only recommended for a short list of items.
|
|
5
|
+
* If keys are not provided, all supported properties will be included. In case of arrays of objects, the keys of the first object will be used.
|
|
6
|
+
* @param data data to format
|
|
7
|
+
* @param dataTypeName name of the data type (e.g., "document", "users")
|
|
8
|
+
* @param keys keys to include in the output; can be property names or tuples of [property name, value extractor function]
|
|
9
|
+
* @returns formatted string representation of the data
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Format data as TOON string for AI context.
|
|
13
|
+
* @param data data to format
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatData(data: Json): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { encode } from '@toon-format/toon';
|
|
2
|
+
/**
|
|
3
|
+
* Formats objects and arrays for AI context. Requires values to be primitive types (or arrays of primitive types).
|
|
4
|
+
* Nesting of arrays is only supported one level deep and only recommended for a short list of items.
|
|
5
|
+
* If keys are not provided, all supported properties will be included. In case of arrays of objects, the keys of the first object will be used.
|
|
6
|
+
* @param data data to format
|
|
7
|
+
* @param dataTypeName name of the data type (e.g., "document", "users")
|
|
8
|
+
* @param keys keys to include in the output; can be property names or tuples of [property name, value extractor function]
|
|
9
|
+
* @returns formatted string representation of the data
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Format data as TOON string for AI context.
|
|
13
|
+
* @param data data to format
|
|
14
|
+
*/
|
|
15
|
+
export function formatData(data) {
|
|
16
|
+
return encode(data, { keyFolding: 'safe', indent: 2 });
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type ListStyle = 'sections' | 'ordered' | 'unordered';
|
|
2
|
+
type InstructionsListContent = string[] | Instructions;
|
|
3
|
+
export type InstructionsList = {
|
|
4
|
+
style: ListStyle;
|
|
5
|
+
instruction?: string;
|
|
6
|
+
items: InstructionsListContent;
|
|
7
|
+
};
|
|
8
|
+
export type Instructions = {
|
|
9
|
+
[key: string]: string | string[] | InstructionsList | Instructions;
|
|
10
|
+
};
|
|
11
|
+
export declare function sections(items: InstructionsListContent): InstructionsList;
|
|
12
|
+
export declare function sections(instruction: string, items: InstructionsListContent): InstructionsList;
|
|
13
|
+
export declare function orderedList(items: InstructionsListContent): InstructionsList;
|
|
14
|
+
export declare function orderedList(instruction: string, items: InstructionsListContent): InstructionsList;
|
|
15
|
+
export declare function unorderedList(items: InstructionsListContent): InstructionsList;
|
|
16
|
+
export declare function unorderedList(instruction: string, items: InstructionsListContent): InstructionsList;
|
|
17
|
+
/**
|
|
18
|
+
* Formats instructions into a string representation suitable for AI prompts.
|
|
19
|
+
* @param node
|
|
20
|
+
* @param options
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatInstructions(node: Instructions | InstructionsList | string[], options?: {
|
|
23
|
+
initialDepth?: number;
|
|
24
|
+
}): string;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { hasOwnProperty, objectEntries } from '../../utils/object/object.js';
|
|
2
|
+
import { assertDefined, isArray, isDefined, isObject, isString } from '../../utils/type-guards.js';
|
|
3
|
+
// --- Factories ---
|
|
4
|
+
function list(style, instructionOrItems, itemsOrNothing) {
|
|
5
|
+
const instruction = isString(instructionOrItems) ? instructionOrItems : undefined;
|
|
6
|
+
const items = isString(instructionOrItems) ? itemsOrNothing : instructionOrItems;
|
|
7
|
+
assertDefined(items, 'Instructions list is empty.');
|
|
8
|
+
return { style, instruction, items };
|
|
9
|
+
}
|
|
10
|
+
export function sections(instructionOrItems, itemsOrNothing) {
|
|
11
|
+
return list('sections', instructionOrItems, itemsOrNothing);
|
|
12
|
+
}
|
|
13
|
+
export function orderedList(instructionOrItems, itemsOrNothing) {
|
|
14
|
+
return list('ordered', instructionOrItems, itemsOrNothing);
|
|
15
|
+
}
|
|
16
|
+
export function unorderedList(instructionOrItems, itemsOrNothing) {
|
|
17
|
+
return list('unordered', instructionOrItems, itemsOrNothing);
|
|
18
|
+
}
|
|
19
|
+
// --- Type Guards ---
|
|
20
|
+
function isInstructionsList(obj) {
|
|
21
|
+
return isObject(obj) && hasOwnProperty(obj, 'style') && hasOwnProperty(obj, 'items');
|
|
22
|
+
}
|
|
23
|
+
// --- Formatter Logic ---
|
|
24
|
+
const INDENT_SIZE = 2;
|
|
25
|
+
function getPrefix(style, index, sectionDepth) {
|
|
26
|
+
switch (style) {
|
|
27
|
+
case 'ordered':
|
|
28
|
+
return `${index + 1}. `;
|
|
29
|
+
case 'unordered':
|
|
30
|
+
return '- ';
|
|
31
|
+
case 'sections':
|
|
32
|
+
return '#'.repeat(Math.max(1, sectionDepth)) + ' ';
|
|
33
|
+
default:
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Formats a string that might span multiple lines.
|
|
39
|
+
* It calculates the hanging indent based on the length of the prefix used on the first line.
|
|
40
|
+
*/
|
|
41
|
+
function formatWithHangingIndent(text, baseIndent, prefix) {
|
|
42
|
+
const lines = text.split('\n');
|
|
43
|
+
if (lines.length == 0) {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
const firstLine = `${baseIndent}${prefix}${lines[0]}`;
|
|
47
|
+
if (lines.length == 1) {
|
|
48
|
+
return firstLine;
|
|
49
|
+
}
|
|
50
|
+
// Create a spacer that exactly matches the visual length of " 1. " or " - "
|
|
51
|
+
const hangingSpacer = ' '.repeat(baseIndent.length + prefix.length);
|
|
52
|
+
return [
|
|
53
|
+
firstLine,
|
|
54
|
+
...lines.slice(1).map((line) => `${hangingSpacer}${line}`),
|
|
55
|
+
].join('\n');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Main recursive formatter.
|
|
59
|
+
*/
|
|
60
|
+
function processNode(node, context) {
|
|
61
|
+
// 1. Unwrap InstructionsList (The Wrapper)
|
|
62
|
+
// If the node is a wrapper, we adopt its style and instruction, then process its items.
|
|
63
|
+
if (isInstructionsList(node)) {
|
|
64
|
+
// Note: We don't print the "instruction" here (e.g., "Use Markdown").
|
|
65
|
+
// If this Wrapper is a root node, the instruction is usually printed by the caller or ignored.
|
|
66
|
+
// If this Wrapper is a value of a key, the key printer handles the instruction.
|
|
67
|
+
// However, if we have a "Root Wrapper" with an instruction (rare in your example), handle it:
|
|
68
|
+
const header = node.instruction ? `${node.instruction}\n` : '';
|
|
69
|
+
// Determine next context
|
|
70
|
+
const nextContext = {
|
|
71
|
+
indentDepth: context.indentDepth, // Wrappers don't indent themselves, their content does
|
|
72
|
+
style: node.style,
|
|
73
|
+
sectionDepth: node.style == 'sections' ? context.sectionDepth : context.sectionDepth, // Section depth increments internally
|
|
74
|
+
};
|
|
75
|
+
return header + processNode(node.items, nextContext);
|
|
76
|
+
}
|
|
77
|
+
// Common Constants for this level
|
|
78
|
+
const isSection = context.style == 'sections';
|
|
79
|
+
const currentBaseIndent = ' '.repeat(isSection ? 0 : context.indentDepth * INDENT_SIZE);
|
|
80
|
+
const separator = isSection ? '\n\n' : '\n';
|
|
81
|
+
// 2. Handle Arrays (Simple Lists)
|
|
82
|
+
if (isArray(node)) {
|
|
83
|
+
return node.map((item, index) => {
|
|
84
|
+
const prefix = getPrefix(context.style, index, context.sectionDepth);
|
|
85
|
+
return formatWithHangingIndent(item, currentBaseIndent, prefix);
|
|
86
|
+
}).join(separator);
|
|
87
|
+
}
|
|
88
|
+
// 3. Handle Objects (Key-Value Maps)
|
|
89
|
+
return objectEntries(node).map(([key, value], index) => {
|
|
90
|
+
const prefix = getPrefix(context.style, index, context.sectionDepth);
|
|
91
|
+
// Detect if the Value is a Wrapper (e.g. `Key: ordered(...)`)
|
|
92
|
+
// This allows us to pull the wrapper's "instruction" up to the Key line.
|
|
93
|
+
const isValueWrapper = isInstructionsList(value);
|
|
94
|
+
const effectiveValue = isValueWrapper ? value.items : value;
|
|
95
|
+
const instruction = (isValueWrapper && isDefined(value.instruction)) ? ` ${value.instruction}` : '';
|
|
96
|
+
const childStyle = isValueWrapper ? value.style : (isSection ? 'unordered' : 'unordered');
|
|
97
|
+
// Formatting the Header Line (The Key)
|
|
98
|
+
let headerLine = '';
|
|
99
|
+
if (isSection) {
|
|
100
|
+
// Header format: "# Key" or "# Key\n\nInstruction"
|
|
101
|
+
const instructionPart = (instruction.length > 0) ? `\n\n${instruction.trim()}` : '';
|
|
102
|
+
headerLine = `${currentBaseIndent}${prefix}${key}${instructionPart}`;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// List format: "- **Key:**" or "- **Key:** Instruction"
|
|
106
|
+
const keyPart = `**${key}:**`;
|
|
107
|
+
headerLine = `${currentBaseIndent}${prefix}${keyPart}${instruction}`;
|
|
108
|
+
}
|
|
109
|
+
// Determine context for the children
|
|
110
|
+
// If we are a Section, children reset indent to 0.
|
|
111
|
+
// If we are a List, children indent + 1.
|
|
112
|
+
const nextIndentDepth = isSection ? 0 : context.indentDepth + 1;
|
|
113
|
+
// If the child acts as a section (Wrapper was `sections(...)`), increment H-level.
|
|
114
|
+
const nextSectionDepth = (isValueWrapper && value.style == 'sections')
|
|
115
|
+
? context.sectionDepth + 1
|
|
116
|
+
: context.sectionDepth;
|
|
117
|
+
// Recurse
|
|
118
|
+
// If the value is a simple string, we print it inline if possible, or block if it's long?
|
|
119
|
+
// Your requirement: Strings in objects are usually descriptions.
|
|
120
|
+
if (isString(effectiveValue)) {
|
|
121
|
+
// If it's a string, we treat it as content on the SAME line for lists (via hanging indent logic),
|
|
122
|
+
// or a new paragraph for Sections.
|
|
123
|
+
if (isSection) {
|
|
124
|
+
// Section: Header \n\n Content
|
|
125
|
+
return `${headerLine}\n\n${effectiveValue.trim()}`;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// List: "- **Key:** Value"
|
|
129
|
+
// We need to construct the full string to calculate hanging indent correctly.
|
|
130
|
+
// headerLine already contains indentation + prefix + key.
|
|
131
|
+
// We strip the indentation to feed it into the formatting helper effectively.
|
|
132
|
+
const fullLine = `${headerLine} ${effectiveValue}`.trim();
|
|
133
|
+
return formatWithHangingIndent(fullLine, currentBaseIndent, '');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// If Value is Object/Array/Wrapper
|
|
137
|
+
const body = processNode(effectiveValue, {
|
|
138
|
+
indentDepth: nextIndentDepth,
|
|
139
|
+
style: childStyle,
|
|
140
|
+
sectionDepth: nextSectionDepth,
|
|
141
|
+
});
|
|
142
|
+
const bodySeparator = isSection ? '\n\n' : '\n';
|
|
143
|
+
// Edge case: If it's a section, we constructed the header, now append body.
|
|
144
|
+
// If it's a list, the header line serves as the parent item.
|
|
145
|
+
return `${headerLine}${bodySeparator}${body}`;
|
|
146
|
+
}).join(separator);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Formats instructions into a string representation suitable for AI prompts.
|
|
150
|
+
* @param node
|
|
151
|
+
* @param options
|
|
152
|
+
*/
|
|
153
|
+
export function formatInstructions(node, options = {}) {
|
|
154
|
+
// Heuristic: If passing a raw object, assume it's a Root Section unless specified otherwise.
|
|
155
|
+
// If passing a Wrapper, the Wrapper dictates the style.
|
|
156
|
+
const initialStyle = isInstructionsList(node)
|
|
157
|
+
? node.style
|
|
158
|
+
: isArray(node)
|
|
159
|
+
? 'unordered'
|
|
160
|
+
: 'sections';
|
|
161
|
+
return processNode(node, {
|
|
162
|
+
indentDepth: options.initialDepth ?? 0,
|
|
163
|
+
sectionDepth: 1,
|
|
164
|
+
style: initialStyle,
|
|
165
|
+
}).trim();
|
|
166
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { unorderedList } from './instructions-formatter.js';
|
|
2
|
+
export const jsonOutputInstructions = {
|
|
3
|
+
'JSON Output': unorderedList({
|
|
4
|
+
'Schema Compliance': 'Generate valid JSON that strictly matches the provided schema.',
|
|
5
|
+
'Nullable fields with missing data': 'Must be set to literal `null`.',
|
|
6
|
+
'Optional fields with missing data': 'Omit the key entirely (sparse JSON).',
|
|
7
|
+
}),
|
|
8
|
+
};
|
|
@@ -88,8 +88,8 @@ export declare const documentManagementApiDefinition: {
|
|
|
88
88
|
resource: string;
|
|
89
89
|
method: "POST";
|
|
90
90
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
91
|
-
parentId: import("../../orm/types.js").Uuid | null;
|
|
92
91
|
label: string;
|
|
92
|
+
parentId: import("../../orm/types.js").Uuid | null;
|
|
93
93
|
metadata?: Partial<{
|
|
94
94
|
attributes: import("../../orm/types.js").HasDefault<import("../../orm/types.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
|
|
95
95
|
}> | undefined;
|
|
@@ -127,10 +127,10 @@ export declare const documentManagementApiDefinition: {
|
|
|
127
127
|
method: "POST";
|
|
128
128
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
129
129
|
date?: import("../../orm/types.js").NumericDate | null | undefined;
|
|
130
|
+
summary?: string | null | undefined;
|
|
130
131
|
title?: string | null | undefined;
|
|
131
132
|
typeId?: import("../../orm/types.js").Uuid | null | undefined;
|
|
132
133
|
subtitle?: string | null | undefined;
|
|
133
|
-
summary?: string | null | undefined;
|
|
134
134
|
comment?: string | null | undefined;
|
|
135
135
|
approval?: import("../models/document.model.js").DocumentApproval | undefined;
|
|
136
136
|
originalFileName?: string | null | undefined;
|
|
@@ -179,7 +179,7 @@ export declare const documentManagementApiDefinition: {
|
|
|
179
179
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
180
180
|
id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/types.js").Uuid>>;
|
|
181
181
|
description?: string | null | undefined;
|
|
182
|
-
tenantId?:
|
|
182
|
+
tenantId?: import("../../orm/types.js").Uuid | undefined;
|
|
183
183
|
label?: string | undefined;
|
|
184
184
|
metadata?: Partial<{
|
|
185
185
|
attributes: import("../../orm/types.js").HasDefault<import("../../orm/types.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
|
|
@@ -232,7 +232,7 @@ export declare const documentManagementApiDefinition: {
|
|
|
232
232
|
method: "PATCH";
|
|
233
233
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
234
234
|
id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/types.js").Uuid>>;
|
|
235
|
-
tenantId?:
|
|
235
|
+
tenantId?: import("../../orm/types.js").Uuid | undefined;
|
|
236
236
|
typeId?: import("../../orm/types.js").Uuid | undefined;
|
|
237
237
|
comment?: string | null | undefined;
|
|
238
238
|
metadata?: Partial<{
|
|
@@ -488,8 +488,8 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
488
488
|
resource: string;
|
|
489
489
|
method: "POST";
|
|
490
490
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
491
|
-
parentId: import("../../orm/types.js").Uuid | null;
|
|
492
491
|
label: string;
|
|
492
|
+
parentId: import("../../orm/types.js").Uuid | null;
|
|
493
493
|
metadata?: Partial<{
|
|
494
494
|
attributes: import("../../orm/types.js").HasDefault<import("../../orm/types.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
|
|
495
495
|
}> | undefined;
|
|
@@ -527,10 +527,10 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
527
527
|
method: "POST";
|
|
528
528
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
529
529
|
date?: import("../../orm/types.js").NumericDate | null | undefined;
|
|
530
|
+
summary?: string | null | undefined;
|
|
530
531
|
title?: string | null | undefined;
|
|
531
532
|
typeId?: import("../../orm/types.js").Uuid | null | undefined;
|
|
532
533
|
subtitle?: string | null | undefined;
|
|
533
|
-
summary?: string | null | undefined;
|
|
534
534
|
comment?: string | null | undefined;
|
|
535
535
|
approval?: import("../models/document.model.js").DocumentApproval | undefined;
|
|
536
536
|
originalFileName?: string | null | undefined;
|
|
@@ -579,7 +579,7 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
579
579
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
580
580
|
id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/types.js").Uuid>>;
|
|
581
581
|
description?: string | null | undefined;
|
|
582
|
-
tenantId?:
|
|
582
|
+
tenantId?: import("../../orm/types.js").Uuid | undefined;
|
|
583
583
|
label?: string | undefined;
|
|
584
584
|
metadata?: Partial<{
|
|
585
585
|
attributes: import("../../orm/types.js").HasDefault<import("../../orm/types.js").Json<import("../../orm/entity.js").EntityMetadataAttributes>>;
|
|
@@ -632,7 +632,7 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
|
|
|
632
632
|
method: "PATCH";
|
|
633
633
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
634
634
|
id: import("../../orm/types.js").IsPrimaryKey<import("../../orm/types.js").HasDefault<import("../../orm/types.js").Uuid>>;
|
|
635
|
-
tenantId?:
|
|
635
|
+
tenantId?: import("../../orm/types.js").Uuid | undefined;
|
|
636
636
|
typeId?: import("../../orm/types.js").Uuid | undefined;
|
|
637
637
|
comment?: string | null | undefined;
|
|
638
638
|
metadata?: Partial<{
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TenantEntity, type Uuid } from '../../orm/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines which collections or requests in these collections (depends on assignment task) are allowed to be assigned to a document in the assignment workflow.
|
|
4
4
|
* This is used to prevent documents from being assigned to collections/requests that are out of scope/context.
|
|
5
5
|
*/
|
|
6
|
-
export declare class DocumentAssignmentScope extends
|
|
7
|
-
static readonly entityName
|
|
8
|
-
tenantId: Uuid;
|
|
6
|
+
export declare class DocumentAssignmentScope extends TenantEntity {
|
|
7
|
+
static readonly entityName = "DocumentAssignmentScope";
|
|
9
8
|
taskId: Uuid;
|
|
10
9
|
collectionId: Uuid;
|
|
11
10
|
}
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { ForeignKey, TenantEntity, TenantReference, Unique, UuidProperty } from '../../orm/index.js';
|
|
11
11
|
import { DocumentAssignmentTask } from './document-assignment-task.model.js';
|
|
12
12
|
import { DocumentCollection } from './document-collection.model.js';
|
|
13
13
|
import { DocumentManagementTable } from './document-management-table.js';
|
|
@@ -15,23 +15,19 @@ import { DocumentManagementTable } from './document-management-table.js';
|
|
|
15
15
|
* Defines which collections or requests in these collections (depends on assignment task) are allowed to be assigned to a document in the assignment workflow.
|
|
16
16
|
* This is used to prevent documents from being assigned to collections/requests that are out of scope/context.
|
|
17
17
|
*/
|
|
18
|
-
let DocumentAssignmentScope = class DocumentAssignmentScope extends
|
|
19
|
-
|
|
18
|
+
let DocumentAssignmentScope = class DocumentAssignmentScope extends TenantEntity {
|
|
19
|
+
static entityName = 'DocumentAssignmentScope';
|
|
20
20
|
taskId;
|
|
21
21
|
collectionId;
|
|
22
22
|
};
|
|
23
23
|
__decorate([
|
|
24
24
|
UuidProperty(),
|
|
25
|
-
|
|
26
|
-
], DocumentAssignmentScope.prototype, "tenantId", void 0);
|
|
27
|
-
__decorate([
|
|
28
|
-
UuidProperty(),
|
|
29
|
-
References(() => DocumentAssignmentTask),
|
|
25
|
+
TenantReference(() => DocumentAssignmentTask),
|
|
30
26
|
__metadata("design:type", String)
|
|
31
27
|
], DocumentAssignmentScope.prototype, "taskId", void 0);
|
|
32
28
|
__decorate([
|
|
33
29
|
UuidProperty(),
|
|
34
|
-
|
|
30
|
+
TenantReference(() => DocumentCollection),
|
|
35
31
|
__metadata("design:type", String)
|
|
36
32
|
], DocumentAssignmentScope.prototype, "collectionId", void 0);
|
|
37
33
|
DocumentAssignmentScope = __decorate([
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { type EnumType } from '../../enumeration/enumeration.js';
|
|
2
|
-
import {
|
|
2
|
+
import { TenantEntity, type Uuid } from '../../orm/index.js';
|
|
3
3
|
export declare const DocumentAssignmentTarget: {
|
|
4
4
|
readonly Collection: "collection";
|
|
5
5
|
readonly Request: "request";
|
|
6
6
|
};
|
|
7
7
|
export type DocumentAssignmentTarget = EnumType<typeof DocumentAssignmentTarget>;
|
|
8
|
-
export declare class DocumentAssignmentTask extends
|
|
9
|
-
static readonly entityName
|
|
10
|
-
tenantId: Uuid;
|
|
8
|
+
export declare class DocumentAssignmentTask extends TenantEntity {
|
|
9
|
+
static readonly entityName = "DocumentAssignmentTask";
|
|
11
10
|
documentId: Uuid;
|
|
12
11
|
target: DocumentAssignmentTarget;
|
|
13
12
|
}
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { defineEnum } from '../../enumeration/enumeration.js';
|
|
11
|
-
import {
|
|
11
|
+
import { ForeignKey, TenantEntity, TenantReference, Unique, UuidProperty } from '../../orm/index.js';
|
|
12
12
|
import { Enumeration } from '../../schema/index.js';
|
|
13
13
|
import { DocumentManagementTable } from './document-management-table.js';
|
|
14
14
|
import { Document } from './document.model.js';
|
|
@@ -16,18 +16,14 @@ export const DocumentAssignmentTarget = defineEnum('DocumentAssignmentTarget', {
|
|
|
16
16
|
Collection: 'collection',
|
|
17
17
|
Request: 'request',
|
|
18
18
|
});
|
|
19
|
-
let DocumentAssignmentTask = class DocumentAssignmentTask extends
|
|
20
|
-
|
|
19
|
+
let DocumentAssignmentTask = class DocumentAssignmentTask extends TenantEntity {
|
|
20
|
+
static entityName = 'DocumentAssignmentTask';
|
|
21
21
|
documentId;
|
|
22
22
|
target;
|
|
23
23
|
};
|
|
24
24
|
__decorate([
|
|
25
25
|
UuidProperty(),
|
|
26
|
-
|
|
27
|
-
], DocumentAssignmentTask.prototype, "tenantId", void 0);
|
|
28
|
-
__decorate([
|
|
29
|
-
UuidProperty(),
|
|
30
|
-
References(() => Document),
|
|
26
|
+
TenantReference(() => Document),
|
|
31
27
|
Unique(),
|
|
32
28
|
__metadata("design:type", String)
|
|
33
29
|
], DocumentAssignmentTask.prototype, "documentId", void 0);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class DocumentCategory extends
|
|
3
|
-
static readonly entityName
|
|
4
|
-
tenantId: string | null;
|
|
1
|
+
import { TenantEntity, type Uuid } from '../../orm/index.js';
|
|
2
|
+
export declare class DocumentCategory extends TenantEntity {
|
|
3
|
+
static readonly entityName = "DocumentCategory";
|
|
5
4
|
parentId: Uuid | null;
|
|
6
5
|
label: string;
|
|
7
6
|
}
|
|
@@ -7,21 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { TenantEntity, TenantReference, Unique, UuidProperty } from '../../orm/index.js';
|
|
11
11
|
import { StringProperty } from '../../schema/index.js';
|
|
12
12
|
import { DocumentManagementTable } from './document-management-table.js';
|
|
13
|
-
let DocumentCategory = class DocumentCategory extends
|
|
14
|
-
|
|
13
|
+
let DocumentCategory = class DocumentCategory extends TenantEntity {
|
|
14
|
+
static entityName = 'DocumentCategory';
|
|
15
15
|
parentId;
|
|
16
16
|
label;
|
|
17
17
|
};
|
|
18
18
|
__decorate([
|
|
19
19
|
UuidProperty({ nullable: true }),
|
|
20
|
-
|
|
21
|
-
], DocumentCategory.prototype, "tenantId", void 0);
|
|
22
|
-
__decorate([
|
|
23
|
-
UuidProperty({ nullable: true }),
|
|
24
|
-
References(() => DocumentCategory),
|
|
20
|
+
TenantReference(() => DocumentCategory),
|
|
25
21
|
__metadata("design:type", Object)
|
|
26
22
|
], DocumentCategory.prototype, "parentId", void 0);
|
|
27
23
|
__decorate([
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class DocumentCollectionAssignment extends
|
|
3
|
-
tenantId: Uuid;
|
|
1
|
+
import { TenantEntity, type Timestamp, type Uuid } from '../../orm/index.js';
|
|
2
|
+
export declare class DocumentCollectionAssignment extends TenantEntity {
|
|
4
3
|
collectionId: Uuid;
|
|
5
4
|
documentId: Uuid;
|
|
6
5
|
archiveTimestamp: Timestamp | null;
|