arri 0.0.11 → 0.0.13

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.
@@ -5,7 +5,7 @@ const cli = require('../cli.cjs');
5
5
  require('node:tty');
6
6
  require('node:path');
7
7
  require('stream');
8
- require('../shared/arri.8e602d87.cjs');
8
+ require('../shared/arri.3605a96c.cjs');
9
9
  require('os');
10
10
  require('path');
11
11
  require('util');
@@ -29,7 +29,7 @@ require('node:module');
29
29
  require('node:assert');
30
30
  require('node:v8');
31
31
  require('node:util');
32
- require('../shared/arri.dd4e8564.cjs');
32
+ require('../shared/arri.d31eb2d5.cjs');
33
33
  require('fs/promises');
34
34
  require('child_process');
35
35
  require('node:http');
@@ -3,7 +3,7 @@ import { c as consola } from '../cli.mjs';
3
3
  import 'node:tty';
4
4
  import 'node:path';
5
5
  import 'stream';
6
- import '../shared/arri.1f1b9dfc.mjs';
6
+ import '../shared/arri.b0ab6d2f.mjs';
7
7
  import 'os';
8
8
  import 'path';
9
9
  import 'util';
@@ -27,7 +27,7 @@ import 'node:module';
27
27
  import 'node:assert';
28
28
  import 'node:v8';
29
29
  import 'node:util';
30
- import '../shared/arri.d491643b.mjs';
30
+ import '../shared/arri.a90e77aa.mjs';
31
31
  import 'fs/promises';
32
32
  import 'child_process';
33
33
  import 'node:http';
@@ -8,7 +8,7 @@ const childProcess = require('node:child_process');
8
8
  const cli = require('../cli.cjs');
9
9
  require('node:tty');
10
10
  require('stream');
11
- require('../shared/arri.8e602d87.cjs');
11
+ require('../shared/arri.3605a96c.cjs');
12
12
  require('os');
13
13
  require('path');
14
14
  require('util');
@@ -31,7 +31,7 @@ require('node:module');
31
31
  require('node:assert');
32
32
  require('node:v8');
33
33
  require('node:util');
34
- require('../shared/arri.dd4e8564.cjs');
34
+ require('../shared/arri.d31eb2d5.cjs');
35
35
  require('fs/promises');
36
36
  require('child_process');
37
37
  require('node:http');
@@ -6,7 +6,7 @@ import { execSync, spawn } from 'node:child_process';
6
6
  import { p as path } from '../cli.mjs';
7
7
  import 'node:tty';
8
8
  import 'stream';
9
- import '../shared/arri.1f1b9dfc.mjs';
9
+ import '../shared/arri.b0ab6d2f.mjs';
10
10
  import 'os';
11
11
  import 'path';
12
12
  import 'util';
@@ -29,7 +29,7 @@ import 'node:module';
29
29
  import 'node:assert';
30
30
  import 'node:v8';
31
31
  import 'node:util';
32
- import '../shared/arri.d491643b.mjs';
32
+ import '../shared/arri.a90e77aa.mjs';
33
33
  import 'fs/promises';
34
34
  import 'child_process';
35
35
  import 'node:http';
@@ -2,7 +2,7 @@
2
2
 
3
3
  const fs$b = require('node:fs/promises');
4
4
  const fs$c = require('node:fs');
5
- const index = require('../shared/arri.8e602d87.cjs');
5
+ const index = require('../shared/arri.3605a96c.cjs');
6
6
  const require$$0 = require('events');
7
7
  const require$$0$1 = require('stream');
8
8
  const require$$2 = require('string_decoder');
@@ -35,7 +35,7 @@ require('v8');
35
35
  require('node:module');
36
36
  require('node:assert');
37
37
  require('node:v8');
38
- require('../shared/arri.dd4e8564.cjs');
38
+ require('../shared/arri.d31eb2d5.cjs');
39
39
  require('fs/promises');
40
40
  require('child_process');
41
41
  require('node:http');
@@ -1,6 +1,6 @@
1
1
  import { rm, mkdir as mkdir$2, readFile, writeFile } from 'node:fs/promises';
2
2
  import { existsSync, readdirSync as readdirSync$1, createWriteStream } from 'node:fs';
