arri 0.0.13 → 0.0.16

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.
Files changed (60) hide show
  1. package/dist/chunks/index.cjs +8839 -68
  2. package/dist/chunks/index.mjs +8820 -69
  3. package/dist/cli.cjs +16918 -50228
  4. package/dist/cli.mjs +16898 -50196
  5. package/dist/codegen.cjs +314 -37
  6. package/dist/codegen.d.cts +23 -15
  7. package/dist/codegen.d.mts +23 -15
  8. package/dist/codegen.d.ts +23 -15
  9. package/dist/codegen.mjs +280 -23
  10. package/dist/index.cjs +47 -19
  11. package/dist/index.d.cts +19 -2
  12. package/dist/index.d.mts +19 -2
  13. package/dist/index.d.ts +19 -2
  14. package/dist/index.mjs +30 -1
  15. package/dist/shared/arri.0671bb8c.mjs +641 -0
  16. package/dist/shared/arri.a9b80e98.cjs +655 -0
  17. package/dist/shared/{arri.2ff96786.d.ts → arri.b176bba1.d.cts} +113 -70
  18. package/dist/shared/{arri.2ff96786.d.cts → arri.b176bba1.d.mts} +113 -70
  19. package/dist/shared/{arri.2ff96786.d.mts → arri.b176bba1.d.ts} +113 -70
  20. package/dist/shared/arri.b2f4eb7d.cjs +851 -0
  21. package/dist/shared/arri.fd713b2e.mjs +812 -0
  22. package/package.json +6 -4
  23. package/dist/chunks/acorn.cjs +0 -18
  24. package/dist/chunks/acorn.mjs +0 -15
  25. package/dist/chunks/angular.cjs +0 -7
  26. package/dist/chunks/angular.mjs +0 -4
  27. package/dist/chunks/babel.cjs +0 -21
  28. package/dist/chunks/babel.mjs +0 -18
  29. package/dist/chunks/browser.cjs +0 -21
  30. package/dist/chunks/browser.mjs +0 -19
  31. package/dist/chunks/estree.cjs +0 -42
  32. package/dist/chunks/estree.mjs +0 -37
  33. package/dist/chunks/flow.cjs +0 -26
  34. package/dist/chunks/flow.mjs +0 -23
  35. package/dist/chunks/glimmer.cjs +0 -37
  36. package/dist/chunks/glimmer.mjs +0 -32
  37. package/dist/chunks/graphql.cjs +0 -37
  38. package/dist/chunks/graphql.mjs +0 -31
  39. package/dist/chunks/html.cjs +0 -27
  40. package/dist/chunks/html.mjs +0 -21
  41. package/dist/chunks/index2.cjs +0 -231
  42. package/dist/chunks/index2.mjs +0 -220
  43. package/dist/chunks/index3.cjs +0 -8854
  44. package/dist/chunks/index3.mjs +0 -8832
  45. package/dist/chunks/markdown.cjs +0 -67
  46. package/dist/chunks/markdown.mjs +0 -61
  47. package/dist/chunks/meriyah.cjs +0 -10
  48. package/dist/chunks/meriyah.mjs +0 -7
  49. package/dist/chunks/postcss.cjs +0 -60
  50. package/dist/chunks/postcss.mjs +0 -54
  51. package/dist/chunks/typescript.cjs +0 -30
  52. package/dist/chunks/typescript.mjs +0 -27
  53. package/dist/chunks/xdg-open.cjs +0 -1071
  54. package/dist/chunks/xdg-open.mjs +0 -1069
  55. package/dist/chunks/yaml.cjs +0 -169
  56. package/dist/chunks/yaml.mjs +0 -163
  57. package/dist/shared/arri.3605a96c.cjs +0 -8796
  58. package/dist/shared/arri.a90e77aa.mjs +0 -29680
  59. package/dist/shared/arri.b0ab6d2f.mjs +0 -8756
  60. package/dist/shared/arri.d31eb2d5.cjs +0 -29706
package/dist/codegen.cjs CHANGED
@@ -1,21 +1,16 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/arri.3605a96c.cjs');
4
- const dart = require('./shared/arri.d31eb2d5.cjs');
5
- const fs = require('fs');
6
- require('module');
7
- require('url');
8
- require('path');
9
- require('process');
10
- require('os');
11
- require('tty');
12
- require('assert');
13
- require('fs/promises');
14
- require('v8');
15
- require('util');
3
+ const require$$0 = require('fs');
4
+ const prettier = require('prettier');
5
+ const app = require('./shared/arri.b2f4eb7d.cjs');
6
+ const dart = require('./shared/arri.a9b80e98.cjs');
7
+ require('@sinclair/typebox');
8
+ require('h3');
9
+ require('@sinclair/typebox/errors');
10
+ require('@sinclair/typebox/value');
16
11
  require('child_process');
17
12
 
18
- let createdModels = [];
13
+ let generatedModels = [];
19
14
  const typescriptClientGenerator = dart.defineClientGeneratorPlugin(
20
15
  (options) => ({
21
16
  generator: async (def) => {
@@ -29,21 +24,21 @@ const typescriptClientGenerator = dart.defineClientGeneratorPlugin(
29
24
  def,
30
25
  options.clientName
31
26
  );
32
- fs.writeFileSync(options.outputFile, result);
27
+ require$$0.writeFileSync(options.outputFile, result);
33
28
  },
34
29
  options
35
30
  })
36
31
  );
