@autobe/utils 0.30.0-dev.20260315 → 0.30.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.
@@ -140,17 +140,17 @@ function writeRelations(props) {
140
140
  ];
141
141
  };
142
142
  return ArrayUtil_1.ArrayUtil.paddle([
143
- print(StringUtil_1.StringUtil.trim `
144
- BELONGED RELATIONS,
145
- - format: (propertyKey targetModel constraint)
143
+ print(StringUtil_1.StringUtil.trim `
144
+ BELONGED RELATIONS,
145
+ - format: (propertyKey targetModel constraint)
146
146
  `, props.model.foreignFields.map((foreign) => writeConstraint({
147
147
  dbms: props.dbms,
148
148
  model: props.model,
149
149
  foreign,
150
150
  }))),
151
- print(StringUtil_1.StringUtil.trim `
152
- HAS RELATIONS
153
- - format: (propertyKey targetModel)
151
+ print(StringUtil_1.StringUtil.trim `
152
+ HAS RELATIONS
153
+ - format: (propertyKey targetModel)
154
154
  `, hasRelationships.map((r) => {
155
155
  var _a, _b;
156
156
  return [
@@ -199,9 +199,9 @@ function writeConstraint(props) {
199
199
  ].join(", ")})`,
200
200
  ].join(" ");
201
201
  return tooMuchLong
202
- ? StringUtil_1.StringUtil.trim `
203
- // spellchecker: ignore-next-line
204
- ${body}
202
+ ? StringUtil_1.StringUtil.trim `
203
+ // spellchecker: ignore-next-line
204
+ ${body}
205
205
  `
206
206
  : body;
207
207
  }
@@ -210,9 +210,9 @@ function writeForeignIndex(props) {
210
210
  const prefix = `@@${props.field.unique === true ? "unique" : "index"}([${props.field.name}]`;
211
211
  if (name.length <= MAX_IDENTIFIER_LENGTH)
212
212
  return `${prefix})`;
213
- return StringUtil_1.StringUtil.trim `
214
- // spellchecker: ignore-next-line
215
- ${prefix}, map: "${shortName(name)}")
213
+ return StringUtil_1.StringUtil.trim `
214
+ // spellchecker: ignore-next-line
215
+ ${prefix}, map: "${shortName(name)}")
216
216
  `;
217
217
  }
218
218
  function writeUniqueIndex(props) {
@@ -220,9 +220,9 @@ function writeUniqueIndex(props) {
220
220
  const prefix = `@@unique([${props.unique.fieldNames.join(", ")}]`;
221
221
  if (name.length <= MAX_IDENTIFIER_LENGTH)
222
222
  return `${prefix})`;
223
- return StringUtil_1.StringUtil.trim `
224
- // spellchecker: ignore-next-line
225
- ${prefix}, map: "${shortName(name)}")
223
+ return StringUtil_1.StringUtil.trim `
224
+ // spellchecker: ignore-next-line
225
+ ${prefix}, map: "${shortName(name)}")
226
226
  `;
227
227
  }
228
228
  function writePlainIndex(props) {
@@ -230,9 +230,9 @@ function writePlainIndex(props) {
230
230
  const prefix = `@@index([${props.plain.fieldNames.join(", ")}]`;
231
231
  if (name.length <= MAX_IDENTIFIER_LENGTH)
232
232
  return `${prefix})`;
233
- return StringUtil_1.StringUtil.trim `
234
- // spellchecker: ignore-next-line
235
- ${prefix}, map: "${shortName(name)}")
233
+ return StringUtil_1.StringUtil.trim `
234
+ // spellchecker: ignore-next-line
235
+ ${prefix}, map: "${shortName(name)}")
236
236
  `;
237
237
  }
238
238
  function writeGinIndex(props) {
@@ -240,9 +240,9 @@ function writeGinIndex(props) {
240
240
  const prefix = `@@index([${props.gin.fieldName}(ops: raw("gin_trgm_ops"))], type: Gin`;
241
241
  if (name.length <= MAX_IDENTIFIER_LENGTH)
242
242
  return `${prefix})`;
243
- return StringUtil_1.StringUtil.trim `
244
- // spellchecker: ignore-next-line
245
- ${prefix}, map: "${shortName(name)}")
243
+ return StringUtil_1.StringUtil.trim `
244
+ // spellchecker: ignore-next-line
245
+ ${prefix}, map: "${shortName(name)}")
246
246
  `;
247
247
  }
248
248
  /* -----------------------------------------------------------
@@ -316,35 +316,35 @@ const POSTGRES_PHYSICAL_TYPES = {
316
316
  datetime: "@db.Timestamptz",
317
317
  uri: "@db.VarChar(80000)",
318
318
  };
319
- const POSTGRES_MAIN_FILE = StringUtil_1.StringUtil.trim `
320
- generator client {
321
- provider = "prisma-client"
322
- previewFeatures = ["postgresqlExtensions", "views"]
323
- output = "../../src/prisma"
324
- moduleFormat = "cjs"
325
- }
326
- datasource db {
327
- provider = "postgresql"
328
- extensions = [pg_trgm]
329
- }
330
- generator markdown {
331
- provider = "prisma-markdown"
332
- output = "../../docs/ERD.md"
333
- }
319
+ const POSTGRES_MAIN_FILE = StringUtil_1.StringUtil.trim `
320
+ generator client {
321
+ provider = "prisma-client"
322
+ previewFeatures = ["postgresqlExtensions", "views"]
323
+ output = "../../src/prisma"
324
+ moduleFormat = "cjs"
325
+ }
326
+ datasource db {
327
+ provider = "postgresql"
328
+ extensions = [pg_trgm]
329
+ }
330
+ generator markdown {
331
+ provider = "prisma-markdown"
332
+ output = "../../docs/ERD.md"
333
+ }
334
334
  `;
335
- const SQLITE_MAIN_FILE = StringUtil_1.StringUtil.trim `
336
- generator client {
337
- provider = "prisma-client"
338
- output = "../../src/prisma"
339
- moduleFormat = "cjs"
340
- }
341
- datasource db {
342
- provider = "sqlite"
343
- }
344
- generator markdown {
345
- provider = "prisma-markdown"
346
- output = "../../docs/ERD.md"
347
- }
335
+ const SQLITE_MAIN_FILE = StringUtil_1.StringUtil.trim `
336
+ generator client {
337
+ provider = "prisma-client"
338
+ output = "../../src/prisma"
339
+ moduleFormat = "cjs"
340
+ }
341
+ datasource db {
342
+ provider = "sqlite"
343
+ }
344
+ generator markdown {
345
+ provider = "prisma-markdown"
346
+ output = "../../docs/ERD.md"
347
+ }
348
348
  `;
349
349
  const MAX_IDENTIFIER_LENGTH = 63;
350
350
  const HASH_TRUNCATION_LENGTH = 8;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobe/utils",
3
- "version": "0.30.0-dev.20260315",
3
+ "version": "0.30.0",
4
4
  "description": "AI backend server code generator",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [],
@@ -28,7 +28,7 @@
28
28
  "@typia/utils": "^12.0.1",
29
29
  "tstl": "^3.0.0",
30
30
  "typia": "^12.0.1",
31
- "@autobe/interface": "^0.30.0-dev.20260315"
31
+ "@autobe/interface": "^0.30.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^24.10.1",
package/src/ArrayUtil.ts CHANGED
@@ -1,21 +1,21 @@
1
- export namespace ArrayUtil {
2
- export async function asyncMap<T, U>(
3
- array: T[],
4
- callback: (value: T, index: number, array: T[]) => Promise<U>,
5
- ): Promise<U[]> {
6
- const result: U[] = new Array(array.length);
7
- for (let i = 0; i < array.length; i++)
8
- result[i] = await callback(array[i], i, array);
9
- return result;
10
- }
11
-
12
- export function paddle(contents: string[][]): string[] {
13
- const output: string[] = [];
14
- contents.forEach((c) => {
15
- if (c.length === 0) return;
16
- else if (output.length === 0) output.push(...c);
17
- else output.push("", ...c);
18
- });
19
- return output;
20
- }
21
- }
1
+ export namespace ArrayUtil {
2
+ export async function asyncMap<T, U>(
3
+ array: T[],
4
+ callback: (value: T, index: number, array: T[]) => Promise<U>,
5
+ ): Promise<U[]> {
6
+ const result: U[] = new Array(array.length);
7
+ for (let i = 0; i < array.length; i++)
8
+ result[i] = await callback(array[i], i, array);
9
+ return result;
10
+ }
11
+
12
+ export function paddle(contents: string[][]): string[] {
13
+ const output: string[] = [];
14
+ contents.forEach((c) => {
15
+ if (c.length === 0) return;
16
+ else if (output.length === 0) output.push(...c);
17
+ else output.push("", ...c);
18
+ });
19
+ return output;
20
+ }
21
+ }
@@ -1,83 +1,83 @@
1
- export namespace AutoBeEscaper {
2
- export const variable = (str: string): boolean =>
3
- reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
4
-
5
- export const reserved = (str: string): boolean => KEYWORDS.includes(str);
6
- }
7
-
8
- const KEYWORDS = [
9
- // data types
10
- "boolean",
11
- "byte",
12
- "char",
13
- "double",
14
- "float",
15
- "int",
16
- "long",
17
- "short",
18
- "void",
19
- // literals
20
- "false",
21
- "null",
22
- "true",
23
- // variable declarations
24
- "let",
25
- "const",
26
- "var",
27
- // control flow
28
- "break",
29
- "case",
30
- "continue",
31
- "default",
32
- "do",
33
- "else",
34
- "for",
35
- "if",
36
- "return",
37
- "switch",
38
- "while",
39
- "with",
40
- // class related
41
- "class",
42
- "extends",
43
- "implements",
44
- "instanceof",
45
- "interface",
46
- "new",
47
- "package",
48
- "super",
49
- "this",
50
- // function related
51
- "function",
52
- // modifiers
53
- "abstract",
54
- "final",
55
- "native",
56
- "private",
57
- "protected",
58
- "public",
59
- "static",
60
- "strictfp",
61
- "synchronized",
62
- "transient",
63
- "volatile",
64
- // exception handling
65
- "assert",
66
- "catch",
67
- "finally",
68
- "throw",
69
- "throws",
70
- "try",
71
- // module system
72
- "export",
73
- "import",
74
- "module",
75
- // operators
76
- "delete",
77
- "in",
78
- "typeof",
79
- // debugging
80
- "debugger",
81
- // other
82
- "enum",
83
- ];
1
+ export namespace AutoBeEscaper {
2
+ export const variable = (str: string): boolean =>
3
+ reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
4
+
5
+ export const reserved = (str: string): boolean => KEYWORDS.includes(str);
6
+ }
7
+
8
+ const KEYWORDS = [
9
+ // data types
10
+ "boolean",
11
+ "byte",
12
+ "char",
13
+ "double",
14
+ "float",
15
+ "int",
16
+ "long",
17
+ "short",
18
+ "void",
19
+ // literals
20
+ "false",
21
+ "null",
22
+ "true",
23
+ // variable declarations
24
+ "let",
25
+ "const",
26
+ "var",
27
+ // control flow
28
+ "break",
29
+ "case",
30
+ "continue",
31
+ "default",
32
+ "do",
33
+ "else",
34
+ "for",
35
+ "if",
36
+ "return",
37
+ "switch",
38
+ "while",
39
+ "with",
40
+ // class related
41
+ "class",
42
+ "extends",
43
+ "implements",
44
+ "instanceof",
45
+ "interface",
46
+ "new",
47
+ "package",
48
+ "super",
49
+ "this",
50
+ // function related
51
+ "function",
52
+ // modifiers
53
+ "abstract",
54
+ "final",
55
+ "native",
56
+ "private",
57
+ "protected",
58
+ "public",
59
+ "static",
60
+ "strictfp",
61
+ "synchronized",
62
+ "transient",
63
+ "volatile",
64
+ // exception handling
65
+ "assert",
66
+ "catch",
67
+ "finally",
68
+ "throw",
69
+ "throws",
70
+ "try",
71
+ // module system
72
+ "export",
73
+ "import",
74
+ "module",
75
+ // operators
76
+ "delete",
77
+ "in",
78
+ "typeof",
79
+ // debugging
80
+ "debugger",
81
+ // other
82
+ "enum",
83
+ ];
package/src/MapUtil.ts CHANGED
@@ -1,10 +1,10 @@
1
- export namespace MapUtil {
2
- export function take<K, V>(map: Map<K, V>, key: K, value: () => V): V {
3
- if (map.has(key)) {
4
- return map.get(key) as V;
5
- }
6
- const newValue = value();
7
- map.set(key, newValue);
8
- return newValue;
9
- }
10
- }
1
+ export namespace MapUtil {
2
+ export function take<K, V>(map: Map<K, V>, key: K, value: () => V): V {
3
+ if (map.has(key)) {
4
+ return map.get(key) as V;
5
+ }
6
+ const newValue = value();
7
+ map.set(key, newValue);
8
+ return newValue;
9
+ }
10
+ }
package/src/StringUtil.ts CHANGED
@@ -1,34 +1,34 @@
1
- import { dedent } from "@typia/utils";
2
-
3
- export namespace StringUtil {
4
- export function trim(
5
- strings: TemplateStringsArray,
6
- // biome-ignore lint: intended
7
- ...values: any[]
8
- ): string {
9
- return dedent(strings, ...values);
10
- }
11
-
12
- export function singleLine(
13
- strings: TemplateStringsArray,
14
- // biome-ignore lint: intended
15
- ...values: any[]
16
- ): string {
17
- let result: string = strings[0];
18
- for (let i = 0; i < values.length; i++) {
19
- result += String(values[i]) + strings[i + 1];
20
- }
21
- return result.replace(/\n/g, " ").replace(/\s+/g, " ").trim();
22
- }
23
-
24
- export function summary(description: string): string {
25
- const newLine: number = description.indexOf("\n");
26
- const dot: number = description.indexOf(".");
27
- const minimum: number = Math.min(
28
- newLine === -1 ? Number.MAX_SAFE_INTEGER : newLine,
29
- dot === -1 ? Number.MAX_SAFE_INTEGER : dot,
30
- description.length,
31
- );
32
- return description.substring(0, minimum);
33
- }
34
- }
1
+ import { dedent } from "@typia/utils";
2
+
3
+ export namespace StringUtil {
4
+ export function trim(
5
+ strings: TemplateStringsArray,
6
+ // biome-ignore lint: intended
7
+ ...values: any[]
8
+ ): string {
9
+ return dedent(strings, ...values);
10
+ }
11
+
12
+ export function singleLine(
13
+ strings: TemplateStringsArray,
14
+ // biome-ignore lint: intended
15
+ ...values: any[]
16
+ ): string {
17
+ let result: string = strings[0];
18
+ for (let i = 0; i < values.length; i++) {
19
+ result += String(values[i]) + strings[i + 1];
20
+ }
21
+ return result.replace(/\n/g, " ").replace(/\s+/g, " ").trim();
22
+ }
23
+
24
+ export function summary(description: string): string {
25
+ const newLine: number = description.indexOf("\n");
26
+ const dot: number = description.indexOf(".");
27
+ const minimum: number = Math.min(
28
+ newLine === -1 ? Number.MAX_SAFE_INTEGER : newLine,
29
+ dot === -1 ? Number.MAX_SAFE_INTEGER : dot,
30
+ description.length,
31
+ );
32
+ return description.substring(0, minimum);
33
+ }
34
+ }
@@ -1,44 +1,44 @@
1
- import { AutoBeFunctionCallingMetric } from "@autobe/interface";
2
-
3
- export namespace AutoBeFunctionCallingMetricFactory {
4
- export const create = (): AutoBeFunctionCallingMetric => ({
5
- attempt: 0,
6
- success: 0,
7
- consent: 0,
8
- validationFailure: 0,
9
- invalidJson: 0,
10
- });
11
-
12
- export const increment = (
13
- x: AutoBeFunctionCallingMetric,
14
- y: AutoBeFunctionCallingMetric,
15
- ): void => {
16
- x.attempt += y.attempt;
17
- x.success += y.success;
18
- x.consent += y.consent;
19
- x.validationFailure += y.validationFailure;
20
- x.invalidJson += y.invalidJson;
21
- };
22
-
23
- export const plus = (
24
- x: AutoBeFunctionCallingMetric,
25
- y: AutoBeFunctionCallingMetric,
26
- ): AutoBeFunctionCallingMetric => ({
27
- attempt: x.attempt + y.attempt,
28
- success: x.success + y.success,
29
- consent: x.consent + y.consent,
30
- validationFailure: x.validationFailure + y.validationFailure,
31
- invalidJson: x.invalidJson + y.invalidJson,
32
- });
33
-
34
- export const minus = (
35
- x: AutoBeFunctionCallingMetric,
36
- y: AutoBeFunctionCallingMetric,
37
- ): AutoBeFunctionCallingMetric => ({
38
- attempt: x.attempt - y.attempt,
39
- success: x.success - y.success,
40
- consent: x.consent - y.consent,
41
- validationFailure: x.validationFailure - y.validationFailure,
42
- invalidJson: x.invalidJson - y.invalidJson,
43
- });
44
- }
1
+ import { AutoBeFunctionCallingMetric } from "@autobe/interface";
2
+
3
+ export namespace AutoBeFunctionCallingMetricFactory {
4
+ export const create = (): AutoBeFunctionCallingMetric => ({
5
+ attempt: 0,
6
+ success: 0,
7
+ consent: 0,
8
+ validationFailure: 0,
9
+ invalidJson: 0,
10
+ });
11
+
12
+ export const increment = (
13
+ x: AutoBeFunctionCallingMetric,
14
+ y: AutoBeFunctionCallingMetric,
15
+ ): void => {
16
+ x.attempt += y.attempt;
17
+ x.success += y.success;
18
+ x.consent += y.consent;
19
+ x.validationFailure += y.validationFailure;
20
+ x.invalidJson += y.invalidJson;
21
+ };
22
+
23
+ export const plus = (
24
+ x: AutoBeFunctionCallingMetric,
25
+ y: AutoBeFunctionCallingMetric,
26
+ ): AutoBeFunctionCallingMetric => ({
27
+ attempt: x.attempt + y.attempt,
28
+ success: x.success + y.success,
29
+ consent: x.consent + y.consent,
30
+ validationFailure: x.validationFailure + y.validationFailure,
31
+ invalidJson: x.invalidJson + y.invalidJson,
32
+ });
33
+
34
+ export const minus = (
35
+ x: AutoBeFunctionCallingMetric,
36
+ y: AutoBeFunctionCallingMetric,
37
+ ): AutoBeFunctionCallingMetric => ({
38
+ attempt: x.attempt - y.attempt,
39
+ success: x.success - y.success,
40
+ consent: x.consent - y.consent,
41
+ validationFailure: x.validationFailure - y.validationFailure,
42
+ invalidJson: x.invalidJson - y.invalidJson,
43
+ });
44
+ }