arri 0.0.5 → 0.0.6

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.
@@ -1,33 +1,31 @@
1
1
  'use strict';
2
2
 
3
- const index = require('../shared/arri.e2731572.cjs');
4
- const module$1 = require('module');
5
- const url = require('url');
6
- const path6 = require('path');
3
+ const require$$2 = require('module');
4
+ const require$$7 = require('url');
5
+ const require$$0 = require('path');
7
6
  const process4 = require('process');
8
- const os = require('os');
7
+ const require$$0$2 = require('os');
9
8
  const tty = require('tty');
10
9
  const fs$1 = require('fs');
11
10
  const assert4 = require('assert');
12
11
  const fs = require('fs/promises');
13
12
  const v8 = require('v8');
14
- const util = require('util');
15
- const child_process = require('child_process');
13
+ const require$$0$1 = require('util');
16
14
 
17
15
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
18
16
 
19
- const path6__default = /*#__PURE__*/_interopDefaultCompat(path6);
17
+ const require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
20
18
  const process4__default = /*#__PURE__*/_interopDefaultCompat(process4);
21
- const os__default = /*#__PURE__*/_interopDefaultCompat(os);
19
+ const require$$0__default$1 = /*#__PURE__*/_interopDefaultCompat(require$$0$2);
22
20
  const tty__default = /*#__PURE__*/_interopDefaultCompat(tty);
23
21
  const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs$1);
24
22
  const assert4__default = /*#__PURE__*/_interopDefaultCompat(assert4);
25
23
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
26
24
  const v8__default = /*#__PURE__*/_interopDefaultCompat(v8);
27
25
 
28
- const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('codegen/index.cjs', document.baseURI).href)));
29
- const __filename$2 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('codegen/index.cjs', document.baseURI).href)));
30
- const __dirname$1 = path6.dirname(__filename$2);
26
+ const require$2 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.38ad6cd0.cjs', document.baseURI).href)));
27
+ const __filename$2 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.38ad6cd0.cjs', document.baseURI).href)));
28
+ const __dirname$1 = require$$0.dirname(__filename$2);
31
29
 
32
30
  var __create$1 = Object.create;
33
31
  var __defProp$2 = Object.defineProperty;
@@ -7791,9 +7789,9 @@ const doc = {
7791
7789
  utils: utils
7792
7790
  };
7793
7791
 
7794
- const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('codegen/index.cjs', document.baseURI).href)));
7795
- const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('codegen/index.cjs', document.baseURI).href)));
7796
- path6.dirname(__filename$1);
7792
+ const require$1 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.38ad6cd0.cjs', document.baseURI).href)));
7793
+ const __filename$1 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.38ad6cd0.cjs', document.baseURI).href)));
7794
+ require$$0.dirname(__filename$1);
7797
7795
 
7798
7796
  var __create = Object.create;
7799
7797
  var __defProp = Object.defineProperty;
@@ -21416,7 +21414,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
21416
21414
  return min;
21417
21415
  }
21418
21416
  if (process4__default.platform === "win32") {
21419
- const osRelease = os__default.release().split(".");
21417
+ const osRelease = require$$0__default$1.release().split(".");
21420
21418
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
21421
21419
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
21422
21420
  }
@@ -26012,10 +26010,10 @@ var partition_default = partition2;
26012
26010
  var import_editorconfig = __toESM(require_src(), 1);
26013
26011
  var import_editorconfig_to_prettier = __toESM(require_editorconfig_to_prettier(), 1);
26014
26012
  var MARKERS = [".git", ".hg"];