3
- import { j as commonjsGlobal, k as getDefaultExportFromCjs } from '../shared/arri.1f1b9dfc.mjs';
3
+ import { j as commonjsGlobal, k as getDefaultExportFromCjs } from '../shared/arri.b0ab6d2f.mjs';
4
4
  import require$$0 from 'events';
5
5
  import require$$0$1 from 'stream';
6
6
  import require$$2 from 'string_decoder';
@@ -33,7 +33,7 @@ import 'v8';
33
33
  import 'node:module';
34
34
  import 'node:assert';
35
35
  import 'node:v8';
36
- import '../shared/arri.d491643b.mjs';
36
+ import '../shared/arri.a90e77aa.mjs';
37
37
  import 'fs/promises';
38
38
  import 'child_process';
39
39
  import 'node:http';
package/dist/cli.cjs CHANGED
@@ -5,7 +5,7 @@ const tty = require('node:tty');
5
5
  const fs$f = require('node:fs');
6
6
  const path$e = require('node:path');
7
7
  const require$$0 = require('stream');
8
- const index = require('./shared/arri.8e602d87.cjs');
8
+ const index = require('./shared/arri.3605a96c.cjs');
9
9
  const require$$0$1 = require('os');
10
10
  const require$$0$2 = require('path');
11
11
  const require$$0$3 = require('util');
@@ -29,7 +29,7 @@ const node_module = require('node:module');
29
29
  const assert = require('node:assert');
30
30
  const v8$1 = require('node:v8');
31
31
  const node_util = require('node:util');
32
- const dart = require('./shared/arri.dd4e8564.cjs');
32
+ const dart = require('./shared/arri.d31eb2d5.cjs');
33
33
  const node_http = require('node:http');
34
34
  const https = require('node:https');
35
35
  const node_net = require('node:net');
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import * as tty from 'node:tty';
3
3
  import fs$f, { existsSync, readFileSync, realpathSync, statSync as statSync$1, Stats, promises, writeFileSync, chmodSync, constants as constants$6 } from 'node:fs';
4
4
  import path$e, { resolve as resolve$1, join as join$1 } from 'node:path';
5
5
  import require$$0 from 'stream';
6
- import { j as commonjsGlobal, k as getDefaultExportFromCjs, l as getAugmentedNamespace, m as destr, n as joinURL, t as toNodeListener, h as camelCase$1, E as ErrorResponse, o as isRpc, q as typebox, p as pascalCase$1, r as removeDisallowedChars, s as kebabCase$1, w as withBase, v as withQuery } from './shared/arri.1f1b9dfc.mjs';
6
+ import { j as commonjsGlobal, k as getDefaultExportFromCjs, l as getAugmentedNamespace, m as destr, n as joinURL, t as toNodeListener, h as camelCase$1, E as ErrorResponse, o as isRpc, q as typebox, p as pascalCase$1, r as removeDisallowedChars, s as kebabCase$1, w as withBase, v as withQuery } from './shared/arri.b0ab6d2f.mjs';
7
7
  import require$$0$1 from 'os';
8
8
  import require$$0$2 from 'path';
9
9
  import require$$0$3 from 'util';
@@ -27,7 +27,7 @@ import { builtinModules } from 'node:module';
27
27
  import assert from 'node:assert';
28
28
  import v8$1 from 'node:v8';
29
29
  import { format as format$1, inspect, promisify as promisify$5 } from 'node:util';
30
- import { f as format2, a as dartClientGenerator } from './shared/arri.d491643b.mjs';
30
+ import { f as format2, a as dartClientGenerator } from './shared/arri.a90e77aa.mjs';
31
31
  import { createServer as createServer$2 } from 'node:http';
32
32
  import { createServer as createServer$1 } from 'node:https';
33
33
  import { createServer } from 'node:net';
package/dist/codegen.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/arri.8e602d87.cjs');
4
- const dart = require('./shared/arri.dd4e8564.cjs');
3
+ const index = require('./shared/arri.3605a96c.cjs');
4
+ const dart = require('./shared/arri.d31eb2d5.cjs');
5
5
  const fs = require('fs');
6
6
  require('module');
7
7
  require('url');
