namirasoft-sdk-generator 1.4.21 → 1.4.23

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.
@@ -28,8 +28,8 @@ export class NPMBuilder extends BaseBuilder
28
28
  await this.dst.download("https://static.namirasoft.com/template/npm/ts/tsconfig.json", "tsconfig.json");
29
29
  await this.dst.download("https://static.namirasoft.com/template/gitlab-ci.yml/npm-publish.yml", ".gitlab-ci.yml");
30
30
  let packagejson: any = {
31
- name: this.name,
32
- title: this.title + " NPM Package",
31
+ name: this.name_parser.api.name_namirasoft,
32
+ title: this.name_parser.api.title_namirasoft + " NPM Package",
33
33
  description: this.description + " NPM Package",
34
34
  "icon": "logo.png",
35
35
  "logo": this.src.json.logo,
@@ -52,9 +52,9 @@ export class NPMBuilder extends BaseBuilder
52
52
  },
53
53
  "bin": {}
54
54
  };
55
- packagejson.bin[this.command] = "./dist/command/cli.js";
55
+ packagejson.bin[this.name_parser.command.name] = "./dist/command/cli.js";
56
56
  if (this.account)
57
- if (this.src.json.name != "namirasoft-account-api-v1")
57
+ if (!this.name_parser.isAccountAPI)
58
58
  packagejson.dependencies["namirasoft-account"] = BaseBuilder.MIN_VERSION;
59
59
  let extra = Object.keys(this.src.json.package?.dependencies ?? {});
60
60
  for (let i = 0; i < extra.length; i++)
@@ -89,13 +89,30 @@ export class NPMBuilder extends BaseBuilder
89
89
  }
90
90
  // Meta
91
91
  let metas: TS[] = [];
92
- let Name = NamingConvention.Pascal_Case_Space.convert(this.title, NamingConvention.Pascal_Case);
93
- let metadatabase = new TS("./src/meta", "./meta/", Name + "MetaDatabase", "NSBaseMetaDatabase", true);
92
+
93
+ let name_class_namirasoft_entity = this.name_parser.api.class_namirasoft;
94
+ let constructor_args = [];
95
+ if (this.account)
96
+ constructor_args.push(`manager: TokenManager`);
97
+ constructor_args.push(`onError: (error: Error) => void`);
98
+ let metadatabase = new TS("./src/meta", "./meta/", name_class_namirasoft_entity + "MetaDatabase", `NSBaseMetaDatabase<${name_class_namirasoft_entity}Server>`, true);
99
+ metadatabase.imports.push(`import { EnvService } from "namirasoft-core";`);
100
+ metadatabase.imports.push(`import { ${name_class_namirasoft_entity}Server } from "../${name_class_namirasoft_entity}Server";`);
94
101
  metadatabase.imports.push(`import { NSBaseMetaDatabase } from "namirasoft-site";`);
95
- metadatabase.fields.push(`public static main: ${Name}MetaDatabase = new ${Name}MetaDatabase();`);
96
- metadatabase.constructors.push(`constructor()`);
102
+ if (this.account)
103
+ if (this.name_parser.isAccountAPI)
104
+ metadatabase.imports.push(`import { TokenManager } from "../TokenManager";`);
105
+ else
106
+ metadatabase.imports.push(`import { TokenManager } from "namirasoft-account";`);
107
+ if (this.account)
108
+ metadatabase.fields.push(`private manager: TokenManager;`);
109
+ metadatabase.fields.push(`private onError: (error: Error) => void;`);
110
+ metadatabase.constructors.push(`constructor(${constructor_args.join(", ")})`);
97
111
  metadatabase.constructors.push(`{`);
98
112
  metadatabase.constructors.push(` super({ id: "${this.product.id}", name: "${this.product.name}", headline: "${this.product.headline}", description: "${this.product.description}", logo: "${this.product.logo}", link: "${this.product.link}" });`);
113
+ if (this.account)
114
+ metadatabase.constructors.push(` this.manager = manager;`);
115
+ metadatabase.constructors.push(` this.onError = onError;`);
99
116
  let metadatabase_fields_tables: string[] = [];
100
117
  let metadatabase_constructors_init: string[] = [];
101
118
  for (let i = 0; i < this.schema.tables.length; i++)
@@ -111,7 +128,19 @@ export class NPMBuilder extends BaseBuilder
111
128
  metadatabase.constructors.push(` this.tables = {`);
112
129
  metadatabase_constructors_init.forEach(x => { metadatabase.constructors.push(x) });
