arri 0.27.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -12,10 +12,9 @@ const esbuild = require('esbuild');
12
12
  const esbuildPluginReplace = require('esbuild-plugin-replace');
13
13
  const path = require('pathe');
14
14
  const prettier = require('prettier');
15
- const config = require('./shared/arri.22a9d5c0.cjs');
15
+ const config = require('./shared/arri.31b22fac.cjs');
16
16
  const globby = require('globby');
17
17
  const scule = require('scule');
18
- const arriCodegenDart = require('arri-codegen-dart');
19
18
  const ofetch = require('ofetch');
20
19
  const listhen = require('@joshmossas/listhen');
21
20
  const chokidar = require('chokidar');
@@ -348,75 +347,70 @@ async function createCodegenEntryFile(config) {
348
347
  );
349
348
  }
350
349
 
351
- const codegenDart = citty.defineCommand({
350
+ const codegen = citty.defineCommand({
352
351
  args: {
353
- location: {
352
+ schema: {
354
353
  type: "positional",
355
- required: true,
356
- description: "The path to an Arri definition file or a url that returns an Arri definition file."
357
- },
358
- clientName: {
359
- type: "string",
360
- alias: ["name"],
354
+ alias: ["l"],
361
355
  required: true
362
356
  },
363
- outFile: {
357
+ config: {
364
358
  type: "string",
365
- alias: ["out", "o"],
366
- required: true
359
+ alias: ["c"],
360
+ default: "arri.config.ts"
367
361
  }
368
362
  },
369
363
  async run({ args }) {
370
- const isUrl = args.location.startsWith("http://") || args.location.startsWith("https://");
364
+ const isUrl = args.schema.startsWith("http://") || args.schema.startsWith("https://");
365
+ const isTs = args.schema.endsWith(".ts");
366
+ const isJs = args.schema.endsWith(".js");
371
367
  let def;
372
368
  if (isUrl) {
373
- const result = await ofetch.ofetch(args.location);
369
+ const result = await ofetch.ofetch(args.schema);
370
+ if (!arriCodegenUtils.isAppDefinition(result)) {
371
+ throw new Error(`Invalid App Definition at ${args.schema}`);
372
+ }
374
373
  def = result;
375
374
  } else {
376
- if (!fs.existsSync(args.location)) {
377
- throw new Error(`Unable to find ${args.location}`);
375
+ if (!fs__default$1.existsSync(args.schema)) {
376
+ throw new Error(`Unable to find ${args.schema}`);
377
+ }
378
+ if (isTs || isJs) {
379
+ const schemaResult = await c12.loadConfig({
380
+ configFile: args.schema
381
+ });
382
+ if (!arriCodegenUtils.isAppDefinition(schemaResult.config)) {
383
+ throw new Error(`Invalid App Definition at ${args.schema}`);
384
+ }
385
+ def = schemaResult.config;
386
+ } else {
387
+ const jsonString = JSON.parse(
388
+ fs__default$1.readFileSync(args.schema, { encoding: "utf-8" })
389
+ );
390
+ if (!arriCodegenUtils.isAppDefinition(jsonString)) {
391
+ throw new Error(`Invalid App Definition at ${args.schema}`);
392
+ }
393
+ def = jsonString;
378
394
  }
379
- const jsonString = JSON.parse(
380
- fs.readFileSync(args.location, { encoding: "utf-8" })
381
- );
382
- def = jsonString;
383
395
  }
384
396
  if (!def) {
385
- throw new Error("Unable to load ApplicationDefinition json file");
397
+ throw new Error(`Unable to find App Definition at ${args.schema}`);
386
398
  }
387
- await arriCodegenDart.dartClientGenerator({
388
- clientName: args.clientName,
389
- outputFile: args.outFile
390
- }).generator(def);
391
- }
392
- });
393
- const codegenTypescript = citty.defineCommand({
394
- args: {
395
- location: {
396
- type: "positional",
397
- required: true,
398
- description: "The path to an Arri definition file or a url that returns an Arri definition file."
399
- },
400
- clientName: {
401
- type: "string",
402
- alias: ["name"],
403
- required: true
404
- },
405
- outFile: {
406
- type: "string",
407
- alias: ["out", "o"],
408
- required: true
399
+ if (!fs__default$1.existsSync(path__default.resolve(args.config))) {
400
+ throw new Error(
401
+ `Unable to load arri config at ${args.config}. Please specify a valid config path with --config`
402
+ );
409
403
  }
410
- },
411
- run({ args }) {
412
- }
413
- });
414
- const codegen = citty.defineCommand({
415
- subCommands: {
416
- dart: codegenDart,
417
- typescript: codegenTypescript
418
- },
419
- run({ args }) {
404
+ const configPath = path__default.resolve(args.config);
405
+ const { config: config$1 } = await c12.loadConfig({ configFile: configPath });
406
+ if (!config.isResolvedArriConfig(config$1)) {
407
+ throw new Error(`Invalid arri config at ${args.config}`);
408
+ }
409
+ consola__default.info(`Generating ${config$1.clientGenerators.length} clients`);
410
+ await Promise.allSettled(
411
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
412
+ config$1.clientGenerators.map((gen) => gen.generator(def))
413
+ );
420
414
  }
421
415
  });
422
416
 
package/dist/cli.mjs CHANGED
@@ -11,10 +11,9 @@ import { build as build$1 } from 'esbuild';
11
11
  import { replace } from 'esbuild-plugin-replace';
12
12
  import path from 'pathe';
13
13
  import prettier from 'prettier';
14
- import { n as defaultConfig, m as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.8cfc63cb.mjs';
14
+ import { n as defaultConfig, m as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.d9f65487.mjs';
15
15
  import { globby } from 'globby';
16
16
  import { camelCase, kebabCase } from 'scule';
17
- import { dartClientGenerator } from 'arri-codegen-dart';
18
17
  import { ofetch } from 'ofetch';
19
18
  import { listenAndWatch } from '@joshmossas/listhen';
20
19
  import chokidar from 'chokidar';
@@ -324,75 +323,70 @@ async function createCodegenEntryFile(config) {
324
323
  );
325
324
  }
326
325
 
327
- const codegenDart = defineCommand({
326
+ const codegen = defineCommand({
328
327
  args: {
329
- location: {
328
+ schema: {
330
329
  type: "positional",
331
- required: true,
332
- description: "The path to an Arri definition file or a url that returns an Arri definition file."
333
- },
334
- clientName: {
335
- type: "string",
336
- alias: ["name"],
330
+ alias: ["l"],
337
331
  required: true
338
332
  },
339
- outFile: {
333
+ config: {
340
334
  type: "string",
341
- alias: ["out", "o"],
342
- required: true
335
+ alias: ["c"],
336
+ default: "arri.config.ts"
343
337
  }
344
338
  },
345
339
  async run({ args }) {
346
- const isUrl = args.location.startsWith("http://") || args.location.startsWith("https://");
340
+ const isUrl = args.schema.startsWith("http://") || args.schema.startsWith("https://");
341
+ const isTs = args.schema.endsWith(".ts");
342
+ const isJs = args.schema.endsWith(".js");
347
343
  let def;
348
344
  if (isUrl) {
349
- const result = await ofetch(args.location);
345
+ const result = await ofetch(args.schema);
346
+ if (!isAppDefinition(result)) {
347
+ throw new Error(`Invalid App Definition at ${args.schema}`);
348
+ }
350
349
  def = result;
351
350
  } else {
352
- if (!existsSync(args.location)) {
353
- throw new Error(`Unable to find ${args.location}`);
351
+ if (!fs$1.existsSync(args.schema)) {
352
+ throw new Error(`Unable to find ${args.schema}`);
353
+ }
354
+ if (isTs || isJs) {
355
+ const schemaResult = await loadConfig({
356
+ configFile: args.schema
357
+ });
358
+ if (!isAppDefinition(schemaResult.config)) {
359
+ throw new Error(`Invalid App Definition at ${args.schema}`);
360
+ }
361
+ def = schemaResult.config;
362
+ } else {
363
+ const jsonString = JSON.parse(
364
+ fs$1.readFileSync(args.schema, { encoding: "utf-8" })
365
+ );
366
+ if (!isAppDefinition(jsonString)) {
367
+ throw new Error(`Invalid App Definition at ${args.schema}`);
368
+ }
369
+ def = jsonString;
354
370
  }
355
- const jsonString = JSON.parse(
356
- readFileSync(args.location, { encoding: "utf-8" })
357
- );
358
- def = jsonString;
359
371
  }
360
372
  if (!def) {
361
- throw new Error("Unable to load ApplicationDefinition json file");
373
+ throw new Error(`Unable to find App Definition at ${args.schema}`);
362
374
  }
363
- await dartClientGenerator({
364
- clientName: args.clientName,
365
- outputFile: args.outFile
366
- }).generator(def);
367
- }
368
- });
369
- const codegenTypescript = defineCommand({
370
- args: {
371
- location: {
372
- type: "positional",
373
- required: true,
374
- description: "The path to an Arri definition file or a url that returns an Arri definition file."
375
- },
376
- clientName: {
377
- type: "string",
378
- alias: ["name"],
379
- required: true
380
- },
381
- outFile: {
382
- type: "string",
383
- alias: ["out", "o"],
384
- required: true
375
+ if (!fs$1.existsSync(path.resolve(args.config))) {
376
+ throw new Error(
377
+ `Unable to load arri config at ${args.config}. Please specify a valid config path with --config`
378
+ );
385
379
  }
386
- },
387
- run({ args }) {
388
- }
389
- });
390
- const codegen = defineCommand({
391
- subCommands: {
392
- dart: codegenDart,
393
- typescript: codegenTypescript
394
- },
395
- run({ args }) {
380
+ const configPath = path.resolve(args.config);
381
+ const { config } = await loadConfig({ configFile: configPath });
382
+ if (!isResolvedArriConfig(config)) {
383
+ throw new Error(`Invalid arri config at ${args.config}`);
384
+ }
385
+ consola.info(`Generating ${config.clientGenerators.length} clients`);
386
+ await Promise.allSettled(
387
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
388
+ config.clientGenerators.map((gen) => gen.generator(def))
389
+ );
396
390
  }
397
391
  });
398
392
 
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const config = require('./shared/arri.22a9d5c0.cjs');
3
+ const config = require('./shared/arri.31b22fac.cjs');
4
4
  const h3 = require('h3');
5
+ require('arri-codegen-utils');
5
6
  require('arri-validate');
6
7
  require('h3-sse');
7
- require('arri-codegen-utils');
8
8
  require('scule');
9
9
 
10
10
  const defineMiddleware = (middleware) => middleware;
package/dist/index.d.cts CHANGED
@@ -119,6 +119,7 @@ interface Rpc<TIsEventStream extends boolean = false, TParams extends RpcParamSc
119
119
  description?: string;
120
120
  params: TParams;
121
121
  response: TResponse;
122
+ isDeprecated?: boolean;
122
123
  isEventStream?: TIsEventStream;
123
124
  pingInterval?: TIsEventStream extends true ? number : undefined;
124
125
  handler: TIsEventStream extends true ? EventStreamRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined> : RpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : void>;
package/dist/index.d.mts CHANGED
@@ -119,6 +119,7 @@ interface Rpc<TIsEventStream extends boolean = false, TParams extends RpcParamSc
119
119
  description?: string;
120
120
  params: TParams;
121
121
  response: TResponse;
122
+ isDeprecated?: boolean;
122
123
  isEventStream?: TIsEventStream;
123
124
  pingInterval?: TIsEventStream extends true ? number : undefined;
124
125
  handler: TIsEventStream extends true ? EventStreamRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined> : RpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : void>;
package/dist/index.d.ts CHANGED
@@ -119,6 +119,7 @@ interface Rpc<TIsEventStream extends boolean = false, TParams extends RpcParamSc
119
119
  description?: string;
120
120
  params: TParams;
121
121
  response: TResponse;
122
+ isDeprecated?: boolean;
122
123
  isEventStream?: TIsEventStream;
123
124
  pingInterval?: TIsEventStream extends true ? number : undefined;
124
125
  handler: TIsEventStream extends true ? EventStreamRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined> : RpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : void>;
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- export { A as ArriApp, p as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, x as EventStreamConnection, c as createRpcDefinition, n as defaultConfig, o as defineConfig, h as defineError, u as defineEventStreamRpc, q as defineRoute, d as defineRpc, j as errorResponseFromValidationErrors, e as getRpcParamName, g as getRpcPath, f as getRpcResponseName, k as handleH3Error, t as handleRoute, l as isArriConfig, w as isEventStreamRpc, m as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, y as registerEventStreamRpc, s as registerRoute, r as registerRpc, v as validateRpcRequestInput } from './shared/arri.8cfc63cb.mjs';
1
+ export { A as ArriApp, p as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, x as EventStreamConnection, c as createRpcDefinition, n as defaultConfig, o as defineConfig, h as defineError, u as defineEventStreamRpc, q as defineRoute, d as defineRpc, j as errorResponseFromValidationErrors, e as getRpcParamName, g as getRpcPath, f as getRpcResponseName, k as handleH3Error, t as handleRoute, l as isArriConfig, w as isEventStreamRpc, m as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, y as registerEventStreamRpc, s as registerRoute, r as registerRpc, v as validateRpcRequestInput } from './shared/arri.d9f65487.mjs';
2
2
  export * from 'h3';
3
+ import 'arri-codegen-utils';
3
4
  import 'arri-validate';
4
5
  import 'h3-sse';
5
- import 'arri-codegen-utils';
6
6
  import 'scule';
7
7
 
8
8
  const defineMiddleware = (middleware) => middleware;
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ const arriCodegenUtils = require('arri-codegen-utils');
3
4
  const h3 = require('h3');
4
5
  const arriValidate = require('arri-validate');
5
6
  const h3Sse = require('h3-sse');
6
- const arriCodegenUtils = require('arri-codegen-utils');
7
7
  const scule = require('scule');
8
8
 
9
9
  const ErrorResponse = arriValidate.a.object({
@@ -233,6 +233,7 @@ function createRpcDefinition(rpcName, httpPath, procedure) {
233
233
  method,
234
234
  params: getRpcParamName(rpcName, procedure),
235
235
  response: getRpcResponseDefinition(rpcName, procedure),
236
+ isDeprecated: procedure.isDeprecated,
236
237
  isEventStream: procedure.isEventStream === true ? true : void 0
237
238
  };
238
239
  }
@@ -934,7 +935,7 @@ class ArriApp {
934
935
  }
935
936
  getAppDefinition() {
936
937
  const appDef = {
937
- arriSchemaVersion: "0.0.2",
938
+ arriSchemaVersion: arriCodegenUtils.SCHEMA_VERSION,
938
939
  info: this.appInfo,
939
940
  procedures: {},
940
941
  models: this.models
@@ -1,7 +1,7 @@
1
+ import { isRpcHttpMethod, removeDisallowedChars, SCHEMA_VERSION } from 'arri-codegen-utils';
1
2
  import { createError, isError, setResponseStatus, send, eventHandler, isPreflightRequest, setResponseHeader, readRawBody, getValidatedQuery, defineEventHandler, getQuery, setHeader, createRouter, createApp, sendError } from 'h3';
2
3
  import { a, isAObjectSchema, isARecordSchema, isADiscriminatorSchema } from 'arri-validate';
3
4
  import { createEventStream } from 'h3-sse';
4
- import { isRpcHttpMethod, removeDisallowedChars } from 'arri-codegen-utils';
5
5
  import { kebabCase, pascalCase } from 'scule';
6
6
 
7
7
  const ErrorResponse = a.object({
@@ -231,6 +231,7 @@ function createRpcDefinition(rpcName, httpPath, procedure) {
231
231
  method,
232
232
  params: getRpcParamName(rpcName, procedure),
233
233
  response: getRpcResponseDefinition(rpcName, procedure),
234
+ isDeprecated: procedure.isDeprecated,
234
235
  isEventStream: procedure.isEventStream === true ? true : void 0
235
236
  };
236
237
  }
@@ -932,7 +933,7 @@ class ArriApp {
932
933
  }
933
934
  getAppDefinition() {
934
935
  const appDef = {
935
- arriSchemaVersion: "0.0.2",
936
+ arriSchemaVersion: SCHEMA_VERSION,
936
937
  info: this.appInfo,
937
938
  procedures: {},
938
939
  models: this.models
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@joshmossas/listhen": "1.6.0",
29
- "c12": "^1.9.0",
29
+ "c12": "^1.10.0",
30
30
  "chokidar": "^3.6.0",
31
31
  "citty": "^0.1.6",
32
32
  "consola": "^3.2.3",
@@ -42,13 +42,13 @@
42
42
  "prettier": "^3.2.5",
43
43
  "scule": "^1.3.0",
44
44
  "uncrypto": "^0.1.3",
45
- "arri-codegen-utils": "0.27.1",
46
- "arri-validate": "0.27.1",
47
- "arri-codegen-ts": "0.27.1",
48
- "arri-codegen-dart": "0.27.1"
45
+ "arri-codegen-dart": "0.28.0",
46
+ "arri-validate": "0.28.0",
47
+ "arri-codegen-ts": "0.28.0",
48
+ "arri-codegen-utils": "0.28.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/degit": "^2.8.6",
52
- "bun-types": "^1.0.29"
52
+ "bun-types": "^1.0.30"
53
53
  }
54
54
  }