reactivated 0.34.1 → 0.35.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.
@@ -6,7 +6,7 @@ const stdinBuffer = fs.readFileSync(0);
6
6
  import { Project, VariableDeclarationKind, Writers, } from "ts-morph";
7
7
  const schema = JSON.parse(stdinBuffer.toString("utf8"));
8
8
  const project = new Project();
9
- const interfaces = project.createSourceFile("");
9
+ const statemenets = [];
10
10
  const { urls, templates, types, values } = schema;
11
11
  for (const name of Object.keys(values)) {
12
12
  // Top level constants are deprecated.
@@ -14,7 +14,7 @@ for (const name of Object.keys(values)) {
14
14
  if (name.includes(".")) {
15
15
  continue;
16
16
  }
17
- interfaces.addVariableStatement({
17
+ statemenets.push({
18
18
  declarationKind: VariableDeclarationKind.Const,
19
19
  isExported: true,
20
20
  declarations: [
@@ -25,7 +25,7 @@ for (const name of Object.keys(values)) {
25
25
  ],
26
26
  });
27
27
  }
28
- interfaces.addVariableStatement({
28
+ statemenets.push({
29
29
  declarationKind: VariableDeclarationKind.Const,
30
30
  isExported: true,
31
31
  declarations: [
@@ -35,5 +35,7 @@ interfaces.addVariableStatement({
35
35
  },
36
36
  ],
37
37
  });
38
- process.stdout.write(interfaces.getText());
38
+ const constantsSource = project.createSourceFile("");
39
+ constantsSource.addVariableStatements(statemenets);
40
+ process.stdout.write(constantsSource.getText());
39
41
  //# sourceMappingURL=constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/generator/constants.mts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,wDAAwD;AACxD,qEAAqE;AACrE,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAEvC,OAAO,EACH,OAAO,EAIP,uBAAuB,EAEvB,OAAO,GACV,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WA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CAAC,EAAE,CAAC,CAAC;AACrD,eAAe,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAEnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC"}
@@ -4,7 +4,7 @@ import fs from "fs";
4
4
  // json-schema-to-typescript messes up the descriptor even if unused.
5
5
  const stdinBuffer = fs.readFileSync(0);
6
6
  const { compile } = await import("json-schema-to-typescript");
7
- import { Project, Scope, VariableDeclarationKind, Writers, } from "ts-morph";
7
+ import { Project, Scope, StructureKind, VariableDeclarationKind, Writers, } from "ts-morph";
8
8
  const schema = JSON.parse(stdinBuffer.toString("utf8"));
9
9
  const { urls: possibleEmptyUrls, templates, interfaces, rpc: uncastedRpc, types, values, } = schema;
10
10
  const rpc = uncastedRpc;
@@ -23,22 +23,53 @@ const urls = {
23
23
  };
24
24
  const project = new Project();
25
25
  const sourceFile = project.createSourceFile("");
26
- const classDeclaration = sourceFile.addClass({
26
+ const rpcConstructorStructure = {
27
+ statements: [],
28
+ parameters: [
29
+ {
30
+ name: "requester",
31
+ type: "rpcUtils.Requester",
32
+ isReadonly: false,
33
+ scope: Scope.Public,
34
+ decorators: [],
35
+ hasQuestionToken: false,
36
+ hasOverrideKeyword: false,
37
+ kind: StructureKind.Parameter,
38
+ isRestParameter: false,
39
+ },
40
+ ],
41
+ typeParameters: [],
42
+ docs: [],
43
+ kind: StructureKind.Constructor,
44
+ overloads: [],
45
+ };
46
+ const rpcStructure = {
47
+ decorators: [],
48
+ typeParameters: [],
49
+ docs: [],
50
+ isAbstract: false,
51
+ implements: [],
27
52
  name: "RPC",
28
53
  isExported: true,
29
- });
30
- const rpcConstructor = classDeclaration.addConstructor({
31
- parameters: [{ name: "requester", type: "rpcUtils.Requester", scope: Scope.Public }],
32
- });
33
- let rpcConstructorBody = "";
54
+ isDefaultExport: false,
55
+ hasDeclareKeyword: false,
56
+ kind: StructureKind.Class,
57
+ ctors: [rpcConstructorStructure],
58
+ properties: [],
59
+ methods: [],
60
+ };
34
61
  for (const name of Object.keys(rpc)) {
35
62
  const { url, input, output, type, params } = rpc[name];
36
- const functionDeclaration = classDeclaration.addMethod({
63
+ const methodStructure = {
64
+ kind: StructureKind.Method,
37
65
  name,
38
- });
39
- rpcConstructorBody += `this.${name} = (this.${name} as any).bind(this);\n`;
40
- functionDeclaration.setIsAsync(true);
41
- functionDeclaration.addParameter({
66
+ isAsync: true,
67
+ parameters: [],
68
+ statements: [],
69
+ returnType: "",
70
+ };
71
+ rpcConstructorStructure.statements.push(`this.${name} = (this.${name} as any).bind(this);\n`);
72
+ methodStructure.parameters?.push({
42
73
  name: "this",
43
74
  type: "void",
44
75
  });
@@ -48,17 +79,21 @@ for (const name of Object.keys(rpc)) {
48
79
  name: (writer) => writer.quote(name),
49
80
  };
50
81
  if (params.length >= 1) {
51
- const paramsInterface = functionDeclaration.addInterface({
52
- name: "WILL_BE_STRIPPED",
53
- });
82
+ const paramsProperties = [];
54
83
  const iterator = [];
55
84
  for (const [paramType, paramName] of params) {
56
- paramsInterface.addProperty({ name: paramName, type: "string | number" });
85
+ paramsProperties.push({ name: paramName, type: "string | number" });
57
86
  iterator.push(paramName);
58
87
  }
59
- functionDeclaration.addParameter({
88
+ methodStructure.parameters?.push({
60
89
  name: "params",
61
- type: paramsInterface.getText().replace("interface WILL_BE_STRIPPED", ""),
90
+ type: Writers.objectType({ properties: paramsProperties }),
91
+ isReadonly: false,
92
+ decorators: [],
93
+ hasQuestionToken: false,
94
+ hasOverrideKeyword: false,
95
+ kind: StructureKind.Parameter,
96
+ isRestParameter: false,
62
97
  });
63
98
  Object.assign(initializer, {
64
99
  paramsAndIterator: Writers.object({
@@ -66,24 +101,21 @@ for (const name of Object.keys(rpc)) {
66
101
  params: "params",
67
102
  }),
68
103
  });
69
- // Otherwise our interface will be inserted.
70
- functionDeclaration.setBodyText("");
71
104
  }
72
105
  else {
73
106
  Object.assign(initializer, { paramsAndIterator: "null" });
74
107
  }
75
108
  if (input != null) {
76
- const property = classDeclaration.addProperty({
77
- // isStatic: true,
109
+ rpcStructure.properties?.push({
78
110
  name: input,
79
111
  type: `_Types["${input}"]`,
80
112
  initializer: JSON.stringify(values[input]),
81
113
  });
82
- functionDeclaration.addParameter({
114
+ methodStructure.parameters?.push({
83
115
  name: "input",
84
116
  type: `forms.FormOrFormSetValues<_Types["${input}"]>`,
85
117
  });
86
- functionDeclaration.setReturnType(`Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>, _Types["RPCPermission"]>>`);
118
+ methodStructure.returnType = `Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>, _Types["RPCPermission"]>>`;
87
119
  Object.assign(initializer, {
88
120
  input: Writers.object({
89
121
  values: "input",
@@ -92,67 +124,23 @@ for (const name of Object.keys(rpc)) {
92
124
  });
93
125
  }
94
126
  else {
95
- functionDeclaration.setReturnType(`Promise<rpcUtils.Result<_Types["${output}"], null, _Types["RPCPermission"]>>`);
127
+ methodStructure.returnType = `Promise<rpcUtils.Result<_Types["${output}"], null, _Types["RPCPermission"]>>`;
96
128
  Object.assign(initializer, { input: "null" });
97
129
  }
98
- functionDeclaration.addVariableStatement({
130
+ methodStructure.statements?.push({
131
+ kind: StructureKind.VariableStatement,
99
132
  declarationKind: VariableDeclarationKind.Const,
100
133
  declarations: [
101
134
  {
102
135
  name: "options",
103
136
  initializer: Writers.object(initializer),
104
- /*
105
- x: 123,
106
- y: (writer) => writer.quote("abc"),
107
- z: Writers.object({
108
- one: (writer) => writer.quote("1"),
109
- }),
110
- */
111
137
  },
112
138
  ],
113
139
  });
114
- functionDeclaration.setBodyText(`${functionDeclaration.getBodyText()} return rpcUtils.rpcCall((this as any).requester, options)`);
115
- /*
116
-
117
- if (input != null) {
118
- functionDeclaration.addParameter({
119
- name: "input",
120
- type: `forms.FormOrFormSetValues<_Types["${input}"]>`,
121
- });
122
- bodyText = bodyText.concat(`
123
- const input = ${JSON.stringify({
124
- type: "form",
125
- })};
126
- }
127
- `);
128
- }
129
- else {
130
- }
131
- */
132
- /*
133
- if (instance.length === 1) {
134
- functionDeclaration.addParameter({name: "instance", type: `string | number`});
135
- functionDeclaration.setBodyText(`return rpcUtils.rpcCall("${url}", input, "${type}", instance)`);
136
- }
137
- else if (instance.length >= 2) {
138
- const instanceInterface = functionDeclaration.addInterface({name: "WILL_BE_STRIPPED"});
139
-
140
- for (const instanceArg of instance) {
141
- instanceInterface.addProperty({name: instanceArg, type: "string | number"});
142
- }
143
- functionDeclaration.addParameter({name: "instance", type: instanceInterface.getText().replace("interface WILL_BE_STRIPPED", "")});
144
- functionDeclaration.setBodyText(`const iterator = ${JSON.stringify(instance)}; return rpcUtils.rpcCall("${url}", input, "${type}", {iterator, params: instance})`);
145
- }
146
- else {
147
- functionDeclaration.setBodyText(`return rpcUtils.rpcCall("${url}", input, "${type}")`);
148
- }
149
-
150
- functionDeclaration.addParameter({name: "input", type: `forms.FormOrFormSetValues<_Types["${input}"]>`});
151
- functionDeclaration.setReturnType(`Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>>>`);
152
- functionDeclaration.setIsAsync(true);
153
- */
140
+ methodStructure.statements?.push("return rpcUtils.rpcCall((this as any).requester, options)");
141
+ rpcStructure.methods?.push(methodStructure);
154
142
  }
155
- rpcConstructor.setBodyText(rpcConstructorBody);
143
+ sourceFile.addClass(rpcStructure);
156
144
  if (Object.keys(urls).length !== 0) {
157
145
  sourceFile.addVariableStatement({
158
146
  declarationKind: VariableDeclarationKind.Const,
@@ -163,33 +151,34 @@ if (Object.keys(urls).length !== 0) {
163
151
  },
164
152
  ],
165
153
  });
166
- const urlMap = sourceFile.addInterface({
154
+ const urlMap = {
167
155
  name: "URLMap",
168
- });
169
- urlMap.setIsExported(true);
156
+ properties: [],
157
+ // isExported: true,
158
+ };
170
159
  const withArguments = [""];
171
160
  const withoutArguments = [""];
161
+ const interfaces = [urlMap];
172
162
  for (const name of Object.keys(urls)) {
173
163
  const properties = urls[name].args;
174
164
  const normalizedName = name.replace(/[^\w]/g, "_");
175
- const urlInterface = sourceFile.addInterface({
176
- name: normalizedName,
177
- properties: [{ name: "name", type: `'${name}'` }],
178
- });
179
- const argsInterface = sourceFile.addInterface({
180
- name: `${normalizedName}_args`,
181
- });
182
- for (const propertyName of Object.keys(properties)) {
183
- argsInterface.addProperty({
184
- name: propertyName,
185
- type: properties[propertyName],
186
- });
187
- }
188
- urlInterface.addProperty({
189
- name: "args",
190
- type: `${normalizedName}_args`,
191
- });
192
- urlMap.addProperty({
165
+ interfaces.push(...[
166
+ {
167
+ name: normalizedName,
168
+ properties: [
169
+ { name: "name", type: `'${name}'` },
170
+ { name: "args", type: `${normalizedName}_args` },
171
+ ],
172
+ },
173
+ {
174
+ name: `${normalizedName}_args`,
175
+ properties: Object.keys(properties).map((propertyName) => ({
176
+ name: propertyName,
177
+ type: properties[propertyName],
178
+ })),
179
+ },
180
+ ]);
181
+ urlMap.properties.push({
193
182
  name: normalizedName,
194
183
  type: normalizedName,
195
184
  });
@@ -200,6 +189,7 @@ if (Object.keys(urls).length !== 0) {
200
189
  withArguments.push(normalizedName);
201
190
  }
202
191
  }
192
+ sourceFile.addInterfaces(interfaces);
203
193
  sourceFile.addTypeAlias({ name: "WithArguments", type: withArguments.join("|") });
204
194
  sourceFile.addTypeAlias({
205
195
  name: "WithoutArguments",
@@ -264,10 +254,11 @@ export const {Form, FormSet, Widget, useForm, useFormSet, ManagementForm} = form
264
254
  compile(types, "this is unused").then((ts) => {
265
255
  process.stdout.write("/* eslint-disable */\n");
266
256
  process.stdout.write(ts);
257
+ const statements = [];
267
258
  if (!fs.existsSync("./reactivated-skip-template-check")) {
268
259
  for (const name of Object.keys(templates)) {
269
260
  const propsName = templates[name];
270
- sourceFile.addStatements(`
261
+ statements.push(`
271
262
 
272
263
  import ${name}Implementation from "@client/templates/${name}"
273
264
  export type ${name}Check = Checker<_Types["${propsName}"], typeof ${name}Implementation>;
@@ -282,7 +273,7 @@ export namespace templates {
282
273
  }
283
274
  for (const name of Object.keys(interfaces)) {
284
275
  const propsName = interfaces[name];
285
- sourceFile.addStatements(`
276
+ statements.push(`
286
277
 
287
278
  export namespace interfaces {
288
279
  export type ${name} = _Types["${propsName}"];
@@ -291,6 +282,7 @@ export namespace interfaces {
291
282
 
292
283
  `);
293
284
  }
285
+ sourceFile.addStatements(statements);
294
286
  process.stdout.write(sourceFile.getText());
295
287
  });
296
288
  //# sourceMappingURL=generator.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.mjs","sourceRoot":"","sources":["../src/generator.mts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,wDAAwD;AACxD,qEAAqE;AACrE,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAEvC,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAE5D,OAAO,EAEH,OAAO,EACP,KAAK,EAIL,uBAAuB,EAEvB,OAAO,GACV,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACxD,MAAM,EACF,IAAI,EAAE,iBAAiB,EACvB,SAAS,EACT,UAAU,EACV,GAAG,EAAE,WAAW,EAChB,KAAK,EACL,MAAM,GACT,GAAG,MAAM,CAAC;AAEX,MAAM,GAAG,GAAmC,WAAW,CAAC;AAExD,MAAM,IAAI,GAAiC;IACvC,GAAG,iBAAiB;IACpB,wBAAwB,EAAE;QACtB,KAAK,EAAE,0BAA0B;QACjC,IAAI,EAAE,EAAE;KACX;IACD,6BAA6B,EAAE;QAC3B,KAAK,EAAE,+BAA+B;QACtC,IAAI,EAAE;YACF,CAAC,EAAE,QAAQ;SACd;KACJ;CACJ,CAAC;AAEF,MAAM,OAAO,GAAG,IAAI,OA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CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzB,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,mCAAmC,CAAC,EAAE;QACrD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YACvC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YAElC,UAAU,CAAC,IAAI,CAAC;;SAEnB,IAAI,0CAA0C,IAAI;cAC7C,IAAI,2BAA2B,SAAS,cAAc,IAAI;;;kBAGtD,IAAI,cAAc,SAAS;;;;SAIpC,CAAC,CAAC;SACF;KACJ;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;QACxC,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,UAAU,CAAC,IAAI,CAAC;;;kBAGN,IAAI,cAAc,SAAS;;;;SAIpC,CAAC,CAAC;KACN;IAED,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAErC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactivated",
3
- "version": "0.34.1",
3
+ "version": "0.35.0",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -20,7 +20,7 @@ const schema = JSON.parse(stdinBuffer.toString("utf8"));
20
20
 
21
21
  const project = new Project();
22
22
 
23
- const interfaces = project.createSourceFile("");
23
+ const statemenets = [];
24
24
 
25
25
  const {urls, templates, types, values} = schema;
26
26
 
@@ -31,7 +31,7 @@ for (const name of Object.keys(values)) {
31
31
  continue;
32
32
  }
33
33
 
34
- interfaces.addVariableStatement({
34
+ statemenets.push({
35
35
  declarationKind: VariableDeclarationKind.Const,
36
36
  isExported: true,
37
37
  declarations: [
@@ -46,7 +46,7 @@ for (const name of Object.keys(values)) {
46
46
  });
47
47
  }
48
48
 
49
- interfaces.addVariableStatement({
49
+ statemenets.push({
50
50
  declarationKind: VariableDeclarationKind.Const,
51
51
  isExported: true,
52
52
  declarations: [
@@ -57,4 +57,7 @@ interfaces.addVariableStatement({
57
57
  ],
58
58
  });
59
59
 
60
- process.stdout.write(interfaces.getText());
60
+ const constantsSource = project.createSourceFile("");
61
+ constantsSource.addVariableStatements(statemenets);
62
+
63
+ process.stdout.write(constantsSource.getText());
package/src/generator.mts CHANGED
@@ -19,6 +19,13 @@ import {
19
19
  VariableDeclarationKind,
20
20
  WriterFunction,
21
21
  Writers,
22
+ InterfaceDeclarationStructure,
23
+ OptionalKind,
24
+ MethodDeclarationStructure,
25
+ PropertyDeclarationStructure,
26
+ ParameterDeclarationStructure,
27
+ StatementedNodeStructure,
28
+ StatementStructures,
22
29
  } from "ts-morph";
23
30
 
24
31
  const schema = JSON.parse(stdinBuffer.toString("utf8"));
@@ -51,27 +58,60 @@ const project = new Project();
51
58
 
52
59
  const sourceFile = project.createSourceFile("");
53
60
 
54
- const classDeclaration = sourceFile.addClass({
61
+ const rpcConstructorStructure = {
62
+ statements: [] as string[],
63
+ parameters: [
64
+ {
65
+ name: "requester",
66
+ type: "rpcUtils.Requester",
67
+ isReadonly: false,
68
+ scope: Scope.Public,
69
+ decorators: [],
70
+ hasQuestionToken: false,
71
+ hasOverrideKeyword: false,
72
+ kind: StructureKind.Parameter as const,
73
+ isRestParameter: false,
74
+ },
75
+ ],
76
+ typeParameters: [],
77
+ docs: [],
78
+ kind: StructureKind.Constructor as const,
79
+ overloads: [],
80
+ };
81
+
82
+ const rpcStructure = {
83
+ decorators: [],
84
+ typeParameters: [],
85
+ docs: [],
86
+ isAbstract: false,
87
+ implements: [],
55
88
  name: "RPC",
56
89
  isExported: true,
57
- });
58
-
59
- const rpcConstructor = classDeclaration.addConstructor({
60
- parameters: [{name: "requester", type: "rpcUtils.Requester", scope: Scope.Public}],
61
- });
62
-
63
- let rpcConstructorBody = "";
90
+ isDefaultExport: false,
91
+ hasDeclareKeyword: false,
92
+ kind: StructureKind.Class as const,
93
+ ctors: [rpcConstructorStructure],
94
+ properties: [] as OptionalKind<PropertyDeclarationStructure>[],
95
+ methods: [] as OptionalKind<MethodDeclarationStructure>[],
96
+ };
64
97
 
65
98
  for (const name of Object.keys(rpc)) {
66
99
  const {url, input, output, type, params} = rpc[name];
67
- const functionDeclaration = classDeclaration.addMethod({
100
+
101
+ const methodStructure = {
102
+ kind: StructureKind.Method as const,
68
103
  name,
69
- });
104
+ isAsync: true,
105
+ parameters: [] as OptionalKind<ParameterDeclarationStructure>[],
106
+ statements: [] as (string | StatementStructures)[],
107
+ returnType: "",
108
+ };
70
109
 
71
- rpcConstructorBody += `this.${name} = (this.${name} as any).bind(this);\n`;
72
- functionDeclaration.setIsAsync(true);
110
+ rpcConstructorStructure.statements.push(
111
+ `this.${name} = (this.${name} as any).bind(this);\n`,
112
+ );
73
113
 
74
- functionDeclaration.addParameter({
114
+ methodStructure.parameters?.push({
75
115
  name: "this",
76
116
  type: "void",
77
117
  });
@@ -83,18 +123,22 @@ for (const name of Object.keys(rpc)) {
83
123
  };
84
124
 
85
125
  if (params.length >= 1) {
86
- const paramsInterface = functionDeclaration.addInterface({
87
- name: "WILL_BE_STRIPPED",
88
- });
126
+ const paramsProperties = [];
89
127
 
90
128
  const iterator = [];
91
129
  for (const [paramType, paramName] of params) {
92
- paramsInterface.addProperty({name: paramName, type: "string | number"});
130
+ paramsProperties.push({name: paramName, type: "string | number"});
93
131
  iterator.push(paramName);
94
132
  }
95
- functionDeclaration.addParameter({
133
+ methodStructure.parameters?.push({
96
134
  name: "params",
97
- type: paramsInterface.getText().replace("interface WILL_BE_STRIPPED", ""),
135
+ type: Writers.objectType({properties: paramsProperties}),
136
+ isReadonly: false,
137
+ decorators: [],
138
+ hasQuestionToken: false,
139
+ hasOverrideKeyword: false,
140
+ kind: StructureKind.Parameter as const,
141
+ isRestParameter: false,
98
142
  });
99
143
 
100
144
  Object.assign(initializer, {
@@ -103,26 +147,23 @@ for (const name of Object.keys(rpc)) {
103
147
  params: "params",
104
148
  }),
105
149
  });
106
- // Otherwise our interface will be inserted.
107
- functionDeclaration.setBodyText("");
108
150
  } else {
109
151
  Object.assign(initializer, {paramsAndIterator: "null"});
110
152
  }
111
153
 
112
154
  if (input != null) {
113
- const property = classDeclaration.addProperty({
114
- // isStatic: true,
155
+ rpcStructure.properties?.push({
115
156
  name: input,
116
157
  type: `_Types["${input}"]`,
117
158
  initializer: JSON.stringify(values[input]),
118
159
  });
119
- functionDeclaration.addParameter({
160
+ methodStructure.parameters?.push({
120
161
  name: "input",
121
162
  type: `forms.FormOrFormSetValues<_Types["${input}"]>`,
122
163
  });
123
- functionDeclaration.setReturnType(
124
- `Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>, _Types["RPCPermission"]>>`,
125
- );
164
+
165
+ methodStructure.returnType = `Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>, _Types["RPCPermission"]>>`;
166
+
126
167
  Object.assign(initializer, {
127
168
  input: Writers.object({
128
169
  values: "input",
@@ -131,73 +172,27 @@ for (const name of Object.keys(rpc)) {
131
172
  }),
132
173
  });
133
174
  } else {
134
- functionDeclaration.setReturnType(
135
- `Promise<rpcUtils.Result<_Types["${output}"], null, _Types["RPCPermission"]>>`,
136
- );
175
+ methodStructure.returnType = `Promise<rpcUtils.Result<_Types["${output}"], null, _Types["RPCPermission"]>>`;
137
176
  Object.assign(initializer, {input: "null"});
138
177
  }
139
178
 
140
- functionDeclaration.addVariableStatement({
179
+ methodStructure.statements?.push({
180
+ kind: StructureKind.VariableStatement,
141
181
  declarationKind: VariableDeclarationKind.Const,
142
182
  declarations: [
143
183
  {
144
184
  name: "options",
145
185
  initializer: Writers.object(initializer),
146
- /*
147
- x: 123,
148
- y: (writer) => writer.quote("abc"),
149
- z: Writers.object({
150
- one: (writer) => writer.quote("1"),
151
- }),
152
- */
153
186
  },
154
187
  ],
155
188
  });
156
- functionDeclaration.setBodyText(
157
- `${functionDeclaration.getBodyText()} return rpcUtils.rpcCall((this as any).requester, options)`,
189
+ methodStructure.statements?.push(
190
+ "return rpcUtils.rpcCall((this as any).requester, options)",
158
191
  );
159
- /*
160
-
161
- if (input != null) {
162
- functionDeclaration.addParameter({
163
- name: "input",
164
- type: `forms.FormOrFormSetValues<_Types["${input}"]>`,
165
- });
166
- bodyText = bodyText.concat(`
167
- const input = ${JSON.stringify({
168
- type: "form",
169
- })};
170
- }
171
- `);
172
- }
173
- else {
174
- }
175
- */
176
-
177
- /*
178
- if (instance.length === 1) {
179
- functionDeclaration.addParameter({name: "instance", type: `string | number`});
180
- functionDeclaration.setBodyText(`return rpcUtils.rpcCall("${url}", input, "${type}", instance)`);
181
- }
182
- else if (instance.length >= 2) {
183
- const instanceInterface = functionDeclaration.addInterface({name: "WILL_BE_STRIPPED"});
184
-
185
- for (const instanceArg of instance) {
186
- instanceInterface.addProperty({name: instanceArg, type: "string | number"});
187
- }
188
- functionDeclaration.addParameter({name: "instance", type: instanceInterface.getText().replace("interface WILL_BE_STRIPPED", "")});
189
- functionDeclaration.setBodyText(`const iterator = ${JSON.stringify(instance)}; return rpcUtils.rpcCall("${url}", input, "${type}", {iterator, params: instance})`);
190
- }
191
- else {
192
- functionDeclaration.setBodyText(`return rpcUtils.rpcCall("${url}", input, "${type}")`);
193
- }
194
-
195
- functionDeclaration.addParameter({name: "input", type: `forms.FormOrFormSetValues<_Types["${input}"]>`});
196
- functionDeclaration.setReturnType(`Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>>>`);
197
- functionDeclaration.setIsAsync(true);
198
- */
192
+ rpcStructure.methods?.push(methodStructure);
199
193
  }
200
- rpcConstructor.setBodyText(rpcConstructorBody);
194
+
195
+ sourceFile.addClass(rpcStructure);
201
196
 
202
197
  if (Object.keys(urls).length !== 0) {
203
198
  sourceFile.addVariableStatement({
@@ -210,38 +205,43 @@ if (Object.keys(urls).length !== 0) {
210
205
  ],
211
206
  });
212
207
 
213
- const urlMap = sourceFile.addInterface({
208
+ const urlMap = {
214
209
  name: "URLMap",
215
- });
216
- urlMap.setIsExported(true);
210
+ properties: [] as any,
211
+ // isExported: true,
212
+ };
217
213
 
218
214
  const withArguments = [""];
215
+
219
216
  const withoutArguments = [""];
220
217
 
218
+ const interfaces: OptionalKind<InterfaceDeclarationStructure>[] = [urlMap];
219
+
221
220
  for (const name of Object.keys(urls)) {
222
221
  const properties = urls[name as keyof typeof urls].args;
223
222
  const normalizedName = name.replace(/[^\w]/g, "_");
224
223
 
225
- const urlInterface = sourceFile.addInterface({
226
- name: normalizedName,
227
- properties: [{name: "name", type: `'${name}'`}],
228
- });
229
- const argsInterface = sourceFile.addInterface({
230
- name: `${normalizedName}_args`,
231
- });
232
-
233
- for (const propertyName of Object.keys(properties)) {
234
- argsInterface.addProperty({
235
- name: propertyName,
236
- type: properties[propertyName as keyof typeof properties],
237
- });
238
- }
239
- urlInterface.addProperty({
240
- name: "args",
241
- type: `${normalizedName}_args`,
242
- });
224
+ interfaces.push(
225
+ ...[
226
+ {
227
+ name: normalizedName,
228
+ properties: [
229
+ {name: "name", type: `'${name}'`},
230
+ {name: "args", type: `${normalizedName}_args`},
231
+ ],
232
+ },
233
+ {
234
+ name: `${normalizedName}_args`,
235
+
236
+ properties: Object.keys(properties).map((propertyName) => ({
237
+ name: propertyName,
238
+ type: properties[propertyName as keyof typeof properties],
239
+ })),
240
+ },
241
+ ],
242
+ );
243
243
 
244
- urlMap.addProperty({
244
+ urlMap.properties.push({
245
245
  name: normalizedName,
246
246
  type: normalizedName,
247
247
  });
@@ -252,6 +252,7 @@ if (Object.keys(urls).length !== 0) {
252
252
  withArguments.push(normalizedName);
253
253
  }
254
254
  }
255
+ sourceFile.addInterfaces(interfaces);
255
256
  sourceFile.addTypeAlias({name: "WithArguments", type: withArguments.join("|")});
256
257
  sourceFile.addTypeAlias({
257
258
  name: "WithoutArguments",
@@ -321,12 +322,13 @@ export const {Form, FormSet, Widget, useForm, useFormSet, ManagementForm} = form
321
322
  compile(types, "this is unused").then((ts) => {
322
323
  process.stdout.write("/* eslint-disable */\n");
323
324
  process.stdout.write(ts);
325
+ const statements = [];
324
326
 
325
327
  if (!fs.existsSync("./reactivated-skip-template-check")) {
326
328
  for (const name of Object.keys(templates)) {
327
329
  const propsName = templates[name];
328
330
 
329
- sourceFile.addStatements(`
331
+ statements.push(`
330
332
 
331
333
  import ${name}Implementation from "@client/templates/${name}"
332
334
  export type ${name}Check = Checker<_Types["${propsName}"], typeof ${name}Implementation>;
@@ -342,7 +344,7 @@ export namespace templates {
342
344
 
343
345
  for (const name of Object.keys(interfaces)) {
344
346
  const propsName = interfaces[name];
345
- sourceFile.addStatements(`
347
+ statements.push(`
346
348
 
347
349
  export namespace interfaces {
348
350
  export type ${name} = _Types["${propsName}"];
@@ -352,5 +354,7 @@ export namespace interfaces {
352
354
  `);
353
355
  }
354
356
 
357
+ sourceFile.addStatements(statements);
358
+
355
359
  process.stdout.write(sourceFile.getText());
356
360
  });