113
130
  metadatabase.constructors.push(` };`);
114
- metadatabase.constructors.push(`};`);
131
+ metadatabase.constructors.push(`}`);
132
+
133
+ let getServer_args = [`BASE_URL`];
134
+ if (this.account)
135
+ getServer_args.push(`this.manager`);
136
+ getServer_args.push(`this.onError`);
137
+
138
+ metadatabase.functions.push(`override getServer(): ${name_class_namirasoft_entity}Server`);
139
+ metadatabase.functions.push(`{`);
140
+ metadatabase.functions.push(` let NAME = NSBaseMetaDatabase.getServerBaseURL(this.product.name);`);
141
+ metadatabase.functions.push(` let BASE_URL = new EnvService(NAME, true).getString();`);
142
+ metadatabase.functions.push(` return new ${name_class_namirasoft_entity}Server(${getServer_args.join(", ")});`);
143
+ metadatabase.functions.push(`}`);
115
144
  metas.push(metadatabase);
116
145
 
117
146
  // Row
@@ -193,12 +222,12 @@ export class NPMBuilder extends BaseBuilder
193
222
  ts.imports.push(`import { ${tag}Command } from "./${tag}Command";`);
194
223
  });
195
224
  if (this.account)
196
- if (this.src.json.name != "namirasoft-account-api-v1")
197
- ts.imports.push(`import { AccountCommand } from "namirasoft-account";`);
198
- else
225
+ if (this.name_parser.isAccountAPI)
199
226
  ts.imports.push(`import { AccountCommand } from "./AccountCommand";`);
227
+ else
228
+ ts.imports.push(`import { AccountCommand } from "namirasoft-account";`);
200
229
  ts.imports.push(`import { ConfigCommand } from "namirasoft-node-cli";`);
201
- ts.scripts.push(`let app = new Application("${this.command}", new BaseStorage(), `);
230
+ ts.scripts.push(`let app = new Application("${this.name_parser.command.name}", new BaseStorage(), `);
202
231
  ts.scripts.push(` { `);
203
232
  tags.forEach(tag =>
204
233
  {
@@ -206,8 +235,8 @@ export class NPMBuilder extends BaseBuilder
206
235
  });
207
236
  if (this.account)
208
237
  ts.scripts.push(` "account": AccountCommand,`);
209
- this.command
210
- ts.scripts.push(` "config": (argv: string[]) => new ConfigCommand(argv, ["${this.command}-server-url"])`);
238
+
239
+ ts.scripts.push(` "config": (argv: string[]) => new ConfigCommand(argv, ["${this.name_parser.command.name}-server-url"])`);
211
240
  ts.scripts.push(` });`);
212
241
  ts.scripts.push(`app.run();`);
213
242
  return ts;
@@ -239,7 +268,7 @@ export class NPMBuilder extends BaseBuilder
239
268
  }
240
269
  async getCLIControllerCommand(controller: ControllerSchema): Promise<TS>