package/dist/codegen.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { u as unflattenObject, i as isServiceDefinition, p as pascalCase, a as isProcedureDefinition, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaEnum, f as isJsonSchemaArray } from './shared/arri.1f1b9dfc.mjs';
2
- import { d as defineClientGeneratorPlugin, f as format2 } from './shared/arri.d491643b.mjs';
3
- export { k as classListTransformer, j as classTransformer, c as createDartClient, a as dartClientGenerator, g as dartModelFromJsonSchema, i as dartParsedJsonField, e as dartProcedureFromServiceDefinition, h as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, l as isDartType, m as isDartTypeWithNullables, t as transformers } from './shared/arri.d491643b.mjs';
1
+ import { u as unflattenObject, i as isServiceDefinition, p as pascalCase, a as isProcedureDefinition, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaEnum, f as isJsonSchemaArray } from './shared/arri.b0ab6d2f.mjs';
2
+ import { d as defineClientGeneratorPlugin, f as format2 } from './shared/arri.a90e77aa.mjs';
3
+ export { k as classListTransformer, j as classTransformer, c as createDartClient, a as dartClientGenerator, g as dartModelFromJsonSchema, i as dartParsedJsonField, e as dartProcedureFromServiceDefinition, h as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, l as isDartType, m as isDartTypeWithNullables, t as transformers } from './shared/arri.a90e77aa.mjs';
4
4
  import { writeFileSync } from 'fs';
5
5
  import 'module';
6
6
  import 'url';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/arri.8e602d87.cjs');
3
+ const index = require('./shared/arri.3605a96c.cjs');
4
4
 
5
5
 
6
6
 
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { A as ArriServer, E as ErrorResponse, H as HttpMethodValues, z as createRpcDefinition, L as defineError, J as defineMiddleware, I as defineRoute, y as defineRpc, M as errorResponseFromValidationErrors, D as getRpcParamDefinition, C as getRpcParamName, B as getRpcPath, F as getRpcResponseName, x as isHttpMethod, o as isRpc, K as registerRoute, G as registerRpc } from './shared/arri.1f1b9dfc.mjs';
1
+ export { A as ArriServer, E as ErrorResponse, H as HttpMethodValues, z as createRpcDefinition, L as defineError, J as defineMiddleware, I as defineRoute, y as defineRpc, M as errorResponseFromValidationErrors, D as getRpcParamDefinition, C as getRpcParamName, B as getRpcPath, F as getRpcResponseName, x as isHttpMethod, o as isRpc, K as registerRoute, G as registerRpc } from './shared/arri.b0ab6d2f.mjs';
@@ -8543,6 +8543,7 @@ function getRpcResponseDefinition(rpcName, procedure) {
8543
8543
  return name;
8544
8544
  }
