@soddong/agentic-domain-artifact-standard 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.tbls.yml +54 -0
  2. package/CHANGELOG.md +94 -0
  3. package/README.md +386 -0
  4. package/dist/database.d.ts +8 -0
  5. package/dist/database.d.ts.map +1 -0
  6. package/dist/database.js +76 -0
  7. package/dist/database.js.map +1 -0
  8. package/dist/fixtures.d.ts +11 -0
  9. package/dist/fixtures.d.ts.map +1 -0
  10. package/dist/fixtures.js +537 -0
  11. package/dist/fixtures.js.map +1 -0
  12. package/dist/index.d.ts +72 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +213 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/repositories.d.ts +46 -0
  17. package/dist/repositories.d.ts.map +1 -0
  18. package/dist/repositories.js +730 -0
  19. package/dist/repositories.js.map +1 -0
  20. package/dist/seed-apply.d.ts +20 -0
  21. package/dist/seed-apply.d.ts.map +1 -0
  22. package/dist/seed-apply.js +198 -0
  23. package/dist/seed-apply.js.map +1 -0
  24. package/dist/service.d.ts +40 -0
  25. package/dist/service.d.ts.map +1 -0
  26. package/dist/service.js +105 -0
  27. package/dist/service.js.map +1 -0
  28. package/dist/types.d.ts +499 -0
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/types.js +2 -0
  31. package/dist/types.js.map +1 -0
  32. package/docs/build.md +27 -0
  33. package/docs/configuration.md +5 -0
  34. package/docs/delivery.md +26 -0
  35. package/docs/operations.md +28 -0
  36. package/docs/publishing.md +43 -0
  37. package/docs/schema/generated/README.md +38 -0
  38. package/docs/schema/generated/artifact_standard_blueprint_nodes.md +137 -0
  39. package/docs/schema/generated/artifact_standard_blueprint_nodes.svg +88 -0
  40. package/docs/schema/generated/artifact_standard_code_groups.md +70 -0
  41. package/docs/schema/generated/artifact_standard_code_groups.svg +49 -0
  42. package/docs/schema/generated/artifact_standard_codes.md +88 -0
  43. package/docs/schema/generated/artifact_standard_codes.svg +49 -0
  44. package/docs/schema/generated/artifact_standard_component_bindings.md +118 -0
  45. package/docs/schema/generated/artifact_standard_component_bindings.svg +73 -0
  46. package/docs/schema/generated/artifact_standard_components.md +114 -0
  47. package/docs/schema/generated/artifact_standard_components.svg +73 -0
  48. package/docs/schema/generated/artifact_standard_diagram_policies.md +99 -0
  49. package/docs/schema/generated/artifact_standard_diagram_policies.svg +49 -0
  50. package/docs/schema/generated/artifact_standard_document_blueprints.md +101 -0
  51. package/docs/schema/generated/artifact_standard_document_blueprints.svg +128 -0
  52. package/docs/schema/generated/artifact_standard_document_component_relations.md +118 -0
  53. package/docs/schema/generated/artifact_standard_document_component_relations.svg +87 -0
  54. package/docs/schema/generated/artifact_standard_document_components.md +148 -0
  55. package/docs/schema/generated/artifact_standard_document_components.svg +139 -0
  56. package/docs/schema/generated/artifact_standard_figure_policies.md +99 -0
  57. package/docs/schema/generated/artifact_standard_figure_policies.svg +49 -0
  58. package/docs/schema/generated/artifact_standard_generated_output_links.md +144 -0
  59. package/docs/schema/generated/artifact_standard_generated_output_links.svg +57 -0
  60. package/docs/schema/generated/artifact_standard_physical_structure_policies.md +124 -0
  61. package/docs/schema/generated/artifact_standard_physical_structure_policies.svg +78 -0
  62. package/docs/schema/generated/artifact_standard_schema_migrations.md +52 -0
  63. package/docs/schema/generated/artifact_standard_schema_migrations.svg +27 -0
  64. package/docs/schema/generated/artifact_standard_source_mappings.md +120 -0
  65. package/docs/schema/generated/artifact_standard_source_mappings.svg +49 -0
  66. package/docs/schema/generated/artifact_standard_standards.md +102 -0
  67. package/docs/schema/generated/artifact_standard_standards.svg +313 -0
  68. package/docs/schema/generated/artifact_standard_table_column_schemas.md +147 -0
  69. package/docs/schema/generated/artifact_standard_table_column_schemas.svg +52 -0
  70. package/docs/schema/generated/artifact_standard_table_schemas.md +99 -0
  71. package/docs/schema/generated/artifact_standard_table_schemas.svg +71 -0
  72. package/docs/schema/generated/artifact_standard_template_slots.md +143 -0
  73. package/docs/schema/generated/artifact_standard_template_slots.svg +88 -0
  74. package/docs/schema/generated/artifact_standard_validation_rule_set_rules.md +128 -0
  75. package/docs/schema/generated/artifact_standard_validation_rule_set_rules.svg +52 -0
  76. package/docs/schema/generated/artifact_standard_validation_rule_sets.md +91 -0
  77. package/docs/schema/generated/artifact_standard_validation_rule_sets.svg +71 -0
  78. package/docs/schema/generated/schema.json +4230 -0
  79. package/docs/schema/generated/schema.mmd +327 -0
  80. package/docs/schema/generated/schema.svg +510 -0
  81. package/docs/usage.md +197 -0
  82. package/package.json +30 -0
  83. package/src/database/migrations/0001_artifact_standard_base.sql +1295 -0
