arri 0.0.44 → 0.1.0-beta.2

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/dist/codegen.cjs CHANGED
@@ -1,528 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const require$$0 = require('fs');
4
- const prettier = require('prettier');
5
- const utils = require('./shared/arri.0752aa2b.cjs');
6
- const dart = require('./shared/arri.bda2f011.cjs');
7
- require('child_process');
3
+ const arriCodegenDart = require('arri-codegen-dart');
4
+ const arriCodegenTs = require('arri-codegen-ts');
8
5
 
9
- let generatedModels = [];
10
- const typescriptClientGenerator = dart.defineClientGeneratorPlugin(
11
- (options) => ({
12
- generator: async (def) => {
13
- if (!options.clientName) {
14
- throw new Error("Name is requires");
15
- }
16
- if (!options.outputFile) {
17
- throw new Error("No output file specified");
18
- }
19
- if (Object.keys(def.procedures).length <= 0) {
20
- throw new Error(
21
- "No procedures found in definition file. Typescript client will not be generated."
22
- );
23
- }
24
- const result = await createTypescriptClient(
25
- def,
26
- options.clientName
27
- );
28
- require$$0.writeFileSync(options.outputFile, result);
29
- },
30
- options
31
- })
32
- );
33
- async function createTypescriptClient(def, prefix = "Client") {
34
- generatedModels = [];
35
- const services = utils.unflattenObject(def.procedures);
36
- const serviceParts = [];
37
- const procedureParts = [];
38
- const modelParts = [];
39
- Object.keys(services).forEach((key) => {
40
- const item = services[key];
41
- if (utils.isServiceDef(item)) {
42
- const serviceName = utils.pascalCase(`${prefix}_${key}_service`);
43
- serviceParts.push({
44
- name: serviceName,
45
- key,
46
- content: tsServiceFromServiceDefinition(serviceName, item)
47
- });
48
- return;
49
- }
50
- procedureParts.push(tsRpcFromProcedureDefinition(key, item));
51
- });
52
- Object.keys(def.models).forEach((key) => {
53
- const modelName = utils.pascalCase(`${key}`);
54
- if (!generatedModels.includes(modelName)) {
55
- modelParts.push(tsModelFromDefinition(modelName, def.models[key]));
56
- generatedModels.push(modelName);
57
- }
58
- });
59
- return prettier.format(
60
- `/* eslint-disable */
61
- import { arriRequest, ArriRequestError } from 'arri-client';
62
-
63
- export class ${prefix} {
64
- private baseUrl: string;
65
- private headers: Record<string, string>;
66
- ${serviceParts.map((service) => `${service.key}: ${service.name}`).join("\n")}
67
- constructor(opts: { baseUrl?: string; headers?: Record<string, string> }) {
68
- this.baseUrl = opts.baseUrl ?? "";
69
- this.headers = opts.headers ?? {};
70
- ${serviceParts.map(
71
- (service) => `this.${service.key} = new ${service.name}(opts);`
72
- ).join("\n")}
73
- }
74
6
 
75
- ${procedureParts.join("\n")}
76
- }
77
7
 
78
- ${serviceParts.map((service) => service.content).join("\n")}
79
- ${modelParts.join("\n")}`,
80
- {
81
- parser: "typescript"
82
- }
83
- );
84
- }
85
- function tsServiceFromServiceDefinition(name, def) {
86
- const rpcParts = [];
87
- const subServiceParts = [];
88
- Object.keys(def).forEach((key) => {
89
- const val = def[key];
90
- if (utils.isProcedureDef(val)) {
91
- rpcParts.push(tsRpcFromProcedureDefinition(key, val));
92
- return;
93
- }
94
- const subServiceName = utils.pascalCase(
95
- `${name.split("Service").join("")}_${key}_service`
96
- );
97
- subServiceParts.push({
98
- name: subServiceName,
99
- key,
100
- content: tsServiceFromServiceDefinition(subServiceName, val)
101
- });
102
- });
103
- return `export class ${name} {
104
- private baseUrl: string;
105
- private headers: Record<string, string>;
106
- ${subServiceParts.map((service) => `${service.key}: ${service.name};`).join("\n")}
107
- constructor(opts: { baseUrl?: string; headers?: Record<string, string> }) {
108
- this.baseUrl = opts.baseUrl ?? "";
109
- this.headers = opts.headers ?? {};
110
- ${subServiceParts.map(
111
- (service) => `this.${service.key} = new ${service.name}(opts);`
112
- ).join("\n")}
113
- }
114
- ${rpcParts.join("\n")}
115
- }
116
- ${subServiceParts.map((service) => service.content).join("\n")}`;
117
- }
118
- function tsRpcFromProcedureDefinition(name, def) {
119
- let paramStr = "";
120
- let responseName = "";
121
- if (def.params) {
122
- paramStr = `params: ${def.params}`;
123
- }
124
- if (def.response) {
125
- responseName = def.response;
126
- }
127
- return `async ${name}(${paramStr}) {
128
- return arriRequest<${responseName || "undefined"}>({
129
- url: \`\${this.baseUrl}${def.path}\`,
130
- method: '${def.method}',
131
- ${paramStr.length ? `params,` : ""}
132
- headers: this.headers,
133
- });
134
- }`;
135
- }
136
- function tsModelFromDefinition(name, def) {
137
- const fieldParts = [];
138
- const subModelParts = [];
139
- Object.keys(def.properties ?? {}).forEach((key) => {
140
- const isOptional = !def.required?.includes(key);
141
- const prop = def.properties?.[key];
142
- const keyPart = isOptional ? `${key}?` : key;
143
- if (dart.isJsonSchemaScalarType(prop)) {
144
- fieldParts.push(
145
- tsInterfaceScalarField(key, prop, isOptional) ?? ""
146
- );
147
- return;
148
- }
149
- if (dart.isJsonSchemaNullType(prop)) {
150
- switch (prop.type) {
151
- case "null":
152
- fieldParts.push(`${keyPart}: null;`);
153
- break;
154
- case "undefined":
155
- fieldParts.push(`${keyPart}: undefined`);
156
- break;
157
- }
158
- return;
159
- }
160
- if (dart.isJsonSchemaObject(prop)) {
161
- const subModelName = prop.$id ?? utils.pascalCase(`${name}_${key}`);
162
- if (!generatedModels.includes(subModelName)) {
163
- const content = tsModelFromDefinition(
164
- subModelName,
165
- prop
166
- );
167
- subModelParts.push(content);
168
- }
169
- fieldParts.push(`${keyPart}: ${subModelName};`);
170
- return;
171
- }
172
- if (dart.isJsonSchemaRecord(prop)) {
173
- fieldParts.push(`${keyPart}: any;`);
174
- }
175
- if (dart.isJsonSchemaEnum(prop)) {
176
- const vals = prop.anyOf.map(
177
- (opt) => opt.type === "string" ? `'${opt.const}'` : `${opt.const}`
178
- );
179
- fieldParts.push(`${keyPart}: ${vals.join(" | ")};`);
180
- return;
181
- }
182
- if (dart.isJsonSchemaArray(prop)) {
183
- if (dart.isJsonSchemaScalarType(prop.items)) {
184
- const part = tsInterfaceScalarField(
185
- key,
186
- prop.items,
187
- isOptional
188
- ).replace(";", "[];");
189
- fieldParts.push(part);
190
- return;
191
- }
192
- if (dart.isJsonSchemaNullType(prop.items)) {
193
- if (prop.items.type === "null") {
194
- fieldParts.push(`${keyPart}: null[]`);
195
- return;
196
- }
197
- fieldParts.push(`${keyPart}: undefined[]`);
198
- return;
199
- }
200
- if (dart.isJsonSchemaObject(prop.items)) {
201
- const subModelName = prop.items.$id ?? utils.pascalCase(`${name}_${key}_item`);
202
- if (!generatedModels.includes(subModelName)) {
203
- subModelParts.push(
204
- tsModelFromDefinition(subModelName, prop.items)
205
- );
206
- }
207
- fieldParts.push(`${keyPart}: ${subModelName}[];`);
208
- }
209
- }
210
- });
211
- return `export interface ${name} {
212
- ${fieldParts.join("\n")}
213
- }
214
- ${subModelParts.join("\n")}`;
215
- }
216
- function tsInterfaceScalarField(key, prop, isOptional = false) {
217
- const keyPart = isOptional ? `${key}?` : key;
218
- switch (prop.type) {
219
- case "string":
220
- return `${keyPart}: string;`;
221
- case "bigint":
222
- return `${keyPart}: bigint;`;
223
- case "Date":
224
- return `${keyPart}: Date;`;
225
- case "boolean":
226
- return `${keyPart}: boolean;`;
227
- case "integer":
228
- return `/**
229
- * must be an integer
230
- */
231
- ${keyPart}: number;`;
232
- case "number":
233
- return `${keyPart}: number;`;
234
- }
235
- }
236
-
237
- const kotlinClientGenerator = dart.defineClientGeneratorPlugin(function(options) {
238
- return {
239
- generator(def) {
240
- },
241
- options
242
- };
243
- });
244
- function createKotlinClient(def, clientName, packageName) {
245
- const procedures = utils.unflattenProcedures(def.procedures);
246
- const modelParts = [];
247
- Object.keys(def.models).forEach((key) => {
248
- const node = def.models[key];
249
- if (dart.isJsonSchemaObject(node)) {
250
- modelParts.push(
251
- createKotlinModelFromDefinition(
252
- utils.pascalCase(`${clientName}_${key}`),
253
- node
254
- )
255
- );
256
- }
257
- });
258
- return `${importStr(packageName)}
259
-
260
- ${createKotlinServiceFromDefinition(clientName, clientName, procedures)}
261
-
262
- ${handleRequestFnString}
263
- `;
264
- }
265
- function createKotlinServiceFromDefinition(clientName, serviceName, def) {
266
- const rpcParts = [];
267
- const subServiceParts = [];
268
- Object.keys(def).forEach((key) => {
269
- const node = def[key];
270
- if (utils.isServiceDef(node)) {
271
- const nameParts = serviceName.split("Service");
272
- nameParts.pop();
273
- const subServiceName = utils.pascalCase(
274
- `${nameParts.join("")}_${key}_service`
275
- );
276
- subServiceParts.push({
277
- name: subServiceName,
278
- key,
279
- content: createKotlinServiceFromDefinition(
280
- clientName,
281
- subServiceName,
282
- node
283
- )
284
- });
285
- return;
286
- }
287
- rpcParts.push(createKotlinRpcFromDefinition(clientName, key, node));
288
- });
289
- return `class ${serviceName}(
290
- private val httpClient: HttpClient,
291
- private val baseUrl: string = "",
292
- private val headers: Map<String, String> = mutableMapOf()
293
- ) {
294
- ${subServiceParts.map(
295
- (service) => `val ${service.key} = ${service.name}(httpClient, baseUrl, headers)`
296
- ).join("\n")}
297
- ${rpcParts.join("\n")}
298
- }
299
- ${subServiceParts.map((service) => service.content).join("\n")}`;
300
- }
301
- function createKotlinRpcFromDefinition(clientName, name, def) {
302
- const paramStr = def.params ? `params: ${utils.pascalCase(def.params)}` : "";
303
- const responseStr = def.response ? utils.pascalCase(`${clientName}_${def.response}`) : "";
304
- return `suspend fun ${utils.camelCase(name)}(${paramStr}): ${responseStr} {
305
- ${responseStr ? "val response = " : ""}handleRequest(
306
- httpClient,
307
- "\${baseUrl}${def.path}",
308
- HttpMethod.${def.method.toUpperCase()},
309
- ${paramStr.length ? `Json.encodeToJsonElement(params),
310
- ` : ""}headers
311
- )
312
- ${responseStr ? `return Json.decodeFromString(${responseStr}.serializer(), response.body())` : ""}
313
- }`;
314
- }
315
- function createKotlinModelFromDefinition(name, def) {
316
- const finalName = utils.pascalCase(name);
317
- const requiredProps = def.required ?? [];
318
- const fieldParts = [];
319
- Object.keys(def.properties).forEach((key) => {
320
- const isRequired = requiredProps.includes(key);
321
- const prop = def.properties[key];
322
- if (dart.isJsonSchemaObject(prop)) {
323
- const subModelName = utils.pascalCase(`${name}_${key}`);
324
- createKotlinModelFromDefinition(
325
- subModelName,
326
- prop
327
- );
328
- fieldParts.push(
329
- isRequired ? `val ${key}: ${subModelName}` : `val ${key} ${subModelName}?`
330
- );
331
- return;
332
- }
333
- if (dart.isJsonSchemaScalarType(prop)) {
334
- switch (prop.type) {
335
- case "string":
336
- case "Date":
337
- fieldParts.push(
338
- isRequired ? `val ${key}: String` : `val ${key}: String?`
339
- );
340
- break;
341
- case "bigint":
342
- case "integer":
343
- fieldParts.push(
344
- isRequired ? `val ${key}: Int` : `val ${key}: Int?`
345
- );
346
- break;
347
- case "number":
348
- fieldParts.push(
349
- isRequired ? `val ${key}: Double` : `val ${key}: Double?`
350
- );
351
- break;
352
- case "boolean":
353
- fieldParts.push(
354
- isRequired ? `val ${key}: Boolean` : `val ${key}: Boolean?`
355
- );
356
- break;
357
- }
358
- return;
359
- }
360
- if (dart.isJsonSchemaEnum(prop)) {
361
- return;
362
- }
363
- if (dart.isJsonSchemaNullType(prop)) {
364
- return;
365
- }
366
- if (dart.isJsonSchemaArray(prop)) {
367
- if (dart.isJsonSchemaScalarType(prop.items)) {
368
- switch (prop.items.type) {
369
- case "string":
370
- case "Date":
371
- fieldParts.push(
372
- isRequired ? `val ${key}: List<String>` : `val ${key}: List<String>?`
373
- );
374
- break;
375
- case "bigint":
376
- case "integer":
377
- fieldParts.push(
378
- isRequired ? `val ${key}: Int` : `val ${key}: Int?`
379
- );
380
- break;
381
- case "boolean":
382
- fieldParts.push(
383
- isRequired ? `val ${key}: Boolean` : `val ${key}: Boolean?`
384
- );
385
- break;
386
- case "number":
387
- fieldParts.push(
388
- isRequired ? `val ${key}: Double` : `val ${key}: Double`
389
- );
390
- break;
391
- }
392
- }
393
- }
394
- });
395
- return `@Serializable
396
- data class ${finalName}(
397
- ${fieldParts.join("\n")}
398
- )`;
399
- }
400
- function importStr(packageName) {
401
- return `package ${packageName}
402
-
403
- import io.ktor.client.HttpClient
404
- import io.ktor.client.call.body
405
- import io.ktor.client.request.delete
406
- import io.ktor.client.request.get
407
- import io.ktor.client.request.head
408
- import io.ktor.client.request.patch
409
- import io.ktor.client.request.post
410
- import io.ktor.client.request.put
411
- import io.ktor.client.request.setBody
412
- import io.ktor.client.statement.HttpResponse
413
- import io.ktor.http.headers
414
- import kotlinx.serialization.SerialName
415
- import kotlinx.serialization.Serializable
416
- import kotlinx.serialization.json.Json
417
- import kotlinx.serialization.json.JsonElement
418
- import kotlinx.serialization.json.encodeToJsonElement
419
- import kotlinx.serialization.json.jsonObject`;
420
- }
421
- const handleRequestFnString = `private suspend fun handleRequest(
422
- client: HttpClient,
423
- url: String,
424
- method: HttpMethod,
425
- params: JsonElement?,
426
- headers: Map<String, String>?,
427
- ): HttpResponse {
428
- var finalUrl = url;
429
- var finalBody = ""
430
- when (method) {
431
- HttpMethod.GET, HttpMethod.HEAD -> {
432
- var queryParts = mutableListOf<String>()
433
- params?.jsonObject?.entries?.forEach {
434
- queryParts.add("\${it.key}=\${it.value.toString()}")
435
- }
436
- finalUrl = "$finalUrl?\${queryParts.joinToString("&")}"
437
- }
438
-
439
- HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH, HttpMethod.DELETE -> {
440
- finalBody = params?.toString() ?: ""
441
- }
442
- }
443
- return when (method) {
444
- HttpMethod.GET -> client.get(finalUrl) {
445
- headers {
446
- headers?.entries?.forEach {
447
- append(it.key, it.value)
448
- }
449
- }
450
- }
451
-
452
- HttpMethod.HEAD -> client.head(finalUrl) {
453
- headers {
454
- headers?.entries?.forEach {
455
- append(it.key, it.value)
456
- }
457
- }
458
- }
459
-
460
- HttpMethod.POST -> client.post(finalUrl) {
461
- headers {
462
- headers?.entries?.forEach {
463
- append(it.key, it.value)
464
- }
465
- }
466
- setBody(finalBody)
467
- }
468
-
469
- HttpMethod.PUT -> client.put(finalUrl) {
470
- headers {
471
- headers?.entries?.forEach {
472
- append(it.key, it.value)
473
- }
474
- }
475
- setBody(finalBody)
476
- }
477
-
478
- HttpMethod.PATCH -> client.patch(finalUrl) {
479
- headers {
480
- headers?.entries?.forEach {
481
- append(it.key, it.value)
482
- }
483
- }
484
- setBody(finalBody)
485
- }
486
-
487
- HttpMethod.DELETE -> client.delete(finalUrl) {
488
- headers {
489
- headers?.entries?.forEach {
490
- append(it.key, it.value)
491
- }
492
- }
493
- setBody(finalBody)
494
- }
495
- }
496
- }`;
497
-
498
- exports.isApplicationDef = utils.isApplicationDef;
499
- exports.isProcedureDef = utils.isProcedureDef;
500
- exports.isServiceDef = utils.isServiceDef;
501
- exports.normalizeWhitespace = utils.normalizeWhitespace;
502
- exports.removeDisallowedChars = utils.removeDisallowedChars;
503
- exports.setNestedObjectProperty = utils.setNestedObjectProperty;
504
- exports.unflattenObject = utils.unflattenObject;
505
- exports.unflattenProcedures = utils.unflattenProcedures;
506
- exports.classListTransformer = dart.classListTransformer;
507
- exports.classTransformer = dart.classTransformer;
508
- exports.createDartClient = dart.createDartClient;
509
- exports.dartClientGenerator = dart.dartClientGenerator;
510
- exports.dartModelFromJsonSchema = dart.dartModelFromJsonSchema;
511
- exports.dartParsedJsonField = dart.dartParsedJsonField;
512
- exports.dartProcedureFromServiceDefinition = dart.dartProcedureFromServiceDefinition;
513
- exports.dartPropertyTypeFromSchema = dart.dartPropertyTypeFromSchema;
514
- exports.dartServiceFromServiceDefinition = dart.dartServiceFromServiceDefinition;
515
- exports.defineClientGeneratorPlugin = dart.defineClientGeneratorPlugin;
516
- exports.isDartType = dart.isDartType;
517
- exports.isDartTypeWithNullables = dart.isDartTypeWithNullables;
518
- exports.transformers = dart.transformers;
519
- exports.createKotlinClient = createKotlinClient;
520
- exports.createKotlinModelFromDefinition = createKotlinModelFromDefinition;
521
- exports.createKotlinRpcFromDefinition = createKotlinRpcFromDefinition;
522
- exports.createKotlinServiceFromDefinition = createKotlinServiceFromDefinition;
523
- exports.createTypescriptClient = createTypescriptClient;
524
- exports.kotlinClientGenerator = kotlinClientGenerator;
525
- exports.tsModelFromDefinition = tsModelFromDefinition;
526
- exports.tsRpcFromProcedureDefinition = tsRpcFromProcedureDefinition;
527
- exports.tsServiceFromServiceDefinition = tsServiceFromServiceDefinition;
528
- exports.typescriptClientGenerator = typescriptClientGenerator;
8
+ exports.dartClientGenerator = arriCodegenDart.dartClientGenerator;
9
+ exports.typescriptClientGenerator = arriCodegenTs.typescriptClientGenerator;
@@ -1,71 +1,2 @@
1
- import { C as ClientGeneratorPlugin, A as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.4536bc49.cjs';
2
- export { a as ClientGenerator, d as defineClientGeneratorPlugin, c as isApplicationDef, i as isProcedureDef, b as isServiceDef, n as normalizeWhitespace, r as removeDisallowedChars, s as setNestedObjectProperty, u as unflattenObject, e as unflattenProcedures } from './shared/arri.4536bc49.cjs';
3
- import '@sinclair/typebox';
4
-
5
- interface TypescriptClientGeneratorOptions {
6
- clientName: string;
7
- outputFile: string;
8
- }
9
- declare const typescriptClientGenerator: ClientGeneratorPlugin<TypescriptClientGeneratorOptions>;
10
- declare function createTypescriptClient(def: ApplicationDef, prefix?: string): Promise<string>;
11
- declare function tsServiceFromServiceDefinition(name: string, def: ServiceDef): string;
12
- declare function tsRpcFromProcedureDefinition(name: string, def: ProcedureDef): string;
13
- declare function tsModelFromDefinition(name: string, def: JsonSchemaObject): string;
14
-
15
- interface DartClientGeneratorOptions {
16
- clientName: string;
17
- outputFile: string;
18
- }
19
- declare const dartClientGenerator: ClientGeneratorPlugin<DartClientGeneratorOptions>;
20
- interface CreateClientOptions {
21
- clientName: string;
22
- }
23
- declare function createDartClient(appDef: ApplicationDef, opts?: CreateClientOptions): string;
24
- declare function dartServiceFromServiceDefinition(name: string, def: ServiceDef, opts: CreateClientOptions): string;
25
- declare function dartProcedureFromServiceDefinition(key: string, def: ProcedureDef, opts: CreateClientOptions): string;
26
- declare function dartModelFromJsonSchema(modelName: string, schema: JsonSchemaObject, opts: CreateClientOptions): string;
27
- declare function dartPropertyTypeFromSchema(objectName: string, propertyName: string, schema: JsonSchemaObject, opts: CreateClientOptions): [DartType | string, string[] | undefined];
28
- declare function dartParsedJsonField(fieldName: string, jsonKey: string, dartType: string): string;
29
- declare const dartTypeMap: {
30
- readonly integer: "int";
31
- readonly bigint: "int";
32
- readonly number: "double";
33
- readonly string: "String";
34
- readonly boolean: "bool";
35
- readonly null: "null";
36
- readonly Date: "DateTime";
37
- readonly object: undefined;
38
- readonly list: undefined;
39
- readonly undefined: undefined;
40
- readonly array: undefined;
41
- readonly Uint8Array: "Uint8List";
42
- };
43
- interface DartMappedType {
44
- classBody?: string;
45
- fromJsonBody: (key: string, jsonKey: string, fallback: string) => string;
46
- toJsonBody: (key: string, jsonKey: string, isNullable?: boolean) => string;
47
- }
48
- declare const transformers: Record<DartType, DartMappedType>;
49
- declare const classTransformer: (typename: string, nullable: boolean) => DartMappedType;
50
- declare const classListTransformer: (typename: string) => DartMappedType;
51
- type DartBaseType = Exclude<(typeof dartTypeMap)[keyof typeof dartTypeMap], undefined>;
52
- type DartType = DartBaseType | `List<${DartBaseType}>`;
53
- type DartTypeWithNullables = DartType | Exclude<`${DartType}?`, "null?">;
54
- declare function isDartType(input: any): input is DartType;
55
- declare function isDartTypeWithNullables(input: any): input is DartTypeWithNullables;
56
-
57
- interface KotlinClientGeneratorOptions {
58
- clientName: string;
59
- outFile: string;
60
- /**
61
- * @example com.example.myapplication
62
- */
63
- packageName: string;
64
- }
65
- declare const kotlinClientGenerator: ClientGeneratorPlugin<KotlinClientGeneratorOptions>;
66
- declare function createKotlinClient(def: ApplicationDef, clientName: string, packageName: string): string;
67
- declare function createKotlinServiceFromDefinition(clientName: string, serviceName: string, def: ServiceDef): string;
68
- declare function createKotlinRpcFromDefinition(clientName: string, name: string, def: ProcedureDef): string;
69
- declare function createKotlinModelFromDefinition(name: string, def: JsonSchemaObject): string;
70
-
71
- export { ApplicationDef, ClientGeneratorPlugin, type DartBaseType, type DartClientGeneratorOptions, type DartType, type DartTypeWithNullables, 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
+ export { dartClientGenerator } from 'arri-codegen-dart';
2
+ export { typescriptClientGenerator } from 'arri-codegen-ts';
@@ -1,71 +1,2 @@
1
- import { C as ClientGeneratorPlugin, A as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.4536bc49.mjs';
2
- export { a as ClientGenerator, d as defineClientGeneratorPlugin, c as isApplicationDef, i as isProcedureDef, b as isServiceDef, n as normalizeWhitespace, r as removeDisallowedChars, s as setNestedObjectProperty, u as unflattenObject, e as unflattenProcedures } from './shared/arri.4536bc49.mjs';
3
- import '@sinclair/typebox';
4
-
5
- interface TypescriptClientGeneratorOptions {
6
- clientName: string;
7
- outputFile: string;
8
- }
9
- declare const typescriptClientGenerator: ClientGeneratorPlugin<TypescriptClientGeneratorOptions>;
10
- declare function createTypescriptClient(def: ApplicationDef, prefix?: string): Promise<string>;
11
- declare function tsServiceFromServiceDefinition(name: string, def: ServiceDef): string;
12
- declare function tsRpcFromProcedureDefinition(name: string, def: ProcedureDef): string;
13
- declare function tsModelFromDefinition(name: string, def: JsonSchemaObject): string;
14
-
15
- interface DartClientGeneratorOptions {
16
- clientName: string;
17
- outputFile: string;
18
- }
19
- declare const dartClientGenerator: ClientGeneratorPlugin<DartClientGeneratorOptions>;
20
- interface CreateClientOptions {
21
- clientName: string;
22
- }
23
- declare function createDartClient(appDef: ApplicationDef, opts?: CreateClientOptions): string;
24
- declare function dartServiceFromServiceDefinition(name: string, def: ServiceDef, opts: CreateClientOptions): string;
25
- declare function dartProcedureFromServiceDefinition(key: string, def: ProcedureDef, opts: CreateClientOptions): string;
26
- declare function dartModelFromJsonSchema(modelName: string, schema: JsonSchemaObject, opts: CreateClientOptions): string;
27
- declare function dartPropertyTypeFromSchema(objectName: string, propertyName: string, schema: JsonSchemaObject, opts: CreateClientOptions): [DartType | string, string[] | undefined];
28
- declare function dartParsedJsonField(fieldName: string, jsonKey: string, dartType: string): string;
29
- declare const dartTypeMap: {
30
- readonly integer: "int";
31
- readonly bigint: "int";
32
- readonly number: "double";
33
- readonly string: "String";
34
- readonly boolean: "bool";
35
- readonly null: "null";
36
- readonly Date: "DateTime";
37
- readonly object: undefined;
38
- readonly list: undefined;
39
- readonly undefined: undefined;
40
- readonly array: undefined;
41
- readonly Uint8Array: "Uint8List";
42
- };
43
- interface DartMappedType {
44
- classBody?: string;
45
- fromJsonBody: (key: string, jsonKey: string, fallback: string) => string;
46
- toJsonBody: (key: string, jsonKey: string, isNullable?: boolean) => string;
47
- }
48
- declare const transformers: Record<DartType, DartMappedType>;
49
- declare const classTransformer: (typename: string, nullable: boolean) => DartMappedType;
50
- declare const classListTransformer: (typename: string) => DartMappedType;
51
- type DartBaseType = Exclude<(typeof dartTypeMap)[keyof typeof dartTypeMap], undefined>;
52
- type DartType = DartBaseType | `List<${DartBaseType}>`;
53
- type DartTypeWithNullables = DartType | Exclude<`${DartType}?`, "null?">;
54
- declare function isDartType(input: any): input is DartType;
55
- declare function isDartTypeWithNullables(input: any): input is DartTypeWithNullables;
56
-
57
- interface KotlinClientGeneratorOptions {
58
- clientName: string;
59
- outFile: string;
60
- /**
61
- * @example com.example.myapplication
62
- */
63
- packageName: string;
64
- }
65
- declare const kotlinClientGenerator: ClientGeneratorPlugin<KotlinClientGeneratorOptions>;
66
- declare function createKotlinClient(def: ApplicationDef, clientName: string, packageName: string): string;
67
- declare function createKotlinServiceFromDefinition(clientName: string, serviceName: string, def: ServiceDef): string;
68
- declare function createKotlinRpcFromDefinition(clientName: string, name: string, def: ProcedureDef): string;
69
- declare function createKotlinModelFromDefinition(name: string, def: JsonSchemaObject): string;
70
-
71
- export { ApplicationDef, ClientGeneratorPlugin, type DartBaseType, type DartClientGeneratorOptions, type DartType, type DartTypeWithNullables, 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
+ export { dartClientGenerator } from 'arri-codegen-dart';
2
+ export { typescriptClientGenerator } from 'arri-codegen-ts';