37
32
  async function createTypescriptClient(def, prefix = "Client") {
38
- createdModels = [];
39
- const services = index.unflattenObject(def.procedures);
33
+ generatedModels = [];
34
+ const services = app.unflattenObject(def.procedures);
40
35
  const serviceParts = [];
41
36
  const procedureParts = [];
42
37
  const modelParts = [];
43
38
  Object.keys(services).forEach((key) => {
44
39
  const item = services[key];
45
- if (index.isServiceDefinition(item)) {
46
- const serviceName = index.pascalCase(`${prefix}_${key}_service`);
40
+ if (app.isServiceDef(item)) {
41
+ const serviceName = app.pascalCase(`${prefix}_${key}_service`);
47
42
  serviceParts.push({
48
43
  name: serviceName,
49
44
  key,
@@ -54,13 +49,13 @@ async function createTypescriptClient(def, prefix = "Client") {
54
49
  procedureParts.push(tsRpcFromProcedureDefinition(key, item));
55
50
  });
56
51
  Object.keys(def.models).forEach((key) => {
57
- const modelName = index.pascalCase(`${key}`);
58
- if (!createdModels.includes(modelName)) {
52
+ const modelName = app.pascalCase(`${key}`);
53
+ if (!generatedModels.includes(modelName)) {
59
54
  modelParts.push(tsModelFromDefinition(modelName, def.models[key]));
60
- createdModels.push(modelName);
55
+ generatedModels.push(modelName);
61
56
  }
62
57
  });
63
- return dart.format2(
58
+ return prettier.format(
64
59
  `/* eslint-disable */
65
60
  import { arriRequest, ArriRequestError } from 'arri-client';
66
61
 
@@ -91,11 +86,11 @@ function tsServiceFromServiceDefinition(name, def) {
91
86
  const subServiceParts = [];
92
87
  Object.keys(def).forEach((key) => {
93
88
  const val = def[key];
94
- if (index.isProcedureDefinition(val)) {
89
+ if (app.isProcedureDef(val)) {
95
90
  rpcParts.push(tsRpcFromProcedureDefinition(key, val));
96
91
  return;
97
92
  }
98
- const subServiceName = index.pascalCase(
93
+ const subServiceName = app.pascalCase(
99
94
  `${name.split("Service").join("")}_${key}_service`
100
95
  );
101
96
  subServiceParts.push({
@@ -144,13 +139,13 @@ function tsModelFromDefinition(name, def) {
144
139
  const isOptional = !def.required?.includes(key);
145
140
  const prop = def.properties?.[key];
146
141
  const keyPart = isOptional ? `${key}?` : key;
147
- if (index.isJsonSchemaScalarType(prop)) {
142
+ if (app.isJsonSchemaScalarType(prop)) {
148
143
  fieldParts.push(
149
144
  tsInterfaceScalarField(key, prop, isOptional) ?? ""
150
145
  );
151
146
  return;
152
147
  }
153
- if (index.isJsonSchemaNullType(prop)) {
148
+ if (app.isJsonSchemaNullType(prop)) {
154
149
  switch (prop.type) {
155
150
  case "null":
156
151
  fieldParts.push(`${keyPart}: null;`);
@@ -161,9 +156,9 @@ function tsModelFromDefinition(name, def) {
161
156
  }
162
157
  return;
163
158
  }
164
- if (index.isJsonSchemaObject(prop)) {
165
- const subModelName = prop.$id ?? index.pascalCase(`${name}_${key}`);
166
- if (!createdModels.includes(subModelName)) {
159
+ if (app.isJsonSchemaObject(prop)) {
160
+ const subModelName = prop.$id ?? app.pascalCase(`${name}_${key}`);
161
+ if (!generatedModels.includes(subModelName)) {
167
162
  const content = tsModelFromDefinition(
168
163
  subModelName,
169
164
  prop
@@ -173,15 +168,15 @@ function tsModelFromDefinition(name, def) {
173
168
  fieldParts.push(`${keyPart}: ${subModelName};`);
174
169
  return;
175
170
  }
176
- if (index.isJsonSchemaEnum(prop)) {
171
+ if (app.isJsonSchemaEnum(prop)) {
177
172
  const vals = prop.anyOf.map(
178
173
  (opt) => opt.type === "string" ? `'${opt.const}'` : `${opt.const}`
179
174
  );
180
175
  fieldParts.push(`${keyPart}: ${vals.join(" | ")};`);
181
176
  return;
182
177
  }
183
- if (index.isJsonSchemaArray(prop)) {
184
- if (index.isJsonSchemaScalarType(prop.items)) {
178
+ if (app.isJsonSchemaArray(prop)) {
179
+ if (app.isJsonSchemaScalarType(prop.items)) {
185
180
  const part = tsInterfaceScalarField(
186
181
  key,
187
182
  prop.items,
@@ -190,7 +185,7 @@ function tsModelFromDefinition(name, def) {
190
185
  fieldParts.push(part);
191
186
  return;
192
187
  }
193
- if (index.isJsonSchemaNullType(prop.items)) {
188
+ if (app.isJsonSchemaNullType(prop.items)) {
194
189
  if (prop.items.type === "null") {
195
190
  fieldParts.push(`${keyPart}: null[]`);
196
191
  return;
@@ -198,9 +193,9 @@ function tsModelFromDefinition(name, def) {
198
193
  fieldParts.push(`${keyPart}: undefined[]`);
199
194
  return;
200
195
  }
201
- if (index.isJsonSchemaObject(prop.items)) {
202
- const subModelName = prop.items.$id ?? index.pascalCase(`${name}_${key}_item`);
203
- if (!createdModels.includes(subModelName)) {
196
+ if (app.isJsonSchemaObject(prop.items)) {
197
+ const subModelName = prop.items.$id ?? app.pascalCase(`${name}_${key}_item`);
198
+ if (!generatedModels.includes(subModelName)) {
204
199
  subModelParts.push(
205
200
  tsModelFromDefinition(subModelName, prop.items)
206
201
  );
@@ -235,6 +230,283 @@ function tsInterfaceScalarField(key, prop, isOptional = false) {
235
230
  }
236
231
  }
237
232
 
233
+ const kotlinClientGenerator = dart.defineClientGeneratorPlugin(function(options) {
234
+ return {
235
+ generator(def) {
236
+ },
237
+ options
238
+ };
239
+ });
240
+ function createKotlinClient(def, clientName, packageName) {
241
+ const procedures = app.unflattenProcedures(def.procedures);
242
+ const modelParts = [];
243
+ Object.keys(def.models).forEach((key) => {
244
+ const node = def.models[key];
245
+ if (app.isJsonSchemaObject(node)) {
246
+ modelParts.push(
247
+ createKotlinModelFromDefinition(
248
+ app.pascalCase(`${clientName}_${key}`),
249
+ node
250
+ )
251
+ );
252
+ }
253
+ });
254
+ return `${importStr(packageName)}
255
+
256
+ ${createKotlinServiceFromDefinition(clientName, clientName, procedures)}
257
+
258
+ ${handleRequestFnString}
259
+ `;
260
+ }
261
+ function createKotlinServiceFromDefinition(clientName, serviceName, def) {
262
+ const rpcParts = [];
263
+ const subServiceParts = [];
264
+ Object.keys(def).forEach((key) => {
265
+ const node = def[key];
266
+ if (app.isServiceDef(node)) {
267
+ const nameParts = serviceName.split("Service");
268
+ nameParts.pop();
269
+ const subServiceName = app.pascalCase(
270
+ `${nameParts.join("")}_${key}_service`
271
+ );
272
+ subServiceParts.push({
273
+ name: subServiceName,
274
+ key,
275
+ content: createKotlinServiceFromDefinition(
276
+ clientName,
277
+ subServiceName,
278
+ node
279
+ )
280
+ });
281
+ return;
282
+ }
283
+ rpcParts.push(createKotlinRpcFromDefinition(clientName, key, node));
284
+ });
285
+ return `class ${serviceName}(
286
+ private val httpClient: HttpClient,
287
+ private val baseUrl: string = "",
288
+ private val headers: Map<String, String> = mutableMapOf()
289
+ ) {
290
+ ${subServiceParts.map(
291
+ (service) => `val ${service.key} = ${service.name}(httpClient, baseUrl, headers)`
292
+ ).join("\n")}
293
+ ${rpcParts.join("\n")}
294
+ }
295
+ ${subServiceParts.map((service) => service.content).join("\n")}`;
296
+ }
297
+ function createKotlinRpcFromDefinition(clientName, name, def) {
298
+ const paramStr = def.params ? `params: ${app.pascalCase(def.params)}` : "";
299
+ const responseStr = def.response ? app.pascalCase(`${clientName}_${def.response}`) : "";
300
+ return `suspend fun ${app.camelCase(name)}(${paramStr}): ${responseStr} {
301
+ ${responseStr ? "val response = " : ""}handleRequest(
302
+ httpClient,
303
+ "\${baseUrl}${def.path}",
304
+ HttpMethod.${def.method.toUpperCase()},
305
+ ${paramStr.length ? `Json.encodeToJsonElement(params),
306
+ ` : ""}headers
307
+ )
308
+ ${responseStr ? `return Json.decodeFromString(${responseStr}.serializer(), response.body())` : ""}
309
+ }`;
310
+ }
311
+ function createKotlinModelFromDefinition(name, def) {
312
+ const finalName = app.pascalCase(name);
313
+ const requiredProps = def.required ?? [];
314
+ const fieldParts = [];
315
+ Object.keys(def.properties).forEach((key) => {
316
+ const isRequired = requiredProps.includes(key);
317
+ const prop = def.properties[key];
318
+ if (app.isJsonSchemaObject(prop)) {
319
+ const subModelName = app.pascalCase(`${name}_${key}`);
320
+ createKotlinModelFromDefinition(
321
+ subModelName,
322
+ prop
323
+ );
324
+ fieldParts.push(
325
+ isRequired ? `val ${key}: ${subModelName}` : `val ${key} ${subModelName}?`
326
+ );
327
+ return;
328
+ }
329
+ if (app.isJsonSchemaScalarType(prop)) {
330
+ switch (prop.type) {
331
+ case "string":
332
+ case "Date":
333
+ fieldParts.push(
334
+ isRequired ? `val ${key}: String` : `val ${key}: String?`
335
+ );
336
+ break;
337
+ case "bigint":
338
+ case "integer":
339
+ fieldParts.push(
340
+ isRequired ? `val ${key}: Int` : `val ${key}: Int?`
341
+ );
342
+ break;
343
+ case "number":
344
+ fieldParts.push(
345
+ isRequired ? `val ${key}: Double` : `val ${key}: Double?`
346
+ );
347
+ break;
348
+ case "boolean":
349
+ fieldParts.push(
350
+ isRequired ? `val ${key}: Boolean` : `val ${key}: Boolean?`
351
+ );
352
+ break;
353
+ }
354
+ return;
355
+ }
356
+ if (app.isJsonSchemaEnum(prop)) {
357
+ return;
358
+ }
359
+ if (app.isJsonSchemaNullType(prop)) {
360
+ return;
361
+ }
362
+ if (app.isJsonSchemaArray(prop)) {
363
+ if (app.isJsonSchemaScalarType(prop.items)) {
364
+ switch (prop.items.type) {
365
+ case "string":
366
+ case "Date":
367
+ fieldParts.push(
368
+ isRequired ? `val ${key}: List<String>` : `val ${key}: List<String>?`
369
+ );
370
+ break;
371
+ case "bigint":
372
+ case "integer":
373
+ fieldParts.push(
374
+ isRequired ? `val ${key}: Int` : `val ${key}: Int?`
375
+ );
376
+ break;
377
+ case "boolean":
378
+ fieldParts.push(
379
+ isRequired ? `val ${key}: Boolean` : `val ${key}: Boolean?`
380
+ );
381
+ break;
382
+ case "number":
383
+ fieldParts.push(
384
+ isRequired ? `val ${key}: Double` : `val ${key}: Double`
385
+ );
386
+ break;
387
+ }
388
+ }
389
+ }
390
+ });
391
+ return `@Serializable
392
+ data class ${finalName}(
393
+ ${fieldParts.join("\n")}
394
+ )`;
395
+ }
396
+ function importStr(packageName) {
397
+ return `package ${packageName}
398
+
399
+ import io.ktor.client.HttpClient
400
+ import io.ktor.client.call.body
401
+ import io.ktor.client.request.delete
402
+ import io.ktor.client.request.get
403
+ import io.ktor.client.request.head
404
+ import io.ktor.client.request.patch
405
+ import io.ktor.client.request.post
406
+ import io.ktor.client.request.put
407
+ import io.ktor.client.request.setBody
408
+ import io.ktor.client.statement.HttpResponse
409
+ import io.ktor.http.headers
410
+ import kotlinx.serialization.SerialName
411
+ import kotlinx.serialization.Serializable
412
+ import kotlinx.serialization.json.Json
413
+ import kotlinx.serialization.json.JsonElement
414
+ import kotlinx.serialization.json.encodeToJsonElement
415
+ import kotlinx.serialization.json.jsonObject`;
416
+ }
417
+ const handleRequestFnString = `private suspend fun handleRequest(
418
+ client: HttpClient,
419
+ url: String,
420
+ method: HttpMethod,
421
+ params: JsonElement?,
422
+ headers: Map<String, String>?,
423
+ ): HttpResponse {
424
+ var finalUrl = url;
425
+ var finalBody = ""
426
+ when (method) {
427
+ HttpMethod.GET, HttpMethod.HEAD -> {
428
+ var queryParts = mutableListOf<String>()
429
+ params?.jsonObject?.entries?.forEach {
430
+ queryParts.add("\${it.key}=\${it.value.toString()}")
431
+ }
432
+ finalUrl = "$finalUrl?\${queryParts.joinToString("&")}"
433
+ }
434
+
435
+ HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH, HttpMethod.DELETE -> {
436
+ finalBody = params?.toString() ?: ""
437
+ }
438
+ }
439
+ return when (method) {
440
+ HttpMethod.GET -> client.get(finalUrl) {
441
+ headers {
442
+ headers?.entries?.forEach {
443
+ append(it.key, it.value)
444
+ }
445
+ }
446
+ }
447
+
448
+ HttpMethod.HEAD -> client.head(finalUrl) {
449
+ headers {
450
+ headers?.entries?.forEach {
451
+ append(it.key, it.value)
452
+ }
453
+ }
454
+ }
455
+
456
+ HttpMethod.POST -> client.post(finalUrl) {
457
+ headers {
458
+ headers?.entries?.forEach {
459
+ append(it.key, it.value)
460
+ }
461
+ }
462
+ setBody(finalBody)
463
+ }
464
+
465
+ HttpMethod.PUT -> client.put(finalUrl) {
466
+ headers {
467
+ headers?.entries?.forEach {
468
+ append(it.key, it.value)
469
+ }
470
+ }
471
+ setBody(finalBody)
472
+ }
473
+
474
+ HttpMethod.PATCH -> client.patch(finalUrl) {
475
+ headers {
476
+ headers?.entries?.forEach {
477
+ append(it.key, it.value)
478
+ }
479
+ }
480
+ setBody(finalBody)
481
+ }
482
+
483
+ HttpMethod.DELETE -> client.delete(finalUrl) {
484
+ headers {
485
+ headers?.entries?.forEach {
486
+ append(it.key, it.value)
487
+ }
488
+ }
489
+ setBody(finalBody)
490
+ }
491
+ }
492
+ }`;
493
+
494
+ exports.JsonSchemaComplexTypeValues = app.JsonSchemaComplexTypeValues;
495
+ exports.JsonSchemaNullTypeValues = app.JsonSchemaNullTypeValues;
496
+ exports.JsonSchemaScalarTypeValues = app.JsonSchemaScalarTypeValues;
497
+ exports.isApplicationDef = app.isApplicationDef;
498
+ exports.isJsonSchemaArray = app.isJsonSchemaArray;
499
+ exports.isJsonSchemaEnum = app.isJsonSchemaEnum;
500
+ exports.isJsonSchemaNullType = app.isJsonSchemaNullType;
501
+ exports.isJsonSchemaObject = app.isJsonSchemaObject;
502
+ exports.isJsonSchemaScalarType = app.isJsonSchemaScalarType;
503
+ exports.isProcedureDef = app.isProcedureDef;
504
+ exports.isServiceDef = app.isServiceDef;
505
+ exports.normalizeWhitespace = app.normalizeWhitespace;
506
+ exports.removeDisallowedChars = app.removeDisallowedChars;
507
+ exports.setNestedObjectProperty = app.setNestedObjectProperty;
508
+ exports.unflattenObject = app.unflattenObject;
509
+ exports.unflattenProcedures = app.unflattenProcedures;
238
510
  exports.classListTransformer = dart.classListTransformer;
239
511
  exports.classTransformer = dart.classTransformer;
240
512
  exports.createDartClient = dart.createDartClient;
@@ -248,7 +520,12 @@ exports.defineClientGeneratorPlugin = dart.defineClientGeneratorPlugin;
248
520
  exports.isDartType = dart.isDartType;
249
521
  exports.isDartTypeWithNullables = dart.isDartTypeWithNullables;
250
522
  exports.transformers = dart.transformers;
523
+ exports.createKotlinClient = createKotlinClient;
524
+ exports.createKotlinModelFromDefinition = createKotlinModelFromDefinition;
525
+ exports.createKotlinRpcFromDefinition = createKotlinRpcFromDefinition;
526
+ exports.createKotlinServiceFromDefinition = createKotlinServiceFromDefinition;
251
527
  exports.createTypescriptClient = createTypescriptClient;
528
+ exports.kotlinClientGenerator = kotlinClientGenerator;
252
529
  exports.tsModelFromDefinition = tsModelFromDefinition;
253
530
  exports.tsRpcFromProcedureDefinition = tsRpcFromProcedureDefinition;
254
531
  exports.tsServiceFromServiceDefinition = tsServiceFromServiceDefinition;
@@ -1,22 +1,16 @@
1
- import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.2ff96786.cjs';
1
+ import { B as ClientGeneratorPlugin, F as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.b176bba1.cjs';
2
+ export { C as ClientGenerator, a4 as JsonSchemaArray, a2 as JsonSchemaComplexType, X as JsonSchemaComplexTypeValues, a7 as JsonSchemaEnum, a0 as JsonSchemaNullType, W as JsonSchemaNullTypeValues, _ as JsonSchemaScalarType, V as JsonSchemaScalarTypeValues, Y as JsonSchemaType, Z as JsonSchemaTypeValue, a6 as JsonSchemaUint8Array, G as defineClientGeneratorPlugin, N as isApplicationDef, a5 as isJsonSchemaArray, a8 as isJsonSchemaEnum, a1 as isJsonSchemaNullType, a3 as isJsonSchemaObject, $ as isJsonSchemaScalarType, K as isProcedureDef, L as isServiceDef, I as normalizeWhitespace, U as removeDisallowedChars, T as setNestedObjectProperty, O as unflattenObject, Q as unflattenProcedures } from './shared/arri.b176bba1.cjs';
2
3
  import '@sinclair/typebox';
3
4
  import 'h3';
4
5
 
5
- interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
6
- generator: (def: ApplicationDefinition) => any;
7
- options: TOptions;
8
- }
9
- type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
10
- declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
11
-
12
6
  interface TypescriptClientGeneratorOptions {
13
7
  clientName: string;
14
8
  outputFile: string;
15
9
  }
16
10
  declare const typescriptClientGenerator: ClientGeneratorPlugin<TypescriptClientGeneratorOptions>;
17
- declare function createTypescriptClient(def: ApplicationDefinition, prefix?: string): Promise<string>;
18
- declare function tsServiceFromServiceDefinition(name: string, def: ServiceDefinition): string;
19
- declare function tsRpcFromProcedureDefinition(name: string, def: ProcedureDefinition): string;
11
+ declare function createTypescriptClient(def: ApplicationDef, prefix?: string): Promise<string>;
12
+ declare function tsServiceFromServiceDefinition(name: string, def: ServiceDef): string;
13
+ declare function tsRpcFromProcedureDefinition(name: string, def: ProcedureDef): string;
20
14
  declare function tsModelFromDefinition(name: string, def: JsonSchemaObject): string;
21
15
 
22
16
  interface DartClientGeneratorOptions {
@@ -27,9 +21,9 @@ declare const dartClientGenerator: ClientGeneratorPlugin<DartClientGeneratorOpti
27
21
  interface CreateClientOptions {
28
22
  clientName: string;
29
23
  }
30
- declare function createDartClient(appDef: ApplicationDefinition, opts?: CreateClientOptions): string;
31
- declare function dartServiceFromServiceDefinition(name: string, def: ServiceDefinition, opts: CreateClientOptions): string;
32
- declare function dartProcedureFromServiceDefinition(key: string, def: ProcedureDefinition, opts: CreateClientOptions): string;
24
+ declare function createDartClient(appDef: ApplicationDef, opts?: CreateClientOptions): string;
25
+ declare function dartServiceFromServiceDefinition(name: string, def: ServiceDef, opts: CreateClientOptions): string;
26
+ declare function dartProcedureFromServiceDefinition(key: string, def: ProcedureDef, opts: CreateClientOptions): string;
33
27
  declare function dartModelFromJsonSchema(modelName: string, schema: JsonSchemaObject, opts: CreateClientOptions): string;
34
28
  declare function dartPropertyTypeFromSchema(objectName: string, propertyName: string, schema: JsonSchemaObject, opts: CreateClientOptions): [DartType | string, string[] | undefined];
35
29
  declare function dartParsedJsonField(fieldName: string, jsonKey: string, dartType: string): string;
@@ -61,4 +55,18 @@ type DartTypeWithNullables = DartType | Exclude<`${DartType}?`, "null?">;
61
55
  declare function isDartType(input: any): input is DartType;
62
56
  declare function isDartTypeWithNullables(input: any): input is DartTypeWithNullables;
63
57
 
64
- export { type ClientGenerator, type ClientGeneratorPlugin, type DartBaseType, type DartClientGeneratorOptions, type DartType, type DartTypeWithNullables, classListTransformer, classTransformer, createDartClient, createTypescriptClient, dartClientGenerator, dartModelFromJsonSchema, dartParsedJsonField, dartProcedureFromServiceDefinition, dartPropertyTypeFromSchema, dartServiceFromServiceDefinition, defineClientGeneratorPlugin, isDartType, isDartTypeWithNullables, transformers, tsModelFromDefinition, tsRpcFromProcedureDefinition, tsServiceFromServiceDefinition, typescriptClientGenerator };
58
+ interface KotlinClientGeneratorOptions {
59
+ clientName: string;
60
+ outFile: string;
61
+ /**
62
+ * @example com.example.myapplication
63
+ */
64
+ packageName: string;
65
+ }
66
+ declare const kotlinClientGenerator: ClientGeneratorPlugin<KotlinClientGeneratorOptions>;
67
+ declare function createKotlinClient(def: ApplicationDef, clientName: string, packageName: string): string;
68
+ declare function createKotlinServiceFromDefinition(clientName: string, serviceName: string, def: ServiceDef): string;
69
+ declare function createKotlinRpcFromDefinition(clientName: string, name: string, def: ProcedureDef): string;
70
+ declare function createKotlinModelFromDefinition(name: string, def: JsonSchemaObject): string;
71
+
72
+ export { ApplicationDef, ClientGeneratorPlugin, type DartBaseType, type DartClientGeneratorOptions, type DartType, type DartTypeWithNullables, JsonSchemaObject, ProcedureDef, ServiceDef, classListTransformer, classTransformer, createDartClient, createKotlinClient, createKotlinModelFromDefinition, createKotlinRpcFromDefinition, createKotlinServiceFromDefinition, createTypescriptClient, dartClientGenerator, dartModelFromJsonSchema, dartParsedJsonField, dartProcedureFromServiceDefinition, dartPropertyTypeFromSchema, dartServiceFromServiceDefinition, isDartType, isDartTypeWithNullables, kotlinClientGenerator, transformers, tsModelFromDefinition, tsRpcFromProcedureDefinition, tsServiceFromServiceDefinition, typescriptClientGenerator };
@@ -1,22 +1,16 @@
1
- import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.2ff96786.mjs';
1
+ import { B as ClientGeneratorPlugin, F as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.b176bba1.mjs';
2
+ export { C as ClientGenerator, a4 as JsonSchemaArray, a2 as JsonSchemaComplexType, X as JsonSchemaComplexTypeValues, a7 as JsonSchemaEnum, a0 as JsonSchemaNullType, W as JsonSchemaNullTypeValues, _ as JsonSchemaScalarType, V as JsonSchemaScalarTypeValues, Y as JsonSchemaType, Z as JsonSchemaTypeValue, a6 as JsonSchemaUint8Array, G as defineClientGeneratorPlugin, N as isApplicationDef, a5 as isJsonSchemaArray, a8 as isJsonSchemaEnum, a1 as isJsonSchemaNullType, a3 as isJsonSchemaObject, $ as isJsonSchemaScalarType, K as isProcedureDef, L as isServiceDef, I as normalizeWhitespace, U as removeDisallowedChars, T as setNestedObjectProperty, O as unflattenObject, Q as unflattenProcedures } from './shared/arri.b176bba1.mjs';
2
3
  import '@sinclair/typebox';
3
4
  import 'h3';
4
5
 
5
- interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
6
- generator: (def: ApplicationDefinition) => any;
7
- options: TOptions;
8
- }
9
- type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
10
- declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
11
-
12
6
  interface TypescriptClientGeneratorOptions {
13
7
  clientName: string;
14
8
  outputFile: string;
15
9
  }
16
10
  declare const typescriptClientGenerator: ClientGeneratorPlugin<TypescriptClientGeneratorOptions>;
17
- declare function createTypescriptClient(def: ApplicationDefinition, prefix?: string): Promise<string>;
18
- declare function tsServiceFromServiceDefinition(name: string, def: ServiceDefinition): string;
19
- declare function tsRpcFromProcedureDefinition(name: string, def: ProcedureDefinition): string;
11
+ declare function createTypescriptClient(def: ApplicationDef, prefix?: string): Promise<string>;
12
+ declare function tsServiceFromServiceDefinition(name: string, def: ServiceDef): string;
13
+ declare function tsRpcFromProcedureDefinition(name: string, def: ProcedureDef): string;
20
14
  declare function tsModelFromDefinition(name: string, def: JsonSchemaObject): string;
21
15
 
22
16
  interface DartClientGeneratorOptions {
@@ -27,9 +21,9 @@ declare const dartClientGenerator: ClientGeneratorPlugin<DartClientGeneratorOpti
27
21
  interface CreateClientOptions {
28
22
  clientName: string;
29
23
  }
30
- declare function createDartClient(appDef: ApplicationDefinition, opts?: CreateClientOptions): string;
31
- declare function dartServiceFromServiceDefinition(name: string, def: ServiceDefinition, opts: CreateClientOptions): string;
32
- declare function dartProcedureFromServiceDefinition(key: string, def: ProcedureDefinition, opts: CreateClientOptions): string;
24
+ declare function createDartClient(appDef: ApplicationDef, opts?: CreateClientOptions): string;
25
+ declare function dartServiceFromServiceDefinition(name: string, def: ServiceDef, opts: CreateClientOptions): string;
26
+ declare function dartProcedureFromServiceDefinition(key: string, def: ProcedureDef, opts: CreateClientOptions): string;
33
27
  declare function dartModelFromJsonSchema(modelName: string, schema: JsonSchemaObject, opts: CreateClientOptions): string;
34
28
  declare function dartPropertyTypeFromSchema(objectName: string, propertyName: string, schema: JsonSchemaObject, opts: CreateClientOptions): [DartType | string, string[] | undefined];
35
29
  declare function dartParsedJsonField(fieldName: string, jsonKey: string, dartType: string): string;
@@ -61,4 +55,18 @@ type DartTypeWithNullables = DartType | Exclude<`${DartType}?`, "null?">;
61
55
  declare function isDartType(input: any): input is DartType;
62
56
  declare function isDartTypeWithNullables(input: any): input is DartTypeWithNullables;
63
57
 
64
- export { type ClientGenerator, type ClientGeneratorPlugin, type DartBaseType, type DartClientGeneratorOptions, type DartType, type DartTypeWithNullables, classListTransformer, classTransformer, createDartClient, createTypescriptClient, dartClientGenerator, dartModelFromJsonSchema, dartParsedJsonField, dartProcedureFromServiceDefinition, dartPropertyTypeFromSchema, dartServiceFromServiceDefinition, defineClientGeneratorPlugin, isDartType, isDartTypeWithNullables, transformers, tsModelFromDefinition, tsRpcFromProcedureDefinition, tsServiceFromServiceDefinition, typescriptClientGenerator };
58
+ interface KotlinClientGeneratorOptions {
59
+ clientName: string;
60
+ outFile: string;
61
+ /**
62
+ * @example com.example.myapplication
63
+ */
64
+ packageName: string;
65
+ }
66
+ declare const kotlinClientGenerator: ClientGeneratorPlugin<KotlinClientGeneratorOptions>;
67
+ declare function createKotlinClient(def: ApplicationDef, clientName: string, packageName: string): string;
68
+ declare function createKotlinServiceFromDefinition(clientName: string, serviceName: string, def: ServiceDef): string;
69
+ declare function createKotlinRpcFromDefinition(clientName: string, name: string, def: ProcedureDef): string;
70
+ declare function createKotlinModelFromDefinition(name: string, def: JsonSchemaObject): string;
71
+
72
+ export { ApplicationDef, ClientGeneratorPlugin, type DartBaseType, type DartClientGeneratorOptions, type DartType, type DartTypeWithNullables, JsonSchemaObject, ProcedureDef, ServiceDef, classListTransformer, classTransformer, createDartClient, createKotlinClient, createKotlinModelFromDefinition, createKotlinRpcFromDefinition, createKotlinServiceFromDefinition, createTypescriptClient, dartClientGenerator, dartModelFromJsonSchema, dartParsedJsonField, dartProcedureFromServiceDefinition, dartPropertyTypeFromSchema, dartServiceFromServiceDefinition, isDartType, isDartTypeWithNullables, kotlinClientGenerator, transformers, tsModelFromDefinition, tsRpcFromProcedureDefinition, tsServiceFromServiceDefinition, typescriptClientGenerator };
package/dist/codegen.d.ts CHANGED
@@ -1,22 +1,16 @@
1
- import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.2ff96786.js';
1
+ import { B as ClientGeneratorPlugin, F as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.b176bba1.js';
2
+ export { C as ClientGenerator, a4 as JsonSchemaArray, a2 as JsonSchemaComplexType, X as JsonSchemaComplexTypeValues, a7 as JsonSchemaEnum, a0 as JsonSchemaNullType, W as JsonSchemaNullTypeValues, _ as JsonSchemaScalarType, V as JsonSchemaScalarTypeValues, Y as JsonSchemaType, Z as JsonSchemaTypeValue, a6 as JsonSchemaUint8Array, G as defineClientGeneratorPlugin, N as isApplicationDef, a5 as isJsonSchemaArray, a8 as isJsonSchemaEnum, a1 as isJsonSchemaNullType, a3 as isJsonSchemaObject, $ as isJsonSchemaScalarType, K as isProcedureDef, L as isServiceDef, I as normalizeWhitespace, U as removeDisallowedChars, T as setNestedObjectProperty, O as unflattenObject, Q as unflattenProcedures } from './shared/arri.b176bba1.js';
2
3
  import '@sinclair/typebox';
3
4
  import 'h3';
4
5
 
5
- interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
6
- generator: (def: ApplicationDefinition) => any;
7
- options: TOptions;
8
- }
9
- type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
10
- declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
11
-
12
6
  interface TypescriptClientGeneratorOptions {
13
7
  clientName: string;
14
8
  outputFile: string;
15
9
  }
16
10
  declare const typescriptClientGenerator: ClientGeneratorPlugin<TypescriptClientGeneratorOptions>;
17
- declare function createTypescriptClient(def: ApplicationDefinition, prefix?: string): Promise<string>;
18
- declare function tsServiceFromServiceDefinition(name: string, def: ServiceDefinition): string;
19
- declare function tsRpcFromProcedureDefinition(name: string, def: ProcedureDefinition): string;
11
+ declare function createTypescriptClient(def: ApplicationDef, prefix?: string): Promise<string>;
12
+ declare function tsServiceFromServiceDefinition(name: string, def: ServiceDef): string;
13
+ declare function tsRpcFromProcedureDefinition(name: string, def: ProcedureDef): string;
20
14
  declare function tsModelFromDefinition(name: string, def: JsonSchemaObject): string;
21
15
 
22
16
  interface DartClientGeneratorOptions {
@@ -27,9 +21,9 @@ declare const dartClientGenerator: ClientGeneratorPlugin<DartClientGeneratorOpti
27
21
  interface CreateClientOptions {
28
22
  clientName: string;
29
23
  }
30
- declare function createDartClient(appDef: ApplicationDefinition, opts?: CreateClientOptions): string;
31
- declare function dartServiceFromServiceDefinition(name: string, def: ServiceDefinition, opts: CreateClientOptions): string;
32
- declare function dartProcedureFromServiceDefinition(key: string, def: ProcedureDefinition, opts: CreateClientOptions): string;
24
+ declare function createDartClient(appDef: ApplicationDef, opts?: CreateClientOptions): string;
25
+ declare function dartServiceFromServiceDefinition(name: string, def: ServiceDef, opts: CreateClientOptions): string;
26
+ declare function dartProcedureFromServiceDefinition(key: string, def: ProcedureDef, opts: CreateClientOptions): string;
33
27
  declare function dartModelFromJsonSchema(modelName: string, schema: JsonSchemaObject, opts: CreateClientOptions): string;
34
28
  declare function dartPropertyTypeFromSchema(objectName: string, propertyName: string, schema: JsonSchemaObject, opts: CreateClientOptions): [DartType | string, string[] | undefined];
35
29
  declare function dartParsedJsonField(fieldName: string, jsonKey: string, dartType: string): string;
@@ -61,4 +55,18 @@ type DartTypeWithNullables = DartType | Exclude<`${DartType}?`, "null?">;
61
55
  declare function isDartType(input: any): input is DartType;
62
56
  declare function isDartTypeWithNullables(input: any): input is DartTypeWithNullables;
63
57
 
64
- export { type ClientGenerator, type ClientGeneratorPlugin, type DartBaseType, type DartClientGeneratorOptions, type DartType, type DartTypeWithNullables, classListTransformer, classTransformer, createDartClient, createTypescriptClient, dartClientGenerator, dartModelFromJsonSchema, dartParsedJsonField, dartProcedureFromServiceDefinition, dartPropertyTypeFromSchema, dartServiceFromServiceDefinition, defineClientGeneratorPlugin, isDartType, isDartTypeWithNullables, transformers, tsModelFromDefinition, tsRpcFromProcedureDefinition, tsServiceFromServiceDefinition, typescriptClientGenerator };
58
+ interface KotlinClientGeneratorOptions {
59
+ clientName: string;
60
+ outFile: string;
61
+ /**
62
+ * @example com.example.myapplication
63
+ */
64
+ packageName: string;
65
+ }
66
+ declare const kotlinClientGenerator: ClientGeneratorPlugin<KotlinClientGeneratorOptions>;
67
+ declare function createKotlinClient(def: ApplicationDef, clientName: string, packageName: string): string;
68
+ declare function createKotlinServiceFromDefinition(clientName: string, serviceName: string, def: ServiceDef): string;
69
+ declare function createKotlinRpcFromDefinition(clientName: string, name: string, def: ProcedureDef): string;
70
+ declare function createKotlinModelFromDefinition(name: string, def: JsonSchemaObject): string;
71
+
72
+ export { ApplicationDef, ClientGeneratorPlugin, type DartBaseType, type DartClientGeneratorOptions, type DartType, type DartTypeWithNullables, JsonSchemaObject, ProcedureDef, ServiceDef, classListTransformer, classTransformer, createDartClient, createKotlinClient, createKotlinModelFromDefinition, createKotlinRpcFromDefinition, createKotlinServiceFromDefinition, createTypescriptClient, dartClientGenerator, dartModelFromJsonSchema, dartParsedJsonField, dartProcedureFromServiceDefinition, dartPropertyTypeFromSchema, dartServiceFromServiceDefinition, isDartType, isDartTypeWithNullables, kotlinClientGenerator, transformers, tsModelFromDefinition, tsRpcFromProcedureDefinition, tsServiceFromServiceDefinition, typescriptClientGenerator };