241
270
  {
242
- let className = this.title.replace(/\s/gm, "") + "Server";
271
+ let name_class_namirasoft_entity_server = this.name_parser.api.class_namirasoft.replace(/\s/gm, "") + "Server";
243
272
 
244
273
  let args = ControllerSchema.getArgs(controller).map(a => a.name);
245
274
  let options = ControllerSchema.getOptions(controller);
@@ -257,14 +286,14 @@ export class NPMBuilder extends BaseBuilder
257
286
  let ts = new TS("./src/command", "./command/", controller.tag + controller.name + "Command", "BaseFinalCommand", true);
258
287
  if (this.account)
259
288
  {
260
- if (this.src.json.name == "namirasoft-account-api-v1")
289
+ if (this.name_parser.isAccountAPI)
261
290
  ts.imports.push(`import { TokenManager } from "../TokenManager";`);
262
291
  else
263
292
  ts.imports.push(`import { TokenManager } from "namirasoft-account";`);
264
293
  ts.imports.push(`import { IStorageMemory } from "namirasoft-core";`);
265
294
  }
266
295
  ts.imports.push(`import { BaseFinalCommand } from "namirasoft-node-cli";`);
267
- ts.imports.push(`import { ${className} } from "../${className}";`);
296
+ ts.imports.push(`import { ${name_class_namirasoft_entity_server} } from "../${name_class_namirasoft_entity_server}";`);
268
297
  ts.constructors.push(`constructor(argv: string[])`);
269
298
  ts.constructors.push(`{`);
270
299
  if ((options ?? []).length == 0)
@@ -292,18 +321,18 @@ export class NPMBuilder extends BaseBuilder
292
321
  {
293
322
  ts.functions.push(` let token = this.app.storage.getNSAToken();`);
294
323
  ts.functions.push(` if (token == null)`);
295
- ts.functions.push(` throw new Error("Token is not available. Please login first using:\\n${this.command} account config \\nor \\n{this.command} account login.");`); // todo
324
+ ts.functions.push(` throw new Error("Token is not available. Please login first using:\\n${this.name_parser.command.name} account config \\nor \\n${this.name_parser.command.name} account login.");`); // todo
296
325
  ts.functions.push(` let storage = new IStorageMemory();`);
297
326
  ts.functions.push(` let manager = new TokenManager(storage, () => { });`);
298
327
  ts.functions.push(` manager.setValue(token, false);`);
299
328
  }
300
- ts.functions.push(` let url = this.app.storage.getItem("${this.command}-server-url");`);
301
- ts.functions.push(` let server = new ${className}(url, ${this.account ? "manager, " : ""}e => this.app.logger.error(e.message));`);
329
+ ts.functions.push(` let url = this.app.storage.getItem("${this.name_parser.command.name}-server-url");`);
330
+ ts.functions.push(` let server = new ${name_class_namirasoft_entity_server}(url, ${this.account ? "manager, " : ""}e => this.app.logger.error(e.message));`);
302
331
  if (options.length == 0 && controller.body?.type !== VariableType.Any)
303
- ts.functions.push(` let ans = await server.${controller.tag.toLowerCase()}.${controller.name}(${args.map((_, index) => `this.arg_values[${index}]`).join(", ")});`);
332
+ ts.functions.push(` let ans = await server.${NamingConvention.auto.convert(controller.tag, NamingConvention.lower_case_underscore)}.${controller.name}(${args.map((_, index) => `this.arg_values[${index}]`).join(", ")});`);
304
333
  else
305
334
  {
306
- ts.functions.push(` let ans = await server.${controller.tag.toLowerCase()}.${controller.name}(${args.map((_, index) => `this.arg_values[${index}]`).join(", ")}${args.length == 0 ? "" : ", "}{`);
335
+ ts.functions.push(` let ans = await server.${NamingConvention.auto.convert(controller.tag, NamingConvention.lower_case_underscore)}.${controller.name}(${args.map((_, index) => `this.arg_values[${index}]`).join(", ")}${args.length == 0 ? "" : ", "}{`);
307
336
  forEachVariable((option, last) =>
308
337
  {
309
338
  ts.functions.push(` ${option.name}: this.option_values.${option.name}${last ? "" : ","}`);
@@ -324,11 +353,14 @@ export class NPMBuilder extends BaseBuilder
324
353
  let TName = NamingConvention.Pascal_Case.convert(name, NamingConvention.Pascal_Case);
325
354
  let TNameSpace = NamingConvention.Pascal_Case.convert(name, NamingConvention.Pascal_Case_Space);
326
355
  let tname = NamingConvention.Pascal_Case.convert(name, NamingConvention.lower_case_underscore);
327
- let ts = new TS("./src/meta", "./meta/", TName + "MetaTable", "NSBaseMetaTable", true);
328
- ts.imports.push(`import { BaseUUID, BaseMetaColumn } from "namirasoft-core";`);
356
+ let row_name = this.src.json["ns-sdkg"]?.meta?.table?.[TName]?.row ?? (`${TName}Row`);
357
+ let ts = new TS("./src/meta", "./meta/", TName + "MetaTable", `NSBaseMetaTable<${this.name_parser.api.class_namirasoft}Server, ${row_name}>`, true);
358
+ ts.imports.push(`import { BaseUUID, BaseMetaColumn, FilterItem, SortItem } from "namirasoft-core";`);
329
359
  ts.imports.push(`import { NSBaseMetaDatabase, NSBaseMetaTable } from "namirasoft-site";`);
360
+ ts.imports.push(`import { ${row_name} } from "../row/${row_name}";`);
361
+ ts.imports.push(`import { ${this.name_parser.api.class_namirasoft}Server } from "../${this.name_parser.api.class_namirasoft}Server";`);
330
362
  ts.fields.push(`public override columns: {`);
331
- ts.constructors.push(`constructor(database: NSBaseMetaDatabase)`);
363
+ ts.constructors.push(`constructor(database: NSBaseMetaDatabase<${this.name_parser.api.class_namirasoft}Server>)`);
332
364
  ts.constructors.push(`{`);
333
365
  ts.constructors.push(` super(database, "${tname}", "${TNameSpace}", new BaseUUID("${short}"));`);
334
366
  ts.constructors.push(` this.columns = {`);
@@ -348,6 +380,34 @@ export class NPMBuilder extends BaseBuilder
348
380
  }
349
381
  ts.fields.push(`}`);
350
382
  ts.constructors.push(` };`);
383
+ ts.constructors.push(` this.back_end.get = async (id: string) =>`);
384
+ ts.constructors.push(` {`);
385
+ if (this.src.json["ns-sdkg"]?.meta?.table?.[TName]?.["Get"]?.enabled ?? true)
386
+ {
387
+ let function_name = this.src.json["ns-sdkg"]?.meta?.table?.[TName]?.["Get"]?.function ?? "Get";
388
+ ts.constructors.push(` let server = this.database.getServer();`);
389
+ ts.constructors.push(` return await server.${tname}.${function_name}(id);`);
390
+ }
391
+ else
392
+ {
393
+ ts.constructors.push(` console.log(id);`);
394
+ ts.constructors.push(` throw new Error("${TName}.Get is not implemented");`);
395
+ }
396
+ ts.constructors.push(` };`);
397
+ ts.constructors.push(` this.back_end.list = async (filters: FilterItem[] | null, page: (number | null), size: (number | null), sorts: SortItem[]) =>`);
398
+ ts.constructors.push(` {`);
399
+ if (this.src.json["ns-sdkg"]?.meta?.table?.[TName]?.["List"]?.enabled ?? true)
400
+ {
401
+ let function_name = this.src.json["ns-sdkg"]?.meta?.table?.[TName]?.["List"]?.function ?? "List";
402
+ ts.constructors.push(` let server = this.database.getServer();`);
403
+ ts.constructors.push(` return await server.${tname}.${function_name}(filters, page, size, sorts);`);
404
+ }
405
+ else
406
+ {
407
+ ts.constructors.push(` console.log(filters, page, size, sorts);`);
408
+ ts.constructors.push(` throw new Error("${TName}.List is not implemented");`);
409
+ }
410
+ ts.constructors.push(` };`);
351
411
  ts.constructors.push(`}`);
352
412
  return ts;
353
413
  };
@@ -442,13 +502,13 @@ export class NPMBuilder extends BaseBuilder
442
502
 
443
503
  getServer(tags: string[]): TS
444
504
  {
445
- let className = this.title.replace(/\s/gm, "") + "Server";
505
+ let name_class_namirasoft_entity_server = this.name_parser.api.class_namirasoft + "Server";
446
506
  let parentName = this.account ? "NSABaseServer" : "NSBaseServer";
447
- let ts = new TS("./src", "./", className, parentName);
507
+ let ts = new TS("./src", "./", name_class_namirasoft_entity_server, parentName);
448
508
 
449
509
  if (this.account)
450
510
  {
451
- if (this.src.json.name == "namirasoft-account-api-v1")
511
+ if (this.name_parser.isAccountAPI)
452
512
  {
453
513
  ts.imports.push(`import { NSABaseServer } from "./NSABaseServer";`);
454
514
  ts.imports.push(`import { TokenManager } from "./TokenManager";`);
@@ -464,8 +524,8 @@ export class NPMBuilder extends BaseBuilder
464
524
  ts.imports.push(`import { NSBaseServer } from "namirasoft-site";`);
465
525
  }
466
526
 
467
- tags.forEach(tag => ts.imports.push(`import { ${className}${tag} } from "./${className}${tag}";`));
468
- tags.forEach(tag => ts.fields.push(`${tag.toLowerCase()}: ${className}${tag};`));
527
+ tags.forEach(tag => ts.imports.push(`import { ${name_class_namirasoft_entity_server}${tag} } from "./${name_class_namirasoft_entity_server}${tag}";`));
528
+ tags.forEach(tag => ts.fields.push(`${NamingConvention.auto.convert(tag, NamingConvention.lower_case_underscore)}: ${name_class_namirasoft_entity_server}${tag};`));
469
529
 
470
530
  let pars: string[] = ["base_url: string"];
471
531
  let args: string[] = [`base_url`, `\`${this.src.json.version}\``];
@@ -487,20 +547,20 @@ export class NPMBuilder extends BaseBuilder
487
547
  ts.fields.push("protected onError;");
488
548
  ts.constructors.push(` this.onError = onError;`);
489
549
  }
490
- tags.forEach(tag => ts.constructors.push(` this.${tag.toLowerCase()} = new ${className}${tag}(this);`));
550
+ tags.forEach(tag => ts.constructors.push(` this.${NamingConvention.auto.convert(tag, NamingConvention.lower_case_underscore)} = new ${name_class_namirasoft_entity_server}${tag}(this);`));
491
551
  ts.constructors.push(`}`);
492
552
  return ts;
493
553
  }
494
554
  getServerBase(): TS
495
555
  {
496
- let className = this.title.replace(/\s/gm, "") + "ServerBase";
497
- let ts = new TS("./src", "./", className);
556
+ let name_class_namirasoft_entity_server_base = this.name_parser.api.class_namirasoft + "ServerBase";
557
+ let ts = new TS("./src", "./", name_class_namirasoft_entity_server_base);
498
558
 
499
- let serverClassName = this.title.replace(/\s/gm, "") + "Server";
500
- ts.imports.push(`import { ${serverClassName} } from "./${serverClassName}";`);
559
+ let name_class_namirasoft_entity_server = this.name_parser.api.class_namirasoft + "Server";
560
+ ts.imports.push(`import { ${name_class_namirasoft_entity_server} } from "./${name_class_namirasoft_entity_server}";`);
501
561
 
502
- ts.fields.push(`public server: ${serverClassName};`);
503
- ts.constructors.push(`constructor(server: ${serverClassName})`);
562
+ ts.fields.push(`public server: ${name_class_namirasoft_entity_server};`);
563
+ ts.constructors.push(`constructor(server: ${name_class_namirasoft_entity_server})`);
504
564
  ts.constructors.push(`{`);
505
565
  ts.constructors.push(` this.server = server;`);
506
566
  ts.constructors.push(`}`);
@@ -509,17 +569,15 @@ export class NPMBuilder extends BaseBuilder
509
569
  }
510
570
  getServerTag(tag: string): TS
511
571
  {
512
- let baseName = NamingConvention.Pascal_Case_Space.convert(this.title, NamingConvention.Pascal_Case) + "Server";
513
- let parentName = baseName + "Base";
514
- let className = baseName + tag;
515
-
516
- let ts = new TS("./src", "./", className, parentName);
517
- ts.imports.push(`import { ${parentName} } from "./${parentName}";`);
572
+ let name_class_namirasoft_entity_server = this.name_parser.api.class_namirasoft + "Server";
573
+ let name_class_namirasoft_entity_server_base = name_class_namirasoft_entity_server + "Base";
574
+ let name_class_namirasoft_entity_server_tag = name_class_namirasoft_entity_server + tag;
518
575
 
519
- let serverClassName = this.title.replace(/\s/gm, "") + "Server";
520
- ts.imports.push(`import { ${serverClassName} } from "./${serverClassName}";`);
576
+ let ts = new TS("./src", "./", name_class_namirasoft_entity_server_tag, name_class_namirasoft_entity_server_base);
577
+ ts.imports.push(`import { ${name_class_namirasoft_entity_server_base} } from "./${name_class_namirasoft_entity_server_base}";`);
578
+ ts.imports.push(`import { ${name_class_namirasoft_entity_server} } from "./${name_class_namirasoft_entity_server}";`);
521
579
 
522
- ts.constructors.push(`constructor(server: ${serverClassName})`);
580
+ ts.constructors.push(`constructor(server: ${name_class_namirasoft_entity_server})`);
523
581
  ts.constructors.push(`{`);
524
582
  ts.constructors.push(` super(server);`);
525
583
  for (let i = 0; i < this.schema.controllers.length; i++)
@@ -13,7 +13,7 @@ export class PHPBuilder extends BaseBuilder
13
13
  private getNameSpace(folder: string): string
14
14
  {
15
15
  let NameSpaceCase: NamingConvention = new NamingConvention("NameSpaceCase", "\\", true, NamingConvention.formatter_pascal, NamingConvention.splitter_uppercase);
16
- let name = NamingConvention.lower_case_dash.convert(this.name, NameSpaceCase);
16
+ let name = NamingConvention.lower_case_dash.convert(this.name_parser.api.name_namirasoft, NameSpaceCase);
17
17
  let ans = [name];
18
18
  if (folder)
19
19
  ans.push(folder);
@@ -33,7 +33,7 @@ export class PHPBuilder extends BaseBuilder
33
33
  await this.dst.download("https://static.namirasoft.com/template/composer/php/.gitignore", ".gitignore");
34
34
 
35
35
  let composerjson: any = {
36
- name: this.name.replace("namirasoft-", "namirasoft/"),
36
+ name: this.name_parser.api.name_namirasoft.replace("namirasoft-", "namirasoft/"),
37
37
  description: this.description + " PHP Package",
38
38
  "type": "library",
39
39
  "version": this.src.json.version,
@@ -56,8 +56,8 @@ export class PHPBuilder extends BaseBuilder
56
56
  composerjson["autoload"]["psr-4"][this.getNameSpace("") + "\\"] = "src/";
57
57
 
58
58
  let packagejson: any = {
59
- name: this.name,
60
- title: this.title + " PHP Package",
59
+ name: this.name_parser.api.name_namirasoft,
60
+ title: this.name_parser.api.title_namirasoft + " PHP Package",
61
61
  description: this.description + " PHP Package",
62
62
  "icon": "logo.png",
63
63
  "logo": this.src.json.logo,
@@ -70,7 +70,7 @@ export class PHPBuilder extends BaseBuilder
70
70
  "license": "MIT"
71
71
  };
72
72
  if (this.account)
73
- if (this.src.json.name != "namirasoft-account-api-v1")
73
+ if (this.name_parser.isAccountAPI)
74
74
  composerjson.require["namirasoft/account"] = BaseBuilder.MIN_VERSION;
75
75
  let extra = Object.keys(this.src.json.package?.dependencies ?? {});
76
76
  for (let i = 0; i < extra.length; i++)
@@ -93,11 +93,11 @@ export class PHPBuilder extends BaseBuilder
93
93
 
94
94
  // Meta
95
95
  let metas: PHP[] = [];
96
- let Name = NamingConvention.Pascal_Case_Space.convert(this.title, NamingConvention.Pascal_Case);
97
- let metadatabasetables = new PHP(this.getNameSpace("meta"), "./src/meta", "./meta/", Name + "MetaDatabaseTables", "", true);
98
- let metadatabase = new PHP(this.getNameSpace("meta"), "./src/meta", "./meta/", Name + "MetaDatabase", "NSBaseMetaDatabase", true);
96
+ let name_class_namirasoft_entity = this.name_parser.api.class_namirasoft;
97
+ let metadatabasetables = new PHP(this.getNameSpace("meta"), "./src/meta", "./meta/", name_class_namirasoft_entity + "MetaDatabaseTables", "", true);
98
+ let metadatabase = new PHP(this.getNameSpace("meta"), "./src/meta", "./meta/", name_class_namirasoft_entity + "MetaDatabase", "NSBaseMetaDatabase", true);
99
99
  metadatabase.uses.push(`use Namirasoft\\Site\\NSBaseMetaDatabase;`);
100
- metadatabase.fields.push(`public static ${Name}MetaDatabase $main;`);
100
+ metadatabase.fields.push(`public static ${name_class_namirasoft_entity}MetaDatabase $main;`);
101
101
  metadatabase.constructors.push(`public function __construct()`);
102
102
  metadatabase.constructors.push(`{`);
103
103
 
@@ -119,7 +119,7 @@ export class PHPBuilder extends BaseBuilder
119
119
  if (php)
120
120
  metas.push(php);
121
121
  }
122
- metadatabase.fields.push(`public ${Name}MetaDatabaseTables $tables;`);
122
+ metadatabase.fields.push(`public ${name_class_namirasoft_entity}MetaDatabaseTables $tables;`);
123
123
  metadatabase.constructors.push(`}`);
124
124
  metadatabase.functions.push(`public function getTables(): array`);
125
125
  metadatabase.functions.push(`{`);
@@ -127,7 +127,7 @@ export class PHPBuilder extends BaseBuilder
127
127
  tnames.forEach(table => { metadatabase.functions.push(` "${table}",`); });
128
128
  metadatabase.functions.push(` ];`);
129
129
  metadatabase.functions.push(`}`);
130
- metadatabase.scripts_after.push(`${Name}MetaDatabase::$main = new ${Name}MetaDatabase();`);
130
+ metadatabase.scripts_after.push(`${name_class_namirasoft_entity}MetaDatabase::$main = new ${name_class_namirasoft_entity}MetaDatabase();`);
131
131
  metas.push(metadatabasetables);
132
132
  metas.push(metadatabase);
133
133
 
@@ -210,7 +210,7 @@ export class PHPBuilder extends BaseBuilder
210
210
  // ts.imports.push(`import { ${tag}Command } from "./${tag}Command";`);
211
211
  // });
212
212
  // if (this.account)
213
- // if (this.src.json.name != "namirasoft-account-api-v1")
213
+ // if (!this.name_parser.isAccountAPI)
214
214
  // ts.imports.push(`import { AccountCommand } from "namirasoft-account";`);
215
215
  // else
216
216
  // ts.imports.push(`import { AccountCommand } from "./AccountCommand";`);
@@ -218,7 +218,7 @@ export class PHPBuilder extends BaseBuilder
218
218
  // ts.scripts.push(` {`);
219
219
  // tags.forEach(tag =>
220
220
  // {
221
- // ts.scripts.push(` "${tag.toLowerCase()}": ${tag}Command,`);
221
+ // ts.scripts.push(` "${NamingConvention.auto.convert(tag, NamingConvention.lower_case_underscore)}": ${tag}Command,`);
222
222
  // });
223
223
  // if (this.account)
224
224
  // ts.scripts.push(` "account": AccountCommand`);
@@ -271,7 +271,7 @@ export class PHPBuilder extends BaseBuilder
271
271
  // let ts = new TS("./src/command", "./command/", controller.tag + controller.name + "Command", "BaseFinalCommand", true);
272
272
  // if (this.account)
273
273
  // {
274
- // if (this.src.json.name == "namirasoft-account-api-v1")
274
+ // if (this.name_parser.isAccountAPI)
275
275
  // ts.imports.push(`import { TokenManager } from "../TokenManager";`);
276
276
  // else
277
277
  // ts.imports.push(`import { TokenManager } from "namirasoft-account";`);
@@ -313,10 +313,10 @@ export class PHPBuilder extends BaseBuilder
313
313
  // }
314
314
  // ts.functions.push(` let server = new ${className}(${this.account ? "manager, " : ""}${this.nws ? "\"zone\", " : ""}e => this.app.logger.error(e.message));`);
315
315
  // if (options.length == 0)
316
- // ts.functions.push(` let ans = await server.${controller.tag.toLowerCase()}.${controller.name}(${args.map((_, index) => `this.arg_values[${index}]`).join(", ")});`);
316
+ // ts.functions.push(` let ans = await server.${NamingConvention.auto.convert(controller.tag, NamingConvention.lower_case_underscore)}.${controller.name}(${args.map((_, index) => `this.arg_values[${index}]`).join(", ")});`);
317
317
  // else
318
318
  // {
319
- // ts.functions.push(` let ans = await server.${controller.tag.toLowerCase()}.${controller.name}(${args.map((_, index) => `this.arg_values[${index}]`).join(", ")}${args.length == 0 ? "" : ", "}{`);
319
+ // ts.functions.push(` let ans = await server.${NamingConvention.auto.convert(controller.tag, NamingConvention.lower_case_underscore)}.${controller.name}(${args.map((_, index) => `this.arg_values[${index}]`).join(", ")}${args.length == 0 ? "" : ", "}{`);
320
320
  // forEachVariable((option, last) =>
321
321
  // {
322
322
  // ts.functions.push(` ${option.name}: this.option_values.${option.name}${last ? "" : ","}`);
@@ -465,19 +465,19 @@ export class PHPBuilder extends BaseBuilder
465
465
  }
466
466
  getServer(tags: string[]): PHP
467
467
  {
468
- let className = this.title.replace(/\s/gm, "") + "Server";
468
+ let name_class_namirasoft_entity_server = this.name_parser.api.class_namirasoft + "Server";
469
469
  let parentName = this.account ? "NSABaseServer" : "NSBaseServer";
470
- let php = new PHP(this.getNameSpace(""), "./src", "./", className, parentName);
470
+ let php = new PHP(this.getNameSpace(""), "./src", "./", name_class_namirasoft_entity_server, parentName);
471
471
 
472
472
  if (this.account)
473
473
  {
474
- if (this.src.json.name != "namirasoft-account-api-v1")
474
+ if (!this.name_parser.isAccountAPI)
475
475
  php.imports.push(`require_once "namirasoft/account";`);
476
476
  }
477
477
 
478
478
  if (this.account)
479
479
  {
480
- if (this.src.json.name != "namirasoft-account-api-v1")
480
+ if (!this.name_parser.isAccountAPI)
481
481
  {
482
482
  php.uses.push(`use Namirasoft\\Account\\NSABaseServer;`);
483
483
  php.uses.push(`use Namirasoft\\Account\\TokenManager;`);
@@ -486,9 +486,9 @@ export class PHPBuilder extends BaseBuilder
486
486
  else
487
487
  php.uses.push(`use Namirasoft\\Site\\NSBaseServer;`);
488
488
 
489
- if (this.src.json.name != "namirasoft-account-api-v1")
490
- tags.forEach(tag => php.uses.push(`use ${this.getNameSpace("") + "\\" + className + tag};`));
491
- tags.forEach(tag => php.fields.push(`public ${className}${tag} $${tag.toLowerCase()}; `));
489
+ if (!this.name_parser.isAccountAPI)
490
+ tags.forEach(tag => php.uses.push(`use ${this.getNameSpace("") + "\\" + name_class_namirasoft_entity_server + tag};`));
491
+ tags.forEach(tag => php.fields.push(`public ${name_class_namirasoft_entity_server}${tag} $${NamingConvention.auto.convert(tag, NamingConvention.lower_case_underscore)}; `));
492
492
 
493
493
  let pars: string[] = ["String $base_url"];
494
494
  let args: string[] = [`$base_url`, `"${this.src.json.version}"`];
@@ -510,7 +510,7 @@ export class PHPBuilder extends BaseBuilder
510
510
  php.fields.push("protected $onError;");
511
511
  php.constructors.push(` $this->onError = $onError;`);
512
512
  }
513
- tags.forEach(tag => php.constructors.push(` $this->${tag.toLowerCase()} = new ${className}${tag}($this); `));
513
+ tags.forEach(tag => php.constructors.push(` $this->${NamingConvention.auto.convert(tag, NamingConvention.lower_case_underscore)} = new ${name_class_namirasoft_entity_server}${tag}($this); `));
514
514
  php.constructors.push(`}`);
515
515
  if (!this.account)
516
516
  {
@@ -524,16 +524,16 @@ export class PHPBuilder extends BaseBuilder
524
524
  }
525
525
  getServerBase(): PHP
526
526
  {
527
- let className = this.title.replace(/\s/gm, "") + "ServerBase";
528
- let php = new PHP(this.getNameSpace(""), "./src", "./", className);
527
+ let name_class_namirasoft_entity_server_base = this.name_parser.api.class_namirasoft + "ServerBase";
528
+ let php = new PHP(this.getNameSpace(""), "./src", "./", name_class_namirasoft_entity_server_base);
529
529
 
530
- let serverClassName = this.title.replace(/\s/gm, "") + "Server";
530
+ let name_class_namirasoft_entity_server = this.name_parser.api.class_namirasoft + "Server";
531
531
 
532
- if (this.src.json.name != "namirasoft-account-api-v1")
533
- php.uses.push(`use ${this.getNameSpace("") + "\\" + serverClassName};`);
532
+ if (!this.name_parser.isAccountAPI)
533
+ php.uses.push(`use ${this.getNameSpace("") + "\\" + name_class_namirasoft_entity_server};`);
534
534
 
535
- php.fields.push(`public ${serverClassName} $server;`);
536
- php.constructors.push(`public function __construct(${serverClassName} $server)`);
535
+ php.fields.push(`public ${name_class_namirasoft_entity_server} $server;`);
536
+ php.constructors.push(`public function __construct(${name_class_namirasoft_entity_server} $server)`);
537
537
  php.constructors.push(`{`);
538
538
  php.constructors.push(` $this->server = $server;`);
539
539
  php.constructors.push(`}`);
@@ -542,13 +542,13 @@ export class PHPBuilder extends BaseBuilder
542
542
  }
543
543
  getServerTag(tag: string): PHP
544
544
  {
545
- let baseName = this.title.replace(/\s/gm, "") + "Server";
546
- let parentName = baseName + "Base";
547
- let className = baseName + tag;
545
+ let name_class_namirasoft_entity_server = this.name_parser.api.class_namirasoft + "Server";
546
+ let name_class_namirasoft_entity_server_base = name_class_namirasoft_entity_server + "Base";
547
+ let name_class_namirasoft_entity_server_tag = name_class_namirasoft_entity_server + tag;
548
548
 
549
- let php = new PHP(this.getNameSpace(""), "./src", "./", className, parentName);
550
- if (this.src.json.name != "namirasoft-account-api-v1")
551
- php.uses.push(`use ${this.getNameSpace("") + "\\" + parentName};`);
549
+ let php = new PHP(this.getNameSpace(""), "./src", "./", name_class_namirasoft_entity_server_tag, name_class_namirasoft_entity_server_base);
550
+ if (!this.name_parser.isAccountAPI)
551
+ php.uses.push(`use ${this.getNameSpace("") + "\\" + name_class_namirasoft_entity_server_base};`);
552
552
 
553
553
  return php;
554
554
  }