@bradleyhodges/addresskit 2.2.3 → 2.4.4

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.
Files changed (4) hide show
  1. package/README.md +430 -156
  2. package/api/swagger.yaml +353 -0
  3. package/dist/cli.js +896 -2296
  4. package/package.json +17 -12
package/dist/cli.js CHANGED
@@ -39,7 +39,7 @@ var version;
39
39
  var init_version = __esm({
40
40
  "packages/core/version.ts"() {
41
41
  "use strict";
42
- version = "2.2.3";
42
+ version = "2.4.4";
43
43
  }
44
44
  });
45
45
 
@@ -3329,8 +3329,8 @@ var require_main = __commonJS({
3329
3329
  const shortPaths = [];
3330
3330
  for (const filePath of optionPaths) {
3331
3331
  try {
3332
- const relative = path5.relative(process.cwd(), filePath);
3333
- shortPaths.push(relative);
3332
+ const relative2 = path5.relative(process.cwd(), filePath);
3333
+ shortPaths.push(relative2);
3334
3334
  } catch (e) {
3335
3335
  if (debug8) {
3336
3336
  _debug(`Failed to load ${filePath} ${e.message}`);
@@ -7469,7 +7469,7 @@ var require_buffer_list = __commonJS({
7469
7469
  }
7470
7470
  }, {
7471
7471
  key: "join",
7472
- value: function join2(s) {
7472
+ value: function join3(s) {
7473
7473
  if (this.length === 0) return "";
7474
7474
  var p = this.head;
7475
7475
  var ret = "" + p.data;
@@ -24729,6 +24729,8 @@ var require_elasticsearch = __commonJS({
24729
24729
  exports2.VERBOSE = exports2.ELASTIC_PORT = void 0;
24730
24730
  exports2.dropIndex = dropIndex;
24731
24731
  exports2.initIndex = initIndex3;
24732
+ exports2.dropLocalityIndex = dropLocalityIndex;
24733
+ exports2.initLocalityIndex = initLocalityIndex2;
24732
24734
  exports2.esConnect = esConnect3;
24733
24735
  var opensearch_1 = require_opensearch();
24734
24736
  var debug_1 = __importDefault3(require_src());
@@ -24736,6 +24738,7 @@ var require_elasticsearch = __commonJS({
24736
24738
  var logger8 = (0, debug_1.default)("api");
24737
24739
  var error8 = (0, debug_1.default)("error");
24738
24740
  var ES_INDEX_NAME2 = process.env.ES_INDEX_NAME ?? "addresskit";
24741
+ var ES_LOCALITY_INDEX_NAME2 = process.env.ES_LOCALITY_INDEX_NAME ?? "addresskit-localities";
24739
24742
  exports2.ELASTIC_PORT = Number.parseInt(process.env.ELASTIC_PORT ?? "9200", 10);
24740
24743
  var ELASTIC_HOST = process.env.ELASTIC_HOST ?? "127.0.0.1";
24741
24744
  var ELASTIC_USERNAME = process.env.ELASTIC_USERNAME ?? void 0;
@@ -24872,6 +24875,163 @@ var require_elasticsearch = __commonJS({
24872
24875
  });
24873
24876
  if (exports2.VERBOSE)
24874
24877
  logger8(`indexGetResult:
24878
+ ${JSON.stringify(indexGetResult, void 0, 2)}`);
24879
+ }
24880
+ async function dropLocalityIndex(esClient) {
24881
+ const exists = await esClient.indices.exists({
24882
+ index: ES_LOCALITY_INDEX_NAME2
24883
+ });
24884
+ if (exists.body === true) {
24885
+ const deleteIndexResult = await esClient.indices.delete({
24886
+ index: ES_LOCALITY_INDEX_NAME2
24887
+ });
24888
+ if (exports2.VERBOSE)
24889
+ logger8({ deleteIndexResult });
24890
+ }
24891
+ const postExists = await esClient.indices.exists({
24892
+ index: ES_LOCALITY_INDEX_NAME2
24893
+ });
24894
+ if (exports2.VERBOSE)
24895
+ logger8("locality index exists:", postExists);
24896
+ }
24897
+ async function initLocalityIndex2(esClient, clear) {
24898
+ if (clear)
24899
+ await dropLocalityIndex(esClient);
24900
+ const exists = await esClient.indices.exists({
24901
+ index: ES_LOCALITY_INDEX_NAME2
24902
+ });
24903
+ if (exports2.VERBOSE)
24904
+ logger8("locality index exists:", exists.body);
24905
+ const indexBody = {
24906
+ settings: {
24907
+ index: {
24908
+ analysis: {
24909
+ filter: {
24910
+ comma_stripper: {
24911
+ type: "pattern_replace",
24912
+ pattern: ",",
24913
+ replacement: ""
24914
+ }
24915
+ },
24916
+ analyzer: {
24917
+ locality_analyzer: {
24918
+ tokenizer: "whitecomma",
24919
+ filter: [
24920
+ "uppercase",
24921
+ "asciifolding",
24922
+ "comma_stripper",
24923
+ "trim"
24924
+ ]
24925
+ }
24926
+ },
24927
+ tokenizer: {
24928
+ whitecomma: {
24929
+ type: "pattern",
24930
+ pattern: "[\\W,]+",
24931
+ lowercase: false
24932
+ }
24933
+ }
24934
+ }
24935
+ }
24936
+ },
24937
+ aliases: {},
24938
+ mappings: {
24939
+ properties: {
24940
+ // Display string for autocomplete (e.g., "SYDNEY NSW 2000")
24941
+ display: {
24942
+ type: "text",
24943
+ analyzer: "locality_analyzer",
24944
+ fields: {
24945
+ raw: {
24946
+ type: "keyword"
24947
+ }
24948
+ }
24949
+ },
24950
+ // Locality name for searching
24951
+ name: {
24952
+ type: "text",
24953
+ analyzer: "locality_analyzer",
24954
+ fields: {
24955
+ raw: {
24956
+ type: "keyword"
24957
+ }
24958
+ }
24959
+ },
24960
+ // State abbreviation for filtering
24961
+ stateAbbreviation: {
24962
+ type: "keyword"
24963
+ },
24964
+ // State full name
24965
+ stateName: {
24966
+ type: "keyword"
24967
+ },
24968
+ // Primary postcode
24969
+ postcode: {
24970
+ type: "keyword"
24971
+ },
24972
+ // All postcodes associated with this locality
24973
+ postcodes: {
24974
+ type: "keyword"
24975
+ },
24976
+ // Locality class code
24977
+ classCode: {
24978
+ type: "keyword"
24979
+ },
24980
+ // Locality class name
24981
+ className: {
24982
+ type: "keyword"
24983
+ },
24984
+ // Original G-NAF locality PID
24985
+ localityPid: {
24986
+ type: "keyword"
24987
+ }
24988
+ }
24989
+ }
24990
+ };
24991
+ if (exists.body !== true) {
24992
+ if (exports2.VERBOSE)
24993
+ logger8(`creating locality index: ${ES_LOCALITY_INDEX_NAME2}`);
24994
+ const indexCreateResult = await esClient.indices.create({
24995
+ index: ES_LOCALITY_INDEX_NAME2,
24996
+ body: indexBody
24997
+ });
24998
+ if (exports2.VERBOSE)
24999
+ logger8({ indexCreateResult });
25000
+ } else {
25001
+ const indexCloseResult = await esClient.indices.close({
25002
+ index: ES_LOCALITY_INDEX_NAME2
25003
+ });
25004
+ if (exports2.VERBOSE)
25005
+ logger8({ indexCloseResult });
25006
+ const indexPutSettingsResult = await esClient.indices.putSettings({
25007
+ index: ES_LOCALITY_INDEX_NAME2,
25008
+ body: indexBody
25009
+ });
25010
+ if (exports2.VERBOSE)
25011
+ logger8({ indexPutSettingsResult });
25012
+ const indexPutMappingResult = await esClient.indices.putMapping({
25013
+ index: ES_LOCALITY_INDEX_NAME2,
25014
+ body: indexBody.mappings
25015
+ });
25016
+ if (exports2.VERBOSE)
25017
+ logger8({ indexPutMappingResult });
25018
+ const indexOpenResult = await esClient.indices.open({
25019
+ index: ES_LOCALITY_INDEX_NAME2
25020
+ });
25021
+ if (exports2.VERBOSE)
25022
+ logger8({ indexOpenResult });
25023
+ const refreshResult = await esClient.indices.refresh({
25024
+ index: ES_LOCALITY_INDEX_NAME2
25025
+ });
25026
+ if (exports2.VERBOSE)
25027
+ logger8({ refreshResult });
25028
+ }
25029
+ const indexGetResult = await esClient.indices.get({
25030
+ index: ES_LOCALITY_INDEX_NAME2,
25031
+ include_defaults: true
25032
+ });
25033
+ if (exports2.VERBOSE)
25034
+ logger8(`localityIndexGetResult:
24875
25035
  ${JSON.stringify(indexGetResult, void 0, 2)}`);
24876
25036
  }
24877
25037
  async function esConnect3(esport = exports2.ELASTIC_PORT, eshost = ELASTIC_HOST, interval = 1e3, timeout = 0) {
@@ -31999,10 +32159,10 @@ var require_symlink = __commonJS({
31999
32159
  pathExists(dstpath, (err, destinationExists) => {
32000
32160
  if (err) return callback(err);
32001
32161
  if (destinationExists) return callback(null);
32002
- symlinkPaths(srcpath, dstpath, (err2, relative) => {
32162
+ symlinkPaths(srcpath, dstpath, (err2, relative2) => {
32003
32163
  if (err2) return callback(err2);
32004
- srcpath = relative.toDst;
32005
- symlinkType(relative.toCwd, type, (err3, type2) => {
32164
+ srcpath = relative2.toDst;
32165
+ symlinkType(relative2.toCwd, type, (err3, type2) => {
32006
32166
  if (err3) return callback(err3);
32007
32167
  const dir = path5.dirname(dstpath);
32008
32168
  pathExists(dir, (err4, dirExists) => {
@@ -32022,9 +32182,9 @@ var require_symlink = __commonJS({
32022
32182
  type = typeof type === "function" ? false : type;
32023
32183
  const destinationExists = fs5.existsSync(dstpath);
32024
32184
  if (destinationExists) return void 0;
32025
- const relative = symlinkPathsSync(srcpath, dstpath);
32026
- srcpath = relative.toDst;
32027
- type = symlinkTypeSync(relative.toCwd, type);
32185
+ const relative2 = symlinkPathsSync(srcpath, dstpath);
32186
+ srcpath = relative2.toDst;
32187
+ type = symlinkTypeSync(relative2.toCwd, type);
32028
32188
  const dir = path5.dirname(dstpath);
32029
32189
  const exists = fs5.existsSync(dir);
32030
32190
  if (exists) return fs5.symlinkSync(srcpath, dstpath, type);
@@ -32469,2247 +32629,6 @@ var require_directory_exists = __commonJS({
32469
32629
  }
32470
32630
  });
32471
32631
 
32472
- // node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js
32473
- var require_old = __commonJS({
32474
- "node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/old.js"(exports2) {
32475
- var pathModule = require("path");
32476
- var isWindows = process.platform === "win32";
32477
- var fs5 = require("fs");
32478
- var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
32479
- function rethrow() {
32480
- var callback;
32481
- if (DEBUG) {
32482
- var backtrace = new Error();
32483
- callback = debugCallback;
32484
- } else
32485
- callback = missingCallback;
32486
- return callback;
32487
- function debugCallback(err) {
32488
- if (err) {
32489
- backtrace.message = err.message;
32490
- err = backtrace;
32491
- missingCallback(err);
32492
- }
32493
- }
32494
- function missingCallback(err) {
32495
- if (err) {
32496
- if (process.throwDeprecation)
32497
- throw err;
32498
- else if (!process.noDeprecation) {
32499
- var msg = "fs: missing callback " + (err.stack || err.message);
32500
- if (process.traceDeprecation)
32501
- console.trace(msg);
32502
- else
32503
- console.error(msg);
32504
- }
32505
- }
32506
- }
32507
- }
32508
- function maybeCallback(cb) {
32509
- return typeof cb === "function" ? cb : rethrow();
32510
- }
32511
- var normalize = pathModule.normalize;
32512
- if (isWindows) {
32513
- nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
32514
- } else {
32515
- nextPartRe = /(.*?)(?:[\/]+|$)/g;
32516
- }
32517
- var nextPartRe;
32518
- if (isWindows) {
32519
- splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
32520
- } else {
32521
- splitRootRe = /^[\/]*/;
32522
- }
32523
- var splitRootRe;
32524
- exports2.realpathSync = function realpathSync(p, cache2) {
32525
- p = pathModule.resolve(p);
32526
- if (cache2 && Object.prototype.hasOwnProperty.call(cache2, p)) {
32527
- return cache2[p];
32528
- }
32529
- var original = p, seenLinks = {}, knownHard = {};
32530
- var pos;
32531
- var current;
32532
- var base;
32533
- var previous;
32534
- start();
32535
- function start() {
32536
- var m = splitRootRe.exec(p);
32537
- pos = m[0].length;
32538
- current = m[0];
32539
- base = m[0];
32540
- previous = "";
32541
- if (isWindows && !knownHard[base]) {
32542
- fs5.lstatSync(base);
32543
- knownHard[base] = true;
32544
- }
32545
- }
32546
- while (pos < p.length) {
32547
- nextPartRe.lastIndex = pos;
32548
- var result = nextPartRe.exec(p);
32549
- previous = current;
32550
- current += result[0];
32551
- base = previous + result[1];
32552
- pos = nextPartRe.lastIndex;
32553
- if (knownHard[base] || cache2 && cache2[base] === base) {
32554
- continue;
32555
- }
32556
- var resolvedLink;
32557
- if (cache2 && Object.prototype.hasOwnProperty.call(cache2, base)) {
32558
- resolvedLink = cache2[base];
32559
- } else {
32560
- var stat2 = fs5.lstatSync(base);
32561
- if (!stat2.isSymbolicLink()) {
32562
- knownHard[base] = true;
32563
- if (cache2) cache2[base] = base;
32564
- continue;
32565
- }
32566
- var linkTarget = null;
32567
- if (!isWindows) {
32568
- var id = stat2.dev.toString(32) + ":" + stat2.ino.toString(32);
32569
- if (seenLinks.hasOwnProperty(id)) {
32570
- linkTarget = seenLinks[id];
32571
- }
32572
- }
32573
- if (linkTarget === null) {
32574
- fs5.statSync(base);
32575
- linkTarget = fs5.readlinkSync(base);
32576
- }
32577
- resolvedLink = pathModule.resolve(previous, linkTarget);
32578
- if (cache2) cache2[base] = resolvedLink;
32579
- if (!isWindows) seenLinks[id] = linkTarget;
32580
- }
32581
- p = pathModule.resolve(resolvedLink, p.slice(pos));
32582
- start();
32583
- }
32584
- if (cache2) cache2[original] = p;
32585
- return p;
32586
- };
32587
- exports2.realpath = function realpath(p, cache2, cb) {
32588
- if (typeof cb !== "function") {
32589
- cb = maybeCallback(cache2);
32590
- cache2 = null;
32591
- }
32592
- p = pathModule.resolve(p);
32593
- if (cache2 && Object.prototype.hasOwnProperty.call(cache2, p)) {
32594
- return process.nextTick(cb.bind(null, null, cache2[p]));
32595
- }
32596
- var original = p, seenLinks = {}, knownHard = {};
32597
- var pos;
32598
- var current;
32599
- var base;
32600
- var previous;
32601
- start();
32602
- function start() {
32603
- var m = splitRootRe.exec(p);
32604
- pos = m[0].length;
32605
- current = m[0];
32606
- base = m[0];
32607
- previous = "";
32608
- if (isWindows && !knownHard[base]) {
32609
- fs5.lstat(base, function(err) {
32610
- if (err) return cb(err);
32611
- knownHard[base] = true;
32612
- LOOP();
32613
- });
32614
- } else {
32615
- process.nextTick(LOOP);
32616
- }
32617
- }
32618
- function LOOP() {
32619
- if (pos >= p.length) {
32620
- if (cache2) cache2[original] = p;
32621
- return cb(null, p);
32622
- }
32623
- nextPartRe.lastIndex = pos;
32624
- var result = nextPartRe.exec(p);
32625
- previous = current;
32626
- current += result[0];
32627
- base = previous + result[1];
32628
- pos = nextPartRe.lastIndex;
32629
- if (knownHard[base] || cache2 && cache2[base] === base) {
32630
- return process.nextTick(LOOP);
32631
- }
32632
- if (cache2 && Object.prototype.hasOwnProperty.call(cache2, base)) {
32633
- return gotResolvedLink(cache2[base]);
32634
- }
32635
- return fs5.lstat(base, gotStat);
32636
- }
32637
- function gotStat(err, stat2) {
32638
- if (err) return cb(err);
32639
- if (!stat2.isSymbolicLink()) {
32640
- knownHard[base] = true;
32641
- if (cache2) cache2[base] = base;
32642
- return process.nextTick(LOOP);
32643
- }
32644
- if (!isWindows) {
32645
- var id = stat2.dev.toString(32) + ":" + stat2.ino.toString(32);
32646
- if (seenLinks.hasOwnProperty(id)) {
32647
- return gotTarget(null, seenLinks[id], base);
32648
- }
32649
- }
32650
- fs5.stat(base, function(err2) {
32651
- if (err2) return cb(err2);
32652
- fs5.readlink(base, function(err3, target) {
32653
- if (!isWindows) seenLinks[id] = target;
32654
- gotTarget(err3, target);
32655
- });
32656
- });
32657
- }
32658
- function gotTarget(err, target, base2) {
32659
- if (err) return cb(err);
32660
- var resolvedLink = pathModule.resolve(previous, target);
32661
- if (cache2) cache2[base2] = resolvedLink;
32662
- gotResolvedLink(resolvedLink);
32663
- }
32664
- function gotResolvedLink(resolvedLink) {
32665
- p = pathModule.resolve(resolvedLink, p.slice(pos));
32666
- start();
32667
- }
32668
- };
32669
- }
32670
- });
32671
-
32672
- // node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js
32673
- var require_fs2 = __commonJS({
32674
- "node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js"(exports2, module2) {
32675
- module2.exports = realpath;
32676
- realpath.realpath = realpath;
32677
- realpath.sync = realpathSync;
32678
- realpath.realpathSync = realpathSync;
32679
- realpath.monkeypatch = monkeypatch;
32680
- realpath.unmonkeypatch = unmonkeypatch;
32681
- var fs5 = require("fs");
32682
- var origRealpath = fs5.realpath;
32683
- var origRealpathSync = fs5.realpathSync;
32684
- var version2 = process.version;
32685
- var ok = /^v[0-5]\./.test(version2);
32686
- var old = require_old();
32687
- function newError(er) {
32688
- return er && er.syscall === "realpath" && (er.code === "ELOOP" || er.code === "ENOMEM" || er.code === "ENAMETOOLONG");
32689
- }
32690
- function realpath(p, cache2, cb) {
32691
- if (ok) {
32692
- return origRealpath(p, cache2, cb);
32693
- }
32694
- if (typeof cache2 === "function") {
32695
- cb = cache2;
32696
- cache2 = null;
32697
- }
32698
- origRealpath(p, cache2, function(er, result) {
32699
- if (newError(er)) {
32700
- old.realpath(p, cache2, cb);
32701
- } else {
32702
- cb(er, result);
32703
- }
32704
- });
32705
- }
32706
- function realpathSync(p, cache2) {
32707
- if (ok) {
32708
- return origRealpathSync(p, cache2);
32709
- }
32710
- try {
32711
- return origRealpathSync(p, cache2);
32712
- } catch (er) {
32713
- if (newError(er)) {
32714
- return old.realpathSync(p, cache2);
32715
- } else {
32716
- throw er;
32717
- }
32718
- }
32719
- }
32720
- function monkeypatch() {
32721
- fs5.realpath = realpath;
32722
- fs5.realpathSync = realpathSync;
32723
- }
32724
- function unmonkeypatch() {
32725
- fs5.realpath = origRealpath;
32726
- fs5.realpathSync = origRealpathSync;
32727
- }
32728
- }
32729
- });
32730
-
32731
- // node_modules/.pnpm/concat-map@0.0.1/node_modules/concat-map/index.js
32732
- var require_concat_map = __commonJS({
32733
- "node_modules/.pnpm/concat-map@0.0.1/node_modules/concat-map/index.js"(exports2, module2) {
32734
- module2.exports = function(xs, fn) {
32735
- var res = [];
32736
- for (var i = 0; i < xs.length; i++) {
32737
- var x = fn(xs[i], i);
32738
- if (isArray(x)) res.push.apply(res, x);
32739
- else res.push(x);
32740
- }
32741
- return res;
32742
- };
32743
- var isArray = Array.isArray || function(xs) {
32744
- return Object.prototype.toString.call(xs) === "[object Array]";
32745
- };
32746
- }
32747
- });
32748
-
32749
- // node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js
32750
- var require_balanced_match = __commonJS({
32751
- "node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports2, module2) {
32752
- "use strict";
32753
- module2.exports = balanced;
32754
- function balanced(a, b, str) {
32755
- if (a instanceof RegExp) a = maybeMatch(a, str);
32756
- if (b instanceof RegExp) b = maybeMatch(b, str);
32757
- var r = range(a, b, str);
32758
- return r && {
32759
- start: r[0],
32760
- end: r[1],
32761
- pre: str.slice(0, r[0]),
32762
- body: str.slice(r[0] + a.length, r[1]),
32763
- post: str.slice(r[1] + b.length)
32764
- };
32765
- }
32766
- function maybeMatch(reg, str) {
32767
- var m = str.match(reg);
32768
- return m ? m[0] : null;
32769
- }
32770
- balanced.range = range;
32771
- function range(a, b, str) {
32772
- var begs, beg, left, right, result;
32773
- var ai = str.indexOf(a);
32774
- var bi = str.indexOf(b, ai + 1);
32775
- var i = ai;
32776
- if (ai >= 0 && bi > 0) {
32777
- if (a === b) {
32778
- return [ai, bi];
32779
- }
32780
- begs = [];
32781
- left = str.length;
32782
- while (i >= 0 && !result) {
32783
- if (i == ai) {
32784
- begs.push(i);
32785
- ai = str.indexOf(a, i + 1);
32786
- } else if (begs.length == 1) {
32787
- result = [begs.pop(), bi];
32788
- } else {
32789
- beg = begs.pop();
32790
- if (beg < left) {
32791
- left = beg;
32792
- right = bi;
32793
- }
32794
- bi = str.indexOf(b, i + 1);
32795
- }
32796
- i = ai < bi && ai >= 0 ? ai : bi;
32797
- }
32798
- if (begs.length) {
32799
- result = [left, right];
32800
- }
32801
- }
32802
- return result;
32803
- }
32804
- }
32805
- });
32806
-
32807
- // node_modules/.pnpm/brace-expansion@1.1.12/node_modules/brace-expansion/index.js
32808
- var require_brace_expansion = __commonJS({
32809
- "node_modules/.pnpm/brace-expansion@1.1.12/node_modules/brace-expansion/index.js"(exports2, module2) {
32810
- var concatMap = require_concat_map();
32811
- var balanced = require_balanced_match();
32812
- module2.exports = expandTop;
32813
- var escSlash = "\0SLASH" + Math.random() + "\0";
32814
- var escOpen = "\0OPEN" + Math.random() + "\0";
32815
- var escClose = "\0CLOSE" + Math.random() + "\0";
32816
- var escComma = "\0COMMA" + Math.random() + "\0";
32817
- var escPeriod = "\0PERIOD" + Math.random() + "\0";
32818
- function numeric(str) {
32819
- return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
32820
- }
32821
- function escapeBraces(str) {
32822
- return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
32823
- }
32824
- function unescapeBraces(str) {
32825
- return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
32826
- }
32827
- function parseCommaParts(str) {
32828
- if (!str)
32829
- return [""];
32830
- var parts = [];
32831
- var m = balanced("{", "}", str);
32832
- if (!m)
32833
- return str.split(",");
32834
- var pre = m.pre;
32835
- var body = m.body;
32836
- var post = m.post;
32837
- var p = pre.split(",");
32838
- p[p.length - 1] += "{" + body + "}";
32839
- var postParts = parseCommaParts(post);
32840
- if (post.length) {
32841
- p[p.length - 1] += postParts.shift();
32842
- p.push.apply(p, postParts);
32843
- }
32844
- parts.push.apply(parts, p);
32845
- return parts;
32846
- }
32847
- function expandTop(str) {
32848
- if (!str)
32849
- return [];
32850
- if (str.substr(0, 2) === "{}") {
32851
- str = "\\{\\}" + str.substr(2);
32852
- }
32853
- return expand(escapeBraces(str), true).map(unescapeBraces);
32854
- }
32855
- function embrace(str) {
32856
- return "{" + str + "}";
32857
- }
32858
- function isPadded(el) {
32859
- return /^-?0\d/.test(el);
32860
- }
32861
- function lte(i, y) {
32862
- return i <= y;
32863
- }
32864
- function gte(i, y) {
32865
- return i >= y;
32866
- }
32867
- function expand(str, isTop) {
32868
- var expansions = [];
32869
- var m = balanced("{", "}", str);
32870
- if (!m || /\$$/.test(m.pre)) return [str];
32871
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
32872
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
32873
- var isSequence = isNumericSequence || isAlphaSequence;
32874
- var isOptions = m.body.indexOf(",") >= 0;
32875
- if (!isSequence && !isOptions) {
32876
- if (m.post.match(/,(?!,).*\}/)) {
32877
- str = m.pre + "{" + m.body + escClose + m.post;
32878
- return expand(str);
32879
- }
32880
- return [str];
32881
- }
32882
- var n;
32883
- if (isSequence) {
32884
- n = m.body.split(/\.\./);
32885
- } else {
32886
- n = parseCommaParts(m.body);
32887
- if (n.length === 1) {
32888
- n = expand(n[0], false).map(embrace);
32889
- if (n.length === 1) {
32890
- var post = m.post.length ? expand(m.post, false) : [""];
32891
- return post.map(function(p) {
32892
- return m.pre + n[0] + p;
32893
- });
32894
- }
32895
- }
32896
- }
32897
- var pre = m.pre;
32898
- var post = m.post.length ? expand(m.post, false) : [""];
32899
- var N;
32900
- if (isSequence) {
32901
- var x = numeric(n[0]);
32902
- var y = numeric(n[1]);
32903
- var width = Math.max(n[0].length, n[1].length);
32904
- var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
32905
- var test = lte;
32906
- var reverse = y < x;
32907
- if (reverse) {
32908
- incr *= -1;
32909
- test = gte;
32910
- }
32911
- var pad = n.some(isPadded);
32912
- N = [];
32913
- for (var i = x; test(i, y); i += incr) {
32914
- var c;
32915
- if (isAlphaSequence) {
32916
- c = String.fromCharCode(i);
32917
- if (c === "\\")
32918
- c = "";
32919
- } else {
32920
- c = String(i);
32921
- if (pad) {
32922
- var need = width - c.length;
32923
- if (need > 0) {
32924
- var z = new Array(need + 1).join("0");
32925
- if (i < 0)
32926
- c = "-" + z + c.slice(1);
32927
- else
32928
- c = z + c;
32929
- }
32930
- }
32931
- }
32932
- N.push(c);
32933
- }
32934
- } else {
32935
- N = concatMap(n, function(el) {
32936
- return expand(el, false);
32937
- });
32938
- }
32939
- for (var j = 0; j < N.length; j++) {
32940
- for (var k = 0; k < post.length; k++) {
32941
- var expansion = pre + N[j] + post[k];
32942
- if (!isTop || isSequence || expansion)
32943
- expansions.push(expansion);
32944
- }
32945
- }
32946
- return expansions;
32947
- }
32948
- }
32949
- });
32950
-
32951
- // node_modules/.pnpm/minimatch@3.1.2/node_modules/minimatch/minimatch.js
32952
- var require_minimatch = __commonJS({
32953
- "node_modules/.pnpm/minimatch@3.1.2/node_modules/minimatch/minimatch.js"(exports2, module2) {
32954
- module2.exports = minimatch;
32955
- minimatch.Minimatch = Minimatch;
32956
- var path5 = (function() {
32957
- try {
32958
- return require("path");
32959
- } catch (e) {
32960
- }
32961
- })() || {
32962
- sep: "/"
32963
- };
32964
- minimatch.sep = path5.sep;
32965
- var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
32966
- var expand = require_brace_expansion();
32967
- var plTypes = {
32968
- "!": { open: "(?:(?!(?:", close: "))[^/]*?)" },
32969
- "?": { open: "(?:", close: ")?" },
32970
- "+": { open: "(?:", close: ")+" },
32971
- "*": { open: "(?:", close: ")*" },
32972
- "@": { open: "(?:", close: ")" }
32973
- };
32974
- var qmark = "[^/]";
32975
- var star = qmark + "*?";
32976
- var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
32977
- var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
32978
- var reSpecials = charSet("().*{}+?[]^$\\!");
32979
- function charSet(s) {
32980
- return s.split("").reduce(function(set, c) {
32981
- set[c] = true;
32982
- return set;
32983
- }, {});
32984
- }
32985
- var slashSplit = /\/+/;
32986
- minimatch.filter = filter;
32987
- function filter(pattern, options) {
32988
- options = options || {};
32989
- return function(p, i, list) {
32990
- return minimatch(p, pattern, options);
32991
- };
32992
- }
32993
- function ext(a, b) {
32994
- b = b || {};
32995
- var t = {};
32996
- Object.keys(a).forEach(function(k) {
32997
- t[k] = a[k];
32998
- });
32999
- Object.keys(b).forEach(function(k) {
33000
- t[k] = b[k];
33001
- });
33002
- return t;
33003
- }
33004
- minimatch.defaults = function(def) {
33005
- if (!def || typeof def !== "object" || !Object.keys(def).length) {
33006
- return minimatch;
33007
- }
33008
- var orig = minimatch;
33009
- var m = function minimatch2(p, pattern, options) {
33010
- return orig(p, pattern, ext(def, options));
33011
- };
33012
- m.Minimatch = function Minimatch2(pattern, options) {
33013
- return new orig.Minimatch(pattern, ext(def, options));
33014
- };
33015
- m.Minimatch.defaults = function defaults(options) {
33016
- return orig.defaults(ext(def, options)).Minimatch;
33017
- };
33018
- m.filter = function filter2(pattern, options) {
33019
- return orig.filter(pattern, ext(def, options));
33020
- };
33021
- m.defaults = function defaults(options) {
33022
- return orig.defaults(ext(def, options));
33023
- };
33024
- m.makeRe = function makeRe2(pattern, options) {
33025
- return orig.makeRe(pattern, ext(def, options));
33026
- };
33027
- m.braceExpand = function braceExpand2(pattern, options) {
33028
- return orig.braceExpand(pattern, ext(def, options));
33029
- };
33030
- m.match = function(list, pattern, options) {
33031
- return orig.match(list, pattern, ext(def, options));
33032
- };
33033
- return m;
33034
- };
33035
- Minimatch.defaults = function(def) {
33036
- return minimatch.defaults(def).Minimatch;
33037
- };
33038
- function minimatch(p, pattern, options) {
33039
- assertValidPattern(pattern);
33040
- if (!options) options = {};
33041
- if (!options.nocomment && pattern.charAt(0) === "#") {
33042
- return false;
33043
- }
33044
- return new Minimatch(pattern, options).match(p);
33045
- }
33046
- function Minimatch(pattern, options) {
33047
- if (!(this instanceof Minimatch)) {
33048
- return new Minimatch(pattern, options);
33049
- }
33050
- assertValidPattern(pattern);
33051
- if (!options) options = {};
33052
- pattern = pattern.trim();
33053
- if (!options.allowWindowsEscape && path5.sep !== "/") {
33054
- pattern = pattern.split(path5.sep).join("/");
33055
- }
33056
- this.options = options;
33057
- this.set = [];
33058
- this.pattern = pattern;
33059
- this.regexp = null;
33060
- this.negate = false;
33061
- this.comment = false;
33062
- this.empty = false;
33063
- this.partial = !!options.partial;
33064
- this.make();
33065
- }
33066
- Minimatch.prototype.debug = function() {
33067
- };
33068
- Minimatch.prototype.make = make;
33069
- function make() {
33070
- var pattern = this.pattern;
33071
- var options = this.options;
33072
- if (!options.nocomment && pattern.charAt(0) === "#") {
33073
- this.comment = true;
33074
- return;
33075
- }
33076
- if (!pattern) {
33077
- this.empty = true;
33078
- return;
33079
- }
33080
- this.parseNegate();
33081
- var set = this.globSet = this.braceExpand();
33082
- if (options.debug) this.debug = function debug8() {
33083
- console.error.apply(console, arguments);
33084
- };
33085
- this.debug(this.pattern, set);
33086
- set = this.globParts = set.map(function(s) {
33087
- return s.split(slashSplit);
33088
- });
33089
- this.debug(this.pattern, set);
33090
- set = set.map(function(s, si, set2) {
33091
- return s.map(this.parse, this);
33092
- }, this);
33093
- this.debug(this.pattern, set);
33094
- set = set.filter(function(s) {
33095
- return s.indexOf(false) === -1;
33096
- });
33097
- this.debug(this.pattern, set);
33098
- this.set = set;
33099
- }
33100
- Minimatch.prototype.parseNegate = parseNegate;
33101
- function parseNegate() {
33102
- var pattern = this.pattern;
33103
- var negate = false;
33104
- var options = this.options;
33105
- var negateOffset = 0;
33106
- if (options.nonegate) return;
33107
- for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
33108
- negate = !negate;
33109
- negateOffset++;
33110
- }
33111
- if (negateOffset) this.pattern = pattern.substr(negateOffset);
33112
- this.negate = negate;
33113
- }
33114
- minimatch.braceExpand = function(pattern, options) {
33115
- return braceExpand(pattern, options);
33116
- };
33117
- Minimatch.prototype.braceExpand = braceExpand;
33118
- function braceExpand(pattern, options) {
33119
- if (!options) {
33120
- if (this instanceof Minimatch) {
33121
- options = this.options;
33122
- } else {
33123
- options = {};
33124
- }
33125
- }
33126
- pattern = typeof pattern === "undefined" ? this.pattern : pattern;
33127
- assertValidPattern(pattern);
33128
- if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
33129
- return [pattern];
33130
- }
33131
- return expand(pattern);
33132
- }
33133
- var MAX_PATTERN_LENGTH = 1024 * 64;
33134
- var assertValidPattern = function(pattern) {
33135
- if (typeof pattern !== "string") {
33136
- throw new TypeError("invalid pattern");
33137
- }
33138
- if (pattern.length > MAX_PATTERN_LENGTH) {
33139
- throw new TypeError("pattern is too long");
33140
- }
33141
- };
33142
- Minimatch.prototype.parse = parse3;
33143
- var SUBPARSE = {};
33144
- function parse3(pattern, isSub) {
33145
- assertValidPattern(pattern);
33146
- var options = this.options;
33147
- if (pattern === "**") {
33148
- if (!options.noglobstar)
33149
- return GLOBSTAR;
33150
- else
33151
- pattern = "*";
33152
- }
33153
- if (pattern === "") return "";
33154
- var re = "";
33155
- var hasMagic = !!options.nocase;
33156
- var escaping = false;
33157
- var patternListStack = [];
33158
- var negativeLists = [];
33159
- var stateChar;
33160
- var inClass = false;
33161
- var reClassStart = -1;
33162
- var classStart = -1;
33163
- var patternStart = pattern.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
33164
- var self2 = this;
33165
- function clearStateChar() {
33166
- if (stateChar) {
33167
- switch (stateChar) {
33168
- case "*":
33169
- re += star;
33170
- hasMagic = true;
33171
- break;
33172
- case "?":
33173
- re += qmark;
33174
- hasMagic = true;
33175
- break;
33176
- default:
33177
- re += "\\" + stateChar;
33178
- break;
33179
- }
33180
- self2.debug("clearStateChar %j %j", stateChar, re);
33181
- stateChar = false;
33182
- }
33183
- }
33184
- for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
33185
- this.debug("%s %s %s %j", pattern, i, re, c);
33186
- if (escaping && reSpecials[c]) {
33187
- re += "\\" + c;
33188
- escaping = false;
33189
- continue;
33190
- }
33191
- switch (c) {
33192
- /* istanbul ignore next */
33193
- case "/": {
33194
- return false;
33195
- }
33196
- case "\\":
33197
- clearStateChar();
33198
- escaping = true;
33199
- continue;
33200
- // the various stateChar values
33201
- // for the "extglob" stuff.
33202
- case "?":
33203
- case "*":
33204
- case "+":
33205
- case "@":
33206
- case "!":
33207
- this.debug("%s %s %s %j <-- stateChar", pattern, i, re, c);
33208
- if (inClass) {
33209
- this.debug(" in class");
33210
- if (c === "!" && i === classStart + 1) c = "^";
33211
- re += c;
33212
- continue;
33213
- }
33214
- self2.debug("call clearStateChar %j", stateChar);
33215
- clearStateChar();
33216
- stateChar = c;
33217
- if (options.noext) clearStateChar();
33218
- continue;
33219
- case "(":
33220
- if (inClass) {
33221
- re += "(";
33222
- continue;
33223
- }
33224
- if (!stateChar) {
33225
- re += "\\(";
33226
- continue;
33227
- }
33228
- patternListStack.push({
33229
- type: stateChar,
33230
- start: i - 1,
33231
- reStart: re.length,
33232
- open: plTypes[stateChar].open,
33233
- close: plTypes[stateChar].close
33234
- });
33235
- re += stateChar === "!" ? "(?:(?!(?:" : "(?:";
33236
- this.debug("plType %j %j", stateChar, re);
33237
- stateChar = false;
33238
- continue;
33239
- case ")":
33240
- if (inClass || !patternListStack.length) {
33241
- re += "\\)";
33242
- continue;
33243
- }
33244
- clearStateChar();
33245
- hasMagic = true;
33246
- var pl = patternListStack.pop();
33247
- re += pl.close;
33248
- if (pl.type === "!") {
33249
- negativeLists.push(pl);
33250
- }
33251
- pl.reEnd = re.length;
33252
- continue;
33253
- case "|":
33254
- if (inClass || !patternListStack.length || escaping) {
33255
- re += "\\|";
33256
- escaping = false;
33257
- continue;
33258
- }
33259
- clearStateChar();
33260
- re += "|";
33261
- continue;
33262
- // these are mostly the same in regexp and glob
33263
- case "[":
33264
- clearStateChar();
33265
- if (inClass) {
33266
- re += "\\" + c;
33267
- continue;
33268
- }
33269
- inClass = true;
33270
- classStart = i;
33271
- reClassStart = re.length;
33272
- re += c;
33273
- continue;
33274
- case "]":
33275
- if (i === classStart + 1 || !inClass) {
33276
- re += "\\" + c;
33277
- escaping = false;
33278
- continue;
33279
- }
33280
- var cs = pattern.substring(classStart + 1, i);
33281
- try {
33282
- RegExp("[" + cs + "]");
33283
- } catch (er) {
33284
- var sp = this.parse(cs, SUBPARSE);
33285
- re = re.substr(0, reClassStart) + "\\[" + sp[0] + "\\]";
33286
- hasMagic = hasMagic || sp[1];
33287
- inClass = false;
33288
- continue;
33289
- }
33290
- hasMagic = true;
33291
- inClass = false;
33292
- re += c;
33293
- continue;
33294
- default:
33295
- clearStateChar();
33296
- if (escaping) {
33297
- escaping = false;
33298
- } else if (reSpecials[c] && !(c === "^" && inClass)) {
33299
- re += "\\";
33300
- }
33301
- re += c;
33302
- }
33303
- }
33304
- if (inClass) {
33305
- cs = pattern.substr(classStart + 1);
33306
- sp = this.parse(cs, SUBPARSE);
33307
- re = re.substr(0, reClassStart) + "\\[" + sp[0];
33308
- hasMagic = hasMagic || sp[1];
33309
- }
33310
- for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
33311
- var tail = re.slice(pl.reStart + pl.open.length);
33312
- this.debug("setting tail", re, pl);
33313
- tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function(_, $1, $2) {
33314
- if (!$2) {
33315
- $2 = "\\";
33316
- }
33317
- return $1 + $1 + $2 + "|";
33318
- });
33319
- this.debug("tail=%j\n %s", tail, tail, pl, re);
33320
- var t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
33321
- hasMagic = true;
33322
- re = re.slice(0, pl.reStart) + t + "\\(" + tail;
33323
- }
33324
- clearStateChar();
33325
- if (escaping) {
33326
- re += "\\\\";
33327
- }
33328
- var addPatternStart = false;
33329
- switch (re.charAt(0)) {
33330
- case "[":
33331
- case ".":
33332
- case "(":
33333
- addPatternStart = true;
33334
- }
33335
- for (var n = negativeLists.length - 1; n > -1; n--) {
33336
- var nl = negativeLists[n];
33337
- var nlBefore = re.slice(0, nl.reStart);
33338
- var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
33339
- var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
33340
- var nlAfter = re.slice(nl.reEnd);
33341
- nlLast += nlAfter;
33342
- var openParensBefore = nlBefore.split("(").length - 1;
33343
- var cleanAfter = nlAfter;
33344
- for (i = 0; i < openParensBefore; i++) {
33345
- cleanAfter = cleanAfter.replace(/\)[+*?]?/, "");
33346
- }
33347
- nlAfter = cleanAfter;
33348
- var dollar = "";
33349
- if (nlAfter === "" && isSub !== SUBPARSE) {
33350
- dollar = "$";
33351
- }
33352
- var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
33353
- re = newRe;
33354
- }
33355
- if (re !== "" && hasMagic) {
33356
- re = "(?=.)" + re;
33357
- }
33358
- if (addPatternStart) {
33359
- re = patternStart + re;
33360
- }
33361
- if (isSub === SUBPARSE) {
33362
- return [re, hasMagic];
33363
- }
33364
- if (!hasMagic) {
33365
- return globUnescape(pattern);
33366
- }
33367
- var flags = options.nocase ? "i" : "";
33368
- try {
33369
- var regExp = new RegExp("^" + re + "$", flags);
33370
- } catch (er) {
33371
- return new RegExp("$.");
33372
- }
33373
- regExp._glob = pattern;
33374
- regExp._src = re;
33375
- return regExp;
33376
- }
33377
- minimatch.makeRe = function(pattern, options) {
33378
- return new Minimatch(pattern, options || {}).makeRe();
33379
- };
33380
- Minimatch.prototype.makeRe = makeRe;
33381
- function makeRe() {
33382
- if (this.regexp || this.regexp === false) return this.regexp;
33383
- var set = this.set;
33384
- if (!set.length) {
33385
- this.regexp = false;
33386
- return this.regexp;
33387
- }
33388
- var options = this.options;
33389
- var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
33390
- var flags = options.nocase ? "i" : "";
33391
- var re = set.map(function(pattern) {
33392
- return pattern.map(function(p) {
33393
- return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
33394
- }).join("\\/");
33395
- }).join("|");
33396
- re = "^(?:" + re + ")$";
33397
- if (this.negate) re = "^(?!" + re + ").*$";
33398
- try {
33399
- this.regexp = new RegExp(re, flags);
33400
- } catch (ex) {
33401
- this.regexp = false;
33402
- }
33403
- return this.regexp;
33404
- }
33405
- minimatch.match = function(list, pattern, options) {
33406
- options = options || {};
33407
- var mm = new Minimatch(pattern, options);
33408
- list = list.filter(function(f) {
33409
- return mm.match(f);
33410
- });
33411
- if (mm.options.nonull && !list.length) {
33412
- list.push(pattern);
33413
- }
33414
- return list;
33415
- };
33416
- Minimatch.prototype.match = function match(f, partial) {
33417
- if (typeof partial === "undefined") partial = this.partial;
33418
- this.debug("match", f, this.pattern);
33419
- if (this.comment) return false;
33420
- if (this.empty) return f === "";
33421
- if (f === "/" && partial) return true;
33422
- var options = this.options;
33423
- if (path5.sep !== "/") {
33424
- f = f.split(path5.sep).join("/");
33425
- }
33426
- f = f.split(slashSplit);
33427
- this.debug(this.pattern, "split", f);
33428
- var set = this.set;
33429
- this.debug(this.pattern, "set", set);
33430
- var filename;
33431
- var i;
33432
- for (i = f.length - 1; i >= 0; i--) {
33433
- filename = f[i];
33434
- if (filename) break;
33435
- }
33436
- for (i = 0; i < set.length; i++) {
33437
- var pattern = set[i];
33438
- var file = f;
33439
- if (options.matchBase && pattern.length === 1) {
33440
- file = [filename];
33441
- }
33442
- var hit = this.matchOne(file, pattern, partial);
33443
- if (hit) {
33444
- if (options.flipNegate) return true;
33445
- return !this.negate;
33446
- }
33447
- }
33448
- if (options.flipNegate) return false;
33449
- return this.negate;
33450
- };
33451
- Minimatch.prototype.matchOne = function(file, pattern, partial) {
33452
- var options = this.options;
33453
- this.debug(
33454
- "matchOne",
33455
- { "this": this, file, pattern }
33456
- );
33457
- this.debug("matchOne", file.length, pattern.length);
33458
- for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
33459
- this.debug("matchOne loop");
33460
- var p = pattern[pi];
33461
- var f = file[fi];
33462
- this.debug(pattern, p, f);
33463
- if (p === false) return false;
33464
- if (p === GLOBSTAR) {
33465
- this.debug("GLOBSTAR", [pattern, p, f]);
33466
- var fr = fi;
33467
- var pr = pi + 1;
33468
- if (pr === pl) {
33469
- this.debug("** at the end");
33470
- for (; fi < fl; fi++) {
33471
- if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
33472
- }
33473
- return true;
33474
- }
33475
- while (fr < fl) {
33476
- var swallowee = file[fr];
33477
- this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
33478
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
33479
- this.debug("globstar found match!", fr, fl, swallowee);
33480
- return true;
33481
- } else {
33482
- if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
33483
- this.debug("dot detected!", file, fr, pattern, pr);
33484
- break;
33485
- }
33486
- this.debug("globstar swallow a segment, and continue");
33487
- fr++;
33488
- }
33489
- }
33490
- if (partial) {
33491
- this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
33492
- if (fr === fl) return true;
33493
- }
33494
- return false;
33495
- }
33496
- var hit;
33497
- if (typeof p === "string") {
33498
- hit = f === p;
33499
- this.debug("string match", p, f, hit);
33500
- } else {
33501
- hit = f.match(p);
33502
- this.debug("pattern match", p, f, hit);
33503
- }
33504
- if (!hit) return false;
33505
- }
33506
- if (fi === fl && pi === pl) {
33507
- return true;
33508
- } else if (fi === fl) {
33509
- return partial;
33510
- } else if (pi === pl) {
33511
- return fi === fl - 1 && file[fi] === "";
33512
- }
33513
- throw new Error("wtf?");
33514
- };
33515
- function globUnescape(s) {
33516
- return s.replace(/\\(.)/g, "$1");
33517
- }
33518
- function regExpEscape(s) {
33519
- return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
33520
- }
33521
- }
33522
- });
33523
-
33524
- // node_modules/.pnpm/path-is-absolute@1.0.1/node_modules/path-is-absolute/index.js
33525
- var require_path_is_absolute = __commonJS({
33526
- "node_modules/.pnpm/path-is-absolute@1.0.1/node_modules/path-is-absolute/index.js"(exports2, module2) {
33527
- "use strict";
33528
- function posix(path5) {
33529
- return path5.charAt(0) === "/";
33530
- }
33531
- function win32(path5) {
33532
- var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
33533
- var result = splitDeviceRe.exec(path5);
33534
- var device = result[1] || "";
33535
- var isUnc = Boolean(device && device.charAt(1) !== ":");
33536
- return Boolean(result[2] || isUnc);
33537
- }
33538
- module2.exports = process.platform === "win32" ? win32 : posix;
33539
- module2.exports.posix = posix;
33540
- module2.exports.win32 = win32;
33541
- }
33542
- });
33543
-
33544
- // node_modules/.pnpm/glob@7.2.3/node_modules/glob/common.js
33545
- var require_common2 = __commonJS({
33546
- "node_modules/.pnpm/glob@7.2.3/node_modules/glob/common.js"(exports2) {
33547
- exports2.setopts = setopts;
33548
- exports2.ownProp = ownProp;
33549
- exports2.makeAbs = makeAbs;
33550
- exports2.finish = finish;
33551
- exports2.mark = mark;
33552
- exports2.isIgnored = isIgnored;
33553
- exports2.childrenIgnored = childrenIgnored;
33554
- function ownProp(obj, field) {
33555
- return Object.prototype.hasOwnProperty.call(obj, field);
33556
- }
33557
- var fs5 = require("fs");
33558
- var path5 = require("path");
33559
- var minimatch = require_minimatch();
33560
- var isAbsolute = require_path_is_absolute();
33561
- var Minimatch = minimatch.Minimatch;
33562
- function alphasort(a, b) {
33563
- return a.localeCompare(b, "en");
33564
- }
33565
- function setupIgnores(self2, options) {
33566
- self2.ignore = options.ignore || [];
33567
- if (!Array.isArray(self2.ignore))
33568
- self2.ignore = [self2.ignore];
33569
- if (self2.ignore.length) {
33570
- self2.ignore = self2.ignore.map(ignoreMap);
33571
- }
33572
- }
33573
- function ignoreMap(pattern) {
33574
- var gmatcher = null;
33575
- if (pattern.slice(-3) === "/**") {
33576
- var gpattern = pattern.replace(/(\/\*\*)+$/, "");
33577
- gmatcher = new Minimatch(gpattern, { dot: true });
33578
- }
33579
- return {
33580
- matcher: new Minimatch(pattern, { dot: true }),
33581
- gmatcher
33582
- };
33583
- }
33584
- function setopts(self2, pattern, options) {
33585
- if (!options)
33586
- options = {};
33587
- if (options.matchBase && -1 === pattern.indexOf("/")) {
33588
- if (options.noglobstar) {
33589
- throw new Error("base matching requires globstar");
33590
- }
33591
- pattern = "**/" + pattern;
33592
- }
33593
- self2.silent = !!options.silent;
33594
- self2.pattern = pattern;
33595
- self2.strict = options.strict !== false;
33596
- self2.realpath = !!options.realpath;
33597
- self2.realpathCache = options.realpathCache || /* @__PURE__ */ Object.create(null);
33598
- self2.follow = !!options.follow;
33599
- self2.dot = !!options.dot;
33600
- self2.mark = !!options.mark;
33601
- self2.nodir = !!options.nodir;
33602
- if (self2.nodir)
33603
- self2.mark = true;
33604
- self2.sync = !!options.sync;
33605
- self2.nounique = !!options.nounique;
33606
- self2.nonull = !!options.nonull;
33607
- self2.nosort = !!options.nosort;
33608
- self2.nocase = !!options.nocase;
33609
- self2.stat = !!options.stat;
33610
- self2.noprocess = !!options.noprocess;
33611
- self2.absolute = !!options.absolute;
33612
- self2.fs = options.fs || fs5;
33613
- self2.maxLength = options.maxLength || Infinity;
33614
- self2.cache = options.cache || /* @__PURE__ */ Object.create(null);
33615
- self2.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
33616
- self2.symlinks = options.symlinks || /* @__PURE__ */ Object.create(null);
33617
- setupIgnores(self2, options);
33618
- self2.changedCwd = false;
33619
- var cwd = process.cwd();
33620
- if (!ownProp(options, "cwd"))
33621
- self2.cwd = cwd;
33622
- else {
33623
- self2.cwd = path5.resolve(options.cwd);
33624
- self2.changedCwd = self2.cwd !== cwd;
33625
- }
33626
- self2.root = options.root || path5.resolve(self2.cwd, "/");
33627
- self2.root = path5.resolve(self2.root);
33628
- if (process.platform === "win32")
33629
- self2.root = self2.root.replace(/\\/g, "/");
33630
- self2.cwdAbs = isAbsolute(self2.cwd) ? self2.cwd : makeAbs(self2, self2.cwd);
33631
- if (process.platform === "win32")
33632
- self2.cwdAbs = self2.cwdAbs.replace(/\\/g, "/");
33633
- self2.nomount = !!options.nomount;
33634
- options.nonegate = true;
33635
- options.nocomment = true;
33636
- options.allowWindowsEscape = false;
33637
- self2.minimatch = new Minimatch(pattern, options);
33638
- self2.options = self2.minimatch.options;
33639
- }
33640
- function finish(self2) {
33641
- var nou = self2.nounique;
33642
- var all = nou ? [] : /* @__PURE__ */ Object.create(null);
33643
- for (var i = 0, l = self2.matches.length; i < l; i++) {
33644
- var matches = self2.matches[i];
33645
- if (!matches || Object.keys(matches).length === 0) {
33646
- if (self2.nonull) {
33647
- var literal = self2.minimatch.globSet[i];
33648
- if (nou)
33649
- all.push(literal);
33650
- else
33651
- all[literal] = true;
33652
- }
33653
- } else {
33654
- var m = Object.keys(matches);
33655
- if (nou)
33656
- all.push.apply(all, m);
33657
- else
33658
- m.forEach(function(m2) {
33659
- all[m2] = true;
33660
- });
33661
- }
33662
- }
33663
- if (!nou)
33664
- all = Object.keys(all);
33665
- if (!self2.nosort)
33666
- all = all.sort(alphasort);
33667
- if (self2.mark) {
33668
- for (var i = 0; i < all.length; i++) {
33669
- all[i] = self2._mark(all[i]);
33670
- }
33671
- if (self2.nodir) {
33672
- all = all.filter(function(e) {
33673
- var notDir = !/\/$/.test(e);
33674
- var c = self2.cache[e] || self2.cache[makeAbs(self2, e)];
33675
- if (notDir && c)
33676
- notDir = c !== "DIR" && !Array.isArray(c);
33677
- return notDir;
33678
- });
33679
- }
33680
- }
33681
- if (self2.ignore.length)
33682
- all = all.filter(function(m2) {
33683
- return !isIgnored(self2, m2);
33684
- });
33685
- self2.found = all;
33686
- }
33687
- function mark(self2, p) {
33688
- var abs = makeAbs(self2, p);
33689
- var c = self2.cache[abs];
33690
- var m = p;
33691
- if (c) {
33692
- var isDir = c === "DIR" || Array.isArray(c);
33693
- var slash = p.slice(-1) === "/";
33694
- if (isDir && !slash)
33695
- m += "/";
33696
- else if (!isDir && slash)
33697
- m = m.slice(0, -1);
33698
- if (m !== p) {
33699
- var mabs = makeAbs(self2, m);
33700
- self2.statCache[mabs] = self2.statCache[abs];
33701
- self2.cache[mabs] = self2.cache[abs];
33702
- }
33703
- }
33704
- return m;
33705
- }
33706
- function makeAbs(self2, f) {
33707
- var abs = f;
33708
- if (f.charAt(0) === "/") {
33709
- abs = path5.join(self2.root, f);
33710
- } else if (isAbsolute(f) || f === "") {
33711
- abs = f;
33712
- } else if (self2.changedCwd) {
33713
- abs = path5.resolve(self2.cwd, f);
33714
- } else {
33715
- abs = path5.resolve(f);
33716
- }
33717
- if (process.platform === "win32")
33718
- abs = abs.replace(/\\/g, "/");
33719
- return abs;
33720
- }
33721
- function isIgnored(self2, path6) {
33722
- if (!self2.ignore.length)
33723
- return false;
33724
- return self2.ignore.some(function(item) {
33725
- return item.matcher.match(path6) || !!(item.gmatcher && item.gmatcher.match(path6));
33726
- });
33727
- }
33728
- function childrenIgnored(self2, path6) {
33729
- if (!self2.ignore.length)
33730
- return false;
33731
- return self2.ignore.some(function(item) {
33732
- return !!(item.gmatcher && item.gmatcher.match(path6));
33733
- });
33734
- }
33735
- }
33736
- });
33737
-
33738
- // node_modules/.pnpm/glob@7.2.3/node_modules/glob/sync.js
33739
- var require_sync = __commonJS({
33740
- "node_modules/.pnpm/glob@7.2.3/node_modules/glob/sync.js"(exports2, module2) {
33741
- module2.exports = globSync;
33742
- globSync.GlobSync = GlobSync;
33743
- var rp = require_fs2();
33744
- var minimatch = require_minimatch();
33745
- var Minimatch = minimatch.Minimatch;
33746
- var Glob = require_glob().Glob;
33747
- var util = require("util");
33748
- var path5 = require("path");
33749
- var assert = require("assert");
33750
- var isAbsolute = require_path_is_absolute();
33751
- var common = require_common2();
33752
- var setopts = common.setopts;
33753
- var ownProp = common.ownProp;
33754
- var childrenIgnored = common.childrenIgnored;
33755
- var isIgnored = common.isIgnored;
33756
- function globSync(pattern, options) {
33757
- if (typeof options === "function" || arguments.length === 3)
33758
- throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");
33759
- return new GlobSync(pattern, options).found;
33760
- }
33761
- function GlobSync(pattern, options) {
33762
- if (!pattern)
33763
- throw new Error("must provide pattern");
33764
- if (typeof options === "function" || arguments.length === 3)
33765
- throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");
33766
- if (!(this instanceof GlobSync))
33767
- return new GlobSync(pattern, options);
33768
- setopts(this, pattern, options);
33769
- if (this.noprocess)
33770
- return this;
33771
- var n = this.minimatch.set.length;
33772
- this.matches = new Array(n);
33773
- for (var i = 0; i < n; i++) {
33774
- this._process(this.minimatch.set[i], i, false);
33775
- }
33776
- this._finish();
33777
- }
33778
- GlobSync.prototype._finish = function() {
33779
- assert.ok(this instanceof GlobSync);
33780
- if (this.realpath) {
33781
- var self2 = this;
33782
- this.matches.forEach(function(matchset, index) {
33783
- var set = self2.matches[index] = /* @__PURE__ */ Object.create(null);
33784
- for (var p in matchset) {
33785
- try {
33786
- p = self2._makeAbs(p);
33787
- var real = rp.realpathSync(p, self2.realpathCache);
33788
- set[real] = true;
33789
- } catch (er) {
33790
- if (er.syscall === "stat")
33791
- set[self2._makeAbs(p)] = true;
33792
- else
33793
- throw er;
33794
- }
33795
- }
33796
- });
33797
- }
33798
- common.finish(this);
33799
- };
33800
- GlobSync.prototype._process = function(pattern, index, inGlobStar) {
33801
- assert.ok(this instanceof GlobSync);
33802
- var n = 0;
33803
- while (typeof pattern[n] === "string") {
33804
- n++;
33805
- }
33806
- var prefix;
33807
- switch (n) {
33808
- // if not, then this is rather simple
33809
- case pattern.length:
33810
- this._processSimple(pattern.join("/"), index);
33811
- return;
33812
- case 0:
33813
- prefix = null;
33814
- break;
33815
- default:
33816
- prefix = pattern.slice(0, n).join("/");
33817
- break;
33818
- }
33819
- var remain = pattern.slice(n);
33820
- var read;
33821
- if (prefix === null)
33822
- read = ".";
33823
- else if (isAbsolute(prefix) || isAbsolute(pattern.map(function(p) {
33824
- return typeof p === "string" ? p : "[*]";
33825
- }).join("/"))) {
33826
- if (!prefix || !isAbsolute(prefix))
33827
- prefix = "/" + prefix;
33828
- read = prefix;
33829
- } else
33830
- read = prefix;
33831
- var abs = this._makeAbs(read);
33832
- if (childrenIgnored(this, read))
33833
- return;
33834
- var isGlobStar = remain[0] === minimatch.GLOBSTAR;
33835
- if (isGlobStar)
33836
- this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);
33837
- else
33838
- this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
33839
- };
33840
- GlobSync.prototype._processReaddir = function(prefix, read, abs, remain, index, inGlobStar) {
33841
- var entries = this._readdir(abs, inGlobStar);
33842
- if (!entries)
33843
- return;
33844
- var pn = remain[0];
33845
- var negate = !!this.minimatch.negate;
33846
- var rawGlob = pn._glob;
33847
- var dotOk = this.dot || rawGlob.charAt(0) === ".";
33848
- var matchedEntries = [];
33849
- for (var i = 0; i < entries.length; i++) {
33850
- var e = entries[i];
33851
- if (e.charAt(0) !== "." || dotOk) {
33852
- var m;
33853
- if (negate && !prefix) {
33854
- m = !e.match(pn);
33855
- } else {
33856
- m = e.match(pn);
33857
- }
33858
- if (m)
33859
- matchedEntries.push(e);
33860
- }
33861
- }
33862
- var len = matchedEntries.length;
33863
- if (len === 0)
33864
- return;
33865
- if (remain.length === 1 && !this.mark && !this.stat) {
33866
- if (!this.matches[index])
33867
- this.matches[index] = /* @__PURE__ */ Object.create(null);
33868
- for (var i = 0; i < len; i++) {
33869
- var e = matchedEntries[i];
33870
- if (prefix) {
33871
- if (prefix.slice(-1) !== "/")
33872
- e = prefix + "/" + e;
33873
- else
33874
- e = prefix + e;
33875
- }
33876
- if (e.charAt(0) === "/" && !this.nomount) {
33877
- e = path5.join(this.root, e);
33878
- }
33879
- this._emitMatch(index, e);
33880
- }
33881
- return;
33882
- }
33883
- remain.shift();
33884
- for (var i = 0; i < len; i++) {
33885
- var e = matchedEntries[i];
33886
- var newPattern;
33887
- if (prefix)
33888
- newPattern = [prefix, e];
33889
- else
33890
- newPattern = [e];
33891
- this._process(newPattern.concat(remain), index, inGlobStar);
33892
- }
33893
- };
33894
- GlobSync.prototype._emitMatch = function(index, e) {
33895
- if (isIgnored(this, e))
33896
- return;
33897
- var abs = this._makeAbs(e);
33898
- if (this.mark)
33899
- e = this._mark(e);
33900
- if (this.absolute) {
33901
- e = abs;
33902
- }
33903
- if (this.matches[index][e])
33904
- return;
33905
- if (this.nodir) {
33906
- var c = this.cache[abs];
33907
- if (c === "DIR" || Array.isArray(c))
33908
- return;
33909
- }
33910
- this.matches[index][e] = true;
33911
- if (this.stat)
33912
- this._stat(e);
33913
- };
33914
- GlobSync.prototype._readdirInGlobStar = function(abs) {
33915
- if (this.follow)
33916
- return this._readdir(abs, false);
33917
- var entries;
33918
- var lstat;
33919
- var stat2;
33920
- try {
33921
- lstat = this.fs.lstatSync(abs);
33922
- } catch (er) {
33923
- if (er.code === "ENOENT") {
33924
- return null;
33925
- }
33926
- }
33927
- var isSym = lstat && lstat.isSymbolicLink();
33928
- this.symlinks[abs] = isSym;
33929
- if (!isSym && lstat && !lstat.isDirectory())
33930
- this.cache[abs] = "FILE";
33931
- else
33932
- entries = this._readdir(abs, false);
33933
- return entries;
33934
- };
33935
- GlobSync.prototype._readdir = function(abs, inGlobStar) {
33936
- var entries;
33937
- if (inGlobStar && !ownProp(this.symlinks, abs))
33938
- return this._readdirInGlobStar(abs);
33939
- if (ownProp(this.cache, abs)) {
33940
- var c = this.cache[abs];
33941
- if (!c || c === "FILE")
33942
- return null;
33943
- if (Array.isArray(c))
33944
- return c;
33945
- }
33946
- try {
33947
- return this._readdirEntries(abs, this.fs.readdirSync(abs));
33948
- } catch (er) {
33949
- this._readdirError(abs, er);
33950
- return null;
33951
- }
33952
- };
33953
- GlobSync.prototype._readdirEntries = function(abs, entries) {
33954
- if (!this.mark && !this.stat) {
33955
- for (var i = 0; i < entries.length; i++) {
33956
- var e = entries[i];
33957
- if (abs === "/")
33958
- e = abs + e;
33959
- else
33960
- e = abs + "/" + e;
33961
- this.cache[e] = true;
33962
- }
33963
- }
33964
- this.cache[abs] = entries;
33965
- return entries;
33966
- };
33967
- GlobSync.prototype._readdirError = function(f, er) {
33968
- switch (er.code) {
33969
- case "ENOTSUP":
33970
- // https://github.com/isaacs/node-glob/issues/205
33971
- case "ENOTDIR":
33972
- var abs = this._makeAbs(f);
33973
- this.cache[abs] = "FILE";
33974
- if (abs === this.cwdAbs) {
33975
- var error8 = new Error(er.code + " invalid cwd " + this.cwd);
33976
- error8.path = this.cwd;
33977
- error8.code = er.code;
33978
- throw error8;
33979
- }
33980
- break;
33981
- case "ENOENT":
33982
- // not terribly unusual
33983
- case "ELOOP":
33984
- case "ENAMETOOLONG":
33985
- case "UNKNOWN":
33986
- this.cache[this._makeAbs(f)] = false;
33987
- break;
33988
- default:
33989
- this.cache[this._makeAbs(f)] = false;
33990
- if (this.strict)
33991
- throw er;
33992
- if (!this.silent)
33993
- console.error("glob error", er);
33994
- break;
33995
- }
33996
- };
33997
- GlobSync.prototype._processGlobStar = function(prefix, read, abs, remain, index, inGlobStar) {
33998
- var entries = this._readdir(abs, inGlobStar);
33999
- if (!entries)
34000
- return;
34001
- var remainWithoutGlobStar = remain.slice(1);
34002
- var gspref = prefix ? [prefix] : [];
34003
- var noGlobStar = gspref.concat(remainWithoutGlobStar);
34004
- this._process(noGlobStar, index, false);
34005
- var len = entries.length;
34006
- var isSym = this.symlinks[abs];
34007
- if (isSym && inGlobStar)
34008
- return;
34009
- for (var i = 0; i < len; i++) {
34010
- var e = entries[i];
34011
- if (e.charAt(0) === "." && !this.dot)
34012
- continue;
34013
- var instead = gspref.concat(entries[i], remainWithoutGlobStar);
34014
- this._process(instead, index, true);
34015
- var below = gspref.concat(entries[i], remain);
34016
- this._process(below, index, true);
34017
- }
34018
- };
34019
- GlobSync.prototype._processSimple = function(prefix, index) {
34020
- var exists = this._stat(prefix);
34021
- if (!this.matches[index])
34022
- this.matches[index] = /* @__PURE__ */ Object.create(null);
34023
- if (!exists)
34024
- return;
34025
- if (prefix && isAbsolute(prefix) && !this.nomount) {
34026
- var trail = /[\/\\]$/.test(prefix);
34027
- if (prefix.charAt(0) === "/") {
34028
- prefix = path5.join(this.root, prefix);
34029
- } else {
34030
- prefix = path5.resolve(this.root, prefix);
34031
- if (trail)
34032
- prefix += "/";
34033
- }
34034
- }
34035
- if (process.platform === "win32")
34036
- prefix = prefix.replace(/\\/g, "/");
34037
- this._emitMatch(index, prefix);
34038
- };
34039
- GlobSync.prototype._stat = function(f) {
34040
- var abs = this._makeAbs(f);
34041
- var needDir = f.slice(-1) === "/";
34042
- if (f.length > this.maxLength)
34043
- return false;
34044
- if (!this.stat && ownProp(this.cache, abs)) {
34045
- var c = this.cache[abs];
34046
- if (Array.isArray(c))
34047
- c = "DIR";
34048
- if (!needDir || c === "DIR")
34049
- return c;
34050
- if (needDir && c === "FILE")
34051
- return false;
34052
- }
34053
- var exists;
34054
- var stat2 = this.statCache[abs];
34055
- if (!stat2) {
34056
- var lstat;
34057
- try {
34058
- lstat = this.fs.lstatSync(abs);
34059
- } catch (er) {
34060
- if (er && (er.code === "ENOENT" || er.code === "ENOTDIR")) {
34061
- this.statCache[abs] = false;
34062
- return false;
34063
- }
34064
- }
34065
- if (lstat && lstat.isSymbolicLink()) {
34066
- try {
34067
- stat2 = this.fs.statSync(abs);
34068
- } catch (er) {
34069
- stat2 = lstat;
34070
- }
34071
- } else {
34072
- stat2 = lstat;
34073
- }
34074
- }
34075
- this.statCache[abs] = stat2;
34076
- var c = true;
34077
- if (stat2)
34078
- c = stat2.isDirectory() ? "DIR" : "FILE";
34079
- this.cache[abs] = this.cache[abs] || c;
34080
- if (needDir && c === "FILE")
34081
- return false;
34082
- return c;
34083
- };
34084
- GlobSync.prototype._mark = function(p) {
34085
- return common.mark(this, p);
34086
- };
34087
- GlobSync.prototype._makeAbs = function(f) {
34088
- return common.makeAbs(this, f);
34089
- };
34090
- }
34091
- });
34092
-
34093
- // node_modules/.pnpm/inflight@1.0.6/node_modules/inflight/inflight.js
34094
- var require_inflight = __commonJS({
34095
- "node_modules/.pnpm/inflight@1.0.6/node_modules/inflight/inflight.js"(exports2, module2) {
34096
- var wrappy = require_wrappy();
34097
- var reqs = /* @__PURE__ */ Object.create(null);
34098
- var once = require_once();
34099
- module2.exports = wrappy(inflight);
34100
- function inflight(key, cb) {
34101
- if (reqs[key]) {
34102
- reqs[key].push(cb);
34103
- return null;
34104
- } else {
34105
- reqs[key] = [cb];
34106
- return makeres(key);
34107
- }
34108
- }
34109
- function makeres(key) {
34110
- return once(function RES() {
34111
- var cbs = reqs[key];
34112
- var len = cbs.length;
34113
- var args = slice(arguments);
34114
- try {
34115
- for (var i = 0; i < len; i++) {
34116
- cbs[i].apply(null, args);
34117
- }
34118
- } finally {
34119
- if (cbs.length > len) {
34120
- cbs.splice(0, len);
34121
- process.nextTick(function() {
34122
- RES.apply(null, args);
34123
- });
34124
- } else {
34125
- delete reqs[key];
34126
- }
34127
- }
34128
- });
34129
- }
34130
- function slice(args) {
34131
- var length = args.length;
34132
- var array = [];
34133
- for (var i = 0; i < length; i++) array[i] = args[i];
34134
- return array;
34135
- }
34136
- }
34137
- });
34138
-
34139
- // node_modules/.pnpm/glob@7.2.3/node_modules/glob/glob.js
34140
- var require_glob = __commonJS({
34141
- "node_modules/.pnpm/glob@7.2.3/node_modules/glob/glob.js"(exports2, module2) {
34142
- module2.exports = glob2;
34143
- var rp = require_fs2();
34144
- var minimatch = require_minimatch();
34145
- var Minimatch = minimatch.Minimatch;
34146
- var inherits = require_inherits();
34147
- var EE = require("events").EventEmitter;
34148
- var path5 = require("path");
34149
- var assert = require("assert");
34150
- var isAbsolute = require_path_is_absolute();
34151
- var globSync = require_sync();
34152
- var common = require_common2();
34153
- var setopts = common.setopts;
34154
- var ownProp = common.ownProp;
34155
- var inflight = require_inflight();
34156
- var util = require("util");
34157
- var childrenIgnored = common.childrenIgnored;
34158
- var isIgnored = common.isIgnored;
34159
- var once = require_once();
34160
- function glob2(pattern, options, cb) {
34161
- if (typeof options === "function") cb = options, options = {};
34162
- if (!options) options = {};
34163
- if (options.sync) {
34164
- if (cb)
34165
- throw new TypeError("callback provided to sync glob");
34166
- return globSync(pattern, options);
34167
- }
34168
- return new Glob(pattern, options, cb);
34169
- }
34170
- glob2.sync = globSync;
34171
- var GlobSync = glob2.GlobSync = globSync.GlobSync;
34172
- glob2.glob = glob2;
34173
- function extend2(origin, add) {
34174
- if (add === null || typeof add !== "object") {
34175
- return origin;
34176
- }
34177
- var keys = Object.keys(add);
34178
- var i = keys.length;
34179
- while (i--) {
34180
- origin[keys[i]] = add[keys[i]];
34181
- }
34182
- return origin;
34183
- }
34184
- glob2.hasMagic = function(pattern, options_) {
34185
- var options = extend2({}, options_);
34186
- options.noprocess = true;
34187
- var g = new Glob(pattern, options);
34188
- var set = g.minimatch.set;
34189
- if (!pattern)
34190
- return false;
34191
- if (set.length > 1)
34192
- return true;
34193
- for (var j = 0; j < set[0].length; j++) {
34194
- if (typeof set[0][j] !== "string")
34195
- return true;
34196
- }
34197
- return false;
34198
- };
34199
- glob2.Glob = Glob;
34200
- inherits(Glob, EE);
34201
- function Glob(pattern, options, cb) {
34202
- if (typeof options === "function") {
34203
- cb = options;
34204
- options = null;
34205
- }
34206
- if (options && options.sync) {
34207
- if (cb)
34208
- throw new TypeError("callback provided to sync glob");
34209
- return new GlobSync(pattern, options);
34210
- }
34211
- if (!(this instanceof Glob))
34212
- return new Glob(pattern, options, cb);
34213
- setopts(this, pattern, options);
34214
- this._didRealPath = false;
34215
- var n = this.minimatch.set.length;
34216
- this.matches = new Array(n);
34217
- if (typeof cb === "function") {
34218
- cb = once(cb);
34219
- this.on("error", cb);
34220
- this.on("end", function(matches) {
34221
- cb(null, matches);
34222
- });
34223
- }
34224
- var self2 = this;
34225
- this._processing = 0;
34226
- this._emitQueue = [];
34227
- this._processQueue = [];
34228
- this.paused = false;
34229
- if (this.noprocess)
34230
- return this;
34231
- if (n === 0)
34232
- return done();
34233
- var sync = true;
34234
- for (var i = 0; i < n; i++) {
34235
- this._process(this.minimatch.set[i], i, false, done);
34236
- }
34237
- sync = false;
34238
- function done() {
34239
- --self2._processing;
34240
- if (self2._processing <= 0) {
34241
- if (sync) {
34242
- process.nextTick(function() {
34243
- self2._finish();
34244
- });
34245
- } else {
34246
- self2._finish();
34247
- }
34248
- }
34249
- }
34250
- }
34251
- Glob.prototype._finish = function() {
34252
- assert(this instanceof Glob);
34253
- if (this.aborted)
34254
- return;
34255
- if (this.realpath && !this._didRealpath)
34256
- return this._realpath();
34257
- common.finish(this);
34258
- this.emit("end", this.found);
34259
- };
34260
- Glob.prototype._realpath = function() {
34261
- if (this._didRealpath)
34262
- return;
34263
- this._didRealpath = true;
34264
- var n = this.matches.length;
34265
- if (n === 0)
34266
- return this._finish();
34267
- var self2 = this;
34268
- for (var i = 0; i < this.matches.length; i++)
34269
- this._realpathSet(i, next);
34270
- function next() {
34271
- if (--n === 0)
34272
- self2._finish();
34273
- }
34274
- };
34275
- Glob.prototype._realpathSet = function(index, cb) {
34276
- var matchset = this.matches[index];
34277
- if (!matchset)
34278
- return cb();
34279
- var found = Object.keys(matchset);
34280
- var self2 = this;
34281
- var n = found.length;
34282
- if (n === 0)
34283
- return cb();
34284
- var set = this.matches[index] = /* @__PURE__ */ Object.create(null);
34285
- found.forEach(function(p, i) {
34286
- p = self2._makeAbs(p);
34287
- rp.realpath(p, self2.realpathCache, function(er, real) {
34288
- if (!er)
34289
- set[real] = true;
34290
- else if (er.syscall === "stat")
34291
- set[p] = true;
34292
- else
34293
- self2.emit("error", er);
34294
- if (--n === 0) {
34295
- self2.matches[index] = set;
34296
- cb();
34297
- }
34298
- });
34299
- });
34300
- };
34301
- Glob.prototype._mark = function(p) {
34302
- return common.mark(this, p);
34303
- };
34304
- Glob.prototype._makeAbs = function(f) {
34305
- return common.makeAbs(this, f);
34306
- };
34307
- Glob.prototype.abort = function() {
34308
- this.aborted = true;
34309
- this.emit("abort");
34310
- };
34311
- Glob.prototype.pause = function() {
34312
- if (!this.paused) {
34313
- this.paused = true;
34314
- this.emit("pause");
34315
- }
34316
- };
34317
- Glob.prototype.resume = function() {
34318
- if (this.paused) {
34319
- this.emit("resume");
34320
- this.paused = false;
34321
- if (this._emitQueue.length) {
34322
- var eq = this._emitQueue.slice(0);
34323
- this._emitQueue.length = 0;
34324
- for (var i = 0; i < eq.length; i++) {
34325
- var e = eq[i];
34326
- this._emitMatch(e[0], e[1]);
34327
- }
34328
- }
34329
- if (this._processQueue.length) {
34330
- var pq = this._processQueue.slice(0);
34331
- this._processQueue.length = 0;
34332
- for (var i = 0; i < pq.length; i++) {
34333
- var p = pq[i];
34334
- this._processing--;
34335
- this._process(p[0], p[1], p[2], p[3]);
34336
- }
34337
- }
34338
- }
34339
- };
34340
- Glob.prototype._process = function(pattern, index, inGlobStar, cb) {
34341
- assert(this instanceof Glob);
34342
- assert(typeof cb === "function");
34343
- if (this.aborted)
34344
- return;
34345
- this._processing++;
34346
- if (this.paused) {
34347
- this._processQueue.push([pattern, index, inGlobStar, cb]);
34348
- return;
34349
- }
34350
- var n = 0;
34351
- while (typeof pattern[n] === "string") {
34352
- n++;
34353
- }
34354
- var prefix;
34355
- switch (n) {
34356
- // if not, then this is rather simple
34357
- case pattern.length:
34358
- this._processSimple(pattern.join("/"), index, cb);
34359
- return;
34360
- case 0:
34361
- prefix = null;
34362
- break;
34363
- default:
34364
- prefix = pattern.slice(0, n).join("/");
34365
- break;
34366
- }
34367
- var remain = pattern.slice(n);
34368
- var read;
34369
- if (prefix === null)
34370
- read = ".";
34371
- else if (isAbsolute(prefix) || isAbsolute(pattern.map(function(p) {
34372
- return typeof p === "string" ? p : "[*]";
34373
- }).join("/"))) {
34374
- if (!prefix || !isAbsolute(prefix))
34375
- prefix = "/" + prefix;
34376
- read = prefix;
34377
- } else
34378
- read = prefix;
34379
- var abs = this._makeAbs(read);
34380
- if (childrenIgnored(this, read))
34381
- return cb();
34382
- var isGlobStar = remain[0] === minimatch.GLOBSTAR;
34383
- if (isGlobStar)
34384
- this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);
34385
- else
34386
- this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
34387
- };
34388
- Glob.prototype._processReaddir = function(prefix, read, abs, remain, index, inGlobStar, cb) {
34389
- var self2 = this;
34390
- this._readdir(abs, inGlobStar, function(er, entries) {
34391
- return self2._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
34392
- });
34393
- };
34394
- Glob.prototype._processReaddir2 = function(prefix, read, abs, remain, index, inGlobStar, entries, cb) {
34395
- if (!entries)
34396
- return cb();
34397
- var pn = remain[0];
34398
- var negate = !!this.minimatch.negate;
34399
- var rawGlob = pn._glob;
34400
- var dotOk = this.dot || rawGlob.charAt(0) === ".";
34401
- var matchedEntries = [];
34402
- for (var i = 0; i < entries.length; i++) {
34403
- var e = entries[i];
34404
- if (e.charAt(0) !== "." || dotOk) {
34405
- var m;
34406
- if (negate && !prefix) {
34407
- m = !e.match(pn);
34408
- } else {
34409
- m = e.match(pn);
34410
- }
34411
- if (m)
34412
- matchedEntries.push(e);
34413
- }
34414
- }
34415
- var len = matchedEntries.length;
34416
- if (len === 0)
34417
- return cb();
34418
- if (remain.length === 1 && !this.mark && !this.stat) {
34419
- if (!this.matches[index])
34420
- this.matches[index] = /* @__PURE__ */ Object.create(null);
34421
- for (var i = 0; i < len; i++) {
34422
- var e = matchedEntries[i];
34423
- if (prefix) {
34424
- if (prefix !== "/")
34425
- e = prefix + "/" + e;
34426
- else
34427
- e = prefix + e;
34428
- }
34429
- if (e.charAt(0) === "/" && !this.nomount) {
34430
- e = path5.join(this.root, e);
34431
- }
34432
- this._emitMatch(index, e);
34433
- }
34434
- return cb();
34435
- }
34436
- remain.shift();
34437
- for (var i = 0; i < len; i++) {
34438
- var e = matchedEntries[i];
34439
- var newPattern;
34440
- if (prefix) {
34441
- if (prefix !== "/")
34442
- e = prefix + "/" + e;
34443
- else
34444
- e = prefix + e;
34445
- }
34446
- this._process([e].concat(remain), index, inGlobStar, cb);
34447
- }
34448
- cb();
34449
- };
34450
- Glob.prototype._emitMatch = function(index, e) {
34451
- if (this.aborted)
34452
- return;
34453
- if (isIgnored(this, e))
34454
- return;
34455
- if (this.paused) {
34456
- this._emitQueue.push([index, e]);
34457
- return;
34458
- }
34459
- var abs = isAbsolute(e) ? e : this._makeAbs(e);
34460
- if (this.mark)
34461
- e = this._mark(e);
34462
- if (this.absolute)
34463
- e = abs;
34464
- if (this.matches[index][e])
34465
- return;
34466
- if (this.nodir) {
34467
- var c = this.cache[abs];
34468
- if (c === "DIR" || Array.isArray(c))
34469
- return;
34470
- }
34471
- this.matches[index][e] = true;
34472
- var st = this.statCache[abs];
34473
- if (st)
34474
- this.emit("stat", e, st);
34475
- this.emit("match", e);
34476
- };
34477
- Glob.prototype._readdirInGlobStar = function(abs, cb) {
34478
- if (this.aborted)
34479
- return;
34480
- if (this.follow)
34481
- return this._readdir(abs, false, cb);
34482
- var lstatkey = "lstat\0" + abs;
34483
- var self2 = this;
34484
- var lstatcb = inflight(lstatkey, lstatcb_);
34485
- if (lstatcb)
34486
- self2.fs.lstat(abs, lstatcb);
34487
- function lstatcb_(er, lstat) {
34488
- if (er && er.code === "ENOENT")
34489
- return cb();
34490
- var isSym = lstat && lstat.isSymbolicLink();
34491
- self2.symlinks[abs] = isSym;
34492
- if (!isSym && lstat && !lstat.isDirectory()) {
34493
- self2.cache[abs] = "FILE";
34494
- cb();
34495
- } else
34496
- self2._readdir(abs, false, cb);
34497
- }
34498
- };
34499
- Glob.prototype._readdir = function(abs, inGlobStar, cb) {
34500
- if (this.aborted)
34501
- return;
34502
- cb = inflight("readdir\0" + abs + "\0" + inGlobStar, cb);
34503
- if (!cb)
34504
- return;
34505
- if (inGlobStar && !ownProp(this.symlinks, abs))
34506
- return this._readdirInGlobStar(abs, cb);
34507
- if (ownProp(this.cache, abs)) {
34508
- var c = this.cache[abs];
34509
- if (!c || c === "FILE")
34510
- return cb();
34511
- if (Array.isArray(c))
34512
- return cb(null, c);
34513
- }
34514
- var self2 = this;
34515
- self2.fs.readdir(abs, readdirCb(this, abs, cb));
34516
- };
34517
- function readdirCb(self2, abs, cb) {
34518
- return function(er, entries) {
34519
- if (er)
34520
- self2._readdirError(abs, er, cb);
34521
- else
34522
- self2._readdirEntries(abs, entries, cb);
34523
- };
34524
- }
34525
- Glob.prototype._readdirEntries = function(abs, entries, cb) {
34526
- if (this.aborted)
34527
- return;
34528
- if (!this.mark && !this.stat) {
34529
- for (var i = 0; i < entries.length; i++) {
34530
- var e = entries[i];
34531
- if (abs === "/")
34532
- e = abs + e;
34533
- else
34534
- e = abs + "/" + e;
34535
- this.cache[e] = true;
34536
- }
34537
- }
34538
- this.cache[abs] = entries;
34539
- return cb(null, entries);
34540
- };
34541
- Glob.prototype._readdirError = function(f, er, cb) {
34542
- if (this.aborted)
34543
- return;
34544
- switch (er.code) {
34545
- case "ENOTSUP":
34546
- // https://github.com/isaacs/node-glob/issues/205
34547
- case "ENOTDIR":
34548
- var abs = this._makeAbs(f);
34549
- this.cache[abs] = "FILE";
34550
- if (abs === this.cwdAbs) {
34551
- var error8 = new Error(er.code + " invalid cwd " + this.cwd);
34552
- error8.path = this.cwd;
34553
- error8.code = er.code;
34554
- this.emit("error", error8);
34555
- this.abort();
34556
- }
34557
- break;
34558
- case "ENOENT":
34559
- // not terribly unusual
34560
- case "ELOOP":
34561
- case "ENAMETOOLONG":
34562
- case "UNKNOWN":
34563
- this.cache[this._makeAbs(f)] = false;
34564
- break;
34565
- default:
34566
- this.cache[this._makeAbs(f)] = false;
34567
- if (this.strict) {
34568
- this.emit("error", er);
34569
- this.abort();
34570
- }
34571
- if (!this.silent)
34572
- console.error("glob error", er);
34573
- break;
34574
- }
34575
- return cb();
34576
- };
34577
- Glob.prototype._processGlobStar = function(prefix, read, abs, remain, index, inGlobStar, cb) {
34578
- var self2 = this;
34579
- this._readdir(abs, inGlobStar, function(er, entries) {
34580
- self2._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
34581
- });
34582
- };
34583
- Glob.prototype._processGlobStar2 = function(prefix, read, abs, remain, index, inGlobStar, entries, cb) {
34584
- if (!entries)
34585
- return cb();
34586
- var remainWithoutGlobStar = remain.slice(1);
34587
- var gspref = prefix ? [prefix] : [];
34588
- var noGlobStar = gspref.concat(remainWithoutGlobStar);
34589
- this._process(noGlobStar, index, false, cb);
34590
- var isSym = this.symlinks[abs];
34591
- var len = entries.length;
34592
- if (isSym && inGlobStar)
34593
- return cb();
34594
- for (var i = 0; i < len; i++) {
34595
- var e = entries[i];
34596
- if (e.charAt(0) === "." && !this.dot)
34597
- continue;
34598
- var instead = gspref.concat(entries[i], remainWithoutGlobStar);
34599
- this._process(instead, index, true, cb);
34600
- var below = gspref.concat(entries[i], remain);
34601
- this._process(below, index, true, cb);
34602
- }
34603
- cb();
34604
- };
34605
- Glob.prototype._processSimple = function(prefix, index, cb) {
34606
- var self2 = this;
34607
- this._stat(prefix, function(er, exists) {
34608
- self2._processSimple2(prefix, index, er, exists, cb);
34609
- });
34610
- };
34611
- Glob.prototype._processSimple2 = function(prefix, index, er, exists, cb) {
34612
- if (!this.matches[index])
34613
- this.matches[index] = /* @__PURE__ */ Object.create(null);
34614
- if (!exists)
34615
- return cb();
34616
- if (prefix && isAbsolute(prefix) && !this.nomount) {
34617
- var trail = /[\/\\]$/.test(prefix);
34618
- if (prefix.charAt(0) === "/") {
34619
- prefix = path5.join(this.root, prefix);
34620
- } else {
34621
- prefix = path5.resolve(this.root, prefix);
34622
- if (trail)
34623
- prefix += "/";
34624
- }
34625
- }
34626
- if (process.platform === "win32")
34627
- prefix = prefix.replace(/\\/g, "/");
34628
- this._emitMatch(index, prefix);
34629
- cb();
34630
- };
34631
- Glob.prototype._stat = function(f, cb) {
34632
- var abs = this._makeAbs(f);
34633
- var needDir = f.slice(-1) === "/";
34634
- if (f.length > this.maxLength)
34635
- return cb();
34636
- if (!this.stat && ownProp(this.cache, abs)) {
34637
- var c = this.cache[abs];
34638
- if (Array.isArray(c))
34639
- c = "DIR";
34640
- if (!needDir || c === "DIR")
34641
- return cb(null, c);
34642
- if (needDir && c === "FILE")
34643
- return cb();
34644
- }
34645
- var exists;
34646
- var stat2 = this.statCache[abs];
34647
- if (stat2 !== void 0) {
34648
- if (stat2 === false)
34649
- return cb(null, stat2);
34650
- else {
34651
- var type = stat2.isDirectory() ? "DIR" : "FILE";
34652
- if (needDir && type === "FILE")
34653
- return cb();
34654
- else
34655
- return cb(null, type, stat2);
34656
- }
34657
- }
34658
- var self2 = this;
34659
- var statcb = inflight("stat\0" + abs, lstatcb_);
34660
- if (statcb)
34661
- self2.fs.lstat(abs, statcb);
34662
- function lstatcb_(er, lstat) {
34663
- if (lstat && lstat.isSymbolicLink()) {
34664
- return self2.fs.stat(abs, function(er2, stat3) {
34665
- if (er2)
34666
- self2._stat2(f, abs, null, lstat, cb);
34667
- else
34668
- self2._stat2(f, abs, er2, stat3, cb);
34669
- });
34670
- } else {
34671
- self2._stat2(f, abs, er, lstat, cb);
34672
- }
34673
- }
34674
- };
34675
- Glob.prototype._stat2 = function(f, abs, er, stat2, cb) {
34676
- if (er && (er.code === "ENOENT" || er.code === "ENOTDIR")) {
34677
- this.statCache[abs] = false;
34678
- return cb();
34679
- }
34680
- var needDir = f.slice(-1) === "/";
34681
- this.statCache[abs] = stat2;
34682
- if (abs.slice(-1) === "/" && stat2 && !stat2.isDirectory())
34683
- return cb(null, false, stat2);
34684
- var c = true;
34685
- if (stat2)
34686
- c = stat2.isDirectory() ? "DIR" : "FILE";
34687
- this.cache[abs] = this.cache[abs] || c;
34688
- if (needDir && c === "FILE")
34689
- return cb();
34690
- return cb(null, c, stat2);
34691
- };
34692
- }
34693
- });
34694
-
34695
- // node_modules/.pnpm/glob-promise@6.0.7_glob@7.2.3/node_modules/glob-promise/lib/index.js
34696
- var require_lib3 = __commonJS({
34697
- "node_modules/.pnpm/glob-promise@6.0.7_glob@7.2.3/node_modules/glob-promise/lib/index.js"(exports2, module2) {
34698
- var glob2 = require_glob();
34699
- var promise = function(pattern, options) {
34700
- return new Promise((resolve2, reject) => {
34701
- glob2(pattern, options, (err, files) => err === null ? resolve2(files) : reject(err));
34702
- });
34703
- };
34704
- module2.exports = promise;
34705
- module2.exports.glob = glob2;
34706
- module2.exports.Glob = glob2.Glob;
34707
- module2.exports.hasMagic = glob2.hasMagic;
34708
- module2.exports.promise = promise;
34709
- module2.exports.sync = glob2.sync;
34710
- }
34711
- });
34712
-
34713
32632
  // node_modules/.pnpm/papaparse@5.5.3/node_modules/papaparse/papaparse.js
34714
32633
  var require_papaparse = __commonJS({
34715
32634
  "node_modules/.pnpm/papaparse@5.5.3/node_modules/papaparse/papaparse.js"(exports2, module2) {
@@ -37923,7 +35842,7 @@ var init_getCoveredStates = __esm({
37923
35842
  });
37924
35843
 
37925
35844
  // apps/server/service/config.ts
37926
- var PAGE_SIZE, MAX_PAGE_SIZE, MAX_PAGE_NUMBER, ES_INDEX_NAME, ES_CLEAR_INDEX, INDEX_BACKOFF_INITIAL, INDEX_BACKOFF_INCREMENT, INDEX_BACKOFF_MAX, INDEX_MAX_RETRIES, INDEX_TIMEOUT, LOADING_CHUNK_SIZE, ENABLE_GEO, GNAF_PACKAGE_URL, GNAF_DIR, ONE_DAY_S, ONE_DAY_MS, THIRTY_DAYS_MS, SERVER_PORT, CORS_ALLOW_ORIGIN, CORS_EXPOSE_HEADERS, CORS_ALLOW_HEADERS, CACHE_MAX_ENTRIES, CACHE_TTL_MS, CACHE_ENABLED, CIRCUIT_FAILURE_THRESHOLD, CIRCUIT_RESET_TIMEOUT_MS, CIRCUIT_SUCCESS_THRESHOLD, DYNAMIC_RESOURCES_ENABLED, TARGET_MEMORY_UTILIZATION, VERBOSE;
35845
+ var PAGE_SIZE, MAX_PAGE_SIZE, MAX_PAGE_NUMBER, ES_INDEX_NAME, ES_LOCALITY_INDEX_NAME, ES_CLEAR_INDEX, INDEX_BACKOFF_INITIAL, INDEX_BACKOFF_INCREMENT, INDEX_BACKOFF_MAX, INDEX_MAX_RETRIES, INDEX_TIMEOUT, LOADING_CHUNK_SIZE, ENABLE_GEO, GNAF_PACKAGE_URL, GNAF_DIR, ONE_DAY_S, ONE_DAY_MS, THIRTY_DAYS_MS, SERVER_PORT, CORS_ALLOW_ORIGIN, CORS_EXPOSE_HEADERS, CORS_ALLOW_HEADERS, CACHE_MAX_ENTRIES, CACHE_TTL_MS, CACHE_ENABLED, CIRCUIT_FAILURE_THRESHOLD, CIRCUIT_RESET_TIMEOUT_MS, CIRCUIT_SUCCESS_THRESHOLD, DYNAMIC_RESOURCES_ENABLED, TARGET_MEMORY_UTILIZATION, VERBOSE;
37927
35846
  var init_config = __esm({
37928
35847
  "apps/server/service/config.ts"() {
37929
35848
  "use strict";
@@ -37931,6 +35850,7 @@ var init_config = __esm({
37931
35850
  MAX_PAGE_SIZE = Number.parseInt(process.env.MAX_PAGE_SIZE ?? "100", 10) || 100;
37932
35851
  MAX_PAGE_NUMBER = Number.parseInt(process.env.MAX_PAGE_NUMBER ?? "1000", 10) || 1e3;
37933
35852
  ES_INDEX_NAME = process.env.ES_INDEX_NAME ?? "addresskit";
35853
+ ES_LOCALITY_INDEX_NAME = process.env.ES_LOCALITY_INDEX_NAME ?? "addresskit-localities";
37934
35854
  ES_CLEAR_INDEX = process.env.ES_CLEAR_INDEX === "true";
37935
35855
  INDEX_BACKOFF_INITIAL = Number.parseInt(
37936
35856
  process.env.ADDRESSKIT_INDEX_BACKOFF ?? "30000",
@@ -39535,7 +37455,7 @@ var init_circuitBreaker = __esm({
39535
37455
  });
39536
37456
 
39537
37457
  // apps/server/service/helpers/jsonapi.ts
39538
- var JSONAPI_IMPLEMENTATION, RESOURCE_TYPES, extractAddressId, buildAutocompleteResource, buildAddressResource, buildPaginationLinks, buildPaginationMeta, buildAutocompleteDocument, buildAddressDetailDocument, buildError, buildErrorDocument, ErrorDocuments;
37458
+ var JSONAPI_IMPLEMENTATION, RESOURCE_TYPES, extractAddressId, extractLocalityId, buildAutocompleteResource, buildAddressResource, buildLocalityAutocompleteResource, buildLocalityResource, buildPaginationLinks, API_WARNINGS, buildPaginationMeta, buildAutocompleteDocument, buildAddressDetailDocument, buildLocalityAutocompleteDocument, buildLocalityDetailDocument, buildError, buildErrorDocument, ErrorDocuments;
39539
37459
  var init_jsonapi = __esm({
39540
37460
  "apps/server/service/helpers/jsonapi.ts"() {
39541
37461
  "use strict";
@@ -39546,11 +37466,18 @@ var init_jsonapi = __esm({
39546
37466
  /** Resource type for address entities */
39547
37467
  ADDRESS: "address",
39548
37468
  /** Resource type for autocomplete suggestions */
39549
- ADDRESS_SUGGESTION: "address-suggestion"
37469
+ ADDRESS_SUGGESTION: "address-suggestion",
37470
+ /** Resource type for locality entities */
37471
+ LOCALITY: "locality",
37472
+ /** Resource type for locality autocomplete suggestions */
37473
+ LOCALITY_SUGGESTION: "locality-suggestion"
39550
37474
  };
39551
37475
  extractAddressId = (path5) => {
39552
37476
  return path5.replace(/^\/addresses\//, "");
39553
37477
  };
37478
+ extractLocalityId = (path5) => {
37479
+ return path5.replace(/^\/localities\//, "");
37480
+ };
39554
37481
  buildAutocompleteResource = (id, sla, rank, ssla) => {
39555
37482
  const attributes = {
39556
37483
  sla,
@@ -39576,6 +37503,30 @@ var init_jsonapi = __esm({
39576
37503
  }
39577
37504
  };
39578
37505
  };
37506
+ buildLocalityAutocompleteResource = (id, display, rank) => {
37507
+ const attributes = {
37508
+ display,
37509
+ rank
37510
+ };
37511
+ return {
37512
+ type: RESOURCE_TYPES.LOCALITY_SUGGESTION,
37513
+ id,
37514
+ attributes,
37515
+ links: {
37516
+ self: `/localities/${id}`
37517
+ }
37518
+ };
37519
+ };
37520
+ buildLocalityResource = (id, attributes) => {
37521
+ return {
37522
+ type: RESOURCE_TYPES.LOCALITY,
37523
+ id,
37524
+ attributes,
37525
+ links: {
37526
+ self: `/localities/${id}`
37527
+ }
37528
+ };
37529
+ };
39579
37530
  buildPaginationLinks = (baseUrl, query, currentPage, totalPages, pageSize2) => {
39580
37531
  const buildQueryString = (page) => {
39581
37532
  const params = new URLSearchParams();
@@ -39610,14 +37561,25 @@ var init_jsonapi = __esm({
39610
37561
  }
39611
37562
  return links;
39612
37563
  };
39613
- buildPaginationMeta = (total, page, pageSize2, responseTime) => {
37564
+ API_WARNINGS = {
37565
+ /** Warning when the address dataset is empty (no addresses loaded) */
37566
+ EMPTY_DATASET: "No addresses are currently loaded in the dataset. Please run the data loader to populate the address index.",
37567
+ /** Warning when a search query returns no matching results */
37568
+ NO_RESULTS: "No addresses matched your search query.",
37569
+ /** Warning when the locality dataset is empty (no localities loaded) */
37570
+ EMPTY_LOCALITY_DATASET: "No localities are currently loaded in the dataset. Please run the data loader to populate the locality index.",
37571
+ /** Warning when a locality search query returns no matching results */
37572
+ NO_LOCALITY_RESULTS: "No localities matched your search query."
37573
+ };
37574
+ buildPaginationMeta = (total, page, pageSize2, responseTime, warning) => {
39614
37575
  const totalPages = Math.ceil(total / pageSize2);
39615
37576
  return {
39616
37577
  total,
39617
37578
  page,
39618
37579
  pageSize: pageSize2,
39619
37580
  totalPages,
39620
- ...responseTime !== void 0 && { responseTime }
37581
+ ...responseTime !== void 0 && { responseTime },
37582
+ ...warning !== void 0 && { warning }
39621
37583
  };
39622
37584
  };
39623
37585
  buildAutocompleteDocument = (resources, links, meta) => {
@@ -39637,6 +37599,23 @@ var init_jsonapi = __esm({
39637
37599
  }
39638
37600
  };
39639
37601
  };
37602
+ buildLocalityAutocompleteDocument = (resources, links, meta) => {
37603
+ return {
37604
+ jsonapi: JSONAPI_IMPLEMENTATION,
37605
+ data: resources,
37606
+ links,
37607
+ meta
37608
+ };
37609
+ };
37610
+ buildLocalityDetailDocument = (resource) => {
37611
+ return {
37612
+ jsonapi: JSONAPI_IMPLEMENTATION,
37613
+ data: resource,
37614
+ links: {
37615
+ self: resource.links?.self
37616
+ }
37617
+ };
37618
+ };
39640
37619
  buildError = (status, title, detail, code, source) => {
39641
37620
  return {
39642
37621
  status,
@@ -39672,6 +37651,23 @@ var init_jsonapi = __esm({
39672
37651
  )
39673
37652
  ]);
39674
37653
  },
37654
+ /**
37655
+ * Builds a 400 Bad Request error document for missing required parameter.
37656
+ *
37657
+ * @param paramName - The name of the missing required parameter.
37658
+ * @returns JSON:API error document for missing parameter.
37659
+ */
37660
+ missingRequiredParameter: (paramName) => {
37661
+ return buildErrorDocument([
37662
+ buildError(
37663
+ "400",
37664
+ "Bad Request",
37665
+ `The '${paramName}' query parameter is required and must not be empty.`,
37666
+ "MISSING_REQUIRED_PARAMETER",
37667
+ { parameter: paramName }
37668
+ )
37669
+ ]);
37670
+ },
39675
37671
  /**
39676
37672
  * Builds a 404 Not Found error document.
39677
37673
  *
@@ -39764,7 +37760,7 @@ var init_helpers = __esm({
39764
37760
  });
39765
37761
 
39766
37762
  // apps/server/service/commands/load.ts
39767
- var crypto, fs3, path3, stream, import_elasticsearch2, import_directory_exists, import_glob_promise, Papa2, unzip, fetchGNAFPackageData, fetchGNAFArchive, unzipGNAFArchive, computeDocumentHash, loadGNAFAddress, processAddressChunk, IndexingError, extractBulkErrors, isRetryableError, sendIndexRequest, getStateName, initGNAFDataLoader, loadStateData, loadStreetLocality, loadLocality, loadSiteGeo, loadDefaultGeo, loadAuthFiles, loadCommandEntry;
37763
+ var crypto, fs3, path3, stream, import_elasticsearch2, import_directory_exists, Papa2, unzip, fetchGNAFPackageData, fetchGNAFArchive, unzipGNAFArchive, computeDocumentHash, loadGNAFAddress, processAddressChunk, IndexingError, extractBulkErrors, isRetryableError, sendIndexRequest, getStateName, indexLocalitiesForState, initGNAFDataLoader, loadStateData, loadStreetLocality, loadLocality, loadSiteGeo, loadDefaultGeo, loadAuthFiles, loadCommandEntry;
39768
37764
  var init_load = __esm({
39769
37765
  "apps/server/service/commands/load.ts"() {
39770
37766
  "use strict";
@@ -39775,7 +37771,6 @@ var init_load = __esm({
39775
37771
  import_elasticsearch2 = __toESM(require_elasticsearch());
39776
37772
  init_stream_down();
39777
37773
  import_directory_exists = __toESM(require_directory_exists());
39778
- import_glob_promise = __toESM(require_lib3());
39779
37774
  Papa2 = __toESM(require_papaparse());
39780
37775
  unzip = __toESM(require_unzip());
39781
37776
  init_conf();
@@ -39911,9 +37906,12 @@ var init_load = __esm({
39911
37906
  }
39912
37907
  });
39913
37908
  const downloadedStats = fs3.statSync(incompleteFile);
39914
- if (dataResource.size && downloadedStats.size !== dataResource.size) {
37909
+ const expectedSize = dataResource.size;
37910
+ const actualSize = downloadedStats.size;
37911
+ const percentageDifference = Math.abs((actualSize - expectedSize) / expectedSize) * 100;
37912
+ if (percentageDifference > 5) {
39915
37913
  throw new Error(
39916
- `Downloaded file size (${downloadedStats.size}) doesn't match expected (${dataResource.size})`
37914
+ `Downloaded file size (${actualSize}) doesn't match expected (${expectedSize})`
39917
37915
  );
39918
37916
  }
39919
37917
  const downloadDuration = Date.now() - downloadStartTime;
@@ -40328,6 +38326,60 @@ var init_load = __esm({
40328
38326
  });
40329
38327
  });
40330
38328
  };
38329
+ indexLocalitiesForState = async (context, addressDetailFile, refresh) => {
38330
+ const localityPostcodes = {};
38331
+ await new Promise((resolve2, reject) => {
38332
+ Papa2.parse(fs3.createReadStream(addressDetailFile), {
38333
+ header: true,
38334
+ delimiter: "|",
38335
+ chunk: (chunk, parser) => {
38336
+ for (const row of chunk.data) {
38337
+ const localityPid = row.LOCALITY_PID;
38338
+ const postcode = row.POSTCODE;
38339
+ if (!localityPid || !postcode) continue;
38340
+ if (localityPostcodes[localityPid] === void 0) {
38341
+ localityPostcodes[localityPid] = /* @__PURE__ */ new Set();
38342
+ }
38343
+ localityPostcodes[localityPid].add(postcode);
38344
+ }
38345
+ },
38346
+ complete: () => resolve2(),
38347
+ error: (parseError) => reject(parseError)
38348
+ });
38349
+ });
38350
+ const localityIndexed = context.localityIndexed ?? {};
38351
+ const state = context.state ?? "";
38352
+ const stateName = context.stateName ?? "";
38353
+ const localityClassCode = context.LOCALITY_CLASS_AUT ?? {};
38354
+ const indexingBody = [];
38355
+ for (const [localityPid, localityData] of Object.entries(localityIndexed)) {
38356
+ const postcodes = localityPostcodes[localityPid] ? Array.from(localityPostcodes[localityPid]).sort() : [];
38357
+ const primaryPostcode = postcodes[0] ?? "";
38358
+ const classCode = localityData.LOCALITY_CLASS_CODE ?? "";
38359
+ const className = localityClassCode[classCode]?.NAME ?? classCode ?? "";
38360
+ const display = primaryPostcode ? `${localityData.LOCALITY_NAME} ${state} ${primaryPostcode}` : `${localityData.LOCALITY_NAME} ${state}`;
38361
+ indexingBody.push({
38362
+ index: {
38363
+ _index: ES_LOCALITY_INDEX_NAME,
38364
+ _id: `/localities/${localityPid}`
38365
+ }
38366
+ });
38367
+ indexingBody.push({
38368
+ display,
38369
+ name: localityData.LOCALITY_NAME,
38370
+ localityPid,
38371
+ stateAbbreviation: state,
38372
+ stateName,
38373
+ postcode: primaryPostcode,
38374
+ postcodes,
38375
+ classCode,
38376
+ className
38377
+ });
38378
+ }
38379
+ if (indexingBody.length > 0) {
38380
+ await sendIndexRequest(indexingBody, void 0, { refresh });
38381
+ }
38382
+ };
40331
38383
  initGNAFDataLoader = async (directory, { refresh = false } = {}) => {
40332
38384
  const countsFile = `${directory}/Counts.csv`;
40333
38385
  const countsFileExists = await fileExists(countsFile);
@@ -40350,6 +38402,7 @@ var init_load = __esm({
40350
38402
  loadContext
40351
38403
  );
40352
38404
  await (0, import_elasticsearch2.initIndex)(global.esClient, ES_CLEAR_INDEX, synonyms);
38405
+ await (0, import_elasticsearch2.initLocalityIndex)(global.esClient, ES_CLEAR_INDEX);
40353
38406
  const addressDetailFiles = files.filter(
40354
38407
  (f) => f.match(/ADDRESS_DETAIL/) && f.match(/\/Standard\//)
40355
38408
  );
@@ -40461,6 +38514,17 @@ var init_load = __esm({
40461
38514
  succeedSpinner(
40462
38515
  `${stateProgress} ${formatState(state)}: ${formatNumber(expectedCount)} addresses indexed in ${formatDuration(indexingDuration)}`
40463
38516
  );
38517
+ const localitySpinner = startSpinner(
38518
+ `${stateProgress} ${formatState(state)}: Indexing localities...`
38519
+ );
38520
+ await indexLocalitiesForState(
38521
+ loadContext,
38522
+ `${directory}/${detailFile}`,
38523
+ refresh
38524
+ );
38525
+ succeedSpinner(
38526
+ `${stateProgress} ${formatState(state)}: Localities indexed`
38527
+ );
40464
38528
  }
40465
38529
  }
40466
38530
  };
@@ -40756,18 +38820,41 @@ var init_load = __esm({
40756
38820
  throw new Error(`Data dir '${unzipped}' is empty`);
40757
38821
  }
40758
38822
  const locateSpinner = startSpinner("Locating G-NAF data directory...");
40759
- const gnafDir = await (0, import_glob_promise.glob)("**/G-NAF/", { cwd: unzipped });
40760
- if (VERBOSE) logger("gnafDir", gnafDir);
40761
- if (gnafDir.length === 0) {
38823
+ const findDirectory = async (baseDir, targetName, maxDepth = 3) => {
38824
+ const searchDir = async (currentDir, depth) => {
38825
+ if (depth > maxDepth) return void 0;
38826
+ const entries = await fsp.readdir(currentDir, {
38827
+ withFileTypes: true
38828
+ });
38829
+ for (const entry of entries) {
38830
+ if (entry.isDirectory()) {
38831
+ if (entry.name === targetName) {
38832
+ return path3.relative(
38833
+ baseDir,
38834
+ path3.join(currentDir, entry.name)
38835
+ );
38836
+ }
38837
+ const found = await searchDir(
38838
+ path3.join(currentDir, entry.name),
38839
+ depth + 1
38840
+ );
38841
+ if (found) return found;
38842
+ }
38843
+ }
38844
+ return void 0;
38845
+ };
38846
+ return searchDir(baseDir, 0);
38847
+ };
38848
+ const gnafDirPath = await findDirectory(unzipped, "G-NAF");
38849
+ if (VERBOSE) logger("gnafDir found", gnafDirPath);
38850
+ if (!gnafDirPath) {
40762
38851
  failSpinner("G-NAF directory not found");
40763
38852
  throw new Error(
40764
38853
  `Cannot find 'G-NAF' directory in Data dir '${unzipped}'`
40765
38854
  );
40766
38855
  }
40767
38856
  succeedSpinner("G-NAF data directory located");
40768
- const mainDirectory = path3.dirname(
40769
- `${unzipped}/${gnafDir[0].slice(0, -1)}`
40770
- );
38857
+ const mainDirectory = path3.dirname(`${unzipped}/${gnafDirPath}`);
40771
38858
  if (VERBOSE) logger("Main Data dir", mainDirectory);
40772
38859
  if (resourceMonitor) {
40773
38860
  if (VERBOSE) logger("Starting data loading phase");
@@ -41841,7 +39928,7 @@ var init_setLinkOptions = __esm({
41841
39928
  });
41842
39929
 
41843
39930
  // apps/server/service/index.ts
41844
- var crypto2, fs4, import_node_https2, import_debug4, got, import_http_link_header, import_keyv, import_keyv_file, fsp, readdir, logger, error, cache, gnafHttpCache, keepAliveAgent, gotClient, validatePaginationParams, normalizeSearchString, searchForAddress, getAddress, getAddresses, mapToJsonApiAutocompleteResponse, service_default;
39931
+ var crypto2, fs4, import_node_https2, import_debug4, got, import_http_link_header, import_keyv, import_keyv_file, fsp, readdir, logger, error, cache, gnafHttpCache, keepAliveAgent, gotClient, validatePaginationParams, normalizeSearchString, isIndexEmpty, searchForAddress, getAddress, getAddresses, mapToJsonApiAutocompleteResponse, isLocalityIndexEmpty, searchForLocality, getLocality, getLocalities, service_default;
41845
39932
  var init_service = __esm({
41846
39933
  "apps/server/service/index.ts"() {
41847
39934
  "use strict";
@@ -41885,6 +39972,19 @@ var init_service = __esm({
41885
39972
  return { validPage, validSize };
41886
39973
  };
41887
39974
  normalizeSearchString = (searchString) => (searchString ?? "").trim().replace(/\s+/g, " ");
39975
+ isIndexEmpty = async () => {
39976
+ try {
39977
+ const circuit = getOpenSearchCircuit();
39978
+ const countResponse = await circuit.execute(async () => {
39979
+ return await global.esClient.count({
39980
+ index: ES_INDEX_NAME
39981
+ });
39982
+ });
39983
+ return countResponse.body.count === 0;
39984
+ } catch {
39985
+ return true;
39986
+ }
39987
+ };
41888
39988
  searchForAddress = async (searchString, p, pageSize2 = PAGE_SIZE) => {
41889
39989
  const normalizedSearch = normalizeSearchString(searchString);
41890
39990
  if (normalizedSearch === "") {
@@ -42142,7 +40242,18 @@ var init_service = __esm({
42142
40242
  title: `${swagger.path.get.operationId} API Docs`,
42143
40243
  type: "text/html"
42144
40244
  };
42145
- const meta = buildPaginationMeta(totalHits, page, size);
40245
+ let warning;
40246
+ if (totalHits === 0) {
40247
+ const datasetEmpty = await isIndexEmpty();
40248
+ warning = datasetEmpty ? API_WARNINGS.EMPTY_DATASET : API_WARNINGS.NO_RESULTS;
40249
+ }
40250
+ const meta = buildPaginationMeta(
40251
+ totalHits,
40252
+ page,
40253
+ size,
40254
+ void 0,
40255
+ warning
40256
+ );
42146
40257
  const jsonApiDocument = buildAutocompleteDocument(
42147
40258
  resources,
42148
40259
  jsonApiLinks,
@@ -42263,10 +40374,361 @@ var init_service = __esm({
42263
40374
  );
42264
40375
  });
42265
40376
  };
40377
+ isLocalityIndexEmpty = async () => {
40378
+ try {
40379
+ const circuit = getOpenSearchCircuit();
40380
+ const countResponse = await circuit.execute(async () => {
40381
+ return await global.esClient.count({
40382
+ index: ES_LOCALITY_INDEX_NAME
40383
+ });
40384
+ });
40385
+ return countResponse.body.count === 0;
40386
+ } catch {
40387
+ return true;
40388
+ }
40389
+ };
40390
+ searchForLocality = async (searchString, p, pageSize2 = PAGE_SIZE) => {
40391
+ const normalizedSearch = (searchString ?? "").trim().replace(/\s+/g, " ");
40392
+ if (normalizedSearch === "") {
40393
+ throw new Error("Search query must not be empty after normalization");
40394
+ }
40395
+ const safePage = Number.isFinite(p) ? p : 1;
40396
+ const safeSize = Number.isFinite(pageSize2) ? pageSize2 : PAGE_SIZE;
40397
+ const validPage = Math.max(1, Math.min(safePage, MAX_PAGE_NUMBER));
40398
+ const validSize = Math.max(1, Math.min(safeSize, MAX_PAGE_SIZE));
40399
+ const from = (validPage - 1) * validSize;
40400
+ const circuit = getOpenSearchCircuit();
40401
+ const searchResp = await circuit.execute(async () => {
40402
+ return await global.esClient.search({
40403
+ index: ES_LOCALITY_INDEX_NAME,
40404
+ body: {
40405
+ from,
40406
+ size: validSize,
40407
+ _source: [
40408
+ "display",
40409
+ "name",
40410
+ "localityPid",
40411
+ "stateAbbreviation",
40412
+ "stateName",
40413
+ "postcode",
40414
+ "postcodes",
40415
+ "classCode",
40416
+ "className"
40417
+ ],
40418
+ query: {
40419
+ bool: {
40420
+ should: [
40421
+ // Highest boost: Display starts with the search query (exact prefix match)
40422
+ {
40423
+ prefix: {
40424
+ "display.raw": {
40425
+ value: normalizedSearch.toUpperCase(),
40426
+ boost: 100
40427
+ }
40428
+ }
40429
+ },
40430
+ // High boost: Locality name starts with search query
40431
+ {
40432
+ prefix: {
40433
+ "name.raw": {
40434
+ value: normalizedSearch.toUpperCase(),
40435
+ boost: 80
40436
+ }
40437
+ }
40438
+ },
40439
+ // Medium boost: Postcode match
40440
+ {
40441
+ term: {
40442
+ postcode: {
40443
+ value: normalizedSearch,
40444
+ boost: 60
40445
+ }
40446
+ }
40447
+ },
40448
+ // Medium boost: Match on any of the postcodes
40449
+ {
40450
+ term: {
40451
+ postcodes: {
40452
+ value: normalizedSearch,
40453
+ boost: 50
40454
+ }
40455
+ }
40456
+ },
40457
+ // Phrase prefix match on display
40458
+ {
40459
+ match_phrase_prefix: {
40460
+ display: {
40461
+ query: normalizedSearch,
40462
+ boost: 40
40463
+ }
40464
+ }
40465
+ },
40466
+ // Phrase prefix match on name
40467
+ {
40468
+ match_phrase_prefix: {
40469
+ name: {
40470
+ query: normalizedSearch,
40471
+ boost: 30
40472
+ }
40473
+ }
40474
+ },
40475
+ // Fuzzy match for typo tolerance
40476
+ {
40477
+ multi_match: {
40478
+ fields: ["display", "name"],
40479
+ query: normalizedSearch,
40480
+ fuzziness: "AUTO",
40481
+ type: "bool_prefix",
40482
+ lenient: true,
40483
+ operator: "AND"
40484
+ }
40485
+ }
40486
+ ]
40487
+ }
40488
+ },
40489
+ sort: ["_score", { "name.raw": { order: "asc" } }]
40490
+ }
40491
+ });
40492
+ });
40493
+ const rawTotal = searchResp.body.hits.total;
40494
+ const totalHits = typeof rawTotal === "number" ? rawTotal : rawTotal.value;
40495
+ return {
40496
+ searchResponse: searchResp,
40497
+ page: validPage,
40498
+ size: validSize,
40499
+ totalHits: totalHits ?? 0
40500
+ };
40501
+ };
40502
+ getLocality = async (localityId) => {
40503
+ try {
40504
+ const circuit = getOpenSearchCircuit();
40505
+ const jsonX = await circuit.execute(async () => {
40506
+ return await global.esClient.get({
40507
+ index: ES_LOCALITY_INDEX_NAME,
40508
+ id: `/localities/${localityId}`
40509
+ });
40510
+ });
40511
+ if (VERBOSE) logger("locality jsonX", jsonX);
40512
+ const source = jsonX.body._source;
40513
+ const attributes = {
40514
+ localityPid: source.localityPid,
40515
+ name: source.name,
40516
+ display: source.display,
40517
+ ...source.classCode !== void 0 && {
40518
+ class: {
40519
+ code: source.classCode,
40520
+ name: source.className
40521
+ }
40522
+ },
40523
+ ...source.stateAbbreviation !== void 0 && {
40524
+ state: {
40525
+ name: source.stateName,
40526
+ abbreviation: source.stateAbbreviation
40527
+ }
40528
+ },
40529
+ ...source.postcode !== void 0 && { postcode: source.postcode },
40530
+ ...source.postcodes !== void 0 && {
40531
+ postcodes: source.postcodes
40532
+ }
40533
+ };
40534
+ const resource = buildLocalityResource(localityId, attributes);
40535
+ const jsonApiDocument = buildLocalityDetailDocument(resource);
40536
+ const link = new import_http_link_header.default();
40537
+ link.set({
40538
+ rel: "self",
40539
+ uri: `/localities/${localityId}`
40540
+ });
40541
+ const hash = crypto2.createHash("md5").update(JSON.stringify(jsonApiDocument)).digest("hex");
40542
+ return { link, json: jsonApiDocument, hash };
40543
+ } catch (error_) {
40544
+ if (error_ instanceof CircuitOpenError) {
40545
+ error("Circuit breaker open for OpenSearch", error_);
40546
+ const retryAfterSeconds = Math.ceil(error_.retryAfterMs / 1e3);
40547
+ return {
40548
+ statusCode: 503,
40549
+ json: ErrorDocuments.serviceUnavailable(
40550
+ retryAfterSeconds
40551
+ )
40552
+ };
40553
+ }
40554
+ const osError = error_;
40555
+ error("error getting locality from elastic search", osError);
40556
+ if (osError.body?.found === false) {
40557
+ return {
40558
+ statusCode: 404,
40559
+ json: ErrorDocuments.notFound("locality", localityId)
40560
+ };
40561
+ }
40562
+ if (osError.body?.error?.type === "index_not_found_exception") {
40563
+ return {
40564
+ statusCode: 503,
40565
+ json: ErrorDocuments.serviceUnavailable()
40566
+ };
40567
+ }
40568
+ return {
40569
+ statusCode: 500,
40570
+ json: ErrorDocuments.internalError()
40571
+ };
40572
+ }
40573
+ };
40574
+ getLocalities = async (url, swagger, q, p = 1) => {
40575
+ try {
40576
+ const normalizedQuery = (q ?? "").trim().replace(/\s+/g, " ");
40577
+ if (normalizedQuery === "") {
40578
+ return {
40579
+ statusCode: 400,
40580
+ json: ErrorDocuments.badRequest(
40581
+ "The 'q' query parameter is required and must not be empty.",
40582
+ "q"
40583
+ )
40584
+ };
40585
+ }
40586
+ const {
40587
+ searchResponse: foundLocalities,
40588
+ page,
40589
+ size,
40590
+ totalHits
40591
+ } = await searchForLocality(normalizedQuery, p);
40592
+ if (VERBOSE) logger("foundLocalities", foundLocalities);
40593
+ const totalPages = Math.ceil(totalHits / size);
40594
+ const maxScore = foundLocalities.body.hits.hits[0] ? foundLocalities.body.hits.hits[0]._score : 1;
40595
+ const resources = foundLocalities.body.hits.hits.map((h) => {
40596
+ const hit = h;
40597
+ const localityId = extractLocalityId(hit._id);
40598
+ const normalizedRank = maxScore > 0 ? hit._score / maxScore : 0;
40599
+ return buildLocalityAutocompleteResource(
40600
+ localityId,
40601
+ hit._source.display,
40602
+ normalizedRank
40603
+ );
40604
+ });
40605
+ const jsonApiLinks = buildPaginationLinks(
40606
+ url,
40607
+ normalizedQuery,
40608
+ page,
40609
+ totalPages
40610
+ );
40611
+ jsonApiLinks.describedby = {
40612
+ href: `/docs/#operations-${swagger.path.get["x-swagger-router-controller"].toLowerCase()}-${swagger.path.get.operationId}`,
40613
+ title: `${swagger.path.get.operationId} API Docs`,
40614
+ type: "text/html"
40615
+ };
40616
+ let warning;
40617
+ if (totalHits === 0) {
40618
+ const datasetEmpty = await isLocalityIndexEmpty();
40619
+ warning = datasetEmpty ? API_WARNINGS.EMPTY_LOCALITY_DATASET : API_WARNINGS.NO_LOCALITY_RESULTS;
40620
+ }
40621
+ const meta = buildPaginationMeta(
40622
+ totalHits,
40623
+ page,
40624
+ size,
40625
+ void 0,
40626
+ warning
40627
+ );
40628
+ const jsonApiDocument = buildLocalityAutocompleteDocument(
40629
+ resources,
40630
+ jsonApiLinks,
40631
+ meta
40632
+ );
40633
+ const link = new import_http_link_header.default();
40634
+ link.set({
40635
+ rel: "describedby",
40636
+ uri: `/docs/#operations-${swagger.path.get["x-swagger-router-controller"].toLowerCase()}-${swagger.path.get.operationId}`,
40637
+ title: `${swagger.path.get.operationId} API Docs`,
40638
+ type: "text/html"
40639
+ });
40640
+ const sp = new URLSearchParams({
40641
+ ...normalizedQuery !== "" && { q: normalizedQuery },
40642
+ ...page !== 1 && { "page[number]": String(page) }
40643
+ });
40644
+ const spString = sp.toString();
40645
+ link.set({
40646
+ rel: "self",
40647
+ uri: `${url}${spString === "" ? "" : "?"}${spString}`
40648
+ });
40649
+ link.set({
40650
+ rel: "first",
40651
+ uri: `${url}${normalizedQuery === "" ? "" : "?"}${new URLSearchParams(
40652
+ {
40653
+ ...normalizedQuery !== "" && { q: normalizedQuery }
40654
+ }
40655
+ ).toString()}`
40656
+ });
40657
+ if (page > 1) {
40658
+ link.set({
40659
+ rel: "prev",
40660
+ uri: `${url}${normalizedQuery === "" && page === 2 ? "" : "?"}${new URLSearchParams({
40661
+ ...normalizedQuery !== "" && { q: normalizedQuery },
40662
+ ...page > 2 && { "page[number]": String(page - 1) }
40663
+ }).toString()}`
40664
+ });
40665
+ }
40666
+ const hasNextPage = totalHits > size * page;
40667
+ if (hasNextPage) {
40668
+ link.set({
40669
+ rel: "next",
40670
+ uri: `${url}?${new URLSearchParams({
40671
+ ...normalizedQuery !== "" && { q: normalizedQuery },
40672
+ "page[number]": String(page + 1)
40673
+ }).toString()}`
40674
+ });
40675
+ }
40676
+ if (totalPages > 0) {
40677
+ link.set({
40678
+ rel: "last",
40679
+ uri: `${url}?${new URLSearchParams({
40680
+ ...normalizedQuery !== "" && { q: normalizedQuery },
40681
+ ...totalPages > 1 && {
40682
+ "page[number]": String(totalPages)
40683
+ }
40684
+ }).toString()}`
40685
+ });
40686
+ }
40687
+ const linkTemplate = new import_http_link_header.default();
40688
+ const op = swagger.path.get;
40689
+ setLinkOptions(op, url, linkTemplate);
40690
+ return {
40691
+ link,
40692
+ json: jsonApiDocument,
40693
+ linkTemplate
40694
+ };
40695
+ } catch (error_) {
40696
+ if (error_ instanceof CircuitOpenError) {
40697
+ error("Circuit breaker open for OpenSearch", error_);
40698
+ const retryAfterSeconds = Math.ceil(error_.retryAfterMs / 1e3);
40699
+ return {
40700
+ statusCode: 503,
40701
+ json: ErrorDocuments.serviceUnavailable(
40702
+ retryAfterSeconds
40703
+ )
40704
+ };
40705
+ }
40706
+ const osError = error_;
40707
+ error("error querying localities in elastic search", osError);
40708
+ if (osError.body?.error?.type === "index_not_found_exception") {
40709
+ return {
40710
+ statusCode: 503,
40711
+ json: ErrorDocuments.serviceUnavailable()
40712
+ };
40713
+ }
40714
+ if (osError.displayName === "RequestTimeout") {
40715
+ return {
40716
+ statusCode: 504,
40717
+ json: ErrorDocuments.gatewayTimeout()
40718
+ };
40719
+ }
40720
+ return {
40721
+ statusCode: 500,
40722
+ json: ErrorDocuments.internalError()
40723
+ };
40724
+ }
40725
+ };
42266
40726
  service_default = {
42267
40727
  load: loadCommandEntry,
42268
40728
  autocomplete: getAddresses,
42269
- lookup: getAddress
40729
+ lookup: getAddress,
40730
+ localityAutocomplete: getLocalities,
40731
+ localityLookup: getLocality
42270
40732
  };
42271
40733
  }
42272
40734
  });
@@ -42287,9 +40749,9 @@ async function runLoadCommand(options) {
42287
40749
  displayKeyValue({
42288
40750
  "OpenSearch URL": process.env.ES_HOST || "http://localhost:9200",
42289
40751
  "Index Name": process.env.ES_INDEX_NAME || "addresskit",
42290
- "Clear Index": options.clear ? "Yes" : "No",
42291
- Geocoding: options.geo ? "Enabled" : "Disabled",
42292
- States: options.states || "All"
40752
+ "Clear Index": process.env.ES_CLEAR_INDEX === "true" || options.clear ? "Yes" : "No",
40753
+ Geocoding: process.env.ADDRESSKIT_ENABLE_GEO === "1" || options.geo ? "Enabled" : "Disabled",
40754
+ States: process.env.COVERED_STATES || options.states || "All"
42293
40755
  });
42294
40756
  }
42295
40757
  const connectSpinner = startSpinner("Connecting to OpenSearch...");
@@ -42383,7 +40845,7 @@ var init_load2 = __esm({
42383
40845
  // node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js
42384
40846
  var require_depd = __commonJS({
42385
40847
  "node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js"(exports2, module2) {
42386
- var relative = require("path").relative;
40848
+ var relative2 = require("path").relative;
42387
40849
  module2.exports = depd;
42388
40850
  var basePath = process.cwd();
42389
40851
  function containsNamespace(str, namespace) {
@@ -42575,7 +41037,7 @@ var require_depd = __commonJS({
42575
41037
  return formatted;
42576
41038
  }
42577
41039
  function formatLocation(callSite) {
42578
- return relative(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
41040
+ return relative2(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
42579
41041
  }
42580
41042
  function getStack() {
42581
41043
  var limit = Error.stackTraceLimit;
@@ -47055,7 +45517,7 @@ var require_extend_node = __commonJS({
47055
45517
  });
47056
45518
 
47057
45519
  // node_modules/.pnpm/iconv-lite@0.4.24/node_modules/iconv-lite/lib/index.js
47058
- var require_lib4 = __commonJS({
45520
+ var require_lib3 = __commonJS({
47059
45521
  "node_modules/.pnpm/iconv-lite@0.4.24/node_modules/iconv-lite/lib/index.js"(exports2, module2) {
47060
45522
  "use strict";
47061
45523
  var Buffer2 = require_safer().Buffer;
@@ -47202,7 +45664,7 @@ var require_raw_body = __commonJS({
47202
45664
  var asyncHooks = tryRequireAsyncHooks();
47203
45665
  var bytes = require_bytes();
47204
45666
  var createError = require_http_errors();
47205
- var iconv = require_lib4();
45667
+ var iconv = require_lib3();
47206
45668
  var unpipe = require_unpipe();
47207
45669
  module2.exports = getRawBody;
47208
45670
  var ICONV_ENCODING_MESSAGE_REGEXP = /^Encoding not recognized: /;
@@ -47551,7 +46013,7 @@ var require_read = __commonJS({
47551
46013
  var createError = require_http_errors();
47552
46014
  var destroy = require_destroy2();
47553
46015
  var getBody = require_raw_body();
47554
- var iconv = require_lib4();
46016
+ var iconv = require_lib3();
47555
46017
  var onFinished = require_on_finished();
47556
46018
  var unpipe = require_unpipe();
47557
46019
  var zlib = require("zlib");
@@ -59243,7 +57705,7 @@ var require_parse = __commonJS({
59243
57705
  });
59244
57706
 
59245
57707
  // node_modules/.pnpm/qs@6.14.1/node_modules/qs/lib/index.js
59246
- var require_lib5 = __commonJS({
57708
+ var require_lib4 = __commonJS({
59247
57709
  "node_modules/.pnpm/qs@6.14.1/node_modules/qs/lib/index.js"(exports2, module2) {
59248
57710
  "use strict";
59249
57711
  var stringify = require_stringify();
@@ -59392,7 +57854,7 @@ var require_urlencoded = __commonJS({
59392
57854
  }
59393
57855
  switch (name) {
59394
57856
  case "qs":
59395
- mod = require_lib5();
57857
+ mod = require_lib4();
59396
57858
  break;
59397
57859
  case "querystring":
59398
57860
  mod = require("querystring");
@@ -60647,7 +59109,7 @@ var require_query = __commonJS({
60647
59109
  "use strict";
60648
59110
  var merge = require_utils_merge();
60649
59111
  var parseUrl = require_parseurl();
60650
- var qs = require_lib5();
59112
+ var qs = require_lib4();
60651
59113
  module2.exports = function query(options) {
60652
59114
  var opts = merge({}, options);
60653
59115
  var queryparse = qs.parse;
@@ -60679,7 +59141,7 @@ var require_view = __commonJS({
60679
59141
  var dirname2 = path5.dirname;
60680
59142
  var basename3 = path5.basename;
60681
59143
  var extname2 = path5.extname;
60682
- var join2 = path5.join;
59144
+ var join3 = path5.join;
60683
59145
  var resolve2 = path5.resolve;
60684
59146
  module2.exports = View;
60685
59147
  function View(name, options) {
@@ -60727,12 +59189,12 @@ var require_view = __commonJS({
60727
59189
  };
60728
59190
  View.prototype.resolve = function resolve3(dir, file) {
60729
59191
  var ext = this.ext;
60730
- var path6 = join2(dir, file);
59192
+ var path6 = join3(dir, file);
60731
59193
  var stat2 = tryStat(path6);
60732
59194
  if (stat2 && stat2.isFile()) {
60733
59195
  return path6;
60734
59196
  }
60735
- path6 = join2(dir, basename3(file, ext), "index" + ext);
59197
+ path6 = join3(dir, basename3(file, ext), "index" + ext);
60736
59198
  stat2 = tryStat(path6);
60737
59199
  if (stat2 && stat2.isFile()) {
60738
59200
  return path6;
@@ -61191,7 +59653,7 @@ var require_send = __commonJS({
61191
59653
  var Stream = require("stream");
61192
59654
  var util = require("util");
61193
59655
  var extname2 = path5.extname;
61194
- var join2 = path5.join;
59656
+ var join3 = path5.join;
61195
59657
  var normalize = path5.normalize;
61196
59658
  var resolve2 = path5.resolve;
61197
59659
  var sep = path5.sep;
@@ -61410,7 +59872,7 @@ var require_send = __commonJS({
61410
59872
  return res;
61411
59873
  }
61412
59874
  parts = path6.split(sep);
61413
- path6 = normalize(join2(root, path6));
59875
+ path6 = normalize(join3(root, path6));
61414
59876
  } else {
61415
59877
  if (UP_PATH_REGEXP.test(path6)) {
61416
59878
  debug8('malicious path "%s"', path6);
@@ -61545,7 +60007,7 @@ var require_send = __commonJS({
61545
60007
  if (err) return self2.onStatError(err);
61546
60008
  return self2.error(404);
61547
60009
  }
61548
- var p = join2(path6, self2._index[i]);
60010
+ var p = join3(path6, self2._index[i]);
61549
60011
  debug8('stat "%s"', p);
61550
60012
  fs5.stat(p, function(err2, stat2) {
61551
60013
  if (err2) return next(err2);
@@ -62554,7 +61016,7 @@ var require_utils3 = __commonJS({
62554
61016
  var mime = require_send().mime;
62555
61017
  var etag = require_etag();
62556
61018
  var proxyaddr = require_proxy_addr();
62557
- var qs = require_lib5();
61019
+ var qs = require_lib4();
62558
61020
  var querystring = require("querystring");
62559
61021
  exports2.etag = createETagGenerator({ weak: false });
62560
61022
  exports2.wetag = createETagGenerator({ weak: true });
@@ -65393,7 +63855,7 @@ var require_waycharter = __commonJS({
65393
63855
  });
65394
63856
 
65395
63857
  // node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/common.js
65396
- var require_common3 = __commonJS({
63858
+ var require_common2 = __commonJS({
65397
63859
  "node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/common.js"(exports2, module2) {
65398
63860
  "use strict";
65399
63861
  function isNothing(subject) {
@@ -65471,7 +63933,7 @@ var require_exception = __commonJS({
65471
63933
  var require_mark = __commonJS({
65472
63934
  "node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/mark.js"(exports2, module2) {
65473
63935
  "use strict";
65474
- var common = require_common3();
63936
+ var common = require_common2();
65475
63937
  function Mark(name, buffer, position, line, column) {
65476
63938
  this.name = name;
65477
63939
  this.buffer = buffer;
@@ -65588,7 +64050,7 @@ var require_type2 = __commonJS({
65588
64050
  var require_schema = __commonJS({
65589
64051
  "node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/schema.js"(exports2, module2) {
65590
64052
  "use strict";
65591
- var common = require_common3();
64053
+ var common = require_common2();
65592
64054
  var YAMLException = require_exception();
65593
64055
  var Type = require_type2();
65594
64056
  function compileList(schema, name, result) {
@@ -65810,7 +64272,7 @@ var require_bool = __commonJS({
65810
64272
  var require_int = __commonJS({
65811
64273
  "node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/type/int.js"(exports2, module2) {
65812
64274
  "use strict";
65813
- var common = require_common3();
64275
+ var common = require_common2();
65814
64276
  var Type = require_type2();
65815
64277
  function isHexCode(c) {
65816
64278
  return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
@@ -65943,7 +64405,7 @@ var require_int = __commonJS({
65943
64405
  var require_float = __commonJS({
65944
64406
  "node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/type/float.js"(exports2, module2) {
65945
64407
  "use strict";
65946
- var common = require_common3();
64408
+ var common = require_common2();
65947
64409
  var Type = require_type2();
65948
64410
  var YAML_FLOAT_PATTERN = new RegExp(
65949
64411
  // 2.5e4, 2.5 and integers
@@ -66508,7 +64970,7 @@ var require_default_full = __commonJS({
66508
64970
  var require_loader = __commonJS({
66509
64971
  "node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/loader.js"(exports2, module2) {
66510
64972
  "use strict";
66511
- var common = require_common3();
64973
+ var common = require_common2();
66512
64974
  var YAMLException = require_exception();
66513
64975
  var Mark = require_mark();
66514
64976
  var DEFAULT_SAFE_SCHEMA = require_default_safe();
@@ -67627,7 +66089,7 @@ var require_loader = __commonJS({
67627
66089
  var require_dumper = __commonJS({
67628
66090
  "node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/dumper.js"(exports2, module2) {
67629
66091
  "use strict";
67630
- var common = require_common3();
66092
+ var common = require_common2();
67631
66093
  var YAMLException = require_exception();
67632
66094
  var DEFAULT_FULL_SCHEMA = require_default_full();
67633
66095
  var DEFAULT_SAFE_SCHEMA = require_default_safe();
@@ -68652,6 +67114,116 @@ async function loadAddressCollection(params) {
68652
67114
  }
68653
67115
  };
68654
67116
  }
67117
+ function mapLocalitySearchHitToResource(hit, maxScore) {
67118
+ const localityId = hit._id.replace("/localities/", "");
67119
+ const normalizedRank = maxScore > 0 ? hit._score / maxScore : 0;
67120
+ return {
67121
+ type: "locality-suggestion",
67122
+ id: localityId,
67123
+ attributes: {
67124
+ display: hit._source.display,
67125
+ rank: Math.round(normalizedRank * 100) / 100
67126
+ },
67127
+ links: {
67128
+ self: `/localities/${localityId}`
67129
+ }
67130
+ };
67131
+ }
67132
+ async function loadLocalityItem({
67133
+ localityPid
67134
+ }) {
67135
+ if (typeof localityPid !== "string" || localityPid.length === 0) {
67136
+ throw new Error("Locality PID is required to load a record.");
67137
+ }
67138
+ const { json, hash, statusCode } = await getLocality(
67139
+ localityPid
67140
+ );
67141
+ return {
67142
+ body: json,
67143
+ headers: {
67144
+ etag: `"${version}-${hash}"`,
67145
+ "cache-control": `public, max-age=${ONE_WEEK}`
67146
+ },
67147
+ status: statusCode ?? 200
67148
+ };
67149
+ }
67150
+ async function loadLocalityCollection(params) {
67151
+ const { page, q } = params;
67152
+ const resolvedPage = Number(page ?? 0);
67153
+ if (!Number.isFinite(resolvedPage)) {
67154
+ throw new Error("Search page value must be numeric.");
67155
+ }
67156
+ const baseUrl = `/localities${q ? `?q=${encodeURIComponent(q)}` : ""}`;
67157
+ if (q && q.length > 1) {
67158
+ logger6("Searching for localities with query:", q);
67159
+ const searchResult = await searchForLocality(
67160
+ q,
67161
+ resolvedPage + 1,
67162
+ pageSize
67163
+ );
67164
+ const hits = searchResult.searchResponse.body.hits.hits;
67165
+ const totalHits = searchResult.totalHits;
67166
+ const totalPages = Math.ceil(totalHits / pageSize);
67167
+ const currentPage = resolvedPage + 1;
67168
+ const maxScore = hits.length > 0 ? hits[0]._score : 1;
67169
+ const data = hits.map(
67170
+ (hit) => mapLocalitySearchHitToResource(hit, maxScore)
67171
+ );
67172
+ const jsonApiDocument = {
67173
+ jsonapi: { version: "1.1" },
67174
+ data,
67175
+ links: {
67176
+ self: `${baseUrl}${currentPage > 1 ? `&page[number]=${currentPage}` : ""}`,
67177
+ first: baseUrl,
67178
+ ...currentPage > 1 && {
67179
+ prev: currentPage === 2 ? baseUrl : `${baseUrl}&page[number]=${currentPage - 1}`
67180
+ },
67181
+ ...currentPage < totalPages && {
67182
+ next: `${baseUrl}&page[number]=${currentPage + 1}`
67183
+ },
67184
+ ...totalPages > 0 && {
67185
+ last: totalPages === 1 ? baseUrl : `${baseUrl}&page[number]=${totalPages}`
67186
+ }
67187
+ },
67188
+ meta: {
67189
+ total: totalHits,
67190
+ page: currentPage,
67191
+ pageSize,
67192
+ totalPages
67193
+ }
67194
+ };
67195
+ const responseHash = (0, import_node_crypto.createHash)("md5").update(JSON.stringify(jsonApiDocument)).digest("hex");
67196
+ return {
67197
+ body: jsonApiDocument,
67198
+ hasMore: currentPage < totalPages,
67199
+ headers: {
67200
+ etag: `"${version}-${responseHash}"`,
67201
+ "cache-control": `public, max-age=${ONE_WEEK}`
67202
+ }
67203
+ };
67204
+ }
67205
+ const emptyDocument = {
67206
+ jsonapi: { version: "1.1" },
67207
+ data: [],
67208
+ links: {
67209
+ self: baseUrl
67210
+ },
67211
+ meta: {
67212
+ total: 0,
67213
+ page: 1,
67214
+ pageSize,
67215
+ totalPages: 0
67216
+ }
67217
+ };
67218
+ return {
67219
+ body: emptyDocument,
67220
+ hasMore: false,
67221
+ headers: {
67222
+ etag: `"${version}"`,
67223
+ "cache-control": `public, max-age=${ONE_WEEK}`
67224
+ }
67225
+ };
67226
+ }
68655
67227
  function transformPaginationParams(req, _res, next) {
68656
67228
  const pageParam = req.query.page;
68657
67229
  if (pageParam && typeof pageParam === "object" && pageParam.number) {
@@ -68696,10 +67268,24 @@ async function startRest2Server() {
68696
67268
  }
68697
67269
  ]
68698
67270
  });
67271
+ const localitiesType = waycharter.registerCollection({
67272
+ itemPath: "/:localityPid",
67273
+ itemLoader: loadLocalityItem,
67274
+ collectionPath: "/localities",
67275
+ collectionLoader: loadLocalityCollection,
67276
+ filters: [
67277
+ {
67278
+ rel: "https://addressr.io/rels/locality-search",
67279
+ parameters: ["q"]
67280
+ }
67281
+ ]
67282
+ });
68699
67283
  const loadIndexResource = async () => {
67284
+ const addressLinks = addressesType.additionalPaths;
67285
+ const localityLinks = localitiesType.additionalPaths;
68700
67286
  return {
68701
67287
  body: {},
68702
- links: addressesType.additionalPaths,
67288
+ links: [...addressLinks, ...localityLinks],
68703
67289
  headers: {
68704
67290
  etag: `"${version}"`,
68705
67291
  "cache-control": `public, max-age=${ONE_WEEK}`
@@ -68823,6 +67409,20 @@ async function runStartCommand(options) {
68823
67409
  ` ${theme.dim("Get detailed information for a specific address")}`
68824
67410
  );
68825
67411
  console.log();
67412
+ console.log(
67413
+ ` ${theme.secondary("GET")} ${theme.muted("/localities?q=<query>")}`
67414
+ );
67415
+ console.log(
67416
+ ` ${theme.dim("Search for suburbs/postcodes matching the query")}`
67417
+ );
67418
+ console.log();
67419
+ console.log(
67420
+ ` ${theme.secondary("GET")} ${theme.muted("/localities/:id")}`
67421
+ );
67422
+ console.log(
67423
+ ` ${theme.dim("Get detailed information for a specific locality")}`
67424
+ );
67425
+ console.log();
68826
67426
  console.log(` ${theme.secondary("GET")} ${theme.muted("/docs")}`);
68827
67427
  console.log(` ${theme.dim("OpenAPI/Swagger documentation")}`);
68828
67428
  console.log();
@@ -68883,7 +67483,7 @@ program2.command("load").description("Load G-NAF address data into the search in
68883
67483
  process.env.COVERED_STATES = options.states;
68884
67484
  }
68885
67485
  if (options.clear) {
68886
- process.env.ES_CLEAR_INDEX = "1";
67486
+ process.env.ES_CLEAR_INDEX = "true";
68887
67487
  }
68888
67488
  if (options.geo) {
68889
67489
  process.env.ADDRESSKIT_ENABLE_GEO = "1";