@wp-typia/project-tools 0.23.1 → 0.24.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 (152) hide show
  1. package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
  2. package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
  3. package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
  4. package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
  5. package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
  6. package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
  7. package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
  8. package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
  9. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
  10. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
  11. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
  12. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
  13. package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
  14. package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
  15. package/dist/runtime/cli-add-collision.js +8 -0
  16. package/dist/runtime/cli-add-help.js +10 -7
  17. package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
  18. package/dist/runtime/cli-add-kind-ids.js +1 -0
  19. package/dist/runtime/cli-add-types.d.ts +28 -1
  20. package/dist/runtime/cli-add-types.js +2 -0
  21. package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
  22. package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
  23. package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
  24. package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
  25. package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
  26. package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -311
  27. package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +1 -1
  28. package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
  29. package/dist/runtime/cli-add-workspace-ai-anchors.js +4 -232
  30. package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
  31. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
  32. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -145
  33. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
  34. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
  35. package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
  36. package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
  37. package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
  38. package/dist/runtime/cli-add-workspace-assets.js +6 -950
  39. package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
  40. package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
  41. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
  42. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
  43. package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
  44. package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
  45. package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
  46. package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
  47. package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
  48. package/dist/runtime/cli-add-workspace-block-style.js +148 -0
  49. package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
  50. package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
  51. package/dist/runtime/cli-add-workspace-contract.js +1 -1
  52. package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
  53. package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
  54. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
  55. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
  56. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
  57. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
  58. package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
  59. package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
  60. package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
  61. package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
  62. package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
  63. package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
  64. package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
  65. package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
  66. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
  67. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
  68. package/dist/runtime/cli-add-workspace-integration-env.js +5 -345
  69. package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
  70. package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
  71. package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
  72. package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
  73. package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
  74. package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
  75. package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
  76. package/dist/runtime/cli-add-workspace-pattern.js +99 -0
  77. package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
  78. package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
  79. package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
  80. package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +6 -9
  81. package/dist/runtime/cli-add-workspace-rest-anchors.js +6 -466
  82. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
  83. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
  84. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
  85. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
  86. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
  87. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
  88. package/dist/runtime/cli-add-workspace-rest-generated.js +5 -3
  89. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
  90. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
  91. package/dist/runtime/cli-add-workspace-rest-manual.js +3 -16
  92. package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +1 -7
  93. package/dist/runtime/cli-add-workspace-rest-php-templates.js +3 -322
  94. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
  95. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
  96. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
  97. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
  98. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
  99. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
  100. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -99
  101. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -663
  102. package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
  103. package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
  104. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
  105. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
  106. package/dist/runtime/cli-add-workspace-rest-types.d.ts +3 -3
  107. package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
  108. package/dist/runtime/cli-add-workspace-variation.js +162 -0
  109. package/dist/runtime/cli-add-workspace.d.ts +42 -107
  110. package/dist/runtime/cli-add-workspace.js +42 -674
  111. package/dist/runtime/cli-add.d.ts +3 -3
  112. package/dist/runtime/cli-add.js +2 -2
  113. package/dist/runtime/cli-core.d.ts +2 -1
  114. package/dist/runtime/cli-core.js +1 -1
  115. package/dist/runtime/cli-doctor-workspace-bindings.js +59 -0
  116. package/dist/runtime/cli-doctor-workspace-block-addons.js +33 -5
  117. package/dist/runtime/cli-doctor.d.ts +2 -0
  118. package/dist/runtime/cli-doctor.js +13 -2
  119. package/dist/runtime/cli-help.js +6 -4
  120. package/dist/runtime/index.d.ts +5 -2
  121. package/dist/runtime/index.js +4 -2
  122. package/dist/runtime/local-dev-presets.js +2 -1
  123. package/dist/runtime/package-versions.d.ts +1 -0
  124. package/dist/runtime/package-versions.js +10 -2
  125. package/dist/runtime/pattern-catalog.d.ts +122 -0
  126. package/dist/runtime/pattern-catalog.js +471 -0
  127. package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
  128. package/dist/runtime/post-meta-binding-fields.js +135 -0
  129. package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
  130. package/dist/runtime/typia-llm-json-schema.js +33 -0
  131. package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
  132. package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
  133. package/dist/runtime/typia-llm-projection.d.ts +25 -0
  134. package/dist/runtime/typia-llm-projection.js +58 -0
  135. package/dist/runtime/typia-llm-render.d.ts +21 -0
  136. package/dist/runtime/typia-llm-render.js +252 -0
  137. package/dist/runtime/typia-llm-sync.d.ts +10 -0
  138. package/dist/runtime/typia-llm-sync.js +63 -0
  139. package/dist/runtime/typia-llm-types.d.ts +197 -0
  140. package/dist/runtime/typia-llm-types.js +1 -0
  141. package/dist/runtime/typia-llm.d.ts +9 -255
  142. package/dist/runtime/typia-llm.js +5 -634
  143. package/dist/runtime/workspace-inventory-mutations.js +13 -0
  144. package/dist/runtime/workspace-inventory-section-descriptors.js +9 -1
  145. package/dist/runtime/workspace-inventory-templates.d.ts +2 -2
  146. package/dist/runtime/workspace-inventory-templates.js +9 -1
  147. package/dist/runtime/workspace-inventory-types.d.ts +9 -1
  148. package/package.json +8 -3
  149. package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
  150. package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
  151. package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
  152. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
