okai 0.0.30 → 0.0.31
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/dist/client.js +1 -4
- package/dist/cs-ast.js +5 -0
- package/dist/cs-migrations.js +1 -1
- package/dist/icons.js +9 -6
- package/dist/index.js +3 -2
- package/dist/ts-once.js +7 -3
- package/dist/ts-parser.js +10 -3
- package/dist/ui-mjs.js +4 -1
- package/dist/utils.js +0 -53
- package/package.json +1 -1
package/dist/client.js
CHANGED
package/dist/cs-ast.js
CHANGED
@@ -205,6 +205,9 @@ export class CSharpAst {
|
|
205
205
|
].map(x => x.toLowerCase());
|
206
206
|
ignoreReadValidators = this.requestPropAttrs.filter(x => x.startsWith('validate')).map(x => x.toLowerCase());
|
207
207
|
ignoreDeleteValidators = this.requestPropAttrs.filter(x => x.startsWith('validate')).map(x => x.toLowerCase());
|
208
|
+
ignoreApisFor = [
|
209
|
+
'User',
|
210
|
+
];
|
208
211
|
isEnum(type) {
|
209
212
|
type = unwrap(type);
|
210
213
|
return this.ast.enums.some(x => x.name === type) || this.result.types.find(x => x.name === type && x.isEnum);
|
@@ -511,6 +514,8 @@ export class CSharpAst {
|
|
511
514
|
for (const type of this.classes) {
|
512
515
|
if (!isDataModel(type))
|
513
516
|
continue;
|
517
|
+
if (this.ignoreApisFor.includes(type.name))
|
518
|
+
continue;
|
514
519
|
const hasPk = type.properties?.some(x => x.isPrimaryKey);
|
515
520
|
if (!hasPk)
|
516
521
|
continue;
|
package/dist/cs-migrations.js
CHANGED
@@ -71,10 +71,10 @@ export class CSharpMigrationGenerator extends CSharpGenerator {
|
|
71
71
|
const deps = typeDeps[type] ?? [];
|
72
72
|
for (const dep of deps) {
|
73
73
|
if (!orderedTypes.includes(dep)) {
|
74
|
-
addDepTypes(dep, orderedTypes);
|
75
74
|
if (!orderedTypes.includes(dep)) {
|
76
75
|
orderedTypes.push(dep);
|
77
76
|
}
|
77
|
+
addDepTypes(dep, orderedTypes);
|
78
78
|
}
|
79
79
|
}
|
80
80
|
}
|
package/dist/icons.js
CHANGED
@@ -57,12 +57,12 @@ const P = `<svg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' `;
|
|
57
57
|
function S(viewbox, body) {
|
58
58
|
return P + `viewBox='${viewbox}'>${body}</svg>`;
|
59
59
|
}
|
60
|
-
export const
|
60
|
+
export const IconMap = {
|
61
61
|
/** Users */
|
62
62
|
User: S(`0 0 24 24`, `<path fill='currentColor' d='M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4'/>`),
|
63
63
|
Contact: S(`0 0 16 16`, `<path fill='currentColor' d='M5 3a3 3 0 1 1 6 0a3 3 0 0 1-6 0zm7.001 4h-.553l-3.111 6.316L9.5 7.5L8 6L6.5 7.5l1.163 5.816L4.552 7h-.554c-1.999 0-1.999 1.344-1.999 3v5h12v-5c0-1.656 0-3-1.999-3z'/>`),
|
64
64
|
Guest: S(`0 0 16 16`, `<path fill='currentColor' d='M8 8a3 3 0 1 0 0-6a3 3 0 0 0 0 6m4.735 6c.618 0 1.093-.561.872-1.139a6.002 6.002 0 0 0-11.215 0c-.22.578.254 1.139.872 1.139z'/>`),
|
65
|
-
Anon: S(`0 0 24 24`, `<path fill='
|
65
|
+
Anon: S(`0 0 24 24`, `<path fill='currentColor' d='M12 2a5 5 0 1 0 5 5a5 5 0 0 0-5-5zm0 8a3 3 0 1 1 3-3a3 3 0 0 1-3 3zm9 11v-1a7 7 0 0 0-7-7h-4a7 7 0 0 0-7 7v1h2v-1a5 5 0 0 1 5-5h4a5 5 0 0 1 5 5v1z'/>`),
|
66
66
|
Team: S('0 0 16 16', '<path fill="currentColor" d="M6.002 4a1.998 1.998 0 1 1 3.996 0a1.998 1.998 0 0 1-3.996 0M8 3.002a.998.998 0 1 0 0 1.996a.998.998 0 0 0 0-1.996M11 4.5a1.5 1.5 0 1 1 3 0a1.5 1.5 0 0 1-3 0m1.5-.5a.5.5 0 1 0 0 1a.5.5 0 0 0 0-1m-9-1a1.5 1.5 0 1 0 0 3a1.5 1.5 0 0 0 0-3M3 4.5a.5.5 0 1 1 1 0a.5.5 0 0 1-1 0M4.268 7A2 2 0 0 0 4 8H2v2.5a1.5 1.5 0 0 0 2.096 1.377c.074.331.19.647.34.942A2.5 2.5 0 0 1 1 10.5V8a1 1 0 0 1 1-1zm7.296 5.819A2.5 2.5 0 0 0 15 10.5V8a1 1 0 0 0-1-1h-2.268c.17.294.268.635.268 1h2v2.5a1.5 1.5 0 0 1-2.096 1.377q-.114.498-.34.942M6 6.999a1 1 0 0 0-1 1V11a3 3 0 0 0 6 0V8a1 1 0 0 0-1-1zm0 1h4V11a2 2 0 0 1-4 0z"/>'),
|
67
67
|
Signup: S(`0 0 16 16`, `<g fill='currentColor'><path fill-rule='evenodd' d='M10.854 7.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 9.793l2.646-2.647a.5.5 0 0 1 .708 0z'/><path d='M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z'/><path d='M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z'/></g>`),
|
68
68
|
Company: S(`0 0 24 24`, `<path fill='currentColor' d='M18 15h-2v2h2m0-6h-2v2h2m2 6h-8v-2h2v-2h-2v-2h2v-2h-2V9h8M10 7H8V5h2m0 6H8V9h2m0 6H8v-2h2m0 6H8v-2h2M6 7H4V5h2m0 6H4V9h2m0 6H4v-2h2m0 6H4v-2h2m6-10V3H2v18h20V7z'/>`),
|
@@ -110,6 +110,7 @@ export const Icons = withAliases({
|
|
110
110
|
Gift: S(`0 0 14 14`, `<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M13.5 2.5h-7v5h7zm-3.5 0v5M8.5.5l1.5 2l1.5-2M.5 11l2.444 2.036a2 2 0 0 0 1.28.463h6.442c.46 0 .834-.373.834-.833c0-.92-.746-1.667-1.667-1.667H5.354"/><path d="m3.5 10l.75.75a1.06 1.06 0 0 0 1.5-1.5L4.586 8.085A2 2 0 0 0 3.17 7.5H.5"/></g>`),
|
111
111
|
Deduct: S(`0 0 20 20`, `<path fill="currentColor" d="M10 20a10 10 0 1 1 0-20a10 10 0 0 1 0 20m0-2a8 8 0 1 0 0-16a8 8 0 0 0 0 16m5-9v2H5V9z"/>`),
|
112
112
|
Tax: S(`0 0 24 24`, `<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" color="currentColor"><path d="M2 8.57c0-1.197.482-1.93 1.48-2.486l4.11-2.287C9.743 2.6 10.82 2 12 2s2.257.6 4.41 1.797l4.11 2.287C21.517 6.64 22 7.373 22 8.57c0 .324 0 .487-.035.62c-.186.7-.821.811-1.434.811H3.469c-.613 0-1.247-.11-1.434-.811C2 9.056 2 8.893 2 8.569M4 10v8.5M8 10v8.5m3 0H5a3 3 0 0 0-3 3a.5.5 0 0 0 .5.5H11m10.5-7.5l-7 7"/><circle cx="15.25" cy="15.25" r=".75"/><circle cx="20.75" cy="20.75" r=".75"/></g>`),
|
113
|
+
Skill: S(`0 0 256 256`, `<path fill="currentColor" d="M188 48a27.75 27.75 0 0 0-12 2.71V44a28 28 0 0 0-54.65-8.6A28 28 0 0 0 80 60v64l-3.82-6.13a28 28 0 0 0-48.6 27.82c16 33.77 28.93 57.72 43.72 72.69C86.24 233.54 103.2 240 128 240a88.1 88.1 0 0 0 88-88V76a28 28 0 0 0-28-28m12 104a72.08 72.08 0 0 1-72 72c-20.38 0-33.51-4.88-45.33-16.85C69.44 193.74 57.26 171 41.9 138.58a6 6 0 0 0-.3-.58a12 12 0 0 1 20.79-12a2 2 0 0 0 .14.23l18.67 30A8 8 0 0 0 96 152V60a12 12 0 0 1 24 0v60a8 8 0 0 0 16 0V44a12 12 0 0 1 24 0v76a8 8 0 0 0 16 0V76a12 12 0 0 1 24 0Z"/>`),
|
113
114
|
/** Media */
|
114
115
|
Creative: S(`0 0 15 15`, `<path fill='currentColor' d='M10.71 3L7.85.15a.5.5 0 0 0-.707-.003L7.14.15L4.29 3H1.5a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5zM7.5 1.21L9.29 3H5.71zM13 12H2V4h11zM5 7a1 1 0 1 1 0-2a1 1 0 0 1 0 2zm7 4H4.5L6 8l1.25 2.5L9.5 6z'/>`),
|
115
116
|
Artifact: S(`0 0 16 16`, `<g fill='currentColor'><path d='M8.002 5.5a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0z'/><path d='M12 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM3 2a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v8l-2.083-2.083a.5.5 0 0 0-.76.063L8 11L5.835 9.7a.5.5 0 0 0-.611.076L3 12V2z'/></g>`),
|
@@ -148,8 +149,8 @@ export const Icons = withAliases({
|
|
148
149
|
Refund: S(`0 0 20 20`, `<path fill="currentColor" fill-rule="evenodd" d="M5 2a2 2 0 0 0-2 2v14l3.5-2l3.5 2l3.5-2l3.5 2V4a2 2 0 0 0-2-2zm4.707 3.707a1 1 0 0 0-1.414-1.414l-3 3a1 1 0 0 0 0 1.414l3 3a1 1 0 0 0 1.414-1.414L8.414 9H10a3 3 0 0 1 3 3v1a1 1 0 1 0 2 0v-1a5 5 0 0 0-5-5H8.414z" clip-rule="evenodd"/>`),
|
149
150
|
Result: S(`0 0 2048 2048`, `<path fill="currentColor" d="M2048 640v640h-768v512H128v128H0V0h128v128h1408v512zM128 256v384h1280V256zm1024 1408v-384H128v384zm768-512V768H128v384z"/>`),
|
150
151
|
/** CMS */
|
151
|
-
Page: S('0 0 24 24', '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><path d="M4 21.4V2.6a.6.6 0 0 1 .6-.6h11.652a.6.6 0 0 1 .424.176l3.148 3.148A.6.6 0 0 1 20 5.75V21.4a.6.6 0 0 1-.6.6H4.6a.6.6 0 0 1-.6-.6M8 10h8m-8 8h8m-8-4h4"/><path d="M16 2v3.4a.6.6 0 0 0 .6.6H20"
|
152
|
-
Tag: S('0 0 24 24', '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0-2 0"/><path d="M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592-5.592a2.41 2.41 0 0 0 0-3.408l-7.71-7.71A2 2 0 0 0 11.172 3H6a3 3 0 0 0-3 3"
|
152
|
+
Page: S('0 0 24 24', '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><path d="M4 21.4V2.6a.6.6 0 0 1 .6-.6h11.652a.6.6 0 0 1 .424.176l3.148 3.148A.6.6 0 0 1 20 5.75V21.4a.6.6 0 0 1-.6.6H4.6a.6.6 0 0 1-.6-.6M8 10h8m-8 8h8m-8-4h4"/><path d="M16 2v3.4a.6.6 0 0 0 .6.6H20"/></g>'),
|
153
|
+
Tag: S('0 0 24 24', '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0-2 0"/><path d="M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592-5.592a2.41 2.41 0 0 0 0-3.408l-7.71-7.71A2 2 0 0 0 11.172 3H6a3 3 0 0 0-3 3"/></g>'),
|
153
154
|
Type: S('0 0 24 24', '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 7V6a2 2 0 0 1 2-2h5m7 3V6a2 2 0 0 0-2-2h-5m0 0v16m0 0H9m3 0h3"/>'),
|
154
155
|
Category: S('0 0 24 24', '<path fill="currentColor" d="m2.25 8.452l9.5 5.48a.5.5 0 0 0 .5 0l9.5-5.48a.5.5 0 0 0 0-.866l-9.5-5.476a.51.51 0 0 0-.5 0l-9.5 5.476a.5.5 0 0 0 0 .866M12 3.122l8.499 4.898L12 12.923L3.501 8.02zm9.248 12.404L12 20.921l-9.248-5.395a.5.5 0 1 0-.504.864l9.5 5.542a.5.5 0 0 0 .504 0l9.5-5.542a.5.5 0 1 0-.504-.864m0-4L12 16.921l-9.248-5.395a.5.5 0 1 0-.504.864l9.5 5.542a.5.5 0 0 0 .504 0l9.5-5.542a.5.5 0 1 0-.504-.864"/>'),
|
155
156
|
Menu: S('0 0 24 24', '<path fill="currentColor" d="M2 2h20v20H2zm2 2v5.5h16V4zm16 7.5H4V20h16zM5.996 6H8v2h-.004v.004h-2zM10 6h8v2h-8z"/>'),
|
@@ -171,7 +172,8 @@ export const Icons = withAliases({
|
|
171
172
|
/** Actions */
|
172
173
|
Completed: S(`0 0 2048 2048`, `<path fill='currentColor' d='M1024 0q141 0 272 36t244 104t207 160t161 207t103 245t37 272q0 141-36 272t-104 244t-160 207t-207 161t-245 103t-272 37q-141 0-272-36t-244-104t-207-160t-161-207t-103-245t-37-272q0-141 36-272t104-244t160-207t207-161T752 37t272-37m603 685l-136-136l-659 659l-275-275l-136 136l411 411z'/>`),
|
173
174
|
Failed: S(`0 0 2048 2048`, `<path fill='currentColor' d='M1024 0q141 0 272 36t244 104t207 160t161 207t103 245t37 272q0 141-36 272t-104 244t-160 207t-207 161t-245 103t-272 37q-141 0-272-36t-244-104t-207-160t-161-207t-103-245t-37-272q0-141 36-272t104-244t160-207t207-161T752 37t272-37m113 1024l342-342l-113-113l-342 342l-342-342l-113 113l342 342l-342 342l113 113l342-342l342 342l113-113z'/>`),
|
174
|
-
}
|
175
|
+
};
|
176
|
+
export const IconGroups = {
|
175
177
|
User: ['AppUser'],
|
176
178
|
Company: ['Organization'],
|
177
179
|
Contact: ['Customer', 'Client', 'Employee', 'Applicant'],
|
@@ -206,5 +208,6 @@ export const Icons = withAliases({
|
|
206
208
|
Markup: ['TextMarkup'],
|
207
209
|
HtmlFormat: ['RichHtml'],
|
208
210
|
Alert: ['Notification'],
|
209
|
-
}
|
211
|
+
};
|
212
|
+
export const Icons = withAliases(IconMap, IconGroups);
|
210
213
|
const IconKeys = Object.keys(Icons).sort((a, b) => b.length - a.length);
|
package/dist/index.js
CHANGED
@@ -2,7 +2,7 @@ import fs from "fs";
|
|
2
2
|
import path from "path";
|
3
3
|
import blessed from 'blessed';
|
4
4
|
import { projectInfo } from './info.js';
|
5
|
-
import {
|
5
|
+
import { leftPart, replaceMyApp, trimStart, toPascalCase, plural } from "./utils.js";
|
6
6
|
import { generateCsAstFromTsd, toAst, astForProject } from "./ts-ast.js";
|
7
7
|
import { CSharpApiGenerator } from "./cs-apis.js";
|
8
8
|
import { CSharpMigrationGenerator } from "./cs-migrations.js";
|
@@ -379,7 +379,8 @@ Options:
|
|
379
379
|
if (command.verbose)
|
380
380
|
console.log(`Removing: ${tsdPath}...`);
|
381
381
|
const tsdContent = fs.readFileSync(tsdPath, 'utf-8');
|
382
|
-
const
|
382
|
+
const ast = toAst(tsdContent);
|
383
|
+
const header = ast.config;
|
383
384
|
if (command.verbose)
|
384
385
|
console.log(JSON.stringify(header, undefined, 2));
|
385
386
|
if (header?.migration) {
|
package/dist/ts-once.js
CHANGED
@@ -150,9 +150,13 @@ function rewriteToPascalCase(ast) {
|
|
150
150
|
});
|
151
151
|
ast.enums?.forEach(e => {
|
152
152
|
e.name = toPascalCase(e.name);
|
153
|
-
e.members?.
|
154
|
-
|
155
|
-
|
153
|
+
if (e.members?.length) {
|
154
|
+
e.members?.forEach((m, i) => {
|
155
|
+
// always reset the value of AI enums
|
156
|
+
m.value = i;
|
157
|
+
m.name = toPascalCase(m.name);
|
158
|
+
});
|
159
|
+
}
|
156
160
|
});
|
157
161
|
}
|
158
162
|
function convertToAuditBase(cls) {
|
package/dist/ts-parser.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { lastLeftPart, lastRightPart, leftPart, rightPart, trimEnd } from "./utils.js";
|
1
|
+
import { lastLeftPart, lastRightPart, leftPart, rightPart, trimEnd, trimStart } from "./utils.js";
|
2
2
|
export class TypeScriptParser {
|
3
3
|
static CONFIG_TYPE_PATTERN = /export\s+type\s+Config\s*=\s*{([^}]+)}/;
|
4
4
|
static CONFIG_PROPERTY_PATTERN = /(\w+)\s*:\s*("[^"]*"|'[^']*')/g;
|
@@ -37,6 +37,10 @@ export class TypeScriptParser {
|
|
37
37
|
if (multiLineMatch) {
|
38
38
|
return multiLineMatch[1].trim();
|
39
39
|
}
|
40
|
+
line = line.trim();
|
41
|
+
if (line.startsWith('/*') || line.startsWith('*')) {
|
42
|
+
return trimStart(trimStart(trimStart(line, '/'), '*'), '/').trim();
|
43
|
+
}
|
40
44
|
return undefined;
|
41
45
|
}
|
42
46
|
getPreviousLine(content, position) {
|
@@ -300,15 +304,18 @@ export class TypeScriptParser {
|
|
300
304
|
if (!s)
|
301
305
|
return false;
|
302
306
|
s = s.trim();
|
303
|
-
return s.startsWith('//') || s.startsWith('/*');
|
307
|
+
return s.startsWith('//') || s.startsWith('/*') || s.startsWith('*');
|
304
308
|
}
|
305
309
|
parseEnums(content) {
|
306
310
|
let match;
|
307
311
|
while ((match = TypeScriptParser.ENUM_PATTERN.exec(content))) {
|
308
312
|
const previousLine = this.getPreviousLine(content, match.index);
|
313
|
+
const { comment, annotations } = previousLine
|
314
|
+
? this.parseMetadata(content.substring(0, match.index), previousLine)
|
315
|
+
: { comment: undefined, annotations: undefined };
|
309
316
|
this.enums.push({
|
310
317
|
name: match[1],
|
311
|
-
comment: previousLine ?
|
318
|
+
comment: previousLine ? comment : undefined,
|
312
319
|
members: this.parseEnumMembers(match[2])
|
313
320
|
});
|
314
321
|
}
|
package/dist/ui-mjs.js
CHANGED
@@ -21,6 +21,9 @@ export default {
|
|
21
21
|
}
|
22
22
|
*/
|
23
23
|
export class UiMjsGroupGenerator {
|
24
|
+
ignore = [
|
25
|
+
'User',
|
26
|
+
];
|
24
27
|
generate(ast, groupLabel) {
|
25
28
|
if (!groupLabel) {
|
26
29
|
const groupName = getGroupName(ast);
|
@@ -30,7 +33,7 @@ export class UiMjsGroupGenerator {
|
|
30
33
|
`export default {`,
|
31
34
|
` group: "${groupLabel}",`,
|
32
35
|
` items: {`,
|
33
|
-
...ast.types.filter(x => !x.isEnum && !x.isInterface).map(x => {
|
36
|
+
...ast.types.filter(x => !x.isEnum && !x.isInterface && !this.ignore.includes(x.name)).map(x => {
|
34
37
|
return [
|
35
38
|
` ${plural(x.name)}: {`,
|
36
39
|
` type: '${x.name}',`,
|
package/dist/utils.js
CHANGED
@@ -187,59 +187,6 @@ export function getGroupName(ast) {
|
|
187
187
|
return null;
|
188
188
|
return plural(types.sort((x, y) => refCount(y) - refCount(x))[0].name);
|
189
189
|
}
|
190
|
-
export function tsdWithPrompt(tsd, prompt) {
|
191
|
-
return `/*prompt: ${prompt}\n*/\n\n${tsd}`;
|
192
|
-
}
|
193
|
-
export function tsdWithoutPrompt(tsd) {
|
194
|
-
return tsd.includes('/*prompt:')
|
195
|
-
? tsd.substring(tsd.indexOf('*/') + 2).trim()
|
196
|
-
: tsd;
|
197
|
-
}
|
198
|
-
export function parseTsdHeader(tsd) {
|
199
|
-
const header = tsd.includes('/*prompt:')
|
200
|
-
? leftPart(rightPart(tsd, '/*prompt:') ?? '', '*/').trim()
|
201
|
-
: null;
|
202
|
-
if (!header)
|
203
|
-
return null;
|
204
|
-
const lines = header.split('\n');
|
205
|
-
const to = { prompt: '', api: '' };
|
206
|
-
for (const line of lines) {
|
207
|
-
if (line.startsWith('api:')) {
|
208
|
-
to.api = line.replace('api:', '').trim();
|
209
|
-
}
|
210
|
-
else if (line.startsWith('migration:')) {
|
211
|
-
to.migration = line.replace('migration:', '').trim();
|
212
|
-
}
|
213
|
-
else if (line.startsWith('ui.mjs:')) {
|
214
|
-
to.uiMjs = line.replace('ui.mjs:', '').trim();
|
215
|
-
}
|
216
|
-
else if (!to.api && !to.migration && line.trim()) {
|
217
|
-
to.prompt += line.trim() + '\n';
|
218
|
-
}
|
219
|
-
}
|
220
|
-
if (!to.api)
|
221
|
-
return null;
|
222
|
-
to.prompt = to.prompt.trim();
|
223
|
-
to.api = to.api.trim();
|
224
|
-
if (to.migration)
|
225
|
-
to.migration = to.migration.trim();
|
226
|
-
return to;
|
227
|
-
}
|
228
|
-
export function toTsdHeader(header) {
|
229
|
-
const sb = [
|
230
|
-
`/*prompt: ${header.prompt}`,
|
231
|
-
`api: ${header.api}`,
|
232
|
-
];
|
233
|
-
if (header.migration) {
|
234
|
-
sb.push(`migration: ${header.migration}`);
|
235
|
-
}
|
236
|
-
if (header.uiMjs) {
|
237
|
-
sb.push(`ui.mjs: ${header.uiMjs}`);
|
238
|
-
}
|
239
|
-
sb.push('*/');
|
240
|
-
sb.push('');
|
241
|
-
return sb.join('\n');
|
242
|
-
}
|
243
190
|
export function toPascalCase(s) {
|
244
191
|
if (!s)
|
245
192
|
return '';
|