@ayasofyazilim/saas 0.0.17 → 0.0.18

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/generator.mjs CHANGED
@@ -1,98 +1,102 @@
1
- import { createClient } from '@hey-api/openapi-ts';
1
+ import { createClient } from "@hey-api/openapi-ts";
2
2
  import SwaggerParser from "@apidevtools/swagger-parser";
3
- import fs from 'fs';
3
+ import fs from "fs";
4
4
 
5
5
  const BASE_URL = "http://192.168.1.105:";
6
6
  const WEBGATEWAY_PORT = 44336;
7
7
  const api_list = [
8
- {
9
- input: 'swagger-json/AuthServer',
10
- output: 'Account',
11
- dereference: true
12
- },
13
- {
14
- input: "",
15
- output: 'Project',
16
- port: 44325,
17
- dereference: true
18
- },
19
- {
20
- input: "swagger-json/Backer",
21
- output: 'Backer',
22
- port: 44325,
23
- dereference: true
24
- },
25
- {
26
- input: "swagger-json/Administration",
27
- output: 'Administration',
28
- dereference: true
29
- },
30
- {
31
- input: "swagger-json/Identity",
32
- output: 'Identity',
33
- dereference: true
34
- },
35
- {
36
- input: "swagger-json/Saas",
37
- output: 'Saas',
38
- dereference: true
39
- },
40
- {
41
- input: "",
42
- output: 'Setting',
43
- port: 44515,
44
- dereference: false
45
- },
46
- {
47
- input: "swagger-json/Merchant",
48
- output: 'Merchant',
49
- port: 44335,
50
- dereference: true
51
- }
52
- ]
8
+ {
9
+ input: "swagger-json/AuthServer",
10
+ output: "Account",
11
+ dereference: true,
12
+ },
13
+ {
14
+ input: "",
15
+ output: "Project",
16
+ port: 44964,
17
+ dereference: true,
18
+ },
19
+ {
20
+ input: "swagger-json/Backer",
21
+ output: "Backer",
22
+ port: 44325,
23
+ dereference: true,
24
+ },
25
+ {
26
+ input: "swagger-json/Administration",
27
+ output: "Administration",
28
+ dereference: true,
29
+ },
30
+ {
31
+ input: "swagger-json/Identity",
32
+ output: "Identity",
33
+ dereference: true,
34
+ },
35
+ {
36
+ input: "swagger-json/Saas",
37
+ output: "Saas",
38
+ dereference: true,
39
+ },
40
+ {
41
+ input: "",
42
+ output: "Setting",
43
+ port: 44515,
44
+ dereference: false,
45
+ },
46
+ {
47
+ input: "swagger-json/Merchant",
48
+ output: "Merchant",
49
+ port: 44335,
50
+ dereference: true,
51
+ },
52
+ ];
53
53
 
54
54
  function clean_URL(url) {
55
- return url.replace(/\/\//g, '/').replace(/:\//g, '://');
55
+ return url.replace(/\/\//g, "/").replace(/:\//g, "://");
56
56
  }
57
57
 
58
58
  function getCircularReplacer() {
59
- const ancestors = [];
60
- return function (key, value) {
61
- if (typeof value !== "object" || value === null) {
62
- return value;
63
- }
64
- // `this` is the object that value is contained in,
65
- // i.e., its direct parent.
66
- while (ancestors.length > 0 && ancestors.at(-1) !== this) {
67
- ancestors.pop();
68
- }
69
- if (ancestors.includes(value)) {
70
- return "[Circular]";
71
- }
72
- ancestors.push(value);
73
- return value;
74
- };
59
+ const ancestors = [];
60
+ return function (key, value) {
61
+ if (typeof value !== "object" || value === null) {
62
+ return value;
63
+ }
64
+ // `this` is the object that value is contained in,
65
+ // i.e., its direct parent.
66
+ while (ancestors.length > 0 && ancestors.at(-1) !== this) {
67
+ ancestors.pop();
68
+ }
69
+ if (ancestors.includes(value)) {
70
+ return "[Circular]";
71
+ }
72
+ ancestors.push(value);
73
+ return value;
74
+ };
75
75
  }
76
76
 
77
77
  for (const api of api_list) {
78
- console.log(`✨ Processing ${api.output}...`);
79
- const port = api?.port ? api.port : WEBGATEWAY_PORT;
80
- const apiURL = clean_URL(`${BASE_URL + port}/${api.input}` + "/swagger/v1/swagger.json");
81
- const swaggerText = await SwaggerParser.dereference(apiURL);
82
- let temp_swagger = apiURL;
83
- if (api.dereference) {
84
- console.log(typeof swaggerText)
85
- console.log(`🎁 Dereferencing ${api.output} is from ${apiURL} done.`);
86
- temp_swagger = `temp_${api.output}_swagger.json`;
87
- fs.writeFileSync(temp_swagger, JSON.stringify(swaggerText, getCircularReplacer()));
88
- }
89
- await createClient({
90
- input: temp_swagger,
91
- output: api.output + "Service",
92
- name: api.output + "ServiceClient",
93
- client: "fetch"
94
- });
95
- if (api.dereference)
96
- fs.unlinkSync(temp_swagger);
97
- console.log(`✅ Generating ${api.output} is done.`);
98
- }
78
+ console.log(`✨ Processing ${api.output}...`);
79
+ const port = api?.port ? api.port : WEBGATEWAY_PORT;
80
+ const apiURL = clean_URL(
81
+ `${BASE_URL + port}/${api.input}` + "/swagger/v1/swagger.json"
82
+ );
83
+ const swaggerText = await SwaggerParser.dereference(apiURL);
84
+ let temp_swagger = apiURL;
85
+ if (api.dereference) {
86
+ console.log(typeof swaggerText);
87
+ console.log(`🎁 Dereferencing ${api.output} is from ${apiURL} done.`);
88
+ temp_swagger = `temp_${api.output}_swagger.json`;
89
+ fs.writeFileSync(
90
+ temp_swagger,
91
+ JSON.stringify(swaggerText, getCircularReplacer())
92
+ );
93
+ }
94
+ await createClient({
95
+ input: temp_swagger,
96
+ output: api.output + "Service",
97
+ name: api.output + "ServiceClient",
98
+ client: "fetch",
99
+ });
100
+ if (api.dereference) fs.unlinkSync(temp_swagger);
101
+ console.log(`✅ Generating ${api.output} is done.`);
102
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayasofyazilim/saas",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Ayasofyazılım SAAS",
5
5
  "exports": {
6
6
  "./AccountService": "./AccountService/index.ts",