@@ -0,0 +1,730 @@
1
+ import { isValidationExecutionModeCode, isValidationSeverityCode, isValidationTypeCode } from "@soddong/agentic-contract-validation";
2
+ function jsonValue(value) {
3
+ return value === undefined || value === null ? null : JSON.stringify(value);
4
+ }
5
+ function parseJson(value) {
6
+ if (typeof value !== "string" || value.length === 0) {
7
+ return undefined;
8
+ }
9
+ return JSON.parse(value);
10
+ }
11
+ function optionalString(value) {
12
+ return typeof value === "string" ? value : undefined;
13
+ }
14
+ function optionalNumber(value) {
15
+ return typeof value === "number" ? value : undefined;
16
+ }
17
+ function boolToInt(value, defaultValue) {
18
+ return value === undefined ? defaultValue : value ? 1 : 0;
19
+ }
20
+ function standardFromRow(row) {
21
+ return {
22
+ artifactStandardId: row.artifact_standard_id,
23
+ artifactStandardCode: row.artifact_standard_code,
24
+ artifactStandardVersion: row.artifact_standard_version,
25
+ artifactStandardName: row.artifact_standard_name,
26
+ standardTypeCode: row.standard_type_code,
27
+ standardStatusCode: row.standard_status_code,
28
+ purpose: optionalString(row.purpose),
29
+ description: optionalString(row.description),
30
+ ownerRoleCode: optionalString(row.owner_role_code),
31
+ isActive: row.is_active,
32
+ createdAt: row.created_at,
33
+ updatedAt: row.updated_at,
34
+ metadata: parseJson(row.metadata_json)
35
+ };
36
+ }
37
+ function componentFromRow(row) {
38
+ return {
39
+ componentId: row.component_id,
40
+ artifactStandardId: row.artifact_standard_id,
41
+ componentCode: row.component_code,
42
+ componentTypeCode: row.component_type_code,
43
+ componentTitle: row.component_title,
44
+ componentPurpose: optionalString(row.component_purpose),
45
+ applicabilityCode: row.applicability_code,
46
+ resourceRefTypeCode: row.resource_ref_type_code,
47
+ resourceRef: optionalString(row.resource_ref),
48
+ sortOrder: row.sort_order,
49
+ isActive: row.is_active,
50
+ createdAt: row.created_at,
51
+ updatedAt: row.updated_at,
52
+ metadata: parseJson(row.metadata_json)
53
+ };
54
+ }
55
+ function componentBindingFromRow(row) {
56
+ return {
57
+ componentBindingId: row.component_binding_id,
58
+ artifactStandardId: row.artifact_standard_id,
59
+ componentId: row.component_id,
60
+ targetTypeCode: row.target_type_code,
61
+ targetRef: row.target_ref,
62
+ bindingRoleCode: row.binding_role_code,
63
+ priority: row.priority,
64
+ appliesWhen: parseJson(row.applies_when_json),
65
+ description: optionalString(row.description),
66
+ isActive: row.is_active,
67
+ createdAt: row.created_at,
68
+ updatedAt: row.updated_at,
69
+ metadata: parseJson(row.metadata_json)
70
+ };
71
+ }
72
+ function blueprintFromRow(row) {
73
+ return {
74
+ blueprintId: row.blueprint_id,
75
+ artifactStandardId: row.artifact_standard_id,
76
+ blueprintCode: row.blueprint_code,
77
+ blueprintName: row.blueprint_name,
78
+ documentTypeCode: row.document_type_code,
79
+ taxonomyCode: optionalString(row.taxonomy_code),
80
+ defaultTocLevelLimit: row.default_toc_level_limit,
81
+ description: optionalString(row.description),
82
+ createdAt: row.created_at,
83
+ updatedAt: row.updated_at,
84
+ metadata: parseJson(row.metadata_json)
85
+ };
86
+ }
87
+ function blueprintNodeFromRow(row) {
88
+ return {
89
+ blueprintNodeId: row.blueprint_node_id,
90
+ blueprintId: row.blueprint_id,
91
+ parentBlueprintNodeId: optionalString(row.parent_blueprint_node_id),
92
+ nodeCode: row.node_code,
93
+ nodeTitle: row.node_title,
94
+ nodeTypeCode: row.node_type_code,
95
+ nodeLevel: row.node_level,
96
+ tocVisible: row.toc_visible,
97
+ isRequired: row.is_required,
98
+ isRepeatable: row.is_repeatable,
99
+ repeatContextCode: optionalString(row.repeat_context_code),
100
+ taxonomyRef: optionalString(row.taxonomy_ref),
101
+ description: optionalString(row.description),
102
+ sortOrder: row.sort_order,
103
+ createdAt: row.created_at,
104
+ updatedAt: row.updated_at,
105
+ metadata: parseJson(row.metadata_json)
106
+ };
107
+ }
108
+ function slotFromRow(row) {
109
+ return {
110
+ templateSlotId: row.template_slot_id,
111
+ blueprintId: row.blueprint_id,
112
+ blueprintNodeId: optionalString(row.blueprint_node_id),
113
+ parentTemplateSlotId: optionalString(row.parent_template_slot_id),
114
+ slotCode: row.slot_code,
115
+ slotName: row.slot_name,
116
+ slotTypeCode: row.slot_type_code,
117
+ blockTypeCode: optionalString(row.block_type_code),
118
+ isRequired: row.is_required,
119
+ isRepeatable: row.is_repeatable,
120
+ repeatContextCode: optionalString(row.repeat_context_code),
121
+ schemaRef: optionalString(row.schema_ref),
122
+ description: optionalString(row.description),
123
+ sortOrder: row.sort_order,
124
+ createdAt: row.created_at,
125
+ updatedAt: row.updated_at,
126
+ metadata: parseJson(row.metadata_json)
127
+ };
128
+ }
129
+ function documentComponentFromRow(row) {
130
+ return {
131
+ documentComponentId: row.document_component_id,
132
+ artifactStandardId: row.artifact_standard_id,
133
+ blueprintId: optionalString(row.blueprint_id),
134
+ parentDocumentComponentId: optionalString(row.parent_document_component_id),
135
+ documentComponentCode: row.document_component_code,
136
+ documentComponentName: row.document_component_name,
137
+ componentRoleCode: row.component_role_code,
138
+ componentTypeCode: row.component_type_code,
139
+ representationCode: row.representation_code,
140
+ logicalLevel: row.logical_level,
141
+ isRequired: row.is_required,
142
+ isRepeatable: row.is_repeatable,
143
+ sortOrder: row.sort_order,
144
+ description: optionalString(row.description),
145
+ createdAt: row.created_at,
146
+ updatedAt: row.updated_at,
147
+ metadata: parseJson(row.metadata_json)
148
+ };
149
+ }
150
+ function documentComponentRelationFromRow(row) {
151
+ return {
152
+ documentComponentRelationId: row.document_component_relation_id,
153
+ artifactStandardId: row.artifact_standard_id,
154
+ sourceDocumentComponentId: row.source_document_component_id,
155
+ targetDocumentComponentId: row.target_document_component_id,
156
+ relationTypeCode: row.relation_type_code,
157
+ isRequired: row.is_required,
158
+ sortOrder: row.sort_order,
159
+ description: optionalString(row.description),
160
+ createdAt: row.created_at,
161
+ updatedAt: row.updated_at,
162
+ metadata: parseJson(row.metadata_json)
163
+ };
164
+ }
165
+ function physicalStructurePolicyFromRow(row) {
166
+ return {
167
+ physicalStructurePolicyId: row.physical_structure_policy_id,
168
+ artifactStandardId: row.artifact_standard_id,
169
+ documentComponentId: optionalString(row.document_component_id),
170
+ policyCode: row.policy_code,
171
+ policyName: row.policy_name,
172
+ strategyCode: row.strategy_code,
173
+ relationSourceCode: row.relation_source_code,
174
+ pathPattern: optionalString(row.path_pattern),
175
+ namingPattern: optionalString(row.naming_pattern),
176
+ isDefault: row.is_default,
177
+ description: optionalString(row.description),
178
+ createdAt: row.created_at,
179
+ updatedAt: row.updated_at,
180
+ metadata: parseJson(row.metadata_json)
181
+ };
182
+ }
183
+ function tableSchemaFromRow(row) {
184
+ return {
185
+ tableSchemaId: row.table_schema_id,
186
+ artifactStandardId: row.artifact_standard_id,
187
+ tableSchemaCode: row.table_schema_code,
188
+ tableName: row.table_name,
189
+ captionRequired: row.caption_required,
190
+ rowsRequired: row.rows_required,
191
+ description: optionalString(row.description),
192
+ createdAt: row.created_at,
193
+ updatedAt: row.updated_at,
194
+ metadata: parseJson(row.metadata_json)
195
+ };
196
+ }
197
+ function tableColumnFromRow(row) {
198
+ return {
199
+ tableColumnSchemaId: row.table_column_schema_id,
200
+ tableSchemaId: row.table_schema_id,
201
+ columnCode: row.column_code,
202
+ displayName: row.display_name,
203
+ valueTypeCode: row.value_type_code,
204
+ isRequired: row.is_required,
205
+ isNullable: row.is_nullable,
206
+ sortOrder: row.sort_order,
207
+ codeSetRef: optionalString(row.code_set_ref),
208
+ allowedValuesRef: optionalString(row.allowed_values_ref),
209
+ validationRuleRef: optionalString(row.validation_rule_ref),
210
+ pattern: optionalString(row.pattern),
211
+ minValue: optionalNumber(row.min_value),
212
+ maxValue: optionalNumber(row.max_value),
213
+ minLength: optionalNumber(row.min_length),
214
+ maxLength: optionalNumber(row.max_length),
215
+ exampleValue: optionalString(row.example_value),
216
+ description: optionalString(row.description),
217
+ createdAt: row.created_at,
218
+ updatedAt: row.updated_at,
219
+ metadata: parseJson(row.metadata_json)
220
+ };
221
+ }
222
+ function ruleSetFromRow(row) {
223
+ return {
224
+ validationRuleSetId: row.validation_rule_set_id,
225
+ artifactStandardId: row.artifact_standard_id,
226
+ ruleSetCode: row.rule_set_code,
227
+ ruleSetName: row.rule_set_name,
228
+ targetDomain: row.target_domain,
229
+ description: optionalString(row.description),
230
+ createdAt: row.created_at,
231
+ updatedAt: row.updated_at,
232
+ metadata: parseJson(row.metadata_json)
233
+ };
234
+ }
235
+ function ruleSetRuleFromRow(row) {
236
+ return {
237
+ validationRuleSetRuleId: row.validation_rule_set_rule_id,
238
+ validationRuleSetId: row.validation_rule_set_id,
239
+ ruleId: row.rule_id,
240
+ validationTypeCode: row.validation_type_code,
241
+ executionModeCode: row.execution_mode_code,
242
+ severityCode: row.severity_code,
243
+ appliesToTypeCode: row.applies_to_type_code,
244
+ appliesToRef: optionalString(row.applies_to_ref),
245
+ sourceComponentRef: optionalString(row.source_component_ref),
246
+ parameters: parseJson(row.parameters_json),
247
+ message: row.message,
248
+ remediation: optionalString(row.remediation),
249
+ sortOrder: row.sort_order,
250
+ isActive: row.is_active,
251
+ createdAt: row.created_at,
252
+ updatedAt: row.updated_at,
253
+ metadata: parseJson(row.metadata_json)
254
+ };
255
+ }
256
+ function generatedOutputLinkFromRow(row) {
257
+ return {
258
+ generatedOutputLinkId: row.generated_output_link_id,
259
+ linkCode: row.link_code,
260
+ sourceArtifactStandardId: row.source_artifact_standard_id,
261
+ sourceArtifactStandardCode: row.source_artifact_standard_code,
262
+ sourceArtifactStandardVersion: row.source_artifact_standard_version,
263
+ targetTypeCode: row.target_type_code,
264
+ targetArtifactStandardId: optionalString(row.target_artifact_standard_id),
265
+ targetArtifactStandardCode: optionalString(row.target_artifact_standard_code),
266
+ targetArtifactStandardVersion: optionalString(row.target_artifact_standard_version),
267
+ targetOutputName: optionalString(row.target_output_name),
268
+ generationModeCode: row.generation_mode_code,
269
+ sortOrder: row.sort_order,
270
+ description: optionalString(row.description),
271
+ isActive: row.is_active,
272
+ createdAt: row.created_at,
273
+ updatedAt: row.updated_at,
274
+ metadata: parseJson(row.metadata_json)
275
+ };
276
+ }
277
+ function sourceMappingFromRow(row) {
278
+ return {
279
+ sourceMappingId: row.source_mapping_id,
280
+ artifactStandardId: row.artifact_standard_id,
281
+ sourceTypeCode: row.source_type_code,
282
+ sourceUri: row.source_uri,
283
+ sourceLabel: optionalString(row.source_label),
284
+ sourceSection: optionalString(row.source_section),
285
+ sourceFragment: optionalString(row.source_fragment),
286
+ targetTypeCode: row.target_type_code,
287
+ targetRef: row.target_ref,
288
+ mappingTypeCode: row.mapping_type_code,
289
+ mappingStatusCode: row.mapping_status_code,
290
+ rationale: optionalString(row.rationale),
291
+ lossNote: optionalString(row.loss_note),
292
+ followUpNote: optionalString(row.follow_up_note),
293
+ createdAt: row.created_at,
294
+ updatedAt: row.updated_at,
295
+ metadata: parseJson(row.metadata_json)
296
+ };
297
+ }
298
+ function validationRuleContractFromRecord(rule) {
299
+ return {
300
+ ruleId: rule.ruleId,
301
+ providerModule: "@soddong/agentic-domain-artifact-standard",
302
+ validationTypeCode: rule.validationTypeCode,
303
+ executionModeCode: rule.executionModeCode,
304
+ severityCode: rule.severityCode,
305
+ appliesToTypeCode: rule.appliesToTypeCode,
306
+ appliesToRef: rule.appliesToRef,
307
+ sourceComponentRef: rule.sourceComponentRef,
308
+ parameters: rule.parameters,
309
+ message: rule.message,
310
+ remediation: rule.remediation,
311
+ metadata: rule.metadata
312
+ };
313
+ }
314
+ const artifactStandardValidationTargetTypeCodes = new Set([
315
+ "ARTIFACT_STANDARD",
316
+ "DOCUMENT_BLUEPRINT",
317
+ "BLUEPRINT_NODE",
318
+ "TEMPLATE_SLOT",
319
+ "TABLE_SCHEMA",
320
+ "TABLE_COLUMN_SCHEMA",
321
+ "FIGURE_POLICY",
322
+ "DIAGRAM_POLICY",
323
+ "COMPONENT",
324
+ "COMPONENT_BINDING",
325
+ "VALIDATION_RULE_SET",
326
+ "DOCUMENT_COMPONENT",
327
+ "DOCUMENT_COMPONENT_RELATION",
328
+ "PHYSICAL_STRUCTURE_POLICY"
329
+ ]);
330
+ export class ArtifactStandardRepository {
331
+ db;
332
+ constructor(db) {
333
+ this.db = db;
334
+ }
335
+ createArtifactStandard(artifactStandardId, input) {
336
+ this.db
337
+ .prepare(`INSERT INTO artifact_standard_standards
338
+ (artifact_standard_id, artifact_standard_code, artifact_standard_version, artifact_standard_name,
339
+ standard_type_code, standard_status_code, purpose, description, owner_role_code, metadata_json)
340
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
341
+ .run(artifactStandardId, input.artifactStandardCode, input.artifactStandardVersion, input.artifactStandardName, input.standardTypeCode ?? "DOCUMENT", input.standardStatusCode ?? "DRAFT", input.purpose ?? null, input.description ?? null, input.ownerRoleCode ?? null, jsonValue(input.metadata));
342
+ return this.getArtifactStandardById(artifactStandardId);
343
+ }
344
+ getArtifactStandardById(artifactStandardId) {
345
+ const row = this.db
346
+ .prepare(`SELECT * FROM artifact_standard_standards WHERE artifact_standard_id = ?`)
347
+ .get(artifactStandardId);
348
+ if (row === undefined) {
349
+ throw new Error(`Artifact standard not found: ${artifactStandardId}`);
350
+ }
351
+ return standardFromRow(row);
352
+ }
353
+ getArtifactStandardByCodeVersion(artifactStandardCode, artifactStandardVersion) {
354
+ const row = this.db
355
+ .prepare(`SELECT *
356
+ FROM artifact_standard_standards
357
+ WHERE artifact_standard_code = ?
358
+ AND artifact_standard_version = ?`)
359
+ .get(artifactStandardCode, artifactStandardVersion);
360
+ return row === undefined ? undefined : standardFromRow(row);
361
+ }
362
+ getArtifactStandardAggregateByCodeVersion(artifactStandardCode, artifactStandardVersion) {
363
+ const standard = this.getArtifactStandardByCodeVersion(artifactStandardCode, artifactStandardVersion);
364
+ if (standard === undefined) {
365
+ return undefined;
366
+ }
367
+ return this.getArtifactStandardAggregateById(standard.artifactStandardId);
368
+ }
369
+ getArtifactStandardAggregateById(artifactStandardId) {
370
+ const standard = this.getArtifactStandardById(artifactStandardId);
371
+ const blueprints = this.listDocumentBlueprints(artifactStandardId).map((blueprint) => ({
372
+ blueprint,
373
+ blueprintNodes: this.listBlueprintNodes(blueprint.blueprintId),
374
+ templateSlots: this.listTemplateSlots(blueprint.blueprintId)
375
+ }));
376
+ const tableSchemas = this.listTableSchemas(artifactStandardId).map((tableSchema) => ({
377
+ tableSchema,
378
+ columns: this.listTableColumnSchemas(tableSchema.tableSchemaId)
379
+ }));
380
+ const validationRuleSets = this.listValidationRuleSets(artifactStandardId).map((ruleSet) => ({
381
+ ruleSet,
382
+ rules: this.listValidationRuleSetRules(ruleSet.validationRuleSetId)
383
+ }));
384
+ return {
385
+ standard,
386
+ components: this.listComponents(artifactStandardId),
387
+ componentBindings: this.listComponentBindings(artifactStandardId),
388
+ blueprints,
389
+ documentComponents: this.listDocumentComponents(artifactStandardId),
390
+ documentComponentRelations: this.listDocumentComponentRelations(artifactStandardId),
391
+ physicalStructurePolicies: this.listPhysicalStructurePolicies(artifactStandardId),
392
+ tableSchemas,
393
+ validationRuleSets,
394
+ generatedOutputLinks: this.listGeneratedOutputLinksBySource(artifactStandardId),
395
+ sourceMappings: this.listSourceMappings(artifactStandardId)
396
+ };
397
+ }
398
+ addComponent(componentId, input) {
399
+ this.db
400
+ .prepare(`INSERT INTO artifact_standard_components
401
+ (component_id, artifact_standard_id, component_code, component_type_code, component_title,
402
+ component_purpose, applicability_code, resource_ref_type_code, resource_ref, sort_order, metadata_json)
403
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
404
+ .run(componentId, input.artifactStandardId, input.componentCode, input.componentTypeCode, input.componentTitle, input.componentPurpose ?? null, input.applicabilityCode ?? "COMMON_REFERENCE", input.resourceRefTypeCode ?? "FILE_PATH", input.resourceRef ?? null, input.sortOrder ?? 0, jsonValue(input.metadata));
405
+ return componentFromRow(this.getById("artifact_standard_components", "component_id", componentId));
406
+ }
407
+ listComponents(artifactStandardId) {
408
+ const rows = this.db
409
+ .prepare(`SELECT *
410
+ FROM artifact_standard_components
411
+ WHERE artifact_standard_id = ?
412
+ ORDER BY sort_order, component_code`)
413
+ .all(artifactStandardId);
414
+ return rows.map(componentFromRow);
415
+ }
416
+ addComponentBinding(componentBindingId, input) {
417
+ this.db
418
+ .prepare(`INSERT INTO artifact_standard_component_bindings
419
+ (component_binding_id, artifact_standard_id, component_id, target_type_code, target_ref,
420
+ binding_role_code, priority, applies_when_json, description, is_active, metadata_json)
421
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
422
+ .run(componentBindingId, input.artifactStandardId, input.componentId, input.targetTypeCode, input.targetRef, input.bindingRoleCode, input.priority ?? 100, jsonValue(input.appliesWhen), input.description ?? null, boolToInt(input.isActive, 1), jsonValue(input.metadata));
423
+ return componentBindingFromRow(this.getById("artifact_standard_component_bindings", "component_binding_id", componentBindingId));
424
+ }
425
+ listComponentBindings(artifactStandardId) {
426
+ const rows = this.db
427
+ .prepare(`SELECT *
428
+ FROM artifact_standard_component_bindings
429
+ WHERE artifact_standard_id = ?
430
+ ORDER BY priority, target_type_code, target_ref, binding_role_code`)
431
+ .all(artifactStandardId);
432
+ return rows.map(componentBindingFromRow);
433
+ }
434
+ listComponentBindingsByTarget(artifactStandardId, targetTypeCode, targetRef) {
435
+ const rows = this.db
436
+ .prepare(`SELECT *
437
+ FROM artifact_standard_component_bindings
438
+ WHERE artifact_standard_id = ?
439
+ AND target_type_code = ?
440
+ AND target_ref = ?
441
+ AND is_active = 1
442
+ ORDER BY priority, binding_role_code`)
443
+ .all(artifactStandardId, targetTypeCode, targetRef);
444
+ return rows.map(componentBindingFromRow);
445
+ }
446
+ addDocumentBlueprint(blueprintId, input) {
447
+ this.db
448
+ .prepare(`INSERT INTO artifact_standard_document_blueprints
449
+ (blueprint_id, artifact_standard_id, blueprint_code, blueprint_name, document_type_code,
450
+ taxonomy_code, default_toc_level_limit, description, metadata_json)
451
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
452
+ .run(blueprintId, input.artifactStandardId, input.blueprintCode, input.blueprintName, input.documentTypeCode, input.taxonomyCode ?? null, input.defaultTocLevelLimit ?? 3, input.description ?? null, jsonValue(input.metadata));
453
+ return blueprintFromRow(this.getById("artifact_standard_document_blueprints", "blueprint_id", blueprintId));
454
+ }
455
+ listDocumentBlueprints(artifactStandardId) {
456
+ const rows = this.db
457
+ .prepare(`SELECT *
458
+ FROM artifact_standard_document_blueprints
459
+ WHERE artifact_standard_id = ?
460
+ ORDER BY blueprint_code`)
461
+ .all(artifactStandardId);
462
+ return rows.map(blueprintFromRow);
463
+ }
464
+ addBlueprintNode(blueprintNodeId, input) {
465
+ this.db
466
+ .prepare(`INSERT INTO artifact_standard_blueprint_nodes
467
+ (blueprint_node_id, blueprint_id, parent_blueprint_node_id, node_code, node_title, node_type_code,
468
+ node_level, toc_visible, is_required, is_repeatable, repeat_context_code, taxonomy_ref,
469
+ description, sort_order, metadata_json)
470
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
471
+ .run(blueprintNodeId, input.blueprintId, input.parentBlueprintNodeId ?? null, input.nodeCode, input.nodeTitle, input.nodeTypeCode ?? "BODY", input.nodeLevel ?? 1, boolToInt(input.tocVisible, 1), boolToInt(input.isRequired, 1), boolToInt(input.isRepeatable, 0), input.repeatContextCode ?? null, input.taxonomyRef ?? null, input.description ?? null, input.sortOrder ?? 0, jsonValue(input.metadata));
472
+ return blueprintNodeFromRow(this.getById("artifact_standard_blueprint_nodes", "blueprint_node_id", blueprintNodeId));
473
+ }
474
+ listBlueprintNodes(blueprintId) {
475
+ const rows = this.db
476
+ .prepare(`SELECT *
477
+ FROM artifact_standard_blueprint_nodes
478
+ WHERE blueprint_id = ?
479
+ ORDER BY sort_order, node_code`)
480
+ .all(blueprintId);
481
+ return rows.map(blueprintNodeFromRow);
482
+ }
483
+ addTemplateSlot(templateSlotId, input) {
484
+ this.db
485
+ .prepare(`INSERT INTO artifact_standard_template_slots
486
+ (template_slot_id, blueprint_id, blueprint_node_id, parent_template_slot_id, slot_code, slot_name, slot_type_code,
487
+ block_type_code, is_required, is_repeatable, repeat_context_code, schema_ref, description, sort_order, metadata_json)
488
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
489
+ .run(templateSlotId, input.blueprintId, input.blueprintNodeId ?? null, input.parentTemplateSlotId ?? null, input.slotCode, input.slotName, input.slotTypeCode, input.blockTypeCode ?? null, boolToInt(input.isRequired, 1), boolToInt(input.isRepeatable, 0), input.repeatContextCode ?? null, input.schemaRef ?? null, input.description ?? null, input.sortOrder ?? 0, jsonValue(input.metadata));
490
+ return slotFromRow(this.getById("artifact_standard_template_slots", "template_slot_id", templateSlotId));
491
+ }
492
+ listTemplateSlots(blueprintId) {
493
+ const rows = this.db
494
+ .prepare(`SELECT *
495
+ FROM artifact_standard_template_slots
496
+ WHERE blueprint_id = ?
497
+ ORDER BY sort_order, slot_code`)
498
+ .all(blueprintId);
499
+ return rows.map(slotFromRow);
500
+ }
501
+ addDocumentComponent(documentComponentId, input) {
502
+ this.db
503
+ .prepare(`INSERT INTO artifact_standard_document_components
504
+ (document_component_id, artifact_standard_id, blueprint_id, parent_document_component_id,
505
+ document_component_code, document_component_name, component_role_code, component_type_code,
506
+ representation_code, logical_level, is_required, is_repeatable, sort_order, description, metadata_json)
507
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
508
+ .run(documentComponentId, input.artifactStandardId, input.blueprintId ?? null, input.parentDocumentComponentId ?? null, input.documentComponentCode, input.documentComponentName, input.componentRoleCode ?? "MAIN", input.componentTypeCode, input.representationCode ?? "SEPARATE_DOCUMENT", input.logicalLevel ?? 0, boolToInt(input.isRequired, 1), boolToInt(input.isRepeatable, 0), input.sortOrder ?? 0, input.description ?? null, jsonValue(input.metadata));
509
+ return documentComponentFromRow(this.getById("artifact_standard_document_components", "document_component_id", documentComponentId));
510
+ }
511
+ listDocumentComponents(artifactStandardId) {
512
+ const rows = this.db
513
+ .prepare(`SELECT *
514
+ FROM artifact_standard_document_components
515
+ WHERE artifact_standard_id = ?
516
+ ORDER BY logical_level, sort_order, document_component_code`)
517
+ .all(artifactStandardId);
518
+ return rows.map(documentComponentFromRow);
519
+ }
520
+ addDocumentComponentRelation(documentComponentRelationId, input) {
521
+ this.db
522
+ .prepare(`INSERT INTO artifact_standard_document_component_relations
523
+ (document_component_relation_id, artifact_standard_id, source_document_component_id,
524
+ target_document_component_id, relation_type_code, is_required, sort_order, description, metadata_json)
525
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
526
+ .run(documentComponentRelationId, input.artifactStandardId, input.sourceDocumentComponentId, input.targetDocumentComponentId, input.relationTypeCode, boolToInt(input.isRequired, 0), input.sortOrder ?? 0, input.description ?? null, jsonValue(input.metadata));
527
+ return documentComponentRelationFromRow(this.getById("artifact_standard_document_component_relations", "document_component_relation_id", documentComponentRelationId));
528
+ }
529
+ listDocumentComponentRelations(artifactStandardId) {
530
+ const rows = this.db
531
+ .prepare(`SELECT *
532
+ FROM artifact_standard_document_component_relations
533
+ WHERE artifact_standard_id = ?
534
+ ORDER BY sort_order, relation_type_code, document_component_relation_id`)
535
+ .all(artifactStandardId);
536
+ return rows.map(documentComponentRelationFromRow);
537
+ }
538
+ addPhysicalStructurePolicy(physicalStructurePolicyId, input) {
539
+ this.db
540
+ .prepare(`INSERT INTO artifact_standard_physical_structure_policies
541
+ (physical_structure_policy_id, artifact_standard_id, document_component_id, policy_code, policy_name,
542
+ strategy_code, relation_source_code, path_pattern, naming_pattern, is_default, description, metadata_json)
543
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
544
+ .run(physicalStructurePolicyId, input.artifactStandardId, input.documentComponentId ?? null, input.policyCode, input.policyName, input.strategyCode, input.relationSourceCode ?? "DB", input.pathPattern ?? null, input.namingPattern ?? null, boolToInt(input.isDefault, 0), input.description ?? null, jsonValue(input.metadata));
545
+ return physicalStructurePolicyFromRow(this.getById("artifact_standard_physical_structure_policies", "physical_structure_policy_id", physicalStructurePolicyId));
546
+ }
547
+ listPhysicalStructurePolicies(artifactStandardId) {
548
+ const rows = this.db
549
+ .prepare(`SELECT *
550
+ FROM artifact_standard_physical_structure_policies
551
+ WHERE artifact_standard_id = ?
552
+ ORDER BY is_default DESC, policy_code`)
553
+ .all(artifactStandardId);
554
+ return rows.map(physicalStructurePolicyFromRow);
555
+ }
556
+ addTableSchema(tableSchemaId, input) {
557
+ this.db
558
+ .prepare(`INSERT INTO artifact_standard_table_schemas
559
+ (table_schema_id, artifact_standard_id, table_schema_code, table_name,
560
+ caption_required, rows_required, description, metadata_json)
561
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`)
562
+ .run(tableSchemaId, input.artifactStandardId, input.tableSchemaCode, input.tableName, boolToInt(input.captionRequired, 1), boolToInt(input.rowsRequired, 0), input.description ?? null, jsonValue(input.metadata));
563
+ return tableSchemaFromRow(this.getById("artifact_standard_table_schemas", "table_schema_id", tableSchemaId));
564
+ }
565
+ listTableSchemas(artifactStandardId) {
566
+ const rows = this.db
567
+ .prepare(`SELECT *
568
+ FROM artifact_standard_table_schemas
569
+ WHERE artifact_standard_id = ?
570
+ ORDER BY table_schema_code`)
571
+ .all(artifactStandardId);
572
+ return rows.map(tableSchemaFromRow);
573
+ }
574
+ addTableColumnSchema(tableColumnSchemaId, input) {
575
+ this.db
576
+ .prepare(`INSERT INTO artifact_standard_table_column_schemas
577
+ (table_column_schema_id, table_schema_id, column_code, display_name, value_type_code,
578
+ is_required, is_nullable, sort_order, code_set_ref, allowed_values_ref, validation_rule_ref,
579
+ pattern, min_value, max_value, min_length, max_length, example_value, description, metadata_json)
580
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
581
+ .run(tableColumnSchemaId, input.tableSchemaId, input.columnCode, input.displayName, input.valueTypeCode ?? "TEXT", boolToInt(input.isRequired, 1), boolToInt(input.isNullable, 0), input.sortOrder ?? 0, input.codeSetRef ?? null, input.allowedValuesRef ?? null, input.validationRuleRef ?? null, input.pattern ?? null, input.minValue ?? null, input.maxValue ?? null, input.minLength ?? null, input.maxLength ?? null, input.exampleValue ?? null, input.description ?? null, jsonValue(input.metadata));
582
+ return tableColumnFromRow(this.getById("artifact_standard_table_column_schemas", "table_column_schema_id", tableColumnSchemaId));
583
+ }
584
+ listTableColumnSchemas(tableSchemaId) {
585
+ const rows = this.db
586
+ .prepare(`SELECT *
587
+ FROM artifact_standard_table_column_schemas
588
+ WHERE table_schema_id = ?
589
+ ORDER BY sort_order, column_code`)
590
+ .all(tableSchemaId);
591
+ return rows.map(tableColumnFromRow);
592
+ }
593
+ addValidationRuleSet(validationRuleSetId, input) {
594
+ this.db
595
+ .prepare(`INSERT INTO artifact_standard_validation_rule_sets
596
+ (validation_rule_set_id, artifact_standard_id, rule_set_code, rule_set_name,
597
+ target_domain, description, metadata_json)
598
+ VALUES (?, ?, ?, ?, ?, ?, ?)`)
599
+ .run(validationRuleSetId, input.artifactStandardId, input.ruleSetCode, input.ruleSetName, input.targetDomain ?? "artifact-standard", input.description ?? null, jsonValue(input.metadata));
600
+ return ruleSetFromRow(this.getById("artifact_standard_validation_rule_sets", "validation_rule_set_id", validationRuleSetId));
601
+ }
602
+ addValidationRuleSetRule(validationRuleSetRuleId, input) {
603
+ assertValidationContractCodes(input);
604
+ this.db
605
+ .prepare(`INSERT INTO artifact_standard_validation_rule_set_rules
606
+ (validation_rule_set_rule_id, validation_rule_set_id, rule_id, validation_type_code, execution_mode_code,
607
+ severity_code, applies_to_type_code, applies_to_ref, source_component_ref, parameters_json,
608
+ message, remediation, sort_order, metadata_json)
609
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
610
+ .run(validationRuleSetRuleId, input.validationRuleSetId, input.ruleId, input.validationTypeCode, input.executionModeCode, input.severityCode, input.appliesToTypeCode, input.appliesToRef ?? null, input.sourceComponentRef ?? null, jsonValue(input.parameters), input.message, input.remediation ?? null, input.sortOrder ?? 0, jsonValue(input.metadata));
611
+ return ruleSetRuleFromRow(this.getById("artifact_standard_validation_rule_set_rules", "validation_rule_set_rule_id", validationRuleSetRuleId));
612
+ }
613
+ listValidationRuleSetRules(validationRuleSetId) {
614
+ const rows = this.db
615
+ .prepare(`SELECT *
616
+ FROM artifact_standard_validation_rule_set_rules
617
+ WHERE validation_rule_set_id = ?
618
+ ORDER BY sort_order, rule_id`)
619
+ .all(validationRuleSetId);
620
+ return rows.map(ruleSetRuleFromRow);
621
+ }
622
+ listValidationRuleSets(artifactStandardId) {
623
+ const rows = this.db
624
+ .prepare(`SELECT *
625
+ FROM artifact_standard_validation_rule_sets
626
+ WHERE artifact_standard_id = ?
627
+ ORDER BY rule_set_code`)
628
+ .all(artifactStandardId);
629
+ return rows.map(ruleSetFromRow);
630
+ }
631
+ exportValidationProviderManifest(providerId, artifactStandardId) {
632
+ const ruleSets = this.db
633
+ .prepare(`SELECT *
634
+ FROM artifact_standard_validation_rule_sets
635
+ WHERE artifact_standard_id = ?
636
+ ORDER BY rule_set_code`)
637
+ .all(artifactStandardId);
638
+ return {
639
+ providerId,
640
+ providerModule: "@soddong/agentic-domain-artifact-standard",
641
+ version: "0.11.0",
642
+ profiles: ruleSets.map((row) => {
643
+ const ruleSet = ruleSetFromRow(row);
644
+ const rules = this.listValidationRuleSetRules(ruleSet.validationRuleSetId).map(validationRuleContractFromRecord);
645
+ return {
646
+ profileId: ruleSet.ruleSetCode,
647
+ providerModule: "@soddong/agentic-domain-artifact-standard",
648
+ targetDomain: ruleSet.targetDomain,
649
+ rules,
650
+ metadata: ruleSet.metadata
651
+ };
652
+ })
653
+ };
654
+ }
655
+ addGeneratedOutputLink(generatedOutputLinkId, input) {
656
+ this.db
657
+ .prepare(`INSERT INTO artifact_standard_generated_output_links
658
+ (generated_output_link_id, link_code, source_artifact_standard_id, source_artifact_standard_code,
659
+ source_artifact_standard_version, target_type_code, target_artifact_standard_id,
660
+ target_artifact_standard_code, target_artifact_standard_version, target_output_name,
661
+ generation_mode_code, sort_order, description, is_active, metadata_json)
662
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
663
+ .run(generatedOutputLinkId, input.linkCode, input.sourceArtifactStandardId, input.sourceArtifactStandardCode, input.sourceArtifactStandardVersion, input.targetTypeCode, input.targetArtifactStandardId ?? null, input.targetArtifactStandardCode ?? null, input.targetArtifactStandardVersion ?? null, input.targetOutputName ?? null, input.generationModeCode ?? "AUTOMATIC", input.sortOrder ?? 0, input.description ?? null, boolToInt(input.isActive, 1), jsonValue(input.metadata));
664
+ return generatedOutputLinkFromRow(this.getById("artifact_standard_generated_output_links", "generated_output_link_id", generatedOutputLinkId));
665
+ }
666
+ getGeneratedOutputLinkByCode(linkCode) {
667
+ const row = this.db
668
+ .prepare(`SELECT * FROM artifact_standard_generated_output_links WHERE link_code = ?`)
669
+ .get(linkCode);
670
+ return row === undefined ? undefined : generatedOutputLinkFromRow(row);
671
+ }
672
+ listGeneratedOutputLinks() {
673
+ const rows = this.db
674
+ .prepare(`SELECT *
675
+ FROM artifact_standard_generated_output_links
676
+ ORDER BY sort_order, link_code`)
677
+ .all();
678
+ return rows.map(generatedOutputLinkFromRow);
679
+ }
680
+ listGeneratedOutputLinksBySource(artifactStandardId) {
681
+ const rows = this.db
682
+ .prepare(`SELECT *
683
+ FROM artifact_standard_generated_output_links
684
+ WHERE source_artifact_standard_id = ?
685
+ ORDER BY sort_order, link_code`)
686
+ .all(artifactStandardId);
687
+ return rows.map(generatedOutputLinkFromRow);
688
+ }
689
+ addSourceMapping(sourceMappingId, input) {
690
+ this.db
691
+ .prepare(`INSERT INTO artifact_standard_source_mappings
692
+ (source_mapping_id, artifact_standard_id, source_type_code, source_uri, source_label,
693
+ source_section, source_fragment, target_type_code, target_ref, mapping_type_code,
694
+ mapping_status_code, rationale, loss_note, follow_up_note, metadata_json)
695
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
696
+ .run(sourceMappingId, input.artifactStandardId, input.sourceTypeCode, input.sourceUri, input.sourceLabel ?? null, input.sourceSection ?? null, input.sourceFragment ?? null, input.targetTypeCode, input.targetRef, input.mappingTypeCode, input.mappingStatusCode ?? "CANDIDATE", input.rationale ?? null, input.lossNote ?? null, input.followUpNote ?? null, jsonValue(input.metadata));
697
+ return sourceMappingFromRow(this.getById("artifact_standard_source_mappings", "source_mapping_id", sourceMappingId));
698
+ }
699
+ listSourceMappings(artifactStandardId) {
700
+ const rows = this.db
701
+ .prepare(`SELECT *
702
+ FROM artifact_standard_source_mappings
703
+ WHERE artifact_standard_id = ?
704
+ ORDER BY created_at, source_mapping_id`)
705
+ .all(artifactStandardId);
706
+ return rows.map(sourceMappingFromRow);
707
+ }
708
+ getById(tableName, idColumnName, id) {
709
+ const row = this.db.prepare(`SELECT * FROM ${tableName} WHERE ${idColumnName} = ?`).get(id);
710
+ if (row === undefined) {
711
+ throw new Error(`Record not found: ${tableName}.${idColumnName}=${id}`);
712
+ }
713
+ return row;
714
+ }
715
+ }
716
+ function assertValidationContractCodes(input) {
717
+ if (!isValidationTypeCode(input.validationTypeCode)) {
718
+ throw new Error(`Unsupported validation type code: ${input.validationTypeCode}`);
719
+ }
720
+ if (!isValidationExecutionModeCode(input.executionModeCode)) {
721
+ throw new Error(`Unsupported validation execution mode code: ${input.executionModeCode}`);
722
+ }
723
+ if (!isValidationSeverityCode(input.severityCode)) {
724
+ throw new Error(`Unsupported validation severity code: ${input.severityCode}`);
725
+ }
726
+ if (!artifactStandardValidationTargetTypeCodes.has(input.appliesToTypeCode)) {
727
+ throw new Error(`Unsupported artifact-standard validation target type code: ${input.appliesToTypeCode}`);
728
+ }
729
+ }
730
+ //# sourceMappingURL=repositories.js.map