arri 0.81.1 → 0.81.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/README.md CHANGED
@@ -12,15 +12,16 @@ Command line interface for ARRI-RPC
12
12
 
13
13
  Run `arri --help` to get a full list of commands
14
14
 
15
- | Cmd | Description |
16
- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
17
- | build | Use the currently registered server plugin to build your arri server and run the code generators |
18
- | dev | Run the currently registered server plugin in dev mode (basically watches for changes and rebuilds the server and reruns code generators as needed) |
19
- | codegen [input-file] | Run generate clients specified in the `arri.config.ts`. See [here](#running-arri-codegen) for details. |
20
- | init [dir] | Scaffold an arri app/library |
21
- | list | List available arri versions |
22
- | use [version] | Update arri dependencies to a specific version (checks recursively for package.json, pubspec.yaml, cargo.toml, etc) |
23
- | version | Print current CLI version |
15
+ | Cmd | Description |
16
+ | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | build | Use the currently registered server plugin to build your arri server and run the code generators |
18
+ | dev | Run the currently registered server plugin in dev mode (basically watches for changes and rebuilds the server and reruns code generators as needed) |
19
+ | codegen [input-file] | Run generate clients specified in the `arri.config.ts`. See [here](#running-arri-codegen) for details. |
20
+ | export [format] [input-file] | Export AppDefinition to various formats. See [here](#exporting-json-schema) for details. |
21
+ | init [dir] | Scaffold an arri app/library |
22
+ | list | List available arri versions |
23
+ | use [version] | Update arri dependencies to a specific version (checks recursively for package.json, pubspec.yaml, cargo.toml, etc) |
24
+ | version | Print current CLI version |
24
25
 
25
26
  ## Usage with an Arri server
26
27
 
@@ -109,3 +110,41 @@ arri codegen https://example.com/__definition
109
110
  | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
110
111
  | --config | -c | Path to an arri config. Default is `arri.config.ts` |
111
112
  | --watch | -w | Watch an app definition file for changes. Only works on files. It will throw an error if invoked against an HTTP endpoint |
113
+
114
+ ## Exporting JSON Schema
115
+
116
+ `arri export json-schema` allows you to export your AppDefinition types as a [JSON Schema](https://json-schema.org/) file. This is useful for:
117
+
118
+ - **Editor support** - YAML/JSON files using Arri-defined schemas can get autocomplete in VS Code, IntelliJ, etc.
119
+ - **Interoperability** - Integration with tools that consume JSON Schema (OpenAPI, documentation generators, etc.)
120
+ - **Configuration validation** - Users defining config files can reference a JSON Schema URL for validation
121
+
122
+ ### Basic Usage
123
+
124
+ ```bash
125
+ # Export from a local file
126
+ arri export json-schema ./path/to/AppDefinition.json
127
+
128
+ # Export from a TS/JS file
129
+ arri export json-schema ./path/to/definitions.ts
130
+
131
+ # Export from an HTTP endpoint
132
+ arri export json-schema https://example.com/__definition
133
+ ```
134
+
135
+ ### Export Flags
136
+
137
+ | Flag | Aliases | Description |
138
+ | ------------- | ------- | ------------------------------------------------------------ |
139
+ | --output | -o | Output file path for JSON Schema. Default is `./schema.json` |
140
+ | --id | | `$id` to use in the JSON Schema |
141
+ | --title | | Title for the JSON Schema |
142
+ | --description | | Description for the JSON Schema |
143
+
144
+ ### Example
145
+
146
+ ```bash
147
+ arri export json-schema ./AppDefinition.json -o ./schemas/api.schema.json --id "https://example.com/schemas/api.json" --title "My API Schema" --description "API type definitions"
148
+ ```
149
+
150
+ This will generate a JSON Schema file with all your type definitions in the `$defs` section, which can then be used for validation and editor support.
package/dist/cli.cjs CHANGED
@@ -3,11 +3,10 @@
3
3
 
4
4
  const citty = require('citty');
5
5
  const c12 = require('c12');
6
- const common = require('./shared/arri.pHQOQ5Wb.cjs');
6
+ const common = require('./shared/arri.CjdtGagO.cjs');
7
7
  const fs = require('node:fs');
8
8
  const codegenUtils = require('@arrirpc/codegen-utils');
9
9
  const chokidar = require('chokidar');
10
- const ofetch = require('ofetch');
11
10
  const path = require('pathe');
12
11
  const schema = require('@arrirpc/schema');
13
12
  const Degit = require('degit');
@@ -15,6 +14,7 @@ const enquirer = require('enquirer');
15
14
  const prettier = require('prettier');
16
15
  const consola = require('consola');
17
16
  const promises = require('fs/promises');
17
+ const ofetch = require('ofetch');
18
18
  const node_url = require('node:url');
19
19
 
20
20
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -114,23 +114,17 @@ const codegen = citty.defineCommand({
114
114
  process.exit(1);
115
115
  }
116
116
  const isUrl = args.schema.startsWith("http://") || args.schema.startsWith("https://");
117
+ if (isUrl && args.watch) {
118
+ throw new Error("Cannot watch a URL");
119
+ }
117
120
  let def;
118
- if (isUrl) {
119
- if (args.watch) throw new Error("Cannot watch a URL");
120
- const result = await ofetch.ofetch(args.schema);
121
- if (!codegenUtils.isAppDefinition(result)) {
122
- throw new Error(`Invalid App Definition at ${args.schema}`);
123
- }
124
- def = result;
125
- } else {
126
- try {
127
- def = await getAppDefinitionFromFile(args.schema);
128
- } catch (err) {
129
- if (!args.watch) {
130
- throw err;
131
- }
132
- common.logger.error(err);
121
+ try {
122
+ def = await common.loadAppDefinition(args.schema);
123
+ } catch (err) {
124
+ if (!args.watch) {
125
+ throw err;
133
126
  }
127
+ common.logger.error(err);
134
128
  }
135
129
  if (!def && !args.watch) {
136
130
  throw new Error(`Unable to find App Definition at ${args.schema}`);
@@ -150,7 +144,7 @@ const codegen = citty.defineCommand({
150
144
  common.logger.info(`Change detected`);
151
145
  const startTime = /* @__PURE__ */ new Date();
152
146
  await runGenerators(
153
- await getAppDefinitionFromFile(args.schema),
147
+ await common.loadAppDefinition(args.schema),
154
148
  config.generators ?? []
155
149
  );
156
150
  common.logger.success(
@@ -165,7 +159,7 @@ const codegen = citty.defineCommand({
165
159
  common.logger.info(`Change detected in AppDefinition file.`);
166
160
  const startTime = /* @__PURE__ */ new Date();
167
161
  await runGenerators(
168
- await getAppDefinitionFromFile(args.schema),
162
+ await common.loadAppDefinition(args.schema),
169
163
  config.generators ?? []
170
164
  );
171
165
  common.logger.success(
@@ -177,37 +171,13 @@ const codegen = citty.defineCommand({
177
171
  });
178
172
  }
179
173
  });
180
- async function getAppDefinitionFromFile(file) {
181
- if (!fs__default.existsSync(file)) {
182
- throw new Error(`Unable to find ${file}`);
183
- }
184
- const isTs = file.endsWith(".ts");
185
- const isJs = file.endsWith(".js");
186
- if (isTs || isJs) {
187
- const schemaResult = await c12.loadConfig({
188
- configFile: file
189
- });
190
- if (!codegenUtils.isAppDefinition(schemaResult.config)) {
191
- throw new Error(`Invalid App Definition at ${file}`);
192
- }
193
- return schemaResult.config;
194
- } else {
195
- const parsingResult = JSON.parse(
196
- fs__default.readFileSync(file, { encoding: "utf-8" })
197
- );
198
- if (!codegenUtils.isAppDefinition(parsingResult)) {
199
- throw new Error(`Invalid App Definition at ${file}`);
200
- }
201
- return parsingResult;
202
- }
203
- }
204
174
  async function runGenerators(def, generators) {
205
175
  common.logger.info(`Generating ${generators?.length} client(s)`);
206
176
  await Promise.allSettled(
207
177
  generators.map(
208
178
  (gen) => gen.run(
209
179
  def ?? {
210
- schemaVersion: "0.0.7",
180
+ schemaVersion: codegenUtils.SCHEMA_VERSION,
211
181
  procedures: {},
212
182
  definitions: {}
213
183
  }
@@ -216,6 +186,72 @@ async function runGenerators(def, generators) {
216
186
  );
217
187
  }
218
188
 
189
+ const jsonSchema = citty.defineCommand({
190
+ meta: {
191
+ name: "json-schema",
192
+ description: "Export AppDefinition types as JSON Schema"
193
+ },
194
+ args: {
195
+ input: {
196
+ type: "positional",
197
+ required: true,
198
+ description: "Path to AppDefinition file (JSON, JS, or TS) or HTTP URL"
199
+ },
200
+ output: {
201
+ type: "string",
202
+ alias: ["o"],
203
+ description: "Output file path for JSON Schema",
204
+ default: "./schema.json"
205
+ },
206
+ id: { type: "string", description: "$id to use in the JSON Schema" },
207
+ title: { type: "string", description: "Title for the JSON Schema" },
208
+ description: {
209
+ type: "string",
210
+ description: "Description for the JSON Schema"
211
+ }
212
+ },
213
+ async run({ args }) {
214
+ common.logger.info(`Loading AppDefinition from ${args.input}...`);
215
+ const def = await common.loadAppDefinition(args.input);
216
+ const jsonSchema = appDefinitionToJsonSchema(def, {
217
+ $id: args.id,
218
+ title: args.title,
219
+ description: args.description
220
+ });
221
+ const outputPath = path__default.resolve(args.output);
222
+ fs__default.mkdirSync(path__default.dirname(outputPath), { recursive: true });
223
+ fs__default.writeFileSync(outputPath, JSON.stringify(jsonSchema, null, 2));
224
+ common.logger.success(`JSON Schema exported to ${outputPath}`);
225
+ }
226
+ });
227
+ function appDefinitionToJsonSchema(def, options) {
228
+ const $defs = Object.fromEntries(
229
+ Object.entries(def.definitions ?? {}).map(([name, schema$1]) => [
230
+ name,
231
+ schema.schemaToJsonSchema(schema$1)
232
+ ])
233
+ );
234
+ const description = options?.description ?? def.info?.description;
235
+ const title = options?.title ?? def.info?.title;
236
+ return {
237
+ $schema: "https://json-schema.org/draft/2020-12/schema",
238
+ ...options?.$id && { $id: options.$id },
239
+ ...title && { title },
240
+ ...description && { description },
241
+ ...Object.keys($defs).length > 0 && { $defs }
242
+ };
243
+ }
244
+
245
+ const exportCmd = citty.defineCommand({
246
+ meta: {
247
+ name: "export",
248
+ description: "Export AppDefinition to various formats"
249
+ },
250
+ subCommands: {
251
+ "json-schema": jsonSchema
252
+ }
253
+ });
254
+
219
255
  const Language = schema.a.enumerator(["typescript", "go"]);
220
256
  const CliArgs = schema.a.object({
221
257
  dir: schema.a.string(),
@@ -820,6 +856,7 @@ const main = citty.defineCommand({
820
856
  build,
821
857
  codegen,
822
858
  dev: common.dev,
859
+ export: exportCmd,
823
860
  init,
824
861
  list,
825
862
  use,
package/dist/cli.mjs CHANGED
@@ -1,18 +1,18 @@
1
1
  #! /usr/bin/env node
2
2
  import { defineCommand, runCommand, runMain } from 'citty';
3
3
  import { loadConfig } from 'c12';
4
- import { a as isArriConfig, l as logger, g as getArriPackageMetadata, e as dev } from './shared/arri.CGlJ9Ywd.mjs';
4
+ import { a as isArriConfig, l as logger, e as loadAppDefinition, g as getArriPackageMetadata, f as dev } from './shared/arri.Bq5F3a0A.mjs';
5
5
  import fs, { rmSync, readFileSync, writeFileSync } from 'node:fs';
6
- import { isAppDefinition, kebabCase } from '@arrirpc/codegen-utils';
6
+ import { SCHEMA_VERSION, kebabCase } from '@arrirpc/codegen-utils';
7
7
  import { watch } from 'chokidar';
8
- import { ofetch } from 'ofetch';
9
8
  import path from 'pathe';
10
- import { a } from '@arrirpc/schema';
9
+ import { schemaToJsonSchema, a } from '@arrirpc/schema';
11
10
  import Degit from 'degit';
12
11
  import enquirer from 'enquirer';
13
12
  import prettier from 'prettier';
14
13
  import consola from 'consola';
15
14
  import { readFile, writeFile } from 'fs/promises';
15
+ import { ofetch } from 'ofetch';
16
16
  import { fileURLToPath } from 'node:url';
17
17
 
18
18
  const build = defineCommand({
@@ -102,23 +102,17 @@ const codegen = defineCommand({
102
102
  process.exit(1);
103
103
  }
104
104
  const isUrl = args.schema.startsWith("http://") || args.schema.startsWith("https://");
105
+ if (isUrl && args.watch) {
106
+ throw new Error("Cannot watch a URL");
107
+ }
105
108
  let def;
106
- if (isUrl) {
107
- if (args.watch) throw new Error("Cannot watch a URL");
108
- const result = await ofetch(args.schema);
109
- if (!isAppDefinition(result)) {
110
- throw new Error(`Invalid App Definition at ${args.schema}`);
111
- }
112
- def = result;
113
- } else {
114
- try {
115
- def = await getAppDefinitionFromFile(args.schema);
116
- } catch (err) {
117
- if (!args.watch) {
118
- throw err;
119
- }
120
- logger.error(err);
109
+ try {
110
+ def = await loadAppDefinition(args.schema);
111
+ } catch (err) {
112
+ if (!args.watch) {
113
+ throw err;
121
114
  }
115
+ logger.error(err);
122
116
  }
123
117
  if (!def && !args.watch) {
124
118
  throw new Error(`Unable to find App Definition at ${args.schema}`);
@@ -138,7 +132,7 @@ const codegen = defineCommand({
138
132
  logger.info(`Change detected`);
139
133
  const startTime = /* @__PURE__ */ new Date();
140
134
  await runGenerators(
141
- await getAppDefinitionFromFile(args.schema),
135
+ await loadAppDefinition(args.schema),
142
136
  config.generators ?? []
143
137
  );
144
138
  logger.success(
@@ -153,7 +147,7 @@ const codegen = defineCommand({
153
147
  logger.info(`Change detected in AppDefinition file.`);
154
148
  const startTime = /* @__PURE__ */ new Date();
155
149
  await runGenerators(
156
- await getAppDefinitionFromFile(args.schema),
150
+ await loadAppDefinition(args.schema),
157
151
  config.generators ?? []
158
152
  );
159
153
  logger.success(
@@ -165,37 +159,13 @@ const codegen = defineCommand({
165
159
  });
166
160
  }
167
161
  });
168
- async function getAppDefinitionFromFile(file) {
169
- if (!fs.existsSync(file)) {
170
- throw new Error(`Unable to find ${file}`);
171
- }
172
- const isTs = file.endsWith(".ts");
173
- const isJs = file.endsWith(".js");
174
- if (isTs || isJs) {
175
- const schemaResult = await loadConfig({
176
- configFile: file
177
- });
178
- if (!isAppDefinition(schemaResult.config)) {
179
- throw new Error(`Invalid App Definition at ${file}`);
180
- }
181
- return schemaResult.config;
182
- } else {
183
- const parsingResult = JSON.parse(
184
- fs.readFileSync(file, { encoding: "utf-8" })
185
- );
186
- if (!isAppDefinition(parsingResult)) {
187
- throw new Error(`Invalid App Definition at ${file}`);
188
- }
189
- return parsingResult;
190
- }
191
- }
192
162
  async function runGenerators(def, generators) {
193
163
  logger.info(`Generating ${generators?.length} client(s)`);
194
164
  await Promise.allSettled(
195
165
  generators.map(
196
166
  (gen) => gen.run(
197
167
  def ?? {
198
- schemaVersion: "0.0.7",
168
+ schemaVersion: SCHEMA_VERSION,
199
169
  procedures: {},
200
170
  definitions: {}
201
171
  }
@@ -204,6 +174,72 @@ async function runGenerators(def, generators) {
204
174
  );
205
175
  }
206
176
 
177
+ const jsonSchema = defineCommand({
178
+ meta: {
179
+ name: "json-schema",
180
+ description: "Export AppDefinition types as JSON Schema"
181
+ },
182
+ args: {
183
+ input: {
184
+ type: "positional",
185
+ required: true,
186
+ description: "Path to AppDefinition file (JSON, JS, or TS) or HTTP URL"
187
+ },
188
+ output: {
189
+ type: "string",
190
+ alias: ["o"],
191
+ description: "Output file path for JSON Schema",
192
+ default: "./schema.json"
193
+ },
194
+ id: { type: "string", description: "$id to use in the JSON Schema" },
195
+ title: { type: "string", description: "Title for the JSON Schema" },
196
+ description: {
197
+ type: "string",
198
+ description: "Description for the JSON Schema"
199
+ }
200
+ },
201
+ async run({ args }) {
202
+ logger.info(`Loading AppDefinition from ${args.input}...`);
203
+ const def = await loadAppDefinition(args.input);
204
+ const jsonSchema = appDefinitionToJsonSchema(def, {
205
+ $id: args.id,
206
+ title: args.title,
207
+ description: args.description
208
+ });
209
+ const outputPath = path.resolve(args.output);
210
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
211
+ fs.writeFileSync(outputPath, JSON.stringify(jsonSchema, null, 2));
212
+ logger.success(`JSON Schema exported to ${outputPath}`);
213
+ }
214
+ });
215
+ function appDefinitionToJsonSchema(def, options) {
216
+ const $defs = Object.fromEntries(
217
+ Object.entries(def.definitions ?? {}).map(([name, schema]) => [
218
+ name,
219
+ schemaToJsonSchema(schema)
220
+ ])
221
+ );
222
+ const description = options?.description ?? def.info?.description;
223
+ const title = options?.title ?? def.info?.title;
224
+ return {
225
+ $schema: "https://json-schema.org/draft/2020-12/schema",
226
+ ...options?.$id && { $id: options.$id },
227
+ ...title && { title },
228
+ ...description && { description },
229
+ ...Object.keys($defs).length > 0 && { $defs }
230
+ };
231
+ }
232
+
233
+ const exportCmd = defineCommand({
234
+ meta: {
235
+ name: "export",
236
+ description: "Export AppDefinition to various formats"
237
+ },
238
+ subCommands: {
239
+ "json-schema": jsonSchema
240
+ }
241
+ });
242
+
207
243
  const Language = a.enumerator(["typescript", "go"]);
208
244
  const CliArgs = a.object({
209
245
  dir: a.string(),
@@ -808,6 +844,7 @@ const main = defineCommand({
808
844
  build,
809
845
  codegen,
810
846
  dev,
847
+ export: exportCmd,
811
848
  init,
812
849
  list,
813
850
  use,
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@ const kotlinCodegen = require('@arrirpc/codegen-kotlin');
5
5
  const rustCodegen = require('@arrirpc/codegen-rust');
6
6
  const swiftCodegen = require('@arrirpc/codegen-swift');
7
7
  const typescriptCodegen = require('@arrirpc/codegen-ts');
8
- const common = require('./shared/arri.pHQOQ5Wb.cjs');
8
+ const common = require('./shared/arri.CjdtGagO.cjs');
9
9
  const node_child_process = require('node:child_process');
10
10
  const fs = require('node:fs');
11
11
  const node_process = require('node:process');
package/dist/index.mjs CHANGED
@@ -3,8 +3,8 @@ import * as kotlinCodegen from '@arrirpc/codegen-kotlin';
3
3
  import * as rustCodegen from '@arrirpc/codegen-rust';
4
4
  import * as swiftCodegen from '@arrirpc/codegen-swift';
5
5
  import * as typescriptCodegen from '@arrirpc/codegen-ts';
6
- import { d as defineServerConfig, l as logger, i as isInsideDir } from './shared/arri.CGlJ9Ywd.mjs';
7
- export { D as DEV_DEFINITION_ENDPOINT, b as defineConfig, a as isArriConfig, c as isServerConfig } from './shared/arri.CGlJ9Ywd.mjs';
6
+ import { d as defineServerConfig, l as logger, i as isInsideDir } from './shared/arri.Bq5F3a0A.mjs';
7
+ export { D as DEV_DEFINITION_ENDPOINT, b as defineConfig, a as isArriConfig, c as isServerConfig } from './shared/arri.Bq5F3a0A.mjs';
8
8
  import { execSync, spawn } from 'node:child_process';
9
9
  import fs$1, { existsSync } from 'node:fs';
10
10
  import { cwd } from 'node:process';
@@ -1,6 +1,8 @@
1
1
  import { loadConfig } from 'c12';
2
2
  import { defineCommand, runCommand } from 'citty';
3
3
  import path from 'pathe';
4
+ import fs from 'node:fs';
5
+ import { isAppDefinition } from '@arrirpc/codegen-utils';
4
6
  import { a, ValidationException } from '@arrirpc/schema';
5
7
  import { createConsola } from 'consola';
6
8
  import { ofetch } from 'ofetch';
@@ -71,6 +73,31 @@ const dev = defineCommand({
71
73
  });
72
74
 
73
75
  const logger = createConsola().withTag("arri");
76
+ async function loadAppDefinition(input) {
77
+ const isUrl = input.startsWith("http://") || input.startsWith("https://");
78
+ if (isUrl) {
79
+ const result = await ofetch(input);
80
+ if (!isAppDefinition(result)) {
81
+ throw new Error(`Invalid App Definition at ${input}`);
82
+ }
83
+ return result;
84
+ }
85
+ if (!fs.existsSync(input)) {
86
+ throw new Error(`Unable to find ${input}`);
87
+ }
88
+ if (input.endsWith(".ts") || input.endsWith(".js")) {
89
+ const { config } = await loadConfig({ configFile: input });
90
+ if (!isAppDefinition(config)) {
91
+ throw new Error(`Invalid App Definition at ${input}`);
92
+ }
93
+ return config;
94
+ }
95
+ const parsed = JSON.parse(fs.readFileSync(input, "utf-8"));
96
+ if (!isAppDefinition(parsed)) {
97
+ throw new Error(`Invalid App Definition at ${input}`);
98
+ }
99
+ return parsed;
100
+ }
74
101
  function isInsideDir(dir, parentDir) {
75
102
  if (path.resolve(dir).startsWith(path.resolve(parentDir))) {
76
103
  return true;
@@ -159,4 +186,4 @@ const NpmRegistryPackage = a.object({
159
186
  readmeFilename: a.optional(a.string())
160
187
  });
161
188
 
162
- export { DEV_DEFINITION_ENDPOINT as D, isArriConfig as a, defineConfig as b, isServerConfig as c, defineServerConfig as d, dev as e, getArriPackageMetadata as g, isInsideDir as i, logger as l };
189
+ export { DEV_DEFINITION_ENDPOINT as D, isArriConfig as a, defineConfig as b, isServerConfig as c, defineServerConfig as d, loadAppDefinition as e, dev as f, getArriPackageMetadata as g, isInsideDir as i, logger as l };
@@ -3,6 +3,8 @@
3
3
  const c12 = require('c12');
4
4
  const citty = require('citty');
5
5
  const path = require('pathe');
6
+ const fs = require('node:fs');
7
+ const codegenUtils = require('@arrirpc/codegen-utils');
6
8
  const schema = require('@arrirpc/schema');
7
9
  const consola = require('consola');
8
10
  const ofetch = require('ofetch');
@@ -10,6 +12,7 @@ const ofetch = require('ofetch');
10
12
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
13
 
12
14
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
15
+ const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
13
16
 
14
17
  function isServerConfig(input) {
15
18
  if (typeof input !== "object" || input === null) {
@@ -77,6 +80,31 @@ const dev = citty.defineCommand({
77
80
  });
78
81
 
79
82
  const logger = consola.createConsola().withTag("arri");
83
+ async function loadAppDefinition(input) {
84
+ const isUrl = input.startsWith("http://") || input.startsWith("https://");
85
+ if (isUrl) {
86
+ const result = await ofetch.ofetch(input);
87
+ if (!codegenUtils.isAppDefinition(result)) {
88
+ throw new Error(`Invalid App Definition at ${input}`);
89
+ }
90
+ return result;
91
+ }
92
+ if (!fs__default.existsSync(input)) {
93
+ throw new Error(`Unable to find ${input}`);
94
+ }
95
+ if (input.endsWith(".ts") || input.endsWith(".js")) {
96
+ const { config } = await c12.loadConfig({ configFile: input });
97
+ if (!codegenUtils.isAppDefinition(config)) {
98
+ throw new Error(`Invalid App Definition at ${input}`);
99
+ }
100
+ return config;
101
+ }
102
+ const parsed = JSON.parse(fs__default.readFileSync(input, "utf-8"));
103
+ if (!codegenUtils.isAppDefinition(parsed)) {
104
+ throw new Error(`Invalid App Definition at ${input}`);
105
+ }
106
+ return parsed;
107
+ }
80
108
  function isInsideDir(dir, parentDir) {
81
109
  if (path__default.resolve(dir).startsWith(path__default.resolve(parentDir))) {
82
110
  return true;
@@ -173,4 +201,5 @@ exports.getArriPackageMetadata = getArriPackageMetadata;
173
201
  exports.isArriConfig = isArriConfig;
174
202
  exports.isInsideDir = isInsideDir;
175
203
  exports.isServerConfig = isServerConfig;
204
+ exports.loadAppDefinition = loadAppDefinition;
176
205
  exports.logger = logger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.81.1",
3
+ "version": "0.81.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -39,13 +39,13 @@
39
39
  "ofetch": "^1.5.1",
40
40
  "pathe": "^2.0.3",
41
41
  "prettier": "^3.7.4",
42
- "@arrirpc/codegen-dart": "0.81.1",
43
- "@arrirpc/codegen-kotlin": "0.81.1",
44
- "@arrirpc/codegen-rust": "0.81.1",
45
- "@arrirpc/codegen-swift": "0.81.1",
46
- "@arrirpc/codegen-utils": "0.81.1",
47
- "@arrirpc/schema": "0.81.1",
48
- "@arrirpc/codegen-ts": "0.81.1"
42
+ "@arrirpc/codegen-dart": "0.81.2",
43
+ "@arrirpc/codegen-kotlin": "0.81.2",
44
+ "@arrirpc/codegen-ts": "0.81.2",
45
+ "@arrirpc/codegen-rust": "0.81.2",
46
+ "@arrirpc/codegen-utils": "0.81.2",
47
+ "@arrirpc/schema": "0.81.2",
48
+ "@arrirpc/codegen-swift": "0.81.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/degit": "^2.8.6"