8545
8545
  function registerRpc(router, path, procedure, middleware) {
8546
+ const httpMethod = procedure.method ?? "post";
8546
8547
  const handler = eventHandler(async (event) => {
8547
8548
  const context = {
8548
8549
  event
@@ -8554,7 +8555,7 @@ function registerRpc(router, path, procedure, middleware) {
8554
8555
  await Promise.all(middleware.map((m) => m(context)));
8555
8556
  }
8556
8557
  if (procedure.params) {
8557
- switch (procedure.method) {
8558
+ switch (httpMethod) {
8558
8559
  case "get":
8559
8560
  case "head": {
8560
8561
  const parsedParams = await getValidatedQuery(
@@ -8589,8 +8590,27 @@ function registerRpc(router, path, procedure, middleware) {
8589
8590
  typeboxSafeValidate(procedure.params)
8590
8591
  );
8591
8592
  if (!parsedParams.success) {
8593
+ let isObjectError = false;
8594
+ const errorParts = [];
8595
+ for (const err of parsedParams.errors) {
8596
+ if (err.type === errors$1.ValueErrorType.Object) {
8597
+ isObjectError = true;
8598
+ }
8599
+ const propName = err.path.split("/");
8600
+ propName.shift();
8601
+ if (!errorParts.includes(propName.join("."))) {
8602
+ errorParts.push(propName.join("."));
8603
+ }
8604
+ }
8605
+ if (isObjectError) {
8606
+ throw defineError(400, {
8607
+ statusMessage: `Invalid request body. Expected object.`
8608
+ });
8609
+ }
8592
8610
  throw defineError(400, {
8593
- statusMessage: "Invalid request body",
8611
+ statusMessage: `Invalid request body. Affected properties [${errorParts.join(
8612
+ ", "
8613
+ )}]`,
8594
8614
  data: parsedParams.errors
8595
8615
  });
8596
8616
  }
@@ -8612,7 +8632,7 @@ function registerRpc(router, path, procedure, middleware) {
8612
8632
  }
8613
8633
  return null;
8614
8634
  });
8615
- switch (procedure.method) {
8635
+ switch (httpMethod) {
8616
8636
  case "get":
8617
8637
  router.get(path, handler);
8618
8638
  break;
@@ -8625,12 +8645,13 @@ function registerRpc(router, path, procedure, middleware) {
8625
8645
  case "patch":
8626
8646
  router.patch(path, handler);
8627
8647
  break;
8628
- case "post":
8629
- router.post(path, handler);
8630
- break;
8631
8648
  case "put":
8632
8649
  router.put(path, handler);
8633
8650
  break;
8651
+ case "post":
8652
+ default:
8653
+ router.post(path, handler);
8654
+ break;
8634
8655
  }
8635
8656
  }
8636
8657
 
@@ -9,7 +9,7 @@ import assert4 from 'assert';
9
9
  import fs from 'fs/promises';
10
10
  import v8 from 'v8';
11
11
  import { format, inspect } from 'util';
12
- import { g as unflattenProcedures, i as isServiceDefinition, p as pascalCase, h as camelCase, a as isProcedureDefinition, d as isJsonSchemaObject, e as isJsonSchemaEnum, c as isJsonSchemaNullType, b as isJsonSchemaScalarType, f as isJsonSchemaArray } from './arri.1f1b9dfc.mjs';
12
+ import { g as unflattenProcedures, i as isServiceDefinition, p as pascalCase, h as camelCase, a as isProcedureDefinition, d as isJsonSchemaObject, e as isJsonSchemaEnum, c as isJsonSchemaNullType, b as isJsonSchemaScalarType, f as isJsonSchemaArray } from './arri.b0ab6d2f.mjs';
13
13
  import { execSync } from 'child_process';
14
14
 
15
15
  const require$1 = createRequire(import.meta.url);
@@ -29096,7 +29096,8 @@ function createDartClient(appDef, opts = { clientName: "Client" }) {
29096
29096
  generatedModels.push(typeName);
29097
29097
  }
29098
29098
  });
29099
- return `// This code was autogenerated by arri. Do not modify directly.
29099
+ return `// This code was autogenerated by Arri. Do not modify directly.
29100
+ // For additional documentation visit http://github.com/modiimedia/arri
29100
29101
  import "dart:convert";
29101
29102
  import "package:http/http.dart" as http;
29102
29103
  import "package:arri_client/arri_client.dart";
@@ -8541,6 +8541,7 @@ function getRpcResponseDefinition(rpcName, procedure) {
8541
8541
  return name;
8542
8542
  }
8543
8543
  function registerRpc(router, path, procedure, middleware) {
8544
+ const httpMethod = procedure.method ?? "post";
8544
8545
  const handler = eventHandler(async (event) => {
8545
8546
  const context = {
8546
8547
  event
@@ -8552,7 +8553,7 @@ function registerRpc(router, path, procedure, middleware) {
8552
8553
  await Promise.all(middleware.map((m) => m(context)));
8553
8554
  }
8554
8555
  if (procedure.params) {
8555
- switch (procedure.method) {
8556
+ switch (httpMethod) {
8556
8557
  case "get":
8557
8558
  case "head": {
8558
8559
  const parsedParams = await getValidatedQuery(
@@ -8587,8 +8588,27 @@ function registerRpc(router, path, procedure, middleware) {
8587
8588
  typeboxSafeValidate(procedure.params)
8588
8589
  );
8589
8590
  if (!parsedParams.success) {
8591
+ let isObjectError = false;
8592
+ const errorParts = [];
8593
+ for (const err of parsedParams.errors) {
8594
+ if (err.type === errors$1.ValueErrorType.Object) {
8595
+ isObjectError = true;
8596
+ }
8597
+ const propName = err.path.split("/");
8598
+ propName.shift();
8599
+ if (!errorParts.includes(propName.join("."))) {
8600
+ errorParts.push(propName.join("."));
8601
+ }
8602
+ }
8603
+ if (isObjectError) {
8604
+ throw defineError(400, {
8605
+ statusMessage: `Invalid request body. Expected object.`
8606
+ });
8607
+ }
8590
8608
  throw defineError(400, {
8591
- statusMessage: "Invalid request body",
8609
+ statusMessage: `Invalid request body. Affected properties [${errorParts.join(
8610
+ ", "
8611
+ )}]`,
8592
8612
  data: parsedParams.errors
8593
8613
  });
8594
8614
  }
@@ -8610,7 +8630,7 @@ function registerRpc(router, path, procedure, middleware) {
8610
8630
  }
8611
8631
  return null;
8612
8632
  });
8613
- switch (procedure.method) {
8633
+ switch (httpMethod) {
8614
8634
  case "get":
8615
8635
  router.get(path, handler);
8616
8636
  break;
@@ -8623,12 +8643,13 @@ function registerRpc(router, path, procedure, middleware) {
8623
8643
  case "patch":
8624
8644
  router.patch(path, handler);
8625
8645
  break;
8626
- case "post":
8627
- router.post(path, handler);
8628
- break;
8629
8646
  case "put":
8630
8647
  router.put(path, handler);
8631
8648
  break;
8649
+ case "post":
8650
+ default:
8651
+ router.post(path, handler);
8652
+ break;
8632
8653
  }
8633
8654
  }
8634
8655
 
@@ -11,7 +11,7 @@ const assert4 = require('assert');
11
11
  const fs = require('fs/promises');
12
12
  const v8 = require('v8');
13
13
  const require$$0$1 = require('util');
14
- const index = require('./arri.8e602d87.cjs');
14
+ const index = require('./arri.3605a96c.cjs');
15
15
  const require$$1 = require('child_process');
16
16
 
17
17
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -25,8 +25,8 @@ const assert4__default = /*#__PURE__*/_interopDefaultCompat(assert4);
25
25
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
26
26
  const v8__default = /*#__PURE__*/_interopDefaultCompat(v8);
27
27
 
28
- const require$2 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.dd4e8564.cjs', document.baseURI).href)));
29
- const __filename$2 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.dd4e8564.cjs', document.baseURI).href)));
28
+ const require$2 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.d31eb2d5.cjs', document.baseURI).href)));
29
+ const __filename$2 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.d31eb2d5.cjs', document.baseURI).href)));
30
30
  const __dirname$1 = require$$0.dirname(__filename$2);
31
31
 
32
32
  var __create$1 = Object.create;
@@ -7791,8 +7791,8 @@ const doc = {
7791
7791
  utils: utils
7792
7792
  };
7793
7793
 
7794
- const require$1 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.dd4e8564.cjs', document.baseURI).href)));
7795
- const __filename$1 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.dd4e8564.cjs', document.baseURI).href)));
7794
+ const require$1 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.d31eb2d5.cjs', document.baseURI).href)));
7795
+ const __filename$1 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.d31eb2d5.cjs', document.baseURI).href)));
7796
7796
  require$$0.dirname(__filename$1);
7797
7797
 
7798
7798
  var __create = Object.create;
@@ -29109,7 +29109,8 @@ function createDartClient(appDef, opts = { clientName: "Client" }) {
29109
29109
  generatedModels.push(typeName);
29110
29110
  }
29111
29111
  });
29112
- return `// This code was autogenerated by arri. Do not modify directly.
29112
+ return `// This code was autogenerated by Arri. Do not modify directly.
29113
+ // For additional documentation visit http://github.com/modiimedia/arri
29113
29114
  import "dart:convert";
29114
29115
  import "package:http/http.dart" as http;
29115
29116
  import "package:arri_client/arri_client.dart";
package/package.json CHANGED
@@ -10,6 +10,7 @@
10
10
  "bin": {
11
11
  "arri": "./dist/cli.mjs"
12
12
  },
13
+ "license": "MIT",
13
14
  "dependencies": {
14
15
  "@sinclair/typebox": "^0.31.5",
15
16
  "h3": "^1.8.1",
@@ -22,7 +23,7 @@
22
23
  "chokidar": "^3.5.3",
23
24
  "listhen": "^1.4.3"
24
25
  },
25
- "version": "0.0.11",
26
+ "version": "0.0.13",
26
27
  "repository": {
27
28
  "url": "https://github.com/modiimedia/arri"
28
29
  }