@aopslab/domain-kit-docman 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.
- package/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +79 -0
- package/dist/config/config.d.ts +55 -0
- package/dist/config/config.js +176 -0
- package/dist/domain-services/index.d.ts +7 -0
- package/dist/domain-services/index.js +7 -0
- package/dist/domain-services/jwt.d.ts +1 -0
- package/dist/domain-services/jwt.js +5 -0
- package/dist/domain-services/metrics.d.ts +5 -0
- package/dist/domain-services/metrics.js +7 -0
- package/dist/domain-services/presets.d.ts +3 -0
- package/dist/domain-services/presets.js +4 -0
- package/dist/domain-services/provider.d.ts +2 -0
- package/dist/domain-services/provider.js +564 -0
- package/dist/domain-services/resilience.d.ts +6 -0
- package/dist/domain-services/resilience.js +19 -0
- package/dist/domain-services/types.d.ts +179 -0
- package/dist/domain-services/types.js +1 -0
- package/dist/domain-services/unified.d.ts +272 -0
- package/dist/domain-services/unified.js +210 -0
- package/dist/errors/error.map.d.ts +21 -0
- package/dist/errors/error.map.js +47 -0
- package/dist/errors/friendly.d.ts +31 -0
- package/dist/errors/friendly.js +407 -0
- package/dist/errors/i18n.d.ts +4 -0
- package/dist/errors/i18n.js +10 -0
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.js +3 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/operations/catalog.d.ts +11 -0
- package/dist/operations/catalog.js +299 -0
- package/dist/operations/contract.d.ts +31 -0
- package/dist/operations/contract.js +667 -0
- package/dist/operations/dcm.d.ts +58 -0
- package/dist/operations/dcm.js +168 -0
- package/dist/operations/definition.d.ts +6 -0
- package/dist/operations/definition.js +140 -0
- package/dist/operations/executor.d.ts +10 -0
- package/dist/operations/executor.js +269 -0
- package/dist/operations/host-projection.d.ts +11 -0
- package/dist/operations/host-projection.js +156 -0
- package/dist/operations/index.d.ts +10 -0
- package/dist/operations/index.js +10 -0
- package/dist/operations/io-types.d.ts +125 -0
- package/dist/operations/io-types.js +1 -0
- package/dist/operations/schemas.d.ts +10 -0
- package/dist/operations/schemas.js +872 -0
- package/dist/operations/scope-owned-create.d.ts +3 -0
- package/dist/operations/scope-owned-create.js +12 -0
- package/dist/operations/tool-input.d.ts +11 -0
- package/dist/operations/tool-input.js +357 -0
- package/dist/operations/types.d.ts +37 -0
- package/dist/operations/types.js +1 -0
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.js +1 -0
- package/dist/resources/resources.docman.server.errors.d.ts +14 -0
- package/dist/resources/resources.docman.server.errors.js +36 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/tool-input-guard.d.ts +1 -0
- package/dist/shared/tool-input-guard.js +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const DOCMAN_SCOPE_OWNED_CREATE_OPERATION_IDS = new Set([
|
|
2
|
+
'document.create',
|
|
3
|
+
'document-group.create',
|
|
4
|
+
'section.create',
|
|
5
|
+
'page.create',
|
|
6
|
+
'snippet.create',
|
|
7
|
+
'asset.create',
|
|
8
|
+
'embed.create',
|
|
9
|
+
]);
|
|
10
|
+
export function isDocmanScopeOwnedCreateOperation(operationId) {
|
|
11
|
+
return DOCMAN_SCOPE_OWNED_CREATE_OPERATION_IDS.has(operationId);
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type FlattenToolingEnvelopeInput, type ParseToolInputWithZodOptions, type ToolOperationArg } from '../shared/tool-input-guard.js';
|
|
3
|
+
import type { DocmanOperationInput, DocmanTypedOperationId } from './io-types.js';
|
|
4
|
+
export type DocmanToolInput<TId extends DocmanTypedOperationId> = FlattenToolingEnvelopeInput<DocmanOperationInput<TId>>;
|
|
5
|
+
type DocmanToolInputParseOptions = Omit<ParseToolInputWithZodOptions, 'operationId' | 'input' | 'args' | 'schema'> & {
|
|
6
|
+
args?: ReadonlyArray<ToolOperationArg>;
|
|
7
|
+
};
|
|
8
|
+
export declare function getDocmanOperationArgs<TId extends DocmanTypedOperationId>(operationId: TId): ReadonlyArray<ToolOperationArg>;
|
|
9
|
+
export declare function getDocmanToolInputSchema<TId extends DocmanTypedOperationId>(operationId: TId): z.ZodType<DocmanOperationInput<TId>> | undefined;
|
|
10
|
+
export declare function parseDocmanToolInput<TId extends DocmanTypedOperationId>(operationId: TId, input: DocmanToolInput<TId> | DocmanOperationInput<TId> | unknown, options?: DocmanToolInputParseOptions): DocmanOperationInput<TId>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { buildToolInputEnvelopeSchema, buildToolInputSchema, optionalToolInputNumber, optionalToolInputString, parseToolInputWithZod, requiredToolInputString, } from '../shared/tool-input-guard.js';
|
|
3
|
+
import { documentGroupZodSchemaInsert, documentSectionLinkZodSchemaInsert, documentVersionZodSchemaInsert, documentZodSchemaInsert, assetVersionMutablePatchZodSchema, assetVersionZodSchemaInsert, assetZodSchemaInsert, embedZodSchemaInsert, pageEmbedLinkZodSchemaInsert, pageSnippetLinkZodSchemaInsert, pageVersionZodSchemaInsert, pageZodSchemaInsert, sectionPageLinkZodSchemaInsert, sectionZodSchemaInsert, snippetZodSchemaInsert, } from '@aopslab/domain-dm-docman/models';
|
|
4
|
+
import { listDocmanOperationSpecs } from './catalog.js';
|
|
5
|
+
import { isDocmanScopeOwnedCreateOperation } from './scope-owned-create.js';
|
|
6
|
+
const DOCMAN_OPERATION_ARGS_BY_ID = new Map(listDocmanOperationSpecs({ refresh: true }).map((operation) => [
|
|
7
|
+
operation.operationId,
|
|
8
|
+
operation.args,
|
|
9
|
+
]));
|
|
10
|
+
const DOCMAN_OPTIONS_SCHEMA = z.record(z.string(), z.unknown());
|
|
11
|
+
const DOCMAN_LOCALE_OPTIONS_SCHEMA = z
|
|
12
|
+
.object({
|
|
13
|
+
locale: optionalToolInputString('locale'),
|
|
14
|
+
fallbackLocale: optionalToolInputString('fallbackLocale'),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
17
|
+
function toRecord(input) {
|
|
18
|
+
if (!input || typeof input !== 'object' || Array.isArray(input))
|
|
19
|
+
return {};
|
|
20
|
+
return input;
|
|
21
|
+
}
|
|
22
|
+
function normalizeNonEmpty(input) {
|
|
23
|
+
if (typeof input !== 'string')
|
|
24
|
+
return undefined;
|
|
25
|
+
const trimmed = input.trim();
|
|
26
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
27
|
+
}
|
|
28
|
+
function normalizeScopeResolution(input) {
|
|
29
|
+
return input === 'explicit' || input === 'cascade' ? input : undefined;
|
|
30
|
+
}
|
|
31
|
+
function buildCrudListInputSchema() {
|
|
32
|
+
return buildToolInputSchema({
|
|
33
|
+
filter: z.record(z.string(), z.unknown()).optional(),
|
|
34
|
+
options: DOCMAN_OPTIONS_SCHEMA.optional(),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function buildCrudGetInputSchema() {
|
|
38
|
+
return buildToolInputSchema({
|
|
39
|
+
id: requiredToolInputString('id'),
|
|
40
|
+
options: DOCMAN_OPTIONS_SCHEMA.optional(),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function buildCrudDeleteInputSchema() {
|
|
44
|
+
return buildToolInputSchema({
|
|
45
|
+
id: requiredToolInputString('id'),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function buildCrudCreateInputSchema(inner) {
|
|
49
|
+
return buildToolInputEnvelopeSchema({
|
|
50
|
+
envelopeKey: 'data',
|
|
51
|
+
inner,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function buildCrudUpdateInputSchema(inner, operationId) {
|
|
55
|
+
return buildToolInputEnvelopeSchema({
|
|
56
|
+
envelopeKey: 'patch',
|
|
57
|
+
extraShape: {
|
|
58
|
+
id: requiredToolInputString('id'),
|
|
59
|
+
},
|
|
60
|
+
inner: z.object(inner.shape).partial().strict(),
|
|
61
|
+
}).superRefine((value, ctx) => {
|
|
62
|
+
const payload = toRecord(value);
|
|
63
|
+
const patch = toRecord(payload.patch);
|
|
64
|
+
if (Object.keys(patch).length > 0)
|
|
65
|
+
return;
|
|
66
|
+
ctx.addIssue({
|
|
67
|
+
code: z.ZodIssueCode.custom,
|
|
68
|
+
message: `validation_failed:${operationId}`,
|
|
69
|
+
path: ['patch'],
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function parseCrudKind(operationId) {
|
|
74
|
+
const segments = operationId
|
|
75
|
+
.split('.')
|
|
76
|
+
.map((segment) => segment.trim())
|
|
77
|
+
.filter(Boolean);
|
|
78
|
+
if (segments.length !== 2)
|
|
79
|
+
return null;
|
|
80
|
+
const kind = segments[1];
|
|
81
|
+
if (kind === 'list' || kind === 'get' || kind === 'create' || kind === 'update' || kind === 'delete') {
|
|
82
|
+
return kind;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function normalizeDocmanScopeAwareInput(operationId, input) {
|
|
87
|
+
const payload = toRecord(input);
|
|
88
|
+
if (Object.keys(payload).length === 0)
|
|
89
|
+
return input;
|
|
90
|
+
if (operationId === 'document.scope.search') {
|
|
91
|
+
return Object.fromEntries(Object.entries(payload).filter(([key]) => !['scopeResolution', '__hostContext'].includes(key)));
|
|
92
|
+
}
|
|
93
|
+
if (operationId === 'document-version.import-headings') {
|
|
94
|
+
return payload;
|
|
95
|
+
}
|
|
96
|
+
const kind = parseCrudKind(operationId);
|
|
97
|
+
if (kind === 'list') {
|
|
98
|
+
const hasFilterEnvelope = Object.prototype.hasOwnProperty.call(payload, 'filter');
|
|
99
|
+
const filter = hasFilterEnvelope
|
|
100
|
+
? { ...toRecord(payload.filter) }
|
|
101
|
+
: Object.fromEntries(Object.entries(payload).filter(([key]) => !['filter', 'options', 'scopeId', 'scopeResolution'].includes(key)));
|
|
102
|
+
const scopeId = normalizeNonEmpty(payload.scopeId);
|
|
103
|
+
const scopeResolution = normalizeScopeResolution(payload.scopeResolution);
|
|
104
|
+
if (scopeId && filter.scopeId === undefined) {
|
|
105
|
+
filter.scopeId = scopeId;
|
|
106
|
+
}
|
|
107
|
+
if (scopeResolution && filter.scopeResolution === undefined) {
|
|
108
|
+
filter.scopeResolution = scopeResolution;
|
|
109
|
+
}
|
|
110
|
+
const options = toRecord(payload.options);
|
|
111
|
+
return {
|
|
112
|
+
...(Object.keys(filter).length > 0 ? { filter } : {}),
|
|
113
|
+
...(Object.keys(options).length > 0 ? { options } : {}),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (kind === 'create') {
|
|
117
|
+
const scopeId = normalizeNonEmpty(payload.scopeId);
|
|
118
|
+
const hasDataEnvelope = Object.prototype.hasOwnProperty.call(payload, 'data');
|
|
119
|
+
const data = hasDataEnvelope ? { ...toRecord(payload.data) } : { ...payload };
|
|
120
|
+
delete data.scopeId;
|
|
121
|
+
delete data.scopeResolution;
|
|
122
|
+
if (scopeId && isDocmanScopeOwnedCreateOperation(operationId)) {
|
|
123
|
+
data.scopeId = scopeId;
|
|
124
|
+
}
|
|
125
|
+
return { data };
|
|
126
|
+
}
|
|
127
|
+
if (kind === 'get') {
|
|
128
|
+
const id = normalizeNonEmpty(payload.id);
|
|
129
|
+
const options = toRecord(payload.options);
|
|
130
|
+
return {
|
|
131
|
+
...(id ? { id } : {}),
|
|
132
|
+
...(Object.keys(options).length > 0 ? { options } : {}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (kind === 'update') {
|
|
136
|
+
const id = normalizeNonEmpty(payload.id);
|
|
137
|
+
const hasPatchEnvelope = Object.prototype.hasOwnProperty.call(payload, 'patch');
|
|
138
|
+
const patch = hasPatchEnvelope
|
|
139
|
+
? { ...toRecord(payload.patch) }
|
|
140
|
+
: Object.fromEntries(Object.entries(payload).filter(([key]) => !['id', 'patch', 'scopeId', 'scopeResolution'].includes(key)));
|
|
141
|
+
delete patch.scopeId;
|
|
142
|
+
delete patch.scopeResolution;
|
|
143
|
+
return {
|
|
144
|
+
...(id ? { id } : {}),
|
|
145
|
+
...(Object.keys(patch).length > 0 ? { patch } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (kind === 'delete') {
|
|
149
|
+
const id = normalizeNonEmpty(payload.id);
|
|
150
|
+
return id ? { id } : input;
|
|
151
|
+
}
|
|
152
|
+
return Object.fromEntries(Object.entries(payload).filter(([key]) => !['scopeId', 'scopeResolution', '__hostContext'].includes(key)));
|
|
153
|
+
}
|
|
154
|
+
const docmanComposeIndexInputSchema = buildToolInputSchema({
|
|
155
|
+
documentVersionId: requiredToolInputString('documentVersionId'),
|
|
156
|
+
options: DOCMAN_LOCALE_OPTIONS_SCHEMA.optional(),
|
|
157
|
+
});
|
|
158
|
+
const docmanDocumentIndexInputSchema = buildToolInputSchema({
|
|
159
|
+
documentVersionId: requiredToolInputString('documentVersionId'),
|
|
160
|
+
locale: optionalToolInputString('locale'),
|
|
161
|
+
fallbackLocale: optionalToolInputString('fallbackLocale'),
|
|
162
|
+
});
|
|
163
|
+
const docmanDocumentSearchInputSchema = buildToolInputSchema({
|
|
164
|
+
documentVersionId: requiredToolInputString('documentVersionId'),
|
|
165
|
+
q: requiredToolInputString('q'),
|
|
166
|
+
limit: optionalToolInputNumber('limit'),
|
|
167
|
+
retrievalStrategy: z.enum(['lexical', 'hybrid', 'semantic']).optional(),
|
|
168
|
+
locale: optionalToolInputString('locale'),
|
|
169
|
+
fallbackLocale: optionalToolInputString('fallbackLocale'),
|
|
170
|
+
});
|
|
171
|
+
const docmanScopeDocumentSearchInputSchema = buildToolInputSchema({
|
|
172
|
+
scopeId: requiredToolInputString('scopeId'),
|
|
173
|
+
q: requiredToolInputString('q'),
|
|
174
|
+
limit: optionalToolInputNumber('limit'),
|
|
175
|
+
retrievalStrategy: z.enum(['lexical', 'hybrid', 'semantic']).optional(),
|
|
176
|
+
locale: optionalToolInputString('locale'),
|
|
177
|
+
fallbackLocale: optionalToolInputString('fallbackLocale'),
|
|
178
|
+
});
|
|
179
|
+
const docmanComposeFetchInputSchema = buildToolInputSchema({
|
|
180
|
+
documentVersionId: requiredToolInputString('documentVersionId'),
|
|
181
|
+
sectionId: optionalToolInputString('sectionId'),
|
|
182
|
+
pageVersionId: optionalToolInputString('pageVersionId'),
|
|
183
|
+
pageNumber: optionalToolInputNumber('pageNumber'),
|
|
184
|
+
locale: optionalToolInputString('locale'),
|
|
185
|
+
fallbackLocale: optionalToolInputString('fallbackLocale'),
|
|
186
|
+
});
|
|
187
|
+
const docmanPublishMaterializeInputSchema = buildToolInputSchema({
|
|
188
|
+
documentVersionId: requiredToolInputString('documentVersionId'),
|
|
189
|
+
target: z.enum(['markdown', 'html']),
|
|
190
|
+
sectionId: optionalToolInputString('sectionId'),
|
|
191
|
+
pageVersionId: optionalToolInputString('pageVersionId'),
|
|
192
|
+
pageNumber: optionalToolInputNumber('pageNumber'),
|
|
193
|
+
locale: optionalToolInputString('locale'),
|
|
194
|
+
fallbackLocale: optionalToolInputString('fallbackLocale'),
|
|
195
|
+
});
|
|
196
|
+
const docmanSectionUsageListInputSchema = buildToolInputSchema({
|
|
197
|
+
sectionId: requiredToolInputString('sectionId'),
|
|
198
|
+
});
|
|
199
|
+
const docmanDeleteSafeInputSchema = buildToolInputSchema({
|
|
200
|
+
id: requiredToolInputString('id'),
|
|
201
|
+
confirmName: requiredToolInputString('confirmName'),
|
|
202
|
+
});
|
|
203
|
+
const docmanParsedHeadingGraphNodeSchema = z.lazy(() => z
|
|
204
|
+
.object({
|
|
205
|
+
kind: z.enum(['section', 'page']),
|
|
206
|
+
title: requiredToolInputString('title'),
|
|
207
|
+
depth: optionalToolInputNumber('depth'),
|
|
208
|
+
slug: optionalToolInputString('slug'),
|
|
209
|
+
bodyMarkdown: z.string().optional(),
|
|
210
|
+
children: z.array(docmanParsedHeadingGraphNodeSchema).optional(),
|
|
211
|
+
})
|
|
212
|
+
.strict());
|
|
213
|
+
const docmanDocumentVersionSetCurrentInputSchema = buildToolInputSchema({
|
|
214
|
+
documentVersionId: requiredToolInputString('documentVersionId'),
|
|
215
|
+
documentId: optionalToolInputString('documentId'),
|
|
216
|
+
publish: z.boolean().optional(),
|
|
217
|
+
publishedAt: z
|
|
218
|
+
.union([
|
|
219
|
+
z.date(),
|
|
220
|
+
z
|
|
221
|
+
.string()
|
|
222
|
+
.datetime()
|
|
223
|
+
.transform((value) => new Date(value)),
|
|
224
|
+
])
|
|
225
|
+
.optional(),
|
|
226
|
+
expectedPreviousVersionId: optionalToolInputString('expectedPreviousVersionId'),
|
|
227
|
+
});
|
|
228
|
+
const docmanDocumentVersionImportHeadingsInputSchema = buildToolInputSchema({
|
|
229
|
+
documentVersionId: requiredToolInputString('documentVersionId'),
|
|
230
|
+
scopeId: optionalToolInputString('scopeId'),
|
|
231
|
+
parsedGraph: z
|
|
232
|
+
.object({
|
|
233
|
+
sourceHash: optionalToolInputString('sourceHash'),
|
|
234
|
+
sourcePath: optionalToolInputString('sourcePath'),
|
|
235
|
+
nodes: z.array(docmanParsedHeadingGraphNodeSchema),
|
|
236
|
+
})
|
|
237
|
+
.strict(),
|
|
238
|
+
options: z
|
|
239
|
+
.object({
|
|
240
|
+
dryRun: z.boolean().optional(),
|
|
241
|
+
existingGraphPolicy: z.enum(['error', 'append', 'replace']).optional(),
|
|
242
|
+
slugStrategy: z.enum(['hash-suffix-on-collision', 'kebab-from-title']).optional(),
|
|
243
|
+
bodyAssignment: z.literal('leaf-page-content').optional(),
|
|
244
|
+
headingToPagePolicy: z.literal('h4-and-below').optional(),
|
|
245
|
+
synthesizeOverviewPages: z.boolean().optional(),
|
|
246
|
+
})
|
|
247
|
+
.strict()
|
|
248
|
+
.optional(),
|
|
249
|
+
createdBy: optionalToolInputString('createdBy'),
|
|
250
|
+
updatedBy: optionalToolInputString('updatedBy'),
|
|
251
|
+
});
|
|
252
|
+
const DOCMAN_OPERATION_INPUT_SCHEMA_BY_ID = new Map([
|
|
253
|
+
['document.list', buildCrudListInputSchema()],
|
|
254
|
+
['document.get', buildCrudGetInputSchema()],
|
|
255
|
+
['document.create', buildCrudCreateInputSchema(documentZodSchemaInsert)],
|
|
256
|
+
['document.update', buildCrudUpdateInputSchema(documentZodSchemaInsert, 'document.update')],
|
|
257
|
+
['document.delete', buildCrudDeleteInputSchema()],
|
|
258
|
+
['document-group.list', buildCrudListInputSchema()],
|
|
259
|
+
['document-group.get', buildCrudGetInputSchema()],
|
|
260
|
+
['document-group.create', buildCrudCreateInputSchema(documentGroupZodSchemaInsert)],
|
|
261
|
+
['document-group.update', buildCrudUpdateInputSchema(documentGroupZodSchemaInsert, 'document-group.update')],
|
|
262
|
+
['document-group.delete', buildCrudDeleteInputSchema()],
|
|
263
|
+
['document-version.list', buildCrudListInputSchema()],
|
|
264
|
+
['document-version.get', buildCrudGetInputSchema()],
|
|
265
|
+
['document-version.create', buildCrudCreateInputSchema(documentVersionZodSchemaInsert)],
|
|
266
|
+
['document-version.update', buildCrudUpdateInputSchema(documentVersionZodSchemaInsert, 'document-version.update')],
|
|
267
|
+
['document-version.delete', buildCrudDeleteInputSchema()],
|
|
268
|
+
['section.list', buildCrudListInputSchema()],
|
|
269
|
+
['section.get', buildCrudGetInputSchema()],
|
|
270
|
+
['section.create', buildCrudCreateInputSchema(sectionZodSchemaInsert)],
|
|
271
|
+
['section.update', buildCrudUpdateInputSchema(sectionZodSchemaInsert, 'section.update')],
|
|
272
|
+
['section.delete', buildCrudDeleteInputSchema()],
|
|
273
|
+
['page.list', buildCrudListInputSchema()],
|
|
274
|
+
['page.get', buildCrudGetInputSchema()],
|
|
275
|
+
['page.create', buildCrudCreateInputSchema(pageZodSchemaInsert)],
|
|
276
|
+
['page.update', buildCrudUpdateInputSchema(pageZodSchemaInsert, 'page.update')],
|
|
277
|
+
['page.delete', buildCrudDeleteInputSchema()],
|
|
278
|
+
['page-version.list', buildCrudListInputSchema()],
|
|
279
|
+
['page-version.get', buildCrudGetInputSchema()],
|
|
280
|
+
['page-version.create', buildCrudCreateInputSchema(pageVersionZodSchemaInsert)],
|
|
281
|
+
['page-version.update', buildCrudUpdateInputSchema(pageVersionZodSchemaInsert, 'page-version.update')],
|
|
282
|
+
['page-version.delete', buildCrudDeleteInputSchema()],
|
|
283
|
+
['document-section-link.list', buildCrudListInputSchema()],
|
|
284
|
+
['document-section-link.get', buildCrudGetInputSchema()],
|
|
285
|
+
['document-section-link.create', buildCrudCreateInputSchema(documentSectionLinkZodSchemaInsert)],
|
|
286
|
+
['document-section-link.update', buildCrudUpdateInputSchema(documentSectionLinkZodSchemaInsert, 'document-section-link.update')],
|
|
287
|
+
['document-section-link.delete', buildCrudDeleteInputSchema()],
|
|
288
|
+
['section-page-link.list', buildCrudListInputSchema()],
|
|
289
|
+
['section-page-link.get', buildCrudGetInputSchema()],
|
|
290
|
+
['section-page-link.create', buildCrudCreateInputSchema(sectionPageLinkZodSchemaInsert)],
|
|
291
|
+
['section-page-link.update', buildCrudUpdateInputSchema(sectionPageLinkZodSchemaInsert, 'section-page-link.update')],
|
|
292
|
+
['section-page-link.delete', buildCrudDeleteInputSchema()],
|
|
293
|
+
['snippet.list', buildCrudListInputSchema()],
|
|
294
|
+
['snippet.get', buildCrudGetInputSchema()],
|
|
295
|
+
['snippet.create', buildCrudCreateInputSchema(snippetZodSchemaInsert)],
|
|
296
|
+
['snippet.update', buildCrudUpdateInputSchema(snippetZodSchemaInsert, 'snippet.update')],
|
|
297
|
+
['snippet.delete', buildCrudDeleteInputSchema()],
|
|
298
|
+
['page-snippet-link.list', buildCrudListInputSchema()],
|
|
299
|
+
['page-snippet-link.get', buildCrudGetInputSchema()],
|
|
300
|
+
['page-snippet-link.create', buildCrudCreateInputSchema(pageSnippetLinkZodSchemaInsert)],
|
|
301
|
+
['page-snippet-link.update', buildCrudUpdateInputSchema(pageSnippetLinkZodSchemaInsert, 'page-snippet-link.update')],
|
|
302
|
+
['page-snippet-link.delete', buildCrudDeleteInputSchema()],
|
|
303
|
+
['asset.list', buildCrudListInputSchema()],
|
|
304
|
+
['asset.get', buildCrudGetInputSchema()],
|
|
305
|
+
['asset.create', buildCrudCreateInputSchema(assetZodSchemaInsert)],
|
|
306
|
+
['asset.update', buildCrudUpdateInputSchema(assetZodSchemaInsert, 'asset.update')],
|
|
307
|
+
['asset.delete', buildCrudDeleteInputSchema()],
|
|
308
|
+
['asset-version.list', buildCrudListInputSchema()],
|
|
309
|
+
['asset-version.get', buildCrudGetInputSchema()],
|
|
310
|
+
['asset-version.create', buildCrudCreateInputSchema(assetVersionZodSchemaInsert)],
|
|
311
|
+
['asset-version.update', buildCrudUpdateInputSchema(assetVersionMutablePatchZodSchema, 'asset-version.update')],
|
|
312
|
+
['asset-version.delete', buildCrudDeleteInputSchema()],
|
|
313
|
+
['embed.list', buildCrudListInputSchema()],
|
|
314
|
+
['embed.get', buildCrudGetInputSchema()],
|
|
315
|
+
['embed.create', buildCrudCreateInputSchema(embedZodSchemaInsert)],
|
|
316
|
+
['embed.update', buildCrudUpdateInputSchema(embedZodSchemaInsert, 'embed.update')],
|
|
317
|
+
['embed.delete', buildCrudDeleteInputSchema()],
|
|
318
|
+
['page-embed-link.list', buildCrudListInputSchema()],
|
|
319
|
+
['page-embed-link.get', buildCrudGetInputSchema()],
|
|
320
|
+
['page-embed-link.create', buildCrudCreateInputSchema(pageEmbedLinkZodSchemaInsert)],
|
|
321
|
+
['page-embed-link.update', buildCrudUpdateInputSchema(pageEmbedLinkZodSchemaInsert, 'page-embed-link.update')],
|
|
322
|
+
['page-embed-link.delete', buildCrudDeleteInputSchema()],
|
|
323
|
+
['document.compose.index', docmanComposeIndexInputSchema],
|
|
324
|
+
['document.index.build', docmanDocumentIndexInputSchema],
|
|
325
|
+
['document.index.get', docmanDocumentIndexInputSchema],
|
|
326
|
+
['document.summary.build', docmanDocumentIndexInputSchema],
|
|
327
|
+
['document.summary.get', docmanDocumentIndexInputSchema],
|
|
328
|
+
['document.search', docmanDocumentSearchInputSchema],
|
|
329
|
+
['document.scope.search', docmanScopeDocumentSearchInputSchema],
|
|
330
|
+
['document.answer-pack', docmanDocumentSearchInputSchema],
|
|
331
|
+
['document.compose.fetch', docmanComposeFetchInputSchema],
|
|
332
|
+
['document.publish.materialize', docmanPublishMaterializeInputSchema],
|
|
333
|
+
['document.delete.safe', docmanDeleteSafeInputSchema],
|
|
334
|
+
['document-version.delete.safe', buildToolInputSchema({ id: requiredToolInputString('id') })],
|
|
335
|
+
['document-version.import-headings', docmanDocumentVersionImportHeadingsInputSchema],
|
|
336
|
+
['document-version.set-current', docmanDocumentVersionSetCurrentInputSchema],
|
|
337
|
+
['document-section-link.usage.list', docmanSectionUsageListInputSchema],
|
|
338
|
+
]);
|
|
339
|
+
export function getDocmanOperationArgs(operationId) {
|
|
340
|
+
return DOCMAN_OPERATION_ARGS_BY_ID.get(operationId) ?? [];
|
|
341
|
+
}
|
|
342
|
+
export function getDocmanToolInputSchema(operationId) {
|
|
343
|
+
return DOCMAN_OPERATION_INPUT_SCHEMA_BY_ID.get(operationId);
|
|
344
|
+
}
|
|
345
|
+
export function parseDocmanToolInput(operationId, input, options = {}) {
|
|
346
|
+
const schema = getDocmanToolInputSchema(operationId);
|
|
347
|
+
if (!schema) {
|
|
348
|
+
throw new Error(`unknown_docman_operation:${operationId}`);
|
|
349
|
+
}
|
|
350
|
+
return parseToolInputWithZod({
|
|
351
|
+
...options,
|
|
352
|
+
operationId,
|
|
353
|
+
input: normalizeDocmanScopeAwareInput(operationId, input),
|
|
354
|
+
args: options.args ?? getDocmanOperationArgs(operationId),
|
|
355
|
+
schema,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type DocmanOperationKind = 'list' | 'get' | 'create' | 'update' | 'delete' | 'custom';
|
|
2
|
+
export type DocmanOperationEffect = 'none' | 'db' | 'mixed';
|
|
3
|
+
export type DocmanOperationSchemaRef = {
|
|
4
|
+
$ref: string;
|
|
5
|
+
};
|
|
6
|
+
export type DocmanOperationSchema = DocmanOperationSchemaRef | Record<string, unknown>;
|
|
7
|
+
export type DocmanOperationArgument = {
|
|
8
|
+
name: string;
|
|
9
|
+
optional: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type DocmanOperationPolicy = Record<string, unknown>;
|
|
12
|
+
export type DocmanOperationDocs = {
|
|
13
|
+
notes?: string[];
|
|
14
|
+
antiPatterns?: string[];
|
|
15
|
+
preconditions?: string[];
|
|
16
|
+
postconditions?: string[];
|
|
17
|
+
};
|
|
18
|
+
export type DocmanOperationSpec = {
|
|
19
|
+
operationId: string;
|
|
20
|
+
toolId: string;
|
|
21
|
+
serviceKey: string;
|
|
22
|
+
serviceEntity: string;
|
|
23
|
+
methodName: string;
|
|
24
|
+
kind: DocmanOperationKind;
|
|
25
|
+
args: DocmanOperationArgument[];
|
|
26
|
+
summary?: string;
|
|
27
|
+
tags?: string[];
|
|
28
|
+
sideEffect?: DocmanOperationEffect;
|
|
29
|
+
inputSchema?: DocmanOperationSchema;
|
|
30
|
+
outputSchema?: DocmanOperationSchema;
|
|
31
|
+
policy?: DocmanOperationPolicy;
|
|
32
|
+
examples?: string[];
|
|
33
|
+
docs?: DocmanOperationDocs;
|
|
34
|
+
};
|
|
35
|
+
export type DefineDocmanKitOperationInput = Omit<DocmanOperationSpec, 'toolId'> & {
|
|
36
|
+
toolId?: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { docmanErrorsResources, type ILabelsDocmanServerErrorsTags, type ILabelsDocmanServerErrorsTranslationKeys, } from './resources.docman.server.errors.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { docmanErrorsResources, } from './resources.docman.server.errors.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BmResourceInline, I18nBmValidKeys } from '@aopslab/xf-i18n/bm';
|
|
2
|
+
import { ValidationResourceType } from '@aopslab/xf-validation';
|
|
3
|
+
export interface ILabelsDocmanServerErrorsTags {
|
|
4
|
+
error__validation: string;
|
|
5
|
+
error__notFound: string;
|
|
6
|
+
error__unauthorized: string;
|
|
7
|
+
error__forbidden: string;
|
|
8
|
+
error__conflict: string;
|
|
9
|
+
error__rateLimit: string;
|
|
10
|
+
error__serviceUnavailable: string;
|
|
11
|
+
error__unexpected: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const docmanErrorsResources: BmResourceInline<never, ILabelsDocmanServerErrorsTags>;
|
|
14
|
+
export type ILabelsDocmanServerErrorsTranslationKeys = I18nBmValidKeys<never, ValidationResourceType, ILabelsDocmanServerErrorsTags>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const docmanErrorsResources = {
|
|
2
|
+
tags: {
|
|
3
|
+
error__validation: {
|
|
4
|
+
en: 'Please review your input and try again.',
|
|
5
|
+
tr: 'Lutfen girdinizi kontrol edip tekrar deneyin.',
|
|
6
|
+
},
|
|
7
|
+
error__notFound: {
|
|
8
|
+
en: 'The requested record could not be found.',
|
|
9
|
+
tr: 'Istenen kayit bulunamadi.',
|
|
10
|
+
},
|
|
11
|
+
error__unauthorized: {
|
|
12
|
+
en: 'You need to sign in before continuing.',
|
|
13
|
+
tr: 'Devam etmeden once giris yapmaniz gerekiyor.',
|
|
14
|
+
},
|
|
15
|
+
error__forbidden: {
|
|
16
|
+
en: 'You do not have permission for this action.',
|
|
17
|
+
tr: 'Bu islem icin yetkiniz yok.',
|
|
18
|
+
},
|
|
19
|
+
error__conflict: {
|
|
20
|
+
en: 'This action conflicts with existing data.',
|
|
21
|
+
tr: 'Bu islem mevcut verilerle cakisiyor.',
|
|
22
|
+
},
|
|
23
|
+
error__rateLimit: {
|
|
24
|
+
en: 'Too many requests. Please try again shortly.',
|
|
25
|
+
tr: 'Cok fazla istek yapildi. Lutfen kisa bir sure sonra tekrar deneyin.',
|
|
26
|
+
},
|
|
27
|
+
error__serviceUnavailable: {
|
|
28
|
+
en: 'Service is temporarily unavailable. Please try again later.',
|
|
29
|
+
tr: 'Servis gecici olarak kullanilamiyor. Lutfen daha sonra tekrar deneyin.',
|
|
30
|
+
},
|
|
31
|
+
error__unexpected: {
|
|
32
|
+
en: 'An unexpected error occurred. Please try again.',
|
|
33
|
+
tr: 'Beklenmeyen bir hata olustu. Lutfen tekrar deneyin.',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tool-input-guard.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_TOOL_INPUT_CONTEXT_KEYS, buildToolInputEnvelopeSchema, buildToolInputSchema, optionalToolInputBoolean, optionalToolInputNumber, optionalToolInputString, optionalToolInputStringArray, parseToolInputWithZod, requiredToolInputBoolean, requiredToolInputNumber, requiredToolInputString, requiredToolInputStringArray, validateToolInputWithZod, type FlattenEnvelopeKey, type FlattenToolingEnvelopeInput, type ParseToolInputWithZodOptions, type ToolOperationArg, } from '@aopslab/xf-validation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_TOOL_INPUT_CONTEXT_KEYS, buildToolInputEnvelopeSchema, buildToolInputSchema, optionalToolInputBoolean, optionalToolInputNumber, optionalToolInputString, optionalToolInputStringArray, parseToolInputWithZod, requiredToolInputBoolean, requiredToolInputNumber, requiredToolInputString, requiredToolInputStringArray, validateToolInputWithZod, } from '@aopslab/xf-validation';
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aopslab/domain-kit-docman",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./operations": {
|
|
16
|
+
"types": "./dist/operations/index.d.ts",
|
|
17
|
+
"import": "./dist/operations/index.js",
|
|
18
|
+
"default": "./dist/operations/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./errors": {
|
|
21
|
+
"types": "./dist/errors/index.d.ts",
|
|
22
|
+
"import": "./dist/errors/index.js",
|
|
23
|
+
"default": "./dist/errors/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./errors/i18n": {
|
|
26
|
+
"types": "./dist/errors/i18n.d.ts",
|
|
27
|
+
"import": "./dist/errors/i18n.js",
|
|
28
|
+
"default": "./dist/errors/i18n.js"
|
|
29
|
+
},
|
|
30
|
+
"./resources": {
|
|
31
|
+
"types": "./dist/resources/index.d.ts",
|
|
32
|
+
"import": "./dist/resources/index.js",
|
|
33
|
+
"default": "./dist/resources/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"!**/*.tsbuildinfo",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"NOTICE"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@aopslab/xf-core": "0.1.69",
|
|
44
|
+
"@aopslab/xf-db": "0.1.75",
|
|
45
|
+
"@aopslab/xf-db-drizzle": "0.1.81",
|
|
46
|
+
"@aopslab/xf-dm-kits": "0.1.14",
|
|
47
|
+
"@aopslab/xf-i18n": "0.1.74",
|
|
48
|
+
"@aopslab/xf-logger": "0.1.61",
|
|
49
|
+
"@aopslab/xf-validation": "0.1.80",
|
|
50
|
+
"dotenv": "^17.3.1",
|
|
51
|
+
"effect": "3.20.0",
|
|
52
|
+
"zod": "4.4.3",
|
|
53
|
+
"@aopslab/domain-dm-docman": "0.1.2"
|
|
54
|
+
},
|
|
55
|
+
"private": false,
|
|
56
|
+
"license": "Apache-2.0",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/eeemzs/docman.git",
|
|
60
|
+
"directory": "docman-kit"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "node ../scripts/clean-build-artifacts.mjs dist tsconfig.lib.tsbuildinfo && tsc -b tsconfig.lib.json",
|
|
64
|
+
"typecheck": "tsc -p tsconfig.lib.json --noEmit",
|
|
65
|
+
"dcm:print": "tsx scripts/dcm-cli.ts print",
|
|
66
|
+
"dcm:emit": "tsx scripts/dcm-cli.ts emit --out dist/dcm.json",
|
|
67
|
+
"dcm:check": "tsx scripts/dcm-cli.ts check --out dist/dcm.json"
|
|
68
|
+
}
|
|
69
|
+
}
|