26015
- var markerExists = (directory) => MARKERS.some((mark) => fs__default$1.existsSync(path6__default.join(directory, mark)));
26013
+ var markerExists = (directory) => MARKERS.some((mark) => fs__default$1.existsSync(require$$0__default.join(directory, mark)));
26016
26014
  function findProjectRoot(directory) {
26017
26015
  while (!markerExists(directory)) {
26018
- const parentDirectory = path6__default.resolve(directory, "..");
26016
+ const parentDirectory = require$$0__default.resolve(directory, "..");
26019
26017
  if (parentDirectory === directory) {
26020
26018
  break;
26021
26019
  }
@@ -26028,7 +26026,7 @@ var find_project_root_default = findProjectRoot;
26028
26026
  // src/config/resolve-editorconfig.js
26029
26027
  async function loadEditorConfig(filePath) {
26030
26028
  const editorConfig = await import_editorconfig.default.parse(filePath, {
26031
- root: find_project_root_default(path6__default.dirname(path6__default.resolve(filePath)))
26029
+ root: find_project_root_default(require$$0__default.dirname(require$$0__default.resolve(filePath)))
26032
26030
  });
26033
26031
  const config = (0, import_editorconfig_to_prettier.default)(editorConfig);
26034
26032
  if (config) {
@@ -26042,7 +26040,7 @@ var resolve_editorconfig_default = loadEditorConfig;
26042
26040
  var import_parse_async = __toESM(require_parse_async(), 1);
26043
26041
  var import_parse3 = __toESM(require_parse3(), 1);
26044
26042
  function requireFromFile(id, parent) {
26045
- const require2 = module$1.createRequire(parent);
26043
+ const require2 = require$$2.createRequire(parent);
26046
26044
  return require2(id);
26047
26045
  }
26048
26046
  var require_from_file_default = requireFromFile;
@@ -26254,7 +26252,7 @@ codes.ERR_INVALID_ARG_VALUE = createError(
26254
26252
  * @param {string} [reason='is invalid']
26255
26253
  */
26256
26254
  (name, value, reason = "is invalid") => {
26257
- let inspected = util.inspect(value);
26255
+ let inspected = require$$0$1.inspect(value);
26258
26256
  if (inspected.length > 128) {
26259
26257
  inspected = `${inspected.slice(0, 128)}...`;
26260
26258
  }
@@ -26379,7 +26377,7 @@ function getMessage(key, args, self) {
26379
26377
  if (args.length === 0)
26380
26378
  return message;
26381
26379
  args.unshift(message);
26382
- return Reflect.apply(util.format, null, args);
26380
+ return Reflect.apply(require$$0$1.format, null, args);
26383
26381
  }
26384
26382
  function determineSpecificType(value) {
26385
26383
  if (value === null || value === void 0) {
@@ -26392,9 +26390,9 @@ function determineSpecificType(value) {
26392
26390
  if (value.constructor && value.constructor.name) {
26393
26391
  return `an instance of ${value.constructor.name}`;
26394
26392
  }
26395
- return `${util.inspect(value, { depth: -1 })}`;
26393
+ return `${require$$0$1.inspect(value, { depth: -1 })}`;
26396
26394
  }
26397
- let inspected = util.inspect(value, { colors: false });
26395
+ let inspected = require$$0$1.inspect(value, { colors: false });
26398
26396
  if (inspected.length > 28) {
26399
26397
  inspected = `${inspected.slice(0, 25)}...`;
26400
26398
  }
@@ -26405,7 +26403,7 @@ var package_json_reader_default = reader;
26405
26403
  function read(jsonPath) {
26406
26404
  try {
26407
26405
  const string = fs__default$1.readFileSync(
26408
- path6__default.toNamespacedPath(path6__default.join(path6__default.dirname(jsonPath), "package.json")),
26406
+ require$$0__default.toNamespacedPath(require$$0__default.join(require$$0__default.dirname(jsonPath), "package.json")),
26409
26407
  "utf8"
26410
26408
  );
26411
26409
  return { string };
@@ -26453,7 +26451,7 @@ function getPackageConfig(path9, specifier, base) {
26453
26451
  );
26454
26452
  throw new ERR_INVALID_PACKAGE_CONFIG(
26455
26453
  path9,
26456
- (base ? `"${specifier}" from ` : "") + url.fileURLToPath(base || specifier),
26454
+ (base ? `"${specifier}" from ` : "") + require$$7.fileURLToPath(base || specifier),
26457
26455
  exception.message
26458
26456
  );
26459
26457
  }
@@ -26473,23 +26471,23 @@ function getPackageConfig(path9, specifier, base) {
26473
26471
  return packageConfig;
26474
26472
  }
26475
26473
  function getPackageScopeConfig(resolved) {
26476
- let packageJsonUrl = new url.URL("package.json", resolved);
26474
+ let packageJsonUrl = new require$$7.URL("package.json", resolved);
26477
26475
  while (true) {
26478
26476
  const packageJsonPath2 = packageJsonUrl.pathname;
26479
26477
  if (packageJsonPath2.endsWith("node_modules/package.json"))
26480
26478
  break;
26481
26479
  const packageConfig2 = getPackageConfig(
26482
- url.fileURLToPath(packageJsonUrl),
26480
+ require$$7.fileURLToPath(packageJsonUrl),
26483
26481
  resolved
26484
26482
  );
26485
26483
  if (packageConfig2.exists)
26486
26484
  return packageConfig2;
26487
26485
  const lastPackageJsonUrl = packageJsonUrl;
26488
- packageJsonUrl = new url.URL("../package.json", packageJsonUrl);
26486
+ packageJsonUrl = new require$$7.URL("../package.json", packageJsonUrl);
26489
26487
  if (packageJsonUrl.pathname === lastPackageJsonUrl.pathname)
26490
26488
  break;
26491
26489
  }
26492
- const packageJsonPath = url.fileURLToPath(packageJsonUrl);
26490
+ const packageJsonPath = require$$7.fileURLToPath(packageJsonUrl);
26493
26491
  const packageConfig = {
26494
26492
  pjsonPath: packageJsonPath,
26495
26493
  exists: false,
@@ -26558,10 +26556,10 @@ function extname(url) {
26558
26556
  }
26559
26557
  return "";
26560
26558
  }
26561
- function getFileProtocolModuleFormat(url$1, _context, ignoreErrors) {
26562
- const ext = extname(url$1);
26559
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
26560
+ const ext = extname(url);
26563
26561
  if (ext === ".js") {
26564
- return getPackageType(url$1) === "module" ? "module" : "commonjs";
26562
+ return getPackageType(url) === "module" ? "module" : "commonjs";
26565
26563
  }
26566
26564
  const format3 = extensionFormatMap[ext];
26567
26565
  if (format3)
@@ -26569,7 +26567,7 @@ function getFileProtocolModuleFormat(url$1, _context, ignoreErrors) {
26569
26567
  if (ignoreErrors) {
26570
26568
  return void 0;
26571
26569
  }
26572
- const filepath = url.fileURLToPath(url$1);
26570
+ const filepath = require$$7.fileURLToPath(url);
26573
26571
  throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath);
26574
26572
  }
26575
26573
  function getHttpProtocolModuleFormat() {
@@ -26628,21 +26626,21 @@ var encodedSepRegEx = /%2f|%5c/i;
26628
26626
  var emittedPackageWarnings = /* @__PURE__ */ new Set();
26629
26627
  var doubleSlashRegEx = /[/\\]{2}/;
26630
26628
  function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
26631
- const pjsonPath = url.fileURLToPath(packageJsonUrl);
26629
+ const pjsonPath = require$$7.fileURLToPath(packageJsonUrl);
26632
26630
  const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
26633
26631
  process4__default.emitWarning(
26634
- `Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${url.fileURLToPath(base)}` : ""}.`,
26632
+ `Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${require$$7.fileURLToPath(base)}` : ""}.`,
26635
26633
  "DeprecationWarning",
26636
26634
  "DEP0166"
26637
26635
  );
26638
26636
  }
26639
- function emitLegacyIndexDeprecation(url$1, packageJsonUrl, base, main) {
26640
- const format3 = defaultGetFormatWithoutErrors(url$1, { parentURL: base.href });
26637
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
26638
+ const format3 = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
26641
26639
  if (format3 !== "module")
26642
26640
  return;
26643
- const path9 = url.fileURLToPath(url$1.href);
26644
- const pkgPath = url.fileURLToPath(new url.URL(".", packageJsonUrl));
26645
- const basePath = url.fileURLToPath(base);
26641
+ const path9 = require$$7.fileURLToPath(url.href);
26642
+ const pkgPath = require$$7.fileURLToPath(new require$$7.URL(".", packageJsonUrl));
26643
+ const basePath = require$$7.fileURLToPath(base);
26646
26644
  if (main)
26647
26645
  process4__default.emitWarning(
26648
26646
  `Package ${pkgPath} has a "main" field set to ${JSON.stringify(main)}, excluding the full filename and extension to the resolved file at "${path9.slice(
@@ -26677,7 +26675,7 @@ function fileExists(url) {
26677
26675
  function legacyMainResolve(packageJsonUrl, packageConfig, base) {
26678
26676
  let guess;
26679
26677
  if (packageConfig.main !== void 0) {
26680
- guess = new url.URL(packageConfig.main, packageJsonUrl);
26678
+ guess = new require$$7.URL(packageConfig.main, packageJsonUrl);
26681
26679
  if (fileExists(guess))
26682
26680
  return guess;
26683
26681
  const tries2 = [
@@ -26690,7 +26688,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
26690
26688
  ];
26691
26689
  let i2 = -1;
26692
26690
  while (++i2 < tries2.length) {
26693
- guess = new url.URL(tries2[i2], packageJsonUrl);
26691
+ guess = new require$$7.URL(tries2[i2], packageJsonUrl);
26694
26692
  if (fileExists(guess))
26695
26693
  break;
26696
26694
  guess = void 0;
@@ -26708,7 +26706,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
26708
26706
  const tries = ["./index.js", "./index.json", "./index.node"];
26709
26707
  let i = -1;
26710
26708
  while (++i < tries.length) {
26711
- guess = new url.URL(tries[i], packageJsonUrl);
26709
+ guess = new require$$7.URL(tries[i], packageJsonUrl);
26712
26710
  if (fileExists(guess))
26713
26711
  break;
26714
26712
  guess = void 0;
@@ -26718,8 +26716,8 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
26718
26716
  return guess;
26719
26717
  }
26720
26718
  throw new ERR_MODULE_NOT_FOUND(
26721
- url.fileURLToPath(new url.URL(".", packageJsonUrl)),
26722
- url.fileURLToPath(base)
26719
+ require$$7.fileURLToPath(new require$$7.URL(".", packageJsonUrl)),
26720
+ require$$7.fileURLToPath(base)
26723
26721
  );
26724
26722
  }
26725
26723
  function finalizeResolution(resolved, base, preserveSymlinks) {
@@ -26727,28 +26725,28 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
26727
26725
  throw new ERR_INVALID_MODULE_SPECIFIER(
26728
26726
  resolved.pathname,
26729
26727
  'must not include encoded "/" or "\\" characters',
26730
- url.fileURLToPath(base)
26728
+ require$$7.fileURLToPath(base)
26731
26729
  );
26732
- const filePath = url.fileURLToPath(resolved);
26730
+ const filePath = require$$7.fileURLToPath(resolved);
26733
26731
  const stats = tryStatSync(
26734
26732
  filePath.endsWith("/") ? filePath.slice(-1) : filePath
26735
26733
  );
26736
26734
  if (stats.isDirectory()) {
26737
- const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, url.fileURLToPath(base));
26735
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, require$$7.fileURLToPath(base));
26738
26736
  error.url = String(resolved);
26739
26737
  throw error;
26740
26738
  }
26741
26739
  if (!stats.isFile()) {
26742
26740
  throw new ERR_MODULE_NOT_FOUND(
26743
26741
  filePath || resolved.pathname,
26744
- base && url.fileURLToPath(base),
26742
+ base && require$$7.fileURLToPath(base),
26745
26743
  "module"
26746
26744
  );
26747
26745
  }
26748
26746
  if (!preserveSymlinks) {
26749
26747
  const real = fs$1.realpathSync(filePath);
26750
26748
  const { search, hash } = resolved;
26751
- resolved = url.pathToFileURL(real + (filePath.endsWith(path6__default.sep) ? "/" : ""));
26749
+ resolved = require$$7.pathToFileURL(real + (filePath.endsWith(require$$0__default.sep) ? "/" : ""));
26752
26750
  resolved.search = search;
26753
26751
  resolved.hash = hash;
26754
26752
  }
@@ -26757,33 +26755,33 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
26757
26755
  function importNotDefined(specifier, packageJsonUrl, base) {
26758
26756
  return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
26759
26757
  specifier,
26760
- packageJsonUrl && url.fileURLToPath(new url.URL(".", packageJsonUrl)),
26761
- url.fileURLToPath(base)
26758
+ packageJsonUrl && require$$7.fileURLToPath(new require$$7.URL(".", packageJsonUrl)),
26759
+ require$$7.fileURLToPath(base)
26762
26760
  );
26763
26761
  }
26764
26762
  function exportsNotFound(subpath, packageJsonUrl, base) {
26765
26763
  return new ERR_PACKAGE_PATH_NOT_EXPORTED(
26766
- url.fileURLToPath(new url.URL(".", packageJsonUrl)),
26764
+ require$$7.fileURLToPath(new require$$7.URL(".", packageJsonUrl)),
26767
26765
  subpath,
26768
- base && url.fileURLToPath(base)
26766
+ base && require$$7.fileURLToPath(base)
26769
26767
  );
26770
26768
  }
26771
26769
  function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
26772
- const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${url.fileURLToPath(packageJsonUrl)}`;
26770
+ const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${require$$7.fileURLToPath(packageJsonUrl)}`;
26773
26771
  throw new ERR_INVALID_MODULE_SPECIFIER(
26774
26772
  request,
26775
26773
  reason,
26776
- base && url.fileURLToPath(base)
26774
+ base && require$$7.fileURLToPath(base)
26777
26775
  );
26778
26776
  }
26779
26777
  function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
26780
26778
  target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
26781
26779
  return new ERR_INVALID_PACKAGE_TARGET(
26782
- url.fileURLToPath(new url.URL(".", packageJsonUrl)),
26780
+ require$$7.fileURLToPath(new require$$7.URL(".", packageJsonUrl)),
26783
26781
  subpath,
26784
26782
  target,
26785
26783
  internal,
26786
- base && url.fileURLToPath(base)
26784
+ base && require$$7.fileURLToPath(base)
26787
26785
  );
26788
26786
  }
26789
26787
  function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
@@ -26793,7 +26791,7 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
26793
26791
  if (internal && !target.startsWith("../") && !target.startsWith("/")) {
26794
26792
  let isURL2 = false;
26795
26793
  try {
26796
- new url.URL(target);
26794
+ new require$$7.URL(target);
26797
26795
  isURL2 = true;
26798
26796
  } catch {
26799
26797
  }
@@ -26831,9 +26829,9 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
26831
26829
  throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
26832
26830
  }
26833
26831
  }
26834
- const resolved = new url.URL(target, packageJsonUrl);
26832
+ const resolved = new require$$7.URL(target, packageJsonUrl);
26835
26833
  const resolvedPath = resolved.pathname;
26836
- const packagePath = new url.URL(".", packageJsonUrl).pathname;
26834
+ const packagePath = new require$$7.URL(".", packageJsonUrl).pathname;
26837
26835
  if (!resolvedPath.startsWith(packagePath))
26838
26836
  throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
26839
26837
  if (subpath === "")
@@ -26862,7 +26860,7 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
26862
26860
  }
26863
26861
  }
26864
26862
  if (pattern) {
26865
- return new url.URL(
26863
+ return new require$$7.URL(
26866
26864
  RegExpPrototypeSymbolReplace.call(
26867
26865
  patternRegEx,
26868
26866
  resolved.href,
@@ -26870,7 +26868,7 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
26870
26868
  )
26871
26869
  );
26872
26870
  }
26873
- return new url.URL(subpath, resolved);
26871
+ return new require$$7.URL(subpath, resolved);
26874
26872
  }
26875
26873
  function isArrayIndex(key) {
26876
26874
  const keyNumber = Number(key);
@@ -26943,7 +26941,7 @@ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, b
26943
26941
  const key = keys[i];
26944
26942
  if (isArrayIndex(key)) {
26945
26943
  throw new ERR_INVALID_PACKAGE_CONFIG2(
26946
- url.fileURLToPath(packageJsonUrl),
26944
+ require$$7.fileURLToPath(packageJsonUrl),
26947
26945
  base,
26948
26946
  '"exports" cannot contain numeric property keys.'
26949
26947
  );
@@ -27002,7 +27000,7 @@ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
27002
27000
  isConditionalSugar = curIsConditionalSugar;
27003
27001
  } else if (isConditionalSugar !== curIsConditionalSugar) {
27004
27002
  throw new ERR_INVALID_PACKAGE_CONFIG2(
27005
- url.fileURLToPath(packageJsonUrl),
27003
+ require$$7.fileURLToPath(packageJsonUrl),
27006
27004
  base,
27007
27005
  `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`
27008
27006
  );
@@ -27011,12 +27009,12 @@ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
27011
27009
  return isConditionalSugar;
27012
27010
  }
27013
27011
  function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
27014
- const pjsonPath = url.fileURLToPath(pjsonUrl);
27012
+ const pjsonPath = require$$7.fileURLToPath(pjsonUrl);
27015
27013
  if (emittedPackageWarnings.has(pjsonPath + "|" + match))
27016
27014
  return;
27017
27015
  emittedPackageWarnings.add(pjsonPath + "|" + match);
27018
27016
  process4__default.emitWarning(
27019
- `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${url.fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
27017
+ `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${require$$7.fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
27020
27018
  "DeprecationWarning",
27021
27019
  "DEP0155"
27022
27020
  );
@@ -27114,12 +27112,12 @@ function patternKeyCompare(a, b) {
27114
27112
  function packageImportsResolve(name, base, conditions) {
27115
27113
  if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
27116
27114
  const reason = "is not a valid internal imports specifier name";
27117
- throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, url.fileURLToPath(base));
27115
+ throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, require$$7.fileURLToPath(base));
27118
27116
  }
27119
27117
  let packageJsonUrl;
27120
27118
  const packageConfig = getPackageScopeConfig(base);
27121
27119
  if (packageConfig.exists) {
27122
- packageJsonUrl = url.pathToFileURL(packageConfig.pjsonPath);
27120
+ packageJsonUrl = require$$7.pathToFileURL(packageConfig.pjsonPath);
27123
27121
  const imports = packageConfig.imports;
27124
27122
  if (imports) {
27125
27123
  if (own2.call(imports, name) && !name.includes("*")) {
@@ -27198,15 +27196,15 @@ function parsePackageName(specifier, base) {
27198
27196
  throw new ERR_INVALID_MODULE_SPECIFIER(
27199
27197
  specifier,
27200
27198
  "is not a valid package name",
27201
- url.fileURLToPath(base)
27199
+ require$$7.fileURLToPath(base)
27202
27200
  );
27203
27201
  }
27204
27202
  const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
27205
27203
  return { packageName, packageSubpath, isScoped };
27206
27204
  }
27207
27205
  function packageResolve(specifier, base, conditions) {
27208
- if (module$1.builtinModules.includes(specifier)) {
27209
- return new url.URL("node:" + specifier);
27206
+ if (require$$2.builtinModules.includes(specifier)) {
27207
+ return new require$$7.URL("node:" + specifier);
27210
27208
  }
27211
27209
  const { packageName, packageSubpath, isScoped } = parsePackageName(
27212
27210
  specifier,
@@ -27214,7 +27212,7 @@ function packageResolve(specifier, base, conditions) {
27214
27212
  );
27215
27213
  const packageConfig = getPackageScopeConfig(base);
27216
27214
  if (packageConfig.exists) {
27217
- const packageJsonUrl2 = url.pathToFileURL(packageConfig.pjsonPath);
27215
+ const packageJsonUrl2 = require$$7.pathToFileURL(packageConfig.pjsonPath);
27218
27216
  if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
27219
27217
  return packageExportsResolve(
27220
27218
  packageJsonUrl2,
@@ -27225,21 +27223,21 @@ function packageResolve(specifier, base, conditions) {
27225
27223
  );
27226
27224
  }
27227
27225
  }
27228
- let packageJsonUrl = new url.URL(
27226
+ let packageJsonUrl = new require$$7.URL(
27229
27227
  "./node_modules/" + packageName + "/package.json",
27230
27228
  base
27231
27229
  );
27232
- let packageJsonPath = url.fileURLToPath(packageJsonUrl);
27230
+ let packageJsonPath = require$$7.fileURLToPath(packageJsonUrl);
27233
27231
  let lastPath;
27234
27232
  do {
27235
27233
  const stat = tryStatSync(packageJsonPath.slice(0, -13));
27236
27234
  if (!stat.isDirectory()) {
27237
27235
  lastPath = packageJsonPath;
27238
- packageJsonUrl = new url.URL(
27236
+ packageJsonUrl = new require$$7.URL(
27239
27237
  (isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
27240
27238
  packageJsonUrl
27241
27239
  );
27242
- packageJsonPath = url.fileURLToPath(packageJsonUrl);
27240
+ packageJsonPath = require$$7.fileURLToPath(packageJsonUrl);
27243
27241
  continue;
27244
27242
  }
27245
27243
  const packageConfig2 = getPackageConfig(packageJsonPath, specifier, base);
@@ -27255,9 +27253,9 @@ function packageResolve(specifier, base, conditions) {
27255
27253
  if (packageSubpath === ".") {
27256
27254
  return legacyMainResolve(packageJsonUrl, packageConfig2, base);
27257
27255
  }
27258
- return new url.URL(packageSubpath, packageJsonUrl);
27256
+ return new require$$7.URL(packageSubpath, packageJsonUrl);
27259
27257
  } while (packageJsonPath.length !== lastPath.length);
27260
- throw new ERR_MODULE_NOT_FOUND(packageName, url.fileURLToPath(base));
27258
+ throw new ERR_MODULE_NOT_FOUND(packageName, require$$7.fileURLToPath(base));
27261
27259
  }
27262
27260
  function isRelativeSpecifier(specifier) {
27263
27261
  if (specifier[0] === ".") {
@@ -27281,12 +27279,12 @@ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
27281
27279
  const isRemote = protocol === "http:" || protocol === "https:";
27282
27280
  let resolved;
27283
27281
  if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
27284
- resolved = new url.URL(specifier, base);
27282
+ resolved = new require$$7.URL(specifier, base);
27285
27283
  } else if (!isRemote && specifier[0] === "#") {
27286
27284
  resolved = packageImportsResolve(specifier, base, conditions);
27287
27285
  } else {
27288
27286
  try {
27289
- resolved = new url.URL(specifier);
27287
+ resolved = new require$$7.URL(specifier);
27290
27288
  } catch {
27291
27289
  if (!isRemote) {
27292
27290
  resolved = packageResolve(specifier, base, conditions);
@@ -27314,7 +27312,7 @@ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
27314
27312
  }
27315
27313
  return { url: (parsed == null ? void 0 : parsed.href) || "" };
27316
27314
  }
27317
- if (module$1.builtinModules.includes(specifier)) {
27315
+ if (require$$2.builtinModules.includes(specifier)) {
27318
27316
  throw new ERR_NETWORK_IMPORT_DISALLOWED(
27319
27317
  specifier,
27320
27318
  parsedParentURL,
@@ -27370,13 +27368,13 @@ function defaultResolve(specifier, context = {}) {
27370
27368
  let parsedParentURL;
27371
27369
  if (parentURL) {
27372
27370
  try {
27373
- parsedParentURL = new url.URL(parentURL);
27371
+ parsedParentURL = new require$$7.URL(parentURL);
27374
27372
  } catch {
27375
27373
  }
27376
27374
  }
27377
27375
  let parsed;
27378
27376
  try {
27379
- parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier) ? new url.URL(specifier, parsedParentURL) : new url.URL(specifier);
27377
+ parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier) ? new require$$7.URL(specifier, parsedParentURL) : new require$$7.URL(specifier);
27380
27378
  const protocol = parsed.protocol;
27381
27379
  if (protocol === "data:" || experimentalNetworkImports && (protocol === "https:" || protocol === "http:")) {
27382
27380
  return { url: parsed.href, format: null };
@@ -27394,13 +27392,13 @@ function defaultResolve(specifier, context = {}) {
27394
27392
  return { url: specifier };
27395
27393
  throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports);
27396
27394
  const conditions = getConditionsSet(context.conditions);
27397
- const url$1 = moduleResolve(specifier, new url.URL(parentURL), conditions, false);
27398
- throwIfUnsupportedURLProtocol(url$1);
27395
+ const url = moduleResolve(specifier, new require$$7.URL(parentURL), conditions, false);
27396
+ throwIfUnsupportedURLProtocol(url);
27399
27397
  return {
27400
27398
  // Do NOT cast `url` to a string: that will work even when there are real
27401
27399
  // problems, silencing them
27402
- url: url$1.href,
27403
- format: defaultGetFormatWithoutErrors(url$1, { parentURL })
27400
+ url: url.href,
27401
+ format: defaultGetFormatWithoutErrors(url, { parentURL })
27404
27402
  };
27405
27403
  }
27406
27404
 
@@ -27427,8 +27425,8 @@ function resolve(specifier, parent) {
27427
27425
 
27428
27426
  // src/utils/import-from-file.js
27429
27427
  function importFromFile(specifier, parent) {
27430
- const url$1 = resolve(specifier, url.pathToFileURL(parent).href);
27431
- return import(url$1);
27428
+ const url = resolve(specifier, require$$7.pathToFileURL(parent).href);
27429
+ return import(url);
27432
27430
  }
27433
27431
  var import_from_file_default = importFromFile;
27434
27432
 
@@ -27547,7 +27545,7 @@ async function resolveConfig(filePath, options8) {
27547
27545
  };
27548
27546
  if (Array.isArray(merged.plugins)) {
27549
27547
  merged.plugins = merged.plugins.map(
27550
- (value) => typeof value === "string" && value.startsWith(".") ? path6__default.resolve(path6__default.dirname(result.filepath), value) : value
27548
+ (value) => typeof value === "string" && value.startsWith(".") ? require$$0__default.resolve(require$$0__default.dirname(result.filepath), value) : value
27551
27549
  );
27552
27550
  }
27553
27551
  return merged;
@@ -27561,7 +27559,7 @@ function mergeOverrides(configResult, filePath) {
27561
27559
  const { config, filepath: configPath } = configResult || {};
27562
27560
  const { overrides, ...options8 } = config || {};
27563
27561
  if (filePath && overrides) {
27564
- const relativeFilePath = path6__default.relative(path6__default.dirname(configPath), filePath);
27562
+ const relativeFilePath = require$$0__default.relative(require$$0__default.dirname(configPath), filePath);
27565
27563
  for (const override of overrides) {
27566
27564
  if (pathMatchesGlobs(
27567
27565
  relativeFilePath,
@@ -27607,7 +27605,7 @@ var read_file_default = readFile;
27607
27605
 
27608
27606
  // src/utils/ignore.js
27609
27607
  var createIgnore = import_ignore.default.default;
27610
- var slash = path6__default.sep === "\\" ? (filepath) => string_replace_all_default(
27608
+ var slash = require$$0__default.sep === "\\" ? (filepath) => string_replace_all_default(
27611
27609
  /* isOptionalObject*/
27612
27610
  false,
27613
27611
  filepath,
@@ -27629,8 +27627,8 @@ async function createSingleIsIgnoredFunction(ignoreFilePath, withNodeModules) {
27629
27627
  allowRelativePaths: true
27630
27628
  }).add(content);
27631
27629
  return (filepath) => {
27632
- filepath = path6__default.resolve(filepath);
27633
- const relativePath = ignoreFilePath ? path6__default.relative(path6__default.dirname(ignoreFilePath), filepath) : path6__default.relative(process.cwd(), filepath);
27630
+ filepath = require$$0__default.resolve(filepath);
27631
+ const relativePath = ignoreFilePath ? require$$0__default.relative(require$$0__default.dirname(ignoreFilePath), filepath) : require$$0__default.relative(process.cwd(), filepath);
27634
27632
  return ignore.ignores(slash(relativePath));
27635
27633
  };
27636
27634
  }
@@ -27680,7 +27678,7 @@ async function getParser(filePath, options8) {
27680
27678
  }
27681
27679
  var get_file_info_default = getFileInfo;
27682
27680
  function importFromDirectory(specifier, directory) {
27683
- return import_from_file_default(specifier, path6__default.join(directory, "noop.js"));
27681
+ return import_from_file_default(specifier, require$$0__default.join(directory, "noop.js"));
27684
27682
  }
27685
27683
  var import_from_directory_default = importFromDirectory;
27686
27684
 
@@ -27695,7 +27693,7 @@ var loadPluginFromDirectory = mem(
27695
27693
  );
27696
27694
  var importPlugin = mem(async (name) => {
27697
27695
  try {
27698
- return await import(url.pathToFileURL(path6__default.resolve(name)).href);
27696
+ return await import(require$$7.pathToFileURL(require$$0__default.resolve(name)).href);
27699
27697
  } catch {
27700
27698
  return import_from_directory_default(name, process.cwd());
27701
27699
  }
@@ -29042,825 +29040,4 @@ var debugApis = {
29042
29040
  printDocToString: withPlugins(printDocToString2)
29043
29041
  };
29044
29042
 
29045
- function defineClientGeneratorPlugin(plugin) {
29046
- return plugin;
29047
- }
29048
-
29049
- let createdModels = [];
29050
- const typescriptClientGenerator = defineClientGeneratorPlugin(
29051
- (options) => ({
29052
- generator: async (def) => {
29053
- if (!options.name) {
29054
- throw new Error("Name is requires");
29055
- }
29056
- if (!options.outputFile) {
29057
- throw new Error("No output file specified");
29058
- }
29059
- const result = await createTypescriptClient(def, options.name);
29060
- fs$1.writeFileSync(options.outputFile, result);
29061
- },
29062
- options
29063
- })
29064
- );
29065
- async function createTypescriptClient(def, prefix = "Client") {
29066
- createdModels = [];
29067
- const services = index.unflattenObject(def.procedures);
29068
- const serviceParts = [];
29069
- const modelParts = [];
29070
- Object.keys(services).forEach((key) => {
29071
- const serviceName = index.pascalCase(`${prefix}_${key}_service`);
29072
- serviceParts.push({
29073
- name: serviceName,
29074
- key,
29075
- content: tsServiceFromServiceDefinition(serviceName, services[key])
29076
- });
29077
- });
29078
- Object.keys(def.models).forEach((key) => {
29079
- const modelName = index.pascalCase(`${key}`);
29080
- if (!createdModels.includes(modelName)) {
29081
- modelParts.push(tsModelFromDefinition(modelName, def.models[key]));
29082
- createdModels.push(modelName);
29083
- }
29084
- });
29085
- return format2(
29086
- `/* eslint-disable */
29087
- import { arriRequest, ArriRequestError } from 'arri-client';
29088
-
29089
- export class ${prefix} {
29090
- ${serviceParts.map((service) => `${service.key}: ${service.name}`).join("\n")}
29091
- constructor(opts: { baseUrl?: string; headers?: Record<string, string> }) {
29092
- ${serviceParts.map(
29093
- (service) => `this.${service.key} = new ${service.name}(opts);`
29094
- ).join("\n")}
29095
- }
29096
- }
29097
-
29098
- ${serviceParts.map((service) => service.content).join("\n")}
29099
- ${modelParts.join("\n")}`,
29100
- {
29101
- parser: "typescript"
29102
- }
29103
- );
29104
- }
29105
- function tsServiceFromServiceDefinition(name, def) {
29106
- const rpcParts = [];
29107
- const subServiceParts = [];
29108
- Object.keys(def).forEach((key) => {
29109
- const val = def[key];
29110
- if (index.isProcedureDefinition(val)) {
29111
- rpcParts.push(tsRpcFromProcedureDefinition(key, val));
29112
- return;
29113
- }
29114
- const subServiceName = index.pascalCase(
29115
- `${name.split("Service").join("")}_${key}_service`
29116
- );
29117
- subServiceParts.push({
29118
- name: subServiceName,
29119
- key,
29120
- content: tsServiceFromServiceDefinition(subServiceName, val)
29121
- });
29122
- });
29123
- return `export class ${name} {
29124
- baseUrl: string;
29125
- headers: Record<string, string>;
29126
- ${subServiceParts.map((service) => `${service.key}: ${service.name};`).join("\n")}
29127
- constructor(opts: { baseUrl?: string; headers?: Record<string, string> }) {
29128
- this.baseUrl = opts.baseUrl ?? "";
29129
- this.headers = opts.headers ?? {};
29130
- ${subServiceParts.map(
29131
- (service) => `this.${service.key} = new ${service.name}(opts);`
29132
- ).join("\n")}
29133
- }
29134
- ${rpcParts.join("\n")}
29135
- }
29136
- ${subServiceParts.map((service) => service.content).join("\n")}`;
29137
- }
29138
- function tsRpcFromProcedureDefinition(name, def) {
29139
- let paramStr = "";
29140
- let responseName = "";
29141
- if (def.params) {
29142
- paramStr = `params: ${def.params}`;
29143
- }
29144
- if (def.response) {
29145
- responseName = def.response;
29146
- }
29147
- return `async ${name}(${paramStr}) {
29148
- return arriRequest<${responseName || "undefined"}>({
29149
- url: \`\${this.baseUrl}${def.path}\`,
29150
- method: '${def.method}',
29151
- ${paramStr.length ? `params,` : ""}
29152
- headers: this.headers,
29153
- });
29154
- }`;
29155
- }
29156
- function tsModelFromDefinition(name, def) {
29157
- const fieldParts = [];
29158
- const subModelParts = [];
29159
- Object.keys(def.properties ?? {}).forEach((key) => {
29160
- const isOptional = !def.required?.includes(key);
29161
- const prop = def.properties?.[key];
29162
- const keyPart = isOptional ? `${key}?` : key;
29163
- if (index.isJsonSchemaScalarType(prop)) {
29164
- fieldParts.push(
29165
- tsInterfaceScalarField(key, prop, isOptional) ?? ""
29166
- );
29167
- return;
29168
- }
29169
- if (index.isJsonSchemaNullType(prop)) {
29170
- switch (prop.type) {
29171
- case "null":
29172
- fieldParts.push(`${keyPart}: null;`);
29173
- break;
29174
- case "undefined":
29175
- fieldParts.push(`${keyPart}: undefined`);
29176
- break;
29177
- }
29178
- return;
29179
- }
29180
- if (index.isJsonSchemaObject(prop)) {
29181
- const subModelName = prop.$id ?? index.pascalCase(`${name}_${key}`);
29182
- if (!createdModels.includes(subModelName)) {
29183
- const content = tsModelFromDefinition(
29184
- subModelName,
29185
- prop
29186
- );
29187
- subModelParts.push(content);
29188
- }
29189
- fieldParts.push(`${keyPart}: ${subModelName};`);
29190
- return;
29191
- }
29192
- if (index.isJsonSchemaEnum(prop)) {
29193
- const vals = prop.anyOf.map(
29194
- (opt) => opt.type === "string" ? `'${opt.const}'` : `${opt.const}`
29195
- );
29196
- fieldParts.push(`${keyPart}: ${vals.join(" | ")};`);
29197
- return;
29198
- }
29199
- if (index.isJsonSchemaArray(prop)) {
29200
- if (index.isJsonSchemaScalarType(prop.items)) {
29201
- const part = tsInterfaceScalarField(
29202
- key,
29203
- prop.items,
29204
- isOptional
29205
- ).replace(";", "[];");
29206
- fieldParts.push(part);
29207
- return;
29208
- }
29209
- if (index.isJsonSchemaNullType(prop.items)) {
29210
- if (prop.items.type === "null") {
29211
- fieldParts.push(`${keyPart}: null[]`);
29212
- return;
29213
- }
29214
- fieldParts.push(`${keyPart}: undefined[]`);
29215
- return;
29216
- }
29217
- if (index.isJsonSchemaObject(prop.items)) {
29218
- const subModelName = prop.items.$id ?? index.pascalCase(`${name}_${key}_item`);
29219
- if (!createdModels.includes(subModelName)) {
29220
- subModelParts.push(
29221
- tsModelFromDefinition(subModelName, prop.items)
29222
- );
29223
- }
29224
- fieldParts.push(`${keyPart}: ${subModelName}[];`);
29225
- }
29226
- }
29227
- });
29228
- return `export interface ${name} {
29229
- ${fieldParts.join("\n")}
29230
- }
29231
- ${subModelParts.join("\n")}`;
29232
- }
29233
- function tsInterfaceScalarField(key, prop, isOptional = false) {
29234
- const keyPart = isOptional ? `${key}?` : key;
29235
- switch (prop.type) {
29236
- case "string":
29237
- return `${keyPart}: string;`;
29238
- case "bigint":
29239
- return `${keyPart}: bigint;`;
29240
- case "Date":
29241
- return `${keyPart}: Date;`;
29242
- case "boolean":
29243
- return `${keyPart}: boolean;`;
29244
- case "integer":
29245
- return `/**
29246
- * must be an integer
29247
- */
29248
- ${keyPart}: number;`;
29249
- case "number":
29250
- return `${keyPart}: number;`;
29251
- }
29252
- }
29253
-
29254
- const dartClientGenerator = defineClientGeneratorPlugin(
29255
- (options) => {
29256
- return {
29257
- generator: async (def) => {
29258
- if (!options.clientName) {
29259
- throw new Error(
29260
- 'Missing "clientName" cannot generate dart client'
29261
- );
29262
- }
29263
- if (!options.outputFile) {
29264
- throw new Error(
29265
- 'Missing "outputFile" cannot generate dart client'
29266
- );
29267
- }
29268
- const result = createDartClient(def, options.clientName);
29269
- fs$1.writeFileSync(options.outputFile, result);
29270
- child_process.execSync(`dart format ${options.outputFile}`);
29271
- },
29272
- options
29273
- };
29274
- }
29275
- );
29276
- const generatedModels = [];
29277
- function createDartClient(appDef, prefix = "Client") {
29278
- const { models, procedures } = appDef;
29279
- const serviceParts = [];
29280
- const services = index.unflattenObject(procedures);
29281
- Object.keys(services).forEach((k) => {
29282
- const service = services[k];
29283
- const serviceName = index.pascalCase(`$_${prefix}_${k}_service`);
29284
- serviceParts.push({
29285
- name: serviceName,
29286
- key: k,
29287
- content: dartServiceFromServiceDefinition(
29288
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
29289
- serviceName,
29290
- service,
29291
- prefix
29292
- )
29293
- });
29294
- });
29295
- const endpoints = {};
29296
- Object.keys(procedures).forEach((key) => {
29297
- const rpc = procedures[key];
29298
- endpoints[rpc.path] = rpc.method;
29299
- });
29300
- const modelParts = [];
29301
- Object.keys(models).forEach((key) => {
29302
- const model = models[key];
29303
- const typeName = `${prefix}${index.pascalCase(key)}`;
29304
- const objModel = model;
29305
- if (!generatedModels.includes(typeName)) {
29306
- modelParts.push(
29307
- dartModelFromJsonSchema(
29308
- `${prefix}${index.pascalCase(key)}`,
29309
- objModel
29310
- )
29311
- );
29312
- generatedModels.push(typeName);
29313
- }
29314
- });
29315
- return `// This code was autogenerated by arri. Do not modify directly.
29316
- import "dart:convert";
29317
- import "package:http/http.dart" as http;
29318
- import "package:arri_client/arri_client.dart";
29319
-
29320
- class ${prefix} {
29321
- final String baseUrl;
29322
- final Map<String, String> headers;
29323
- const ${prefix}({
29324
- this.baseUrl = "",
29325
- this.headers = const {},
29326
- });
29327
- ${prefix} withHeaders(Map<String, String> headers) {
29328
- return ${prefix}(
29329
- baseUrl: baseUrl,
29330
- headers: headers,
29331
- );
29332
- }
29333
- ${serviceParts.map(
29334
- (service) => `${service.name} get ${service.key} {
29335
- return ${service.name}(
29336
- baseUrl: baseUrl, headers: headers,
29337
- );
29338
- }`
29339
- ).join("\n ")}
29340
- Future<http.Response> rawRequest(
29341
- ${prefix}Endpoints endpoint, {
29342
- Map<String, String>? query,
29343
- dynamic body,
29344
- Map<String, String>? headers,
29345
- Encoding? encoding,
29346
- }) async {
29347
- return arriRequest(
29348
- "$baseUrl\${endpoint.path}",
29349
- method: endpoint.method,
29350
- headers: headers ?? this.headers,
29351
- body: body,
29352
- query: query,
29353
- encoding: encoding,
29354
- );
29355
- }
29356
- }
29357
- ${serviceParts.map((item) => item.content).join("\n")}
29358
- ${modelParts.join("\n")}
29359
-
29360
- enum ${prefix}Endpoints implements Comparable<${prefix}Endpoints>, ArriEndpoint {
29361
- ${Object.keys(endpoints).map(
29362
- (key) => `${index.camelCase(key.split("/").join("_"))}(
29363
- path: "${key}",
29364
- method: HttpMethod.${endpoints[key]},
29365
- )`
29366
- ).join(",\n ")};
29367
-
29368
- const ${prefix}Endpoints({
29369
- required this.path, required this.method,
29370
- });
29371
- @override
29372
- final String path;
29373
- @override
29374
- final HttpMethod method;
29375
-
29376
- @override
29377
- compareTo(BackendEndpoints other) => name.compareTo(other.name);
29378
- }`;
29379
- }
29380
- function dartServiceFromServiceDefinition(name, def, prefix = "") {
29381
- const rpcParts = [];
29382
- const subServiceParts = [];
29383
- const serviceName = `${name}`;
29384
- Object.keys(def).forEach((key) => {
29385
- const item = def[key];
29386
- if (index.isProcedureDefinition(item)) {
29387
- let returnType = `Future<String>`;
29388
- let returnTypeName = "String";
29389
- if (item.response) {
29390
- returnType = `Future<${prefix}${item.response}>`;
29391
- returnTypeName = `${prefix}${item.response}`;
29392
- } else {
29393
- returnType = "Future<void>";
29394
- }
29395
- let paramsInput = "";
29396
- if (item.params) {
29397
- paramsInput = `${prefix}${item.params} params`;
29398
- }
29399
- let responseParser = "(body) => body;";
29400
- switch (returnType) {
29401
- case "Future<String>":
29402
- break;
29403
- case "Future<int>":
29404
- responseParser = `(body) => Int.parse(body)`;
29405
- break;
29406
- case "Future<double>":
29407
- responseParser = `(body) => Double.parse(body)`;
29408
- break;
29409
- case "Future<void>":
29410
- responseParser = `(body) {}`;
29411
- break;
29412
- case "Future<bool>":
29413
- responseParser = `(body) {
29414
- switch(body) {
29415
- case "true":
29416
- case "1":
29417
- return true;
29418
- case "false":
29419
- case "0":
29420
- default:
29421
- return false;
29422
- }
29423
- }`;
29424
- break;
29425
- default:
29426
- responseParser = `(body) => ${returnTypeName}.fromJson(json.decode(body))`;
29427
- break;
29428
- }
29429
- rpcParts.push(`${returnType} ${key}(${paramsInput}) {
29430
- return parsedArriRequest(
29431
- "$baseUrl${item.path}",
29432
- method: HttpMethod.${item.method},
29433
- headers: headers,
29434
- params: ${paramsInput.length ? `params.toJson()` : "null"},
29435
- parser: ${responseParser},
29436
- );
29437
- }`);
29438
- return;
29439
- }
29440
- const subServiceName = index.pascalCase(`${name}_${key}_Service`);
29441
- const subService = dartServiceFromServiceDefinition(
29442
- index.pascalCase(`${name}_${key}_Service`),
29443
- item,
29444
- prefix
29445
- );
29446
- subServiceParts.push({
29447
- name: subServiceName,
29448
- key,
29449
- content: subService
29450
- });
29451
- });
29452
- return `class ${serviceName} {
29453
- final String baseUrl;
29454
- final Map<String, String> headers;
29455
- const ${serviceName}({
29456
- this.baseUrl = "",
29457
- this.headers = const {},
29458
- });
29459
- ${subServiceParts.map(
29460
- (sub) => `${sub.name} get ${sub.key} {
29461
- return ${sub.name}(
29462
- baseUrl: baseUrl,
29463
- headers: headers,
29464
- );
29465
- }`
29466
- ).join("\n")}
29467
- ${rpcParts.join("\n ")}
29468
- }
29469
- ${subServiceParts.map((sub) => sub.content).join("\n")}
29470
- `;
29471
- }
29472
- function dartModelFromJsonSchema(name, schema) {
29473
- const fields = [];
29474
- const subModelParts = [];
29475
- Object.entries(schema.properties ?? {}).forEach(([key, val]) => {
29476
- if (typeof val !== "object") {
29477
- return;
29478
- }
29479
- const [dartType, subTypes] = dartPropertyTypeFromSchema(
29480
- name,
29481
- key,
29482
- schema
29483
- );
29484
- if (subTypes?.length) {
29485
- for (const sub of subTypes) {
29486
- subModelParts.push(sub);
29487
- }
29488
- }
29489
- fields.push({ type: dartType, name: key });
29490
- if (!isDartType(dartType) && "type" in val && val.type === "object") {
29491
- subModelParts.push(
29492
- dartModelFromJsonSchema(dartType.replace("?", ""), val)
29493
- );
29494
- }
29495
- });
29496
- return `class ${name} {
29497
- ${fields.map((field) => `final ${field.type} ${field.name};`).join("\n ")}
29498
- const ${name}({
29499
- ${fields.map(
29500
- (field) => field.type.includes("?") ? `this.${field.name},` : `required this.${field.name},`
29501
- ).join("\n ")}
29502
- });
29503
- factory ${name}.fromJson(Map<String, dynamic> json) {
29504
- return ${name}(
29505
- ${fields.map((field) => `${dartParsedJsonField(field.name, field.type)},`).join("\n ")}
29506
- );
29507
- }
29508
- Map<String, dynamic> toJson() {
29509
- return {
29510
- ${fields.map((field) => {
29511
- const isNullable = field.type.endsWith("?");
29512
- const typeName = field.type.replace("?", "");
29513
- if (isDartTypeWithNullables(field.type)) {
29514
- const transformer = transformers[typeName];
29515
- return transformer.toJsonBody(field.name, isNullable);
29516
- }
29517
- if (field.type.includes("List<")) {
29518
- return classListTransformer(typeName).toJsonBody(
29519
- field.name,
29520
- isNullable
29521
- );
29522
- }
29523
- return classTransformer(typeName, isNullable).toJsonBody(
29524
- field.name,
29525
- isNullable
29526
- );
29527
- }).join(",\n ")},
29528
- };
29529
- }
29530
- ${name} copyWith({
29531
- ${fields.map((field) => `${field.type.replace("?", "")}? ${field.name},`).join("\n ")}
29532
- }) {
29533
- return ${name}(
29534
- ${fields.map((field) => `${field.name}: ${field.name} ?? this.${field.name},`).join("\n ")}
29535
- );
29536
- }
29537
- }
29538
-
29539
- ${subModelParts.join("\n")}`;
29540
- }
29541
- function dartPropertyTypeFromSchema(objectName, propertyName, schema) {
29542
- const prop = schema.properties?.[propertyName];
29543
- const isOptional = !schema.required?.includes(propertyName);
29544
- let finalType = "";
29545
- const subTypes = [];
29546
- if (index.isJsonSchemaEnum(prop)) {
29547
- const enumName = index.pascalCase(`${objectName}_${propertyName}`);
29548
- finalType = isOptional ? `${enumName}?` : enumName;
29549
- const options = [];
29550
- for (const opt of prop.anyOf) {
29551
- if (opt.type === "string") {
29552
- options.push({
29553
- name: opt.const.toString(),
29554
- type: "String",
29555
- value: opt.const
29556
- });
29557
- }
29558
- if (opt.type === "number" || opt.type === "integer") {
29559
- options.push({
29560
- name: index.camelCase(
29561
- `num_${opt.const}`.split(".").join("Point")
29562
- ),
29563
- type: opt.type === "number" ? "double" : "int",
29564
- value: opt.const
29565
- });
29566
- }
29567
- }
29568
- subTypes.push(`enum ${enumName} implements Comparable<${enumName}> {
29569
- ${options.map(
29570
- (opt) => `${opt.name}(${opt.type === "String" ? `"${opt.value}"` : opt.value})`
29571
- ).join(",\n ")};
29572
- const ${enumName}(this.value);
29573
- final dynamic value;
29574
-
29575
- @override
29576
- compareTo(${enumName} other) => name.compareTo(other.name);
29577
-
29578
- factory ${enumName}.fromJson(dynamic input) {
29579
- for(final val in values) {
29580
- if(val.value == input) {
29581
- return val;
29582
- }
29583
- }
29584
- return ${options[0].name};
29585
- }
29586
-
29587
- dynamic toJson() {
29588
- return value;
29589
- }
29590
- }`);
29591
- return [finalType, subTypes];
29592
- }
29593
- if (index.isJsonSchemaNullType(prop)) {
29594
- finalType = "null";
29595
- return [finalType, subTypes];
29596
- }
29597
- if (index.isJsonSchemaScalarType(prop)) {
29598
- switch (prop.type) {
29599
- case "string":
29600
- finalType = isOptional ? "String?" : "String";
29601
- break;
29602
- case "integer":
29603
- finalType = isOptional ? "int?" : "int";
29604
- break;
29605
- case "number":
29606
- finalType = isOptional ? "double?" : "double";
29607
- break;
29608
- case "Date":
29609
- finalType = isOptional ? "DateTime?" : "DateTime";
29610
- break;
29611
- case "boolean":
29612
- finalType = isOptional ? "bool?" : "bool";
29613
- break;
29614
- }
29615
- }
29616
- if (index.isJsonSchemaObject(prop)) {
29617
- const joinedPropName = index.pascalCase(
29618
- `${objectName}_${propertyName}`
29619
- );
29620
- finalType = isOptional ? `${joinedPropName}?` : joinedPropName;
29621
- }
29622
- if (index.isJsonSchemaArray(prop)) {
29623
- const item = prop.items;
29624
- const type = item.type;
29625
- if (typeof type !== "string") {
29626
- throw new Error(
29627
- "Union types are not supported in arrays at this time"
29628
- );
29629
- }
29630
- switch (type) {
29631
- case "string":
29632
- finalType = isOptional ? "List<String>?" : "List<String>";
29633
- break;
29634
- case "integer":
29635
- finalType = isOptional ? "List<int>?" : "List<int>";
29636
- break;
29637
- case "number":
29638
- finalType = isOptional ? "List<double>?" : "List<double>";
29639
- break;
29640
- case "null":
29641
- finalType = isOptional ? "List<null>?" : "List<null>";
29642
- break;
29643
- case "boolean":
29644
- finalType = isOptional ? "List<bool>?" : "List<bool>";
29645
- break;
29646
- case "Date":
29647
- finalType = isOptional ? "List<DateTime>?" : "List<DateTime>";
29648
- break;
29649
- case "object": {
29650
- const subTypeName = item.$id ?? index.pascalCase(`${objectName}_${propertyName}_item`);
29651
- const model = dartModelFromJsonSchema(subTypeName, item);
29652
- if (!generatedModels.includes(subTypeName)) {
29653
- subTypes.push(model);
29654
- generatedModels.push(subTypeName);
29655
- }
29656
- finalType = isOptional ? `List<${subTypeName}>?` : `List<${subTypeName}>`;
29657
- break;
29658
- }
29659
- }
29660
- }
29661
- return [finalType, subTypes.length ? subTypes : void 0];
29662
- }
29663
- function dartParsedJsonField(fieldName, dartType) {
29664
- if (isDartTypeWithNullables(dartType)) {
29665
- switch (dartType) {
29666
- case "String":
29667
- return transformers.String.fromJsonBody(fieldName, '""');
29668
- case "String?":
29669
- return transformers.String.fromJsonBody(fieldName, "null");
29670
- case "bool":
29671
- return transformers.bool.fromJsonBody(fieldName, "false");
29672
- case "double":
29673
- return transformers.double.fromJsonBody(fieldName, "0.0");
29674
- case "int":
29675
- return transformers.int.fromJsonBody(fieldName, "0");
29676
- case "null":
29677
- return transformers.null.fromJsonBody(fieldName, "");
29678
- case "DateTime":
29679
- return transformers.DateTime.fromJsonBody(
29680
- fieldName,
29681
- "DateTime(0)"
29682
- );
29683
- case "DateTime?":
29684
- return transformers.DateTime.fromJsonBody(fieldName, "null");
29685
- case "List<String>":
29686
- case "List<bool>":
29687
- case "List<double>":
29688
- case "List<int>":
29689
- case "List<null>":
29690
- return defaultListFromJsonBody(
29691
- fieldName,
29692
- dartType.replace("List<", "").replace(">", ""),
29693
- "[]"
29694
- );
29695
- default:
29696
- return `${fieldName}: json["${fieldName}"] is ${dartType.replace(
29697
- "?",
29698
- ""
29699
- )} ? json["${fieldName}"] : null`;
29700
- }
29701
- }
29702
- if (dartType.includes("List<")) {
29703
- const innerType = dartType.replace("List<", "").replace(">", "").replace("?", "");
29704
- return classListTransformer(innerType).fromJsonBody(
29705
- fieldName,
29706
- dartType.endsWith("?") ? "null" : "[]"
29707
- );
29708
- }
29709
- const classType = dartType.split("?").join("").trim();
29710
- return classTransformer(classType, dartType.endsWith("?")).fromJsonBody(
29711
- fieldName,
29712
- classType
29713
- );
29714
- }
29715
- const dartTypeMap = {
29716
- integer: "int",
29717
- bigint: "int",
29718
- number: "double",
29719
- string: "String",
29720
- boolean: "bool",
29721
- null: "null",
29722
- Date: "DateTime",
29723
- object: void 0,
29724
- list: void 0,
29725
- // eslint-disable-next-line object-shorthand
29726
- undefined: void 0,
29727
- array: void 0,
29728
- Uint8Array: "Uint8List"
29729
- };
29730
- const transformers = {
29731
- null: {
29732
- fromJsonBody: (_) => `null`,
29733
- toJsonBody: defaultToJsonBody
29734
- },
29735
- int: {
29736
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "int", fallback),
29737
- toJsonBody: defaultToJsonBody
29738
- },
29739
- double: {
29740
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "double", fallback),
29741
- toJsonBody: defaultToJsonBody
29742
- },
29743
- String: {
29744
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "String", fallback),
29745
- toJsonBody: defaultToJsonBody
29746
- },
29747
- bool: {
29748
- fromJsonBody: (key, fallback) => defaultFromJsonBody(key, "bool", fallback),
29749
- toJsonBody: defaultToJsonBody
29750
- },
29751
- DateTime: {
29752
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is String ? DateTime.parse(json["${key}"]) : ${fallback}`,
29753
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toIso8601String()`
29754
- },
29755
- "List<null>": {
29756
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "null", fallback),
29757
- toJsonBody: defaultToJsonBody
29758
- },
29759
- "List<int>": {
29760
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "int", fallback),
29761
- toJsonBody: defaultToJsonBody
29762
- },
29763
- "List<double>": {
29764
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "double", fallback),
29765
- toJsonBody: defaultToJsonBody
29766
- },
29767
- "List<String>": {
29768
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "String", fallback),
29769
- toJsonBody: defaultToJsonBody
29770
- },
29771
- "List<bool>": {
29772
- fromJsonBody: (key, fallback) => defaultListFromJsonBody(key, "bool", fallback),
29773
- toJsonBody: defaultToJsonBody
29774
- },
29775
- "List<DateTime>": {
29776
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List<String> ?
29777
- (json["${key}"] as List<String>)
29778
- .map((item) => DateTime.parse(item)).toList() : ${fallback}`,
29779
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toIso8601String()).toList()`
29780
- },
29781
- Uint8List: {
29782
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List ? Uint8List.fromList(json["${key}"]) : ${fallback}`,
29783
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toList()`
29784
- },
29785
- "List<Uint8List>": {
29786
- fromJsonBody: (key, fallback) => `${key}: json["${key}"] is List && (json["${key}"] as List).isNotEmpty && (json["${key}"] as List).first is List ? json["${key}"] : ${fallback}`,
29787
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toList()).toList()`
29788
- }
29789
- };
29790
- function defaultFromJsonBody(key, typename, fallback) {
29791
- return `${key}: json["${key}"] is ${typename} ? json["${key}"] : ${fallback}`;
29792
- }
29793
- function defaultListFromJsonBody(key, typename, fallback) {
29794
- return `${key}: json["${key}"] is List<${typename}> ? json["${key}"] : ${fallback}`;
29795
- }
29796
- function defaultToJsonBody(key) {
29797
- return `"${key}": ${key}`;
29798
- }
29799
- const classTransformer = (typename, nullable) => {
29800
- return {
29801
- fromJsonBody: (key, fallback) => {
29802
- if (nullable) {
29803
- return `${key}: json["${key}"] is Map<String, dynamic> ?
29804
- ${typename}.fromJson(json["${key}"]) : null`;
29805
- }
29806
- return `${key}: ${typename}.fromJson(json["${key}"])`;
29807
- },
29808
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.toJson()`
29809
- };
29810
- };
29811
- const classListTransformer = (typename) => {
29812
- return {
29813
- fromJsonBody: (key, fallback) => {
29814
- return `${key}: json["${key}"] is List<Map<String, dynamic>> ?
29815
- (json["${key}"] as List<Map<String, dynamic>>)
29816
- .map((val) => ${typename}.fromJson(val)).toList() : ${fallback}`;
29817
- },
29818
- toJsonBody: (key, isNullable) => `"${key}": ${key}${isNullable ? "?" : ""}.map((val) => val.toJson()).toList()`
29819
- };
29820
- };
29821
- function isDartType(input) {
29822
- if (typeof input !== "string") {
29823
- return false;
29824
- }
29825
- for (const val of Object.values(dartTypeMap)) {
29826
- if (input === val) {
29827
- return true;
29828
- }
29829
- if (input.replace("List<", "").replace(">", "") === val) {
29830
- return true;
29831
- }
29832
- }
29833
- return false;
29834
- }
29835
- function isDartTypeWithNullables(input) {
29836
- if (typeof input !== "string") {
29837
- return false;
29838
- }
29839
- for (const val of Object.values(dartTypeMap)) {
29840
- if (input.replace("?", "") === val) {
29841
- return true;
29842
- }
29843
- if (input.replace("?", "").replace("List<", "").replace(">", "") === val) {
29844
- return true;
29845
- }
29846
- }
29847
- return false;
29848
- }
29849
-
29850
- exports.classListTransformer = classListTransformer;
29851
- exports.classTransformer = classTransformer;
29852
- exports.createDartClient = createDartClient;
29853
- exports.createTypescriptClient = createTypescriptClient;
29854
- exports.dartClientGenerator = dartClientGenerator;
29855
- exports.dartModelFromJsonSchema = dartModelFromJsonSchema;
29856
- exports.dartParsedJsonField = dartParsedJsonField;
29857
- exports.dartPropertyTypeFromSchema = dartPropertyTypeFromSchema;
29858
- exports.dartServiceFromServiceDefinition = dartServiceFromServiceDefinition;
29859
- exports.defineClientGeneratorPlugin = defineClientGeneratorPlugin;
29860
- exports.isDartType = isDartType;
29861
- exports.isDartTypeWithNullables = isDartTypeWithNullables;
29862
- exports.transformers = transformers;
29863
- exports.tsModelFromDefinition = tsModelFromDefinition;
29864
- exports.tsRpcFromProcedureDefinition = tsRpcFromProcedureDefinition;
29865
- exports.tsServiceFromServiceDefinition = tsServiceFromServiceDefinition;
29866
- exports.typescriptClientGenerator = typescriptClientGenerator;
29043
+ exports.format2 = format2;