@@ -1,634 +1,5 @@
1
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { getOptionalNodeErrorCode, isFileNotFoundError, } from './fs-async.js';
4
- import { cloneJsonValue } from './json-utils.js';
5
- import { normalizeEndpointAuthDefinition, } from './schema-core.js';
6
- const TYPESCRIPT_RESERVED_WORDS = new Set([
7
- 'abstract',
8
- 'any',
9
- 'as',
10
- 'asserts',
11
- 'async',
12
- 'await',
13
- 'bigint',
14
- 'boolean',
15
- 'break',
16
- 'case',
17
- 'catch',
18
- 'class',
19
- 'const',
20
- 'constructor',
21
- 'continue',
22
- 'debugger',
23
- 'declare',
24
- 'default',
25
- 'delete',
26
- 'do',
27
- 'else',
28
- 'enum',
29
- 'export',
30
- 'extends',
31
- 'false',
32
- 'finally',
33
- 'for',
34
- 'from',
35
- 'function',
36
- 'get',
37
- 'global',
38
- 'if',
39
- 'implements',
40
- 'import',
41
- 'in',
42
- 'infer',
43
- 'instanceof',
44
- 'interface',
45
- 'is',
46
- 'keyof',
47
- 'let',
48
- 'module',
49
- 'namespace',
50
- 'never',
51
- 'new',
52
- 'null',
53
- 'number',
54
- 'object',
55
- 'of',
56
- 'package',
57
- 'private',
58
- 'protected',
59
- 'public',
60
- 'readonly',
61
- 'require',
62
- 'return',
63
- 'satisfies',
64
- 'set',
65
- 'static',
66
- 'string',
67
- 'super',
68
- 'switch',
69
- 'symbol',
70
- 'this',
71
- 'throw',
72
- 'true',
73
- 'try',
74
- 'type',
75
- 'typeof',
76
- 'undefined',
77
- 'unique',
78
- 'unknown',
79
- 'var',
80
- 'void',
81
- 'while',
82
- 'with',
83
- 'yield',
84
- ]);
85
- const JSON_SCHEMA_CONSTRAINT_KEYS = [
86
- 'additionalProperties',
87
- 'const',
88
- 'default',
89
- 'enum',
90
- 'exclusiveMaximum',
91
- 'exclusiveMinimum',
92
- 'format',
93
- 'maxItems',
94
- 'maxLength',
95
- 'maximum',
96
- 'minItems',
97
- 'minLength',
98
- 'minimum',
99
- 'multipleOf',
100
- 'pattern',
101
- 'type',
102
- ];
103
- function cloneJsonValueIfDefined(value) {
104
- return value === undefined ? undefined : cloneJsonValue(value);
105
- }
106
- function isJsonSchemaObject(value) {
107
- return typeof value === 'object' && value !== null && !Array.isArray(value);
108
- }
109
- /**
110
- * Narrow a `typia.llm` artifact field before applying JSON Schema mutations.
111
- *
112
- * @param value Candidate schema value emitted by `typia.llm`.
113
- * @param context Human-readable artifact path for diagnostics.
114
- * @returns The value narrowed to the shared JSON Schema object shape.
115
- */
116
- export function assertJsonSchemaObject(value, context) {
117
- if (isJsonSchemaObject(value)) {
118
- return value;
119
- }
120
- throw new Error(`${context} must be a JSON Schema object.`);
121
- }
122
- function decodeJsonPointerSegment(segment) {
123
- return segment.replace(/~1/g, '/').replace(/~0/g, '~');
124
- }
125
- function resolveOpenApiReferenceTarget(document, reference) {
126
- if (!reference.startsWith('#/')) {
127
- throw new Error(`Unsupported OpenAPI schema reference "${reference}".`);
128
- }
129
- let current = document;
130
- for (const rawSegment of reference.slice(2).split('/')) {
131
- const segment = decodeJsonPointerSegment(rawSegment);
132
- if (Array.isArray(current)) {
133
- const index = Number.parseInt(segment, 10);
134
- current = Number.isInteger(index) ? current[index] : undefined;
135
- continue;
136
- }
137
- if (!isJsonSchemaObject(current)) {
138
- current = undefined;
139
- break;
140
- }
141
- current = current[segment];
142
- }
143
- if (!isJsonSchemaObject(current)) {
144
- throw new Error(`Unable to resolve OpenAPI schema reference "${reference}".`);
145
- }
146
- return current;
147
- }
148
- function resolveOpenApiSchemaObject(document, schema, seenReferences = new Set()) {
149
- if (!isJsonSchemaObject(schema)) {
150
- return {};
151
- }
152
- const reference = schema.$ref;
153
- if (typeof reference !== 'string') {
154
- return schema;
155
- }
156
- if (seenReferences.has(reference)) {
157
- return schema;
158
- }
159
- return resolveOpenApiSchemaObject(document, resolveOpenApiReferenceTarget(document, reference), new Set([...seenReferences, reference]));
160
- }
161
- function collectOpenApiSeenReferences(schema, seenReferences) {
162
- const reference = schema.$ref;
163
- if (typeof reference !== 'string' || seenReferences.has(reference)) {
164
- return seenReferences;
165
- }
166
- return new Set([...seenReferences, reference]);
167
- }
168
- /**
169
- * Copy constraint-oriented JSON Schema keywords from `source` into `target`.
170
- *
171
- * This helper intentionally mutates and returns `target` so nested OpenAPI
172
- * constraint restoration can preserve the projected typia.llm schema shape.
173
- * Callers that need immutable behavior should clone the target before calling.
174
- */
175
- function mergeJsonSchemaConstraintProperties(document, target, source, seenReferences = new Set()) {
176
- const nextSeenReferences = collectOpenApiSeenReferences(source, seenReferences);
177
- const resolvedSource = resolveOpenApiSchemaObject(document, source, seenReferences);
178
- const merged = target;
179
- for (const key of JSON_SCHEMA_CONSTRAINT_KEYS) {
180
- if (resolvedSource[key] !== undefined) {
181
- merged[key] = cloneJsonValue(resolvedSource[key]);
182
- }
183
- }
184
- if (Array.isArray(resolvedSource.required)) {
185
- merged.required = resolvedSource.required.filter((value) => typeof value === 'string');
186
- }
187
- if (Array.isArray(resolvedSource.items)) {
188
- merged.items = cloneJsonValue(resolvedSource.items);
189
- }
190
- else if (isJsonSchemaObject(resolvedSource.items)) {
191
- const nextItems = isJsonSchemaObject(merged.items) ? merged.items : {};
192
- merged.items = mergeJsonSchemaConstraintProperties(document, nextItems, resolvedSource.items, nextSeenReferences);
193
- }
194
- if (isJsonSchemaObject(resolvedSource.properties)) {
195
- const targetProperties = isJsonSchemaObject(merged.properties)
196
- ? merged.properties
197
- : {};
198
- for (const [propertyName, propertySchema] of Object.entries(resolvedSource.properties)) {
199
- if (!isJsonSchemaObject(propertySchema)) {
200
- continue;
201
- }
202
- const nextProperty = isJsonSchemaObject(targetProperties[propertyName])
203
- ? targetProperties[propertyName]
204
- : {};
205
- targetProperties[propertyName] = mergeJsonSchemaConstraintProperties(document, nextProperty, propertySchema, nextSeenReferences);
206
- }
207
- merged.properties = targetProperties;
208
- }
209
- return merged;
210
- }
211
- function findOpenApiOperationById(document, operationId) {
212
- for (const pathItem of Object.values(document.paths)) {
213
- if (!isJsonSchemaObject(pathItem)) {
214
- continue;
215
- }
216
- for (const method of ['delete', 'get', 'patch', 'post', 'put']) {
217
- const operation = resolveOpenApiSchemaObject(document, pathItem[method]);
218
- if (!isJsonSchemaObject(operation) ||
219
- typeof operation.operationId !== 'string') {
220
- continue;
221
- }
222
- if (operation.operationId === operationId) {
223
- return operation;
224
- }
225
- }
226
- }
227
- return null;
228
- }
229
- function resolveOpenApiRequestBodySchema(operation, document) {
230
- const requestBody = resolveOpenApiSchemaObject(document, operation.requestBody);
231
- const content = isJsonSchemaObject(requestBody.content)
232
- ? requestBody.content
233
- : null;
234
- const jsonMediaType = content && isJsonSchemaObject(content['application/json'])
235
- ? content['application/json']
236
- : null;
237
- const schema = jsonMediaType?.schema;
238
- if (!isJsonSchemaObject(schema)) {
239
- return null;
240
- }
241
- return resolveOpenApiSchemaObject(document, schema);
242
- }
243
- function resolveOpenApiSuccessResponseSchema(operation, document) {
244
- for (const [statusCode, response] of Object.entries(operation.responses)) {
245
- const resolvedResponse = resolveOpenApiSchemaObject(document, response);
246
- if (!/^2(?:\d\d|XX)$/u.test(statusCode) ||
247
- !isJsonSchemaObject(resolvedResponse)) {
248
- continue;
249
- }
250
- const content = isJsonSchemaObject(resolvedResponse.content)
251
- ? resolvedResponse.content
252
- : null;
253
- const jsonMediaType = content && isJsonSchemaObject(content['application/json'])
254
- ? content['application/json']
255
- : null;
256
- const schema = jsonMediaType?.schema;
257
- if (!isJsonSchemaObject(schema)) {
258
- continue;
259
- }
260
- return resolveOpenApiSchemaObject(document, schema);
261
- }
262
- return null;
263
- }
264
- function getOrCreateObjectProperty(target, propertyName) {
265
- const targetProperties = isJsonSchemaObject(target.properties)
266
- ? target.properties
267
- : {};
268
- const nextProperty = isJsonSchemaObject(targetProperties[propertyName])
269
- ? targetProperties[propertyName]
270
- : {};
271
- targetProperties[propertyName] = nextProperty;
272
- target.properties = targetProperties;
273
- return nextProperty;
274
- }
275
- function applyOpenApiQueryParameterConstraints(target, operation, document) {
276
- for (const parameter of operation.parameters ?? []) {
277
- const resolvedParameter = resolveOpenApiSchemaObject(document, parameter);
278
- if (!isJsonSchemaObject(resolvedParameter) ||
279
- resolvedParameter.in !== 'query' ||
280
- typeof resolvedParameter.name !== 'string') {
281
- continue;
282
- }
283
- const propertyTarget = getOrCreateObjectProperty(target, resolvedParameter.name);
284
- mergeJsonSchemaConstraintProperties(document, propertyTarget, resolveOpenApiSchemaObject(document, resolvedParameter.schema));
285
- if (resolvedParameter.required === true) {
286
- const required = new Set(Array.isArray(target.required)
287
- ? target.required.filter((value) => typeof value === 'string')
288
- : []);
289
- required.add(resolvedParameter.name);
290
- target.required = [...required];
291
- }
292
- }
293
- }
294
- function getContractSourceTypeName(manifest, endpoint, contractName) {
295
- const contract = manifest.contracts[contractName];
296
- if (!contract) {
297
- throw new Error(`Endpoint "${endpoint.operationId}" references missing input contract "${contractName}".`);
298
- }
299
- return contract.sourceTypeName;
300
- }
301
- function getEndpointInputTypeDescriptor(manifest, endpoint) {
302
- if (endpoint.bodyContract && endpoint.queryContract) {
303
- const bodyTypeName = getContractSourceTypeName(manifest, endpoint, endpoint.bodyContract);
304
- const queryTypeName = getContractSourceTypeName(manifest, endpoint, endpoint.queryContract);
305
- return {
306
- importTypeNames: [bodyTypeName, queryTypeName],
307
- signatureTypeName: `{ body: ${bodyTypeName}; query: ${queryTypeName} }`,
308
- };
309
- }
310
- const contractName = endpoint.method === 'GET'
311
- ? endpoint.queryContract ?? null
312
- : endpoint.bodyContract ?? endpoint.queryContract ?? null;
313
- if (!contractName) {
314
- return {
315
- importTypeNames: [],
316
- signatureTypeName: null,
317
- };
318
- }
319
- const sourceTypeName = getContractSourceTypeName(manifest, endpoint, contractName);
320
- return {
321
- importTypeNames: [sourceTypeName],
322
- signatureTypeName: sourceTypeName,
323
- };
324
- }
325
- function getEndpointOutputTypeName(manifest, endpoint) {
326
- const contract = manifest.contracts[endpoint.responseContract];
327
- if (!contract) {
328
- throw new Error(`Endpoint "${endpoint.operationId}" references missing response contract "${endpoint.responseContract}".`);
329
- }
330
- return contract.sourceTypeName;
331
- }
332
- function escapeJsDocLine(line) {
333
- return line.replace(/\*\//g, '* /');
334
- }
335
- function normalizeGeneratedArtifactContent(content) {
336
- return content.replace(/\r\n?/g, '\n');
337
- }
338
- function renderDescriptionJsDocLines(method) {
339
- const description = method.description && method.description.trim().length > 0
340
- ? method.description
341
- : method.operationId;
342
- const descriptionLines = description
343
- .replace(/\r\n?/g, '\n')
344
- .split('\n')
345
- .map((line) => line.trim().replace(/\s+/g, ' '))
346
- .filter(Boolean);
347
- return (descriptionLines.length > 0
348
- ? descriptionLines
349
- : [method.operationId]).map((line) => ` * ${escapeJsDocLine(line)}`);
350
- }
351
- function renderMethodJsDoc(method) {
352
- const lines = [
353
- '/**',
354
- ...renderDescriptionJsDocLines(method),
355
- ' *',
356
- ` * REST path: ${method.method} ${method.path}`,
357
- ` * Auth intent: ${method.authIntent}`,
358
- ...(method.wordpressAuth
359
- ? [
360
- ` * WordPress auth: ${method.wordpressAuth.mechanism}${method.wordpressAuth.publicTokenField
361
- ? ` (field: ${method.wordpressAuth.publicTokenField})`
362
- : ''}`,
363
- ]
364
- : []),
365
- ...method.tags.map((tag) => ` * @tag ${escapeJsDocLine(tag)}`),
366
- ' */',
367
- ];
368
- return lines.join('\n');
369
- }
370
- function renderMethodSignature(method) {
371
- const inputSignature = method.inputTypeName === null ? '' : `input: ${method.inputTypeName}`;
372
- const methodName = /^[$A-Z_][$0-9A-Z_]*$/i.test(method.operationId) &&
373
- !TYPESCRIPT_RESERVED_WORDS.has(method.operationId)
374
- ? method.operationId
375
- : JSON.stringify(method.operationId);
376
- return `${methodName}(${inputSignature}): ${method.outputTypeName};`;
377
- }
378
- function renderTypiaLlmModuleFromMethodDescriptors({ applicationExportName, interfaceName, structuredOutputExportName, structuredOutputTypeName, typesImportPath, }, methods) {
379
- const importedTypeNames = new Set([structuredOutputTypeName]);
380
- for (const method of methods) {
381
- importedTypeNames.add(method.outputTypeName);
382
- if (method.inputTypeImportNames) {
383
- for (const inputTypeImportName of method.inputTypeImportNames) {
384
- importedTypeNames.add(inputTypeImportName);
385
- }
386
- }
387
- else if (method.inputTypeName) {
388
- importedTypeNames.add(method.inputTypeName);
389
- }
390
- }
391
- const imports = Array.from(importedTypeNames).sort().join(',\n\t');
392
- const methodBlocks = methods
393
- .map((method) => {
394
- const jsDoc = renderMethodJsDoc(method)
395
- .split('\n')
396
- .map((line) => `\t${line}`)
397
- .join('\n');
398
- return `${jsDoc}\n\t${renderMethodSignature(method)}`;
399
- })
400
- .join('\n\n');
401
- return `import typia from "typia";
402
- import type {
403
- \t${imports},
404
- } from "${typesImportPath}";
405
-
406
- export interface ${interfaceName} {
407
- ${methodBlocks}
408
- }
409
-
410
- export const ${applicationExportName} =
411
- \ttypia.llm.application<${interfaceName}>();
412
-
413
- export const ${structuredOutputExportName} =
414
- \ttypia.llm.structuredOutput<${structuredOutputTypeName}>();
415
- `;
416
- }
417
- async function reconcileGeneratedTypiaLlmArtifacts(artifacts, check) {
418
- if (!check) {
419
- for (const artifact of artifacts) {
420
- await mkdir(path.dirname(artifact.filePath), {
421
- recursive: true,
422
- });
423
- await writeFile(artifact.filePath, artifact.content, 'utf8');
424
- }
425
- return;
426
- }
427
- const issues = [];
428
- for (const artifact of artifacts) {
429
- try {
430
- const current = normalizeGeneratedArtifactContent(await readFile(artifact.filePath, 'utf8'));
431
- const expected = normalizeGeneratedArtifactContent(artifact.content);
432
- if (current !== expected) {
433
- issues.push(`- ${artifact.filePath} (stale)`);
434
- }
435
- }
436
- catch (error) {
437
- if (isFileNotFoundError(error)) {
438
- issues.push(`- ${artifact.filePath} (missing)`);
439
- continue;
440
- }
441
- const code = getOptionalNodeErrorCode(error);
442
- issues.push(`- ${artifact.filePath} (unreadable: ${error instanceof Error ? error.message : code ?? 'unknown'})`);
443
- }
444
- }
445
- if (issues.length > 0) {
446
- throw new Error(`Generated typia.llm artifacts are missing or stale:\n${issues.join('\n')}`);
447
- }
448
- }
449
- /**
450
- * Builds the generated controller method descriptors that bridge endpoint
451
- * manifests to `typia.llm` TypeScript interfaces.
452
- *
453
- * @param manifest Endpoint manifest that owns operation and source type names.
454
- * @returns Ordered method descriptors matching the manifest endpoints.
455
- * @throws When an endpoint has ambiguous query/body input mapping.
456
- * @throws When an endpoint references a missing input or output contract.
457
- */
458
- export function buildTypiaLlmEndpointMethodDescriptors(manifest) {
459
- return manifest.endpoints.map((endpoint) => {
460
- const normalizedAuth = normalizeEndpointAuthDefinition(endpoint);
461
- const inputTypeDescriptor = getEndpointInputTypeDescriptor(manifest, endpoint);
462
- const inputTypeName = inputTypeDescriptor.signatureTypeName;
463
- const shouldUseInlineInputImports = inputTypeName !== null &&
464
- inputTypeDescriptor.importTypeNames.length > 0 &&
465
- inputTypeDescriptor.importTypeNames[0] !== inputTypeName;
466
- return {
467
- authIntent: normalizedAuth.auth,
468
- ...(normalizedAuth.authMode ? { authMode: normalizedAuth.authMode } : {}),
469
- description: endpoint.summary,
470
- inputTypeName,
471
- ...(shouldUseInlineInputImports
472
- ? { inputTypeImportNames: inputTypeDescriptor.importTypeNames }
473
- : {}),
474
- method: endpoint.method,
475
- operationId: endpoint.operationId,
476
- outputTypeName: getEndpointOutputTypeName(manifest, endpoint),
477
- path: endpoint.path,
478
- tags: endpoint.tags ?? [],
479
- ...(normalizedAuth.wordpressAuth
480
- ? { wordpressAuth: normalizedAuth.wordpressAuth }
481
- : {}),
482
- };
483
- });
484
- }
485
- /**
486
- * Renders a build-time-only TypeScript module that invokes `typia.llm` against
487
- * canonical manifest-owned contracts.
488
- *
489
- * @param options Render options for the generated adapter module.
490
- * @returns The generated TypeScript source.
491
- */
492
- export function renderTypiaLlmModule({ applicationExportName, interfaceName, manifest, structuredOutputExportName, structuredOutputTypeName, typesImportPath, }) {
493
- return renderTypiaLlmModuleFromMethodDescriptors({
494
- applicationExportName,
495
- interfaceName,
496
- structuredOutputExportName,
497
- structuredOutputTypeName,
498
- typesImportPath,
499
- }, buildTypiaLlmEndpointMethodDescriptors(manifest));
500
- }
501
- /**
502
- * Writes or verifies the generated build-time `typia.llm` adapter module. The
503
- * returned TypeScript source still needs to be compiled by the consuming
504
- * project's Typia transformer before JSON artifacts can be read from it.
505
- *
506
- * @param options Generated module destination plus render options.
507
- * @returns Rendered source, method descriptors, and the checked/written file path.
508
- */
509
- export async function syncTypiaLlmAdapterModule({ check = false, generatedSourceFile, ...renderOptions }) {
510
- const methodDescriptors = buildTypiaLlmEndpointMethodDescriptors(renderOptions.manifest);
511
- const source = renderTypiaLlmModuleFromMethodDescriptors(renderOptions, methodDescriptors);
512
- await reconcileGeneratedTypiaLlmArtifacts([
513
- {
514
- content: source,
515
- filePath: generatedSourceFile,
516
- },
517
- ], check);
518
- return {
519
- check,
520
- methodDescriptors,
521
- source,
522
- sourceFile: generatedSourceFile,
523
- };
524
- }
525
- /**
526
- * Projects one compiled `typia.llm` function schema into a JSON-friendly
527
- * artifact record.
528
- *
529
- * @param functionSchema Function schema from a compiled `typia.llm.application(...)`.
530
- * @returns JSON-friendly function artifact.
531
- */
532
- export function projectTypiaLlmApplicationFunction(functionSchema) {
533
- return {
534
- description: functionSchema.description,
535
- name: functionSchema.name,
536
- output: cloneJsonValueIfDefined(functionSchema.output),
537
- parameters: cloneJsonValue(functionSchema.parameters),
538
- ...(functionSchema.tags ? { tags: [...functionSchema.tags] } : {}),
539
- };
540
- }
541
- function cloneProjectedTypiaLlmFunctionArtifact(functionArtifact) {
542
- return {
543
- description: functionArtifact.description,
544
- name: functionArtifact.name,
545
- output: cloneJsonValueIfDefined(functionArtifact.output),
546
- parameters: cloneJsonValue(functionArtifact.parameters),
547
- ...(functionArtifact.tags ? { tags: [...functionArtifact.tags] } : {}),
548
- };
549
- }
550
- /**
551
- * Restores canonical request and response constraints from an endpoint-aware
552
- * OpenAPI document onto one projected `typia.llm` function artifact.
553
- *
554
- * Query-only inputs merge into the root parameter object. Mixed body/query
555
- * inputs merge into the generated `body` and `query` properties.
556
- *
557
- * @param options Projected artifact plus the canonical OpenAPI document.
558
- * @returns A cloned artifact enriched with OpenAPI-backed constraints when available.
559
- */
560
- export function applyOpenApiConstraintsToTypiaLlmFunctionArtifact({ functionArtifact, openApiDocument, operationId, }) {
561
- const constrainedArtifact = cloneProjectedTypiaLlmFunctionArtifact(functionArtifact);
562
- const operation = findOpenApiOperationById(openApiDocument, operationId);
563
- if (!operation) {
564
- return constrainedArtifact;
565
- }
566
- const hasQueryParameters = (operation.parameters ?? []).some((parameter) => {
567
- const resolvedParameter = resolveOpenApiSchemaObject(openApiDocument, parameter);
568
- return (isJsonSchemaObject(resolvedParameter) &&
569
- resolvedParameter.in === 'query' &&
570
- typeof resolvedParameter.name === 'string');
571
- });
572
- const requestBodySchema = resolveOpenApiRequestBodySchema(operation, openApiDocument);
573
- const parameterSchema = assertJsonSchemaObject(constrainedArtifact.parameters, `typia.llm parameters for "${constrainedArtifact.name}"`);
574
- if (requestBodySchema) {
575
- if (hasQueryParameters) {
576
- mergeJsonSchemaConstraintProperties(openApiDocument, getOrCreateObjectProperty(parameterSchema, 'body'), requestBodySchema);
577
- }
578
- else {
579
- mergeJsonSchemaConstraintProperties(openApiDocument, parameterSchema, requestBodySchema);
580
- }
581
- }
582
- if (hasQueryParameters) {
583
- applyOpenApiQueryParameterConstraints(requestBodySchema
584
- ? getOrCreateObjectProperty(parameterSchema, 'query')
585
- : parameterSchema, operation, openApiDocument);
586
- }
587
- if (constrainedArtifact.output) {
588
- const outputSchema = assertJsonSchemaObject(constrainedArtifact.output, `typia.llm output for "${constrainedArtifact.name}"`);
589
- const responseSchema = resolveOpenApiSuccessResponseSchema(operation, openApiDocument);
590
- if (responseSchema) {
591
- mergeJsonSchemaConstraintProperties(openApiDocument, outputSchema, responseSchema);
592
- }
593
- }
594
- return constrainedArtifact;
595
- }
596
- /**
597
- * Projects a compiled `typia.llm.application(...)` result into a JSON-friendly
598
- * downstream adapter artifact.
599
- *
600
- * @param options Compiled application value and source metadata.
601
- * @returns JSON-friendly application artifact.
602
- */
603
- export function projectTypiaLlmApplicationArtifact({ application, generatedFrom, openApiProjection, transformFunction, }) {
604
- return {
605
- functions: application.functions.map((functionSchema) => {
606
- const functionArtifact = projectTypiaLlmApplicationFunction(functionSchema);
607
- const openApiAlignedArtifact = openApiProjection
608
- ? applyOpenApiConstraintsToTypiaLlmFunctionArtifact({
609
- functionArtifact,
610
- openApiDocument: openApiProjection.openApiDocument,
611
- operationId: openApiProjection.resolveOperationId?.(functionSchema, functionArtifact) ?? functionSchema.name,
612
- })
613
- : functionArtifact;
614
- const transformedArtifact = transformFunction
615
- ? transformFunction(openApiAlignedArtifact, functionSchema)
616
- : openApiAlignedArtifact;
617
- return cloneProjectedTypiaLlmFunctionArtifact(transformedArtifact);
618
- }),
619
- generatedFrom: cloneJsonValue(generatedFrom),
620
- };
621
- }
622
- /**
623
- * Projects a compiled `typia.llm.structuredOutput(...)` result into a
624
- * JSON-friendly downstream adapter artifact.
625
- *
626
- * @param options Compiled structured-output value and source metadata.
627
- * @returns JSON-friendly structured-output artifact.
628
- */
629
- export function projectTypiaLlmStructuredOutputArtifact({ generatedFrom, structuredOutput, }) {
630
- return {
631
- generatedFrom: cloneJsonValue(generatedFrom),
632
- parameters: cloneJsonValue(structuredOutput.parameters),
633
- };
634
- }
1
+ export { assertJsonSchemaObject } from './typia-llm-json-schema.js';
2
+ export { applyOpenApiConstraintsToTypiaLlmFunctionArtifact, } from './typia-llm-openapi-constraints.js';
3
+ export { projectTypiaLlmApplicationArtifact, projectTypiaLlmApplicationFunction, projectTypiaLlmStructuredOutputArtifact, } from './typia-llm-projection.js';
4
+ export { buildTypiaLlmEndpointMethodDescriptors, renderTypiaLlmModule, } from './typia-llm-render.js';
5
+ export { syncTypiaLlmAdapterModule } from './typia-llm-sync.js';
@@ -136,8 +136,21 @@ export function updateWorkspaceInventorySource(source, options = {}) {
136
136
  nextSource = options.transformSource(nextSource);
137
137
  }
138
138
  nextSource = appendInventorySectionEntries(nextSource, options);
139
+ for (const [fieldName, fieldSource] of [
140
+ ["contentFile", "\tcontentFile?: string;"],
141
+ ["file", "\tfile?: string;"],
142
+ ["scope", "\tscope?: 'full' | 'section';"],
143
+ ["sectionRole", "\tsectionRole?: string;"],
144
+ ["tags", "\ttags?: string[];"],
145
+ ["thumbnailUrl", "\tthumbnailUrl?: string;"],
146
+ ["title", "\ttitle?: string;"],
147
+ ]) {
148
+ nextSource = upsertInterfaceField(nextSource, "WorkspacePatternConfig", fieldName, fieldSource);
149
+ }
139
150
  nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "attribute", "\tattribute?: string;");
140
151
  nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "block", "\tblock?: string;");
152
+ nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "metaPath", "\tmetaPath?: string;");
153
+ nextSource = ensureInterfaceField(nextSource, "WorkspaceBindingSourceConfig", "postMeta", "\tpostMeta?: string;");
141
154
  nextSource = ensureInterfaceField(nextSource, "WorkspaceAbilityConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD);
142
155
  nextSource = normalizeInterfaceFieldBlock(nextSource, "WorkspaceAbilityConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD, ["optionalFeatureIds: string[];", "requiredFeatureIds: string[];"]);
143
156
  nextSource = ensureInterfaceField(nextSource, "WorkspaceAiFeatureConfig", "compatibility", WORKSPACE_COMPATIBILITY_CONFIG_FIELD);
@@ -133,8 +133,14 @@ export const INVENTORY_SECTIONS = [
133
133
  entry: defineInventoryEntryParser()({
134
134
  entryName: "PATTERNS",
135
135
  fields: [
136
- { key: "file", required: true },
136
+ { key: "contentFile" },
137
+ { key: "file" },
138
+ { key: "scope" },
139
+ { key: "sectionRole" },
137
140
  { key: "slug", required: true },
141
+ { key: "tags", kind: "stringArray" },
142
+ { key: "thumbnailUrl" },
143
+ { key: "title" },
138
144
  ],
139
145
  }),
140
146
  hasSectionKey: "hasPatternsSection",
@@ -161,6 +167,8 @@ export const INVENTORY_SECTIONS = [
161
167
  { key: "attribute" },
162
168
  { key: "block" },
163
169
  { key: "editorFile", required: true },
170
+ { key: "metaPath" },
171
+ { key: "postMeta" },
164
172
  { key: "serverFile", required: true },
165
173
  { key: "slug", required: true },
166
174
  ],