arri 0.0.38 → 0.0.42

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.
@@ -0,0 +1,192 @@
1
+ 'use strict';
2
+
3
+ const NUMBER_CHAR_RE = /\d/;
4
+ const STR_SPLITTERS = ["-", "_", "/", "."];
5
+ function isUppercase(char = "") {
6
+ if (NUMBER_CHAR_RE.test(char)) {
7
+ return void 0;
8
+ }
9
+ return char.toUpperCase() === char;
10
+ }
11
+ function splitByCase(string_, separators) {
12
+ const splitters = separators ?? STR_SPLITTERS;
13
+ const parts = [];
14
+ if (!string_ || typeof string_ !== "string") {
15
+ return parts;
16
+ }
17
+ let buff = "";
18
+ let previousUpper;
19
+ let previousSplitter;
20
+ for (const char of string_) {
21
+ const isSplitter = splitters.includes(char);
22
+ if (isSplitter === true) {
23
+ parts.push(buff);
24
+ buff = "";
25
+ previousUpper = void 0;
26
+ continue;
27
+ }
28
+ const isUpper = isUppercase(char);
29
+ if (previousSplitter === false) {
30
+ if (previousUpper === false && isUpper === true) {
31
+ parts.push(buff);
32
+ buff = char;
33
+ previousUpper = isUpper;
34
+ continue;
35
+ }
36
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
37
+ const lastChar = buff[buff.length - 1];
38
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
39
+ buff = lastChar + char;
40
+ previousUpper = isUpper;
41
+ continue;
42
+ }
43
+ }
44
+ buff += char;
45
+ previousUpper = isUpper;
46
+ previousSplitter = isSplitter;
47
+ }
48
+ parts.push(buff);
49
+ return parts;
50
+ }
51
+ function upperFirst(string_) {
52
+ return !string_ ? "" : string_[0].toUpperCase() + string_.slice(1);
53
+ }
54
+ function lowerFirst(string_) {
55
+ return !string_ ? "" : string_[0].toLowerCase() + string_.slice(1);
56
+ }
57
+ function pascalCase(string_) {
58
+ return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => upperFirst(p)).join("");
59
+ }
60
+ function camelCase(string_) {
61
+ return lowerFirst(pascalCase(string_));
62
+ }
63
+ function kebabCase(string_, joiner) {
64
+ return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => p.toLowerCase()).join(joiner ?? "-");
65
+ }
66
+
67
+ const HttpMethodValues = [
68
+ "get",
69
+ "post",
70
+ "put",
71
+ "patch",
72
+ "delete",
73
+ "head"
74
+ ];
75
+ const isHttpMethod = (input) => {
76
+ if (typeof input !== "string") {
77
+ return false;
78
+ }
79
+ return HttpMethodValues.includes(input);
80
+ };
81
+
82
+ function normalizeWhitespace(input) {
83
+ if (input.includes("\n\n")) {
84
+ return normalizeWhitespace(input.split("\n\n").join("\n"));
85
+ }
86
+ const lines = [];
87
+ for (const line of input.split("\n")) {
88
+ lines.push(line.trim());
89
+ }
90
+ const result = lines.join("\n").trim();
91
+ if (result.includes("\n\n")) {
92
+ return normalizeWhitespace(result.split("\n\n").join("\n"));
93
+ }
94
+ return result;
95
+ }
96
+ function isProcedureDef(input) {
97
+ if (typeof input !== "object") {
98
+ return false;
99
+ }
100
+ const expectedKeys = ["path", "method"];
101
+ const existingKeys = Object.keys(input);
102
+ for (const key of expectedKeys) {
103
+ if (!existingKeys.includes(key)) {
104
+ return false;
105
+ }
106
+ }
107
+ return isHttpMethod(input.method) && typeof input.path === "string" && (typeof input.params === "string" || typeof input.params === "undefined") && (typeof input.response === "string" || typeof input.response === "undefined");
108
+ }
109
+ function isServiceDef(input) {
110
+ if (typeof input !== "object") {
111
+ return false;
112
+ }
113
+ for (const key of Object.keys(input)) {
114
+ if (typeof input[key] !== "object") {
115
+ return false;
116
+ }
117
+ }
118
+ return true;
119
+ }
120
+ function isApplicationDef(input) {
121
+ if (typeof input !== "object") {
122
+ return false;
123
+ }
124
+ if (!("procedures" in input) || typeof input.procedures !== "object") {
125
+ return false;
126
+ }
127
+ if (!("models" in input) || typeof input.models !== "object") {
128
+ return false;
129
+ }
130
+ if (!("errors" in input) || typeof input.errors !== "object") {
131
+ return false;
132
+ }
133
+ return true;
134
+ }
135
+ function unflattenObject(data) {
136
+ if (Object(data) !== data || Array.isArray(data))
137
+ return data;
138
+ const regex = /\.?([^.[\]]+)|\[(\d+)\]/g;
139
+ const result = {};
140
+ for (const p in data) {
141
+ let cur = result;
142
+ let prop = "";
143
+ let m;
144
+ while (m = regex.exec(p)) {
145
+ cur = cur[prop] || (cur[prop] = m[2] ? [] : {});
146
+ prop = m[2] || m[1];
147
+ }
148
+ cur[prop] = data[p];
149
+ }
150
+ return result[""] || result;
151
+ }
152
+ function unflattenProcedures(procedures) {
153
+ return unflattenObject(procedures);
154
+ }
155
+ function setNestedObjectProperty(targetProp, value, object) {
156
+ const parts = targetProp.split(".");
157
+ let current = object;
158
+ for (let i = 0; i < parts.length; i++) {
159
+ const key = parts[i];
160
+ if (i === parts.length - 1) {
161
+ current[key] = value;
162
+ } else {
163
+ if (!current[key]) {
164
+ current[key] = {};
165
+ }
166
+ current = current[key];
167
+ }
168
+ }
169
+ return object;
170
+ }
171
+ const removeDisallowedChars = (input, disallowedChars) => {
172
+ let result = input;
173
+ for (const char of disallowedChars) {
174
+ if (result.includes(char)) {
175
+ result = result.split(char).join("");
176
+ }
177
+ }
178
+ return result;
179
+ };
180
+
181
+ exports.camelCase = camelCase;
182
+ exports.isApplicationDef = isApplicationDef;
183
+ exports.isHttpMethod = isHttpMethod;
184
+ exports.isProcedureDef = isProcedureDef;
185
+ exports.isServiceDef = isServiceDef;
186
+ exports.kebabCase = kebabCase;
187
+ exports.normalizeWhitespace = normalizeWhitespace;
188
+ exports.pascalCase = pascalCase;
189
+ exports.removeDisallowedChars = removeDisallowedChars;
190
+ exports.setNestedObjectProperty = setNestedObjectProperty;
191
+ exports.unflattenObject = unflattenObject;
192
+ exports.unflattenProcedures = unflattenProcedures;
@@ -2,12 +2,84 @@
2
2
 
3
3
  const child_process = require('child_process');
4
4
  const require$$0 = require('fs');
5
- const app = require('./arri.8a065f92.cjs');
5
+ const utils = require('./arri.0752aa2b.cjs');
6
6
 
7
7
  function defineClientGeneratorPlugin(plugin) {
8
8
  return plugin;
9
9
  }
10
10
 
11
+ const JsonSchemaScalarTypeValues = [
12
+ "integer",
13
+ "number",
14
+ "bigint",
15
+ "string",
16
+ "boolean",
17
+ "Date"
18
+ ];
19
+ const JsonSchemaNullTypeValues = ["null", "undefined"];
20
+ function isJsonSchemaScalarType(input) {
21
+ if (typeof input !== "object") {
22
+ return false;
23
+ }
24
+ if (!("type" in input)) {
25
+ return false;
26
+ }
27
+ return JsonSchemaScalarTypeValues.includes(input.type);
28
+ }
29
+ function isJsonSchemaNullType(input) {
30
+ if (typeof input !== "object") {
31
+ return false;
32
+ }
33
+ if (!("type" in input)) {
34
+ return false;
35
+ }
36
+ return JsonSchemaNullTypeValues.includes(input.type);
37
+ }
38
+ const isJsonSchemaObject = (input) => {
39
+ if (typeof input !== "object") {
40
+ return false;
41
+ }
42
+ return "type" in input && input.type === "object" && "properties" in input && typeof input.properties === "object";
43
+ };
44
+ const isJsonSchemaRecord = (input) => {
45
+ if (typeof input !== "object") {
46
+ return false;
47
+ }
48
+ return "type" in input && input.type === "object" && "patternProperties" in input && typeof input.patternProperties === "object";
49
+ };
50
+ function isJsonSchemaArray(input) {
51
+ if (typeof input !== "object") {
52
+ return false;
53
+ }
54
+ if ("type" in input && input.type === "array") {
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+ function isJsonSchemaEnum(input) {
60
+ if (typeof input !== "object") {
61
+ return false;
62
+ }
63
+ if (!("anyOf" in input) || !Array.isArray(input.anyOf)) {
64
+ return false;
65
+ }
66
+ let prevType;
67
+ for (const item of input.anyOf) {
68
+ if (!isJsonSchemaScalarType(item)) {
69
+ return false;
70
+ }
71
+ if (item.type !== "string" && item.type !== "integer" && item.type !== "number") {
72
+ return false;
73
+ }
74
+ if (!prevType) {
75
+ prevType = item.type;
76
+ } else if (prevType !== item.type) {
77
+ return false;
78
+ }
79
+ }
80
+ return true;
81
+ }
82
+
11
83
  const dartClientGenerator = defineClientGeneratorPlugin(
12
84
  (options) => {
13
85
  return {
@@ -49,11 +121,11 @@ function createDartClient(appDef, opts = { clientName: "Client" }) {
49
121
  const { models, procedures } = appDef;
50
122
  const serviceParts = [];
51
123
  const procedureParts = [];
52
- const services = app.unflattenProcedures(procedures);
124
+ const services = utils.unflattenProcedures(procedures);
53
125
  Object.keys(services).forEach((k) => {
54
126
  const item = services[k];
55
- if (app.isServiceDef(item)) {
56
- const serviceName = app.pascalCase(`${opts.clientName}_${k}_service`);
127
+ if (utils.isServiceDef(item)) {
128
+ const serviceName = utils.pascalCase(`${opts.clientName}_${k}_service`);
57
129
  serviceParts.push({
58
130
  name: serviceName,
59
131
  key: k,
@@ -74,11 +146,11 @@ function createDartClient(appDef, opts = { clientName: "Client" }) {
74
146
  const modelParts = [];
75
147
  Object.keys(models).forEach((key) => {
76
148
  const model = models[key];
77
- const typeName = app.pascalCase(key);
149
+ const typeName = utils.pascalCase(key);
78
150
  const objModel = model;
79
151
  if (!generatedModels.includes(typeName)) {
80
152
  modelParts.push(
81
- dartModelFromJsonSchema(`${app.pascalCase(key)}`, objModel)
153
+ dartModelFromJsonSchema(`${utils.pascalCase(key)}`, objModel)
82
154
  );
83
155
  generatedModels.push(typeName);
84
156
  }
@@ -110,7 +182,7 @@ ${modelParts.join("\n")}
110
182
 
111
183
  enum ${opts.clientName}Endpoints implements Comparable<${opts.clientName}Endpoints>, ArriEndpoint {
112
184
  ${Object.keys(endpoints).map(
113
- (key) => `${app.camelCase(key.split("/").join("_"))}(
185
+ (key) => `${utils.camelCase(key.split("/").join("_"))}(
114
186
  path: "${key}",
115
187
  method: HttpMethod.${endpoints[key]},
116
188
  )`
@@ -134,13 +206,13 @@ function dartServiceFromServiceDefinition(name, def, opts) {
134
206
  const serviceName = `${name}`;
135
207
  Object.keys(def).forEach((key) => {
136
208
  const item = def[key];
137
- if (app.isProcedureDef(item)) {
209
+ if (utils.isProcedureDef(item)) {
138
210
  rpcParts.push(dartProcedureFromServiceDefinition(key, item));
139
211
  return;
140
212
  }
141
213
  const nameParts = name.split("Service");
142
214
  nameParts.pop();
143
- const subServiceName = app.pascalCase(
215
+ const subServiceName = utils.pascalCase(
144
216
  `${nameParts.join("")}_${key}_Service`
145
217
  );
146
218
  const subService = dartServiceFromServiceDefinition(
@@ -227,7 +299,7 @@ function dartProcedureFromServiceDefinition(key, def, opts) {
227
299
  }`;
228
300
  }
229
301
  function dartModelFromJsonSchema(modelName, schema, opts) {
230
- const modelDisplayName = app.pascalCase(`${modelName}`);
302
+ const modelDisplayName = utils.pascalCase(`${modelName}`);
231
303
  const fields = [];
232
304
  const subModelParts = [];
233
305
  Object.entries(schema.properties ?? {}).forEach(([key, val]) => {
@@ -243,12 +315,12 @@ function dartModelFromJsonSchema(modelName, schema, opts) {
243
315
  subModelParts.push(sub);
244
316
  }
245
317
  }
246
- fields.push({ type: dartType, name: app.camelCase(key), jsonKey: key });
247
- if (!isDartType(dartType) && app.isJsonSchemaObject(val)) {
318
+ fields.push({ type: dartType, name: utils.camelCase(key), jsonKey: key });
319
+ if (!isDartType(dartType) && isJsonSchemaObject(val)) {
248
320
  if (val.$id && generatedModels.includes(val.$id)) {
249
321
  return;
250
322
  }
251
- const subModelName = val.$id ? app.pascalCase(val.$id) : app.pascalCase(dartType.replace("?", ""));
323
+ const subModelName = val.$id ? utils.pascalCase(val.$id) : utils.pascalCase(dartType.replace("?", ""));
252
324
  subModelParts.push(
253
325
  dartModelFromJsonSchema(subModelName, val)
254
326
  );
@@ -278,6 +350,9 @@ function dartModelFromJsonSchema(modelName, schema, opts) {
278
350
  ${fields.map((field) => {
279
351
  const isNullable = field.type.endsWith("?");
280
352
  const typeName = field.type.replace("?", "");
353
+ if (typeName === "dynamic") {
354
+ return `"${field.jsonKey}": ${field.name}`;
355
+ }
281
356
  if (isDartTypeWithNullables(field.type)) {
282
357
  const transformer = transformers[typeName];
283
358
  return transformer.toJsonBody(
@@ -305,7 +380,9 @@ function dartModelFromJsonSchema(modelName, schema, opts) {
305
380
  };
306
381
  }
307
382
  ${modelDisplayName} copyWith({
308
- ${fields.map((field) => `${field.type.replace("?", "")}? ${field.name},`).join("\n ")}
383
+ ${fields.map(
384
+ (field) => `${field.type.replace("?", "")}${field.type !== "dynamic" ? "?" : ""} ${field.name},`
385
+ ).join("\n ")}
309
386
  }) {
310
387
  return ${modelDisplayName}(
311
388
  ${fields.map((field) => `${field.name}: ${field.name} ?? this.${field.name},`).join("\n ")}
@@ -318,23 +395,23 @@ ${subModelParts.join("\n")}`;
318
395
  function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
319
396
  const prop = schema.properties?.[propertyName];
320
397
  const isOptional = !schema.required?.includes(propertyName);
321
- let finalType = "";
398
+ let finalType = "dynamic";
322
399
  const subTypes = [];
323
- if (app.isJsonSchemaEnum(prop)) {
324
- const enumName = app.pascalCase(`${objectName}_${propertyName}`);
400
+ if (isJsonSchemaEnum(prop)) {
401
+ const enumName = utils.pascalCase(`${objectName}_${propertyName}`);
325
402
  finalType = isOptional ? `${enumName}?` : enumName;
326
403
  const options = [];
327
404
  for (const opt of prop.anyOf) {
328
405
  if (opt.type === "string") {
329
406
  options.push({
330
- name: app.camelCase(opt.const.toString()),
407
+ name: utils.camelCase(opt.const.toString()),
331
408
  type: "String",
332
409
  value: opt.const
333
410
  });
334
411
  }
335
412
  if (opt.type === "number" || opt.type === "integer") {
336
413
  options.push({
337
- name: app.camelCase(
414
+ name: utils.camelCase(
338
415
  `num_${opt.const}`.split(".").join("Point")
339
416
  ),
340
417
  type: opt.type === "number" ? "double" : "int",
@@ -367,11 +444,11 @@ function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
367
444
  }`);
368
445
  return [finalType, subTypes];
369
446
  }
370
- if (app.isJsonSchemaNullType(prop)) {
447
+ if (isJsonSchemaNullType(prop)) {
371
448
  finalType = "null";
372
449
  return [finalType, subTypes];
373
450
  }
374
- if (app.isJsonSchemaScalarType(prop)) {
451
+ if (isJsonSchemaScalarType(prop)) {
375
452
  switch (prop.type) {
376
453
  case "string":
377
454
  finalType = isOptional ? "String?" : "String";
@@ -390,14 +467,14 @@ function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
390
467
  break;
391
468
  }
392
469
  }
393
- if (app.isJsonSchemaObject(prop)) {
394
- const joinedPropName = prop.$id ? app.pascalCase(prop.$id) : app.pascalCase(`${objectName}_${propertyName}`);
470
+ if (isJsonSchemaObject(prop)) {
471
+ const joinedPropName = prop.$id ? utils.pascalCase(prop.$id) : utils.pascalCase(`${objectName}_${propertyName}`);
395
472
  finalType = isOptional ? `${joinedPropName}?` : joinedPropName;
396
473
  }
397
- if (app.isJsonSchemaRecord(prop)) {
474
+ if (isJsonSchemaRecord(prop)) {
398
475
  finalType = isOptional ? `Map<dynamic, dynamic>?` : "Map<dynamic, dynamic>";
399
476
  }
400
- if (app.isJsonSchemaArray(prop)) {
477
+ if (isJsonSchemaArray(prop)) {
401
478
  const item = prop.items;
402
479
  const type = item.type;
403
480
  if (typeof type !== "string") {
@@ -425,8 +502,8 @@ function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
425
502
  finalType = isOptional ? "List<DateTime>?" : "List<DateTime>";
426
503
  break;
427
504
  case "object": {
428
- if (app.isJsonSchemaObject(item)) {
429
- const subTypeName = item.$id ?? app.pascalCase(`${objectName}_${propertyName}_item`);
505
+ if (isJsonSchemaObject(item)) {
506
+ const subTypeName = item.$id ?? utils.pascalCase(`${objectName}_${propertyName}_item`);
430
507
  if (!generatedModels.includes(subTypeName)) {
431
508
  const model = dartModelFromJsonSchema(
432
509
  subTypeName,
@@ -445,6 +522,9 @@ function dartPropertyTypeFromSchema(objectName, propertyName, schema, opts) {
445
522
  return [finalType, subTypes.length ? subTypes : void 0];
446
523
  }
447
524
  function dartParsedJsonField(fieldName, jsonKey, dartType) {
525
+ if (dartType === "dynamic") {
526
+ return `${fieldName}: json["${jsonKey}"]`;
527
+ }
448
528
  if (isDartTypeWithNullables(dartType)) {
449
529
  switch (dartType) {
450
530
  case "String":
@@ -693,4 +773,10 @@ exports.dartServiceFromServiceDefinition = dartServiceFromServiceDefinition;
693
773
  exports.defineClientGeneratorPlugin = defineClientGeneratorPlugin;
694
774
  exports.isDartType = isDartType;
695
775
  exports.isDartTypeWithNullables = isDartTypeWithNullables;
776
+ exports.isJsonSchemaArray = isJsonSchemaArray;
777
+ exports.isJsonSchemaEnum = isJsonSchemaEnum;
778
+ exports.isJsonSchemaNullType = isJsonSchemaNullType;
779
+ exports.isJsonSchemaObject = isJsonSchemaObject;
780
+ exports.isJsonSchemaRecord = isJsonSchemaRecord;
781
+ exports.isJsonSchemaScalarType = isJsonSchemaScalarType;
696
782
  exports.transformers = transformers;
@@ -0,0 +1,77 @@
1
+ import { TObject } from '@sinclair/typebox';
2
+
3
+ declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
4
+ type HttpMethod = (typeof HttpMethodValues)[number];
5
+
6
+ declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
7
+ declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
8
+ type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
9
+ interface JsonSchemaTypeBase {
10
+ $id?: string;
11
+ title?: string;
12
+ description?: string;
13
+ }
14
+ interface JsonSchemaScalarType extends JsonSchemaTypeBase {
15
+ type: (typeof JsonSchemaScalarTypeValues)[number];
16
+ }
17
+ interface JsonSchemaNullType extends JsonSchemaTypeBase {
18
+ type: (typeof JsonSchemaNullTypeValues)[number];
19
+ }
20
+ type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray | JsonSchemaRecord;
21
+ interface JsonSchemaObject extends JsonSchemaTypeBase {
22
+ type: "object";
23
+ properties: Record<string, JsonSchemaType>;
24
+ required?: string[];
25
+ additionalProperties?: boolean;
26
+ }
27
+ interface JsonSchemaRecord extends JsonSchemaTypeBase {
28
+ type: "object";
29
+ patternProperties: Record<string, JsonSchemaType>;
30
+ }
31
+ interface JsonSchemaArray extends JsonSchemaTypeBase {
32
+ type: "array";
33
+ items: JsonSchemaType;
34
+ }
35
+
36
+ interface ApplicationDef {
37
+ arriSchemaVersion: "0.0.1";
38
+ info?: {
39
+ title?: string;
40
+ description?: string;
41
+ version?: string;
42
+ };
43
+ externalDocs?: {
44
+ description?: string;
45
+ url: string;
46
+ };
47
+ procedures: Record<string, ProcedureDef>;
48
+ models: Record<string, JsonSchemaObject>;
49
+ errors: Omit<TObject, symbol>;
50
+ }
51
+ declare function normalizeWhitespace(input: string): string;
52
+ interface ProcedureDef {
53
+ path: string;
54
+ description?: string;
55
+ method: HttpMethod;
56
+ params: string | undefined;
57
+ response: string | undefined;
58
+ }
59
+ declare function isProcedureDef(input: any): input is ProcedureDef;
60
+ interface ServiceDef {
61
+ [key: string]: ProcedureDef | ServiceDef;
62
+ }
63
+ declare function isServiceDef(input: any): input is ServiceDef;
64
+ declare function isApplicationDef(input: any): input is ApplicationDef;
65
+ declare function unflattenObject(data: Record<string, any>): any;
66
+ declare function unflattenProcedures(procedures: ApplicationDef["procedures"]): Record<string, ProcedureDef | ServiceDef>;
67
+ declare function setNestedObjectProperty<T>(targetProp: string, value: T, object: Record<any, any>): Record<any, any>;
68
+ declare const removeDisallowedChars: (input: string, disallowedChars: string) => string;
69
+
70
+ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
71
+ generator: (def: ApplicationDef) => any;
72
+ options: TOptions;
73
+ }
74
+ type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
75
+ declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
76
+
77
+ export { type ApplicationDef as A, type ClientGeneratorPlugin as C, type HttpMethod as H, type JsonSchemaObject as J, type ProcedureDef as P, type ServiceDef as S, type ClientGenerator as a, isServiceDef as b, isApplicationDef as c, defineClientGeneratorPlugin as d, unflattenProcedures as e, isProcedureDef as i, normalizeWhitespace as n, removeDisallowedChars as r, setNestedObjectProperty as s, unflattenObject as u };
@@ -0,0 +1,77 @@
1
+ import { TObject } from '@sinclair/typebox';
2
+
3
+ declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
4
+ type HttpMethod = (typeof HttpMethodValues)[number];
5
+
6
+ declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
7
+ declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
8
+ type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
9
+ interface JsonSchemaTypeBase {
10
+ $id?: string;
11
+ title?: string;
12
+ description?: string;
13
+ }
14
+ interface JsonSchemaScalarType extends JsonSchemaTypeBase {
15
+ type: (typeof JsonSchemaScalarTypeValues)[number];
16
+ }
17
+ interface JsonSchemaNullType extends JsonSchemaTypeBase {
18
+ type: (typeof JsonSchemaNullTypeValues)[number];
19
+ }
20
+ type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray | JsonSchemaRecord;
21
+ interface JsonSchemaObject extends JsonSchemaTypeBase {
22
+ type: "object";
23
+ properties: Record<string, JsonSchemaType>;
24
+ required?: string[];
25
+ additionalProperties?: boolean;
26
+ }
27
+ interface JsonSchemaRecord extends JsonSchemaTypeBase {
28
+ type: "object";
29
+ patternProperties: Record<string, JsonSchemaType>;
30
+ }
31
+ interface JsonSchemaArray extends JsonSchemaTypeBase {
32
+ type: "array";
33
+ items: JsonSchemaType;
34
+ }
35
+
36
+ interface ApplicationDef {
37
+ arriSchemaVersion: "0.0.1";
38
+ info?: {
39
+ title?: string;
40
+ description?: string;
41
+ version?: string;
42
+ };
43
+ externalDocs?: {
44
+ description?: string;
45
+ url: string;
46
+ };
47
+ procedures: Record<string, ProcedureDef>;
48
+ models: Record<string, JsonSchemaObject>;
49
+ errors: Omit<TObject, symbol>;
50
+ }
51
+ declare function normalizeWhitespace(input: string): string;
52
+ interface ProcedureDef {
53
+ path: string;
54
+ description?: string;
55
+ method: HttpMethod;
56
+ params: string | undefined;
57
+ response: string | undefined;
58
+ }
59
+ declare function isProcedureDef(input: any): input is ProcedureDef;
60
+ interface ServiceDef {
61
+ [key: string]: ProcedureDef | ServiceDef;
62
+ }
63
+ declare function isServiceDef(input: any): input is ServiceDef;
64
+ declare function isApplicationDef(input: any): input is ApplicationDef;
65
+ declare function unflattenObject(data: Record<string, any>): any;
66
+ declare function unflattenProcedures(procedures: ApplicationDef["procedures"]): Record<string, ProcedureDef | ServiceDef>;
67
+ declare function setNestedObjectProperty<T>(targetProp: string, value: T, object: Record<any, any>): Record<any, any>;
68
+ declare const removeDisallowedChars: (input: string, disallowedChars: string) => string;
69
+
70
+ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
71
+ generator: (def: ApplicationDef) => any;
72
+ options: TOptions;
73
+ }
74
+ type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
75
+ declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
76
+
77
+ export { type ApplicationDef as A, type ClientGeneratorPlugin as C, type HttpMethod as H, type JsonSchemaObject as J, type ProcedureDef as P, type ServiceDef as S, type ClientGenerator as a, isServiceDef as b, isApplicationDef as c, defineClientGeneratorPlugin as d, unflattenProcedures as e, isProcedureDef as i, normalizeWhitespace as n, removeDisallowedChars as r, setNestedObjectProperty as s, unflattenObject as u };