Skip to content

Commit 3a79137

Browse files
committed
Format codebase with prettier
1 parent 3531130 commit 3a79137

File tree

16 files changed

+208
-189
lines changed

16 files changed

+208
-189
lines changed

.github/workflows/build-image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
type=ref,event=tag,suffix=-{{date 'YYYYMMDDHHmmss'}}
3030
type=semver,pattern={{version}}
3131
type=semver,pattern={{version}},suffix=-{{date 'YYYYMMDDHHmmss'}}
32-
32+
3333
# When a PRODUCTION tag (vX.Y.Z) is pushed → also tag staging and dev
3434
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
3535
type=semver,pattern={{version}},suffix=-beta.{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}

api-tests/app.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {describe} from "node:test";
1+
import { describe } from "node:test";
22

33
var settings = require("./settings");
44
//import { toExport as settings } from "./settings";
@@ -17,32 +17,32 @@ const endpointsToFix = [
1717
//'tiles.ts'
1818
];*/
1919
const testFiles = [
20-
'carto_small.ts',
21-
'columns.ts',
22-
'defs.ts',
23-
'defs_columns.ts',
24-
'defs_econs.ts',
25-
'defs_environments.ts',
26-
'defs_groups.ts',
27-
'defs_intervals.ts',
28-
'defs_lithologies.ts',
29-
'defs_lithology_attributes.ts',
30-
'defs_measurements.ts',
31-
'defs_minerals.ts',
32-
'defs_plates.ts',
33-
'defs_projects.ts',
34-
'defs_refs.ts',
35-
'defs_sources.ts',
36-
'defs_strat_name_concepts.ts',
37-
'defs_strat_names.ts',
38-
'defs_structures.ts',
39-
'defs_timescales.ts',
40-
'fossils.ts',
41-
'geologic_units_burwell.ts',
42-
'index.ts',
43-
'mobile_fossil_collections.ts',
44-
'mobile_macro_summary.ts',
45-
'mobile_map_query.ts',
20+
"carto_small.ts",
21+
"columns.ts",
22+
"defs.ts",
23+
"defs_columns.ts",
24+
"defs_econs.ts",
25+
"defs_environments.ts",
26+
"defs_groups.ts",
27+
"defs_intervals.ts",
28+
"defs_lithologies.ts",
29+
"defs_lithology_attributes.ts",
30+
"defs_measurements.ts",
31+
"defs_minerals.ts",
32+
"defs_plates.ts",
33+
"defs_projects.ts",
34+
"defs_refs.ts",
35+
"defs_sources.ts",
36+
"defs_strat_name_concepts.ts",
37+
"defs_strat_names.ts",
38+
"defs_structures.ts",
39+
"defs_timescales.ts",
40+
"fossils.ts",
41+
"geologic_units_burwell.ts",
42+
"index.ts",
43+
"mobile_fossil_collections.ts",
44+
"mobile_macro_summary.ts",
45+
"mobile_map_query.ts",
4646
"mobile_point.ts",
4747
"mobile_point_details.ts",
4848
"paleogeography.ts",

api-tests/toReview/mancos_test_cases.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ it("should return point data for Detroit", function (done) {
3939
) {
4040
throw new Error("Invalid data returned for Detroit");
4141
}
42-
if (res.body.success.data.strat_unit != 'Dundee Limestone') {
42+
if (res.body.success.data.strat_unit != "Dundee Limestone") {
4343
throw new Error("Invalid strat unit returned for Detroit");
4444
}
4545
if (res.body.success.data.col_id !== 1594) {
@@ -105,7 +105,7 @@ it("should return point data for Toronto", function (done) {
105105
if (res.body.success.data.age != "Ordovician") {
106106
throw new Error("Invalid age returned for Toronto");
107107
}
108-
if (res.body.success.data.name != 'Georgian Bay') {
108+
if (res.body.success.data.name != "Georgian Bay") {
109109
throw new Error("Invalid data returned for Toronto");
110110
}
111111
if (res.body.success.data.col_id !== 1598) {
@@ -168,10 +168,10 @@ it("should return point data for Buenos Aires", function (done) {
168168
if (res.body.success.data.rocktype.length === 0) {
169169
throw new Error("Invalid rocktypes returned for Buenos Aires");
170170
}
171-
if (res.body.success.data.age != 'Quaternary') {
171+
if (res.body.success.data.age != "Quaternary") {
172172
throw new Error("Invalid age returned for Buenos Aires");
173173
}
174-
if (res.body.success.data.name != 'Cenozoic sedimentary rocks') {
174+
if (res.body.success.data.name != "Cenozoic sedimentary rocks") {
175175
throw new Error("Invalid data returned for Buenos Aires");
176176
}
177177
if (

api-tests/toReview/mobile_point_details.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ it("should accept a lat and lng", function (done) {
3232
});
3333
});*/
3434

35-
3635
//TODO endpoint is failing because of the gmus error
3736
/*
3837
it("should accept a col_id and unit_id", function (done) {

api-tests/v2Tests/defs_econs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ var request = require("supertest"),
33
settings = require("../settings");
44

55
it("should return metadata", function (done) {
6-
this.timeout(10000);
7-
request(settings.host)
6+
this.timeout(10000);
7+
request(settings.host)
88
.get("/defs/econs")
99
.expect(validators.aSuccessfulRequest)
1010
.expect(validators.json)

api-tests/v2Tests/defs_measurements.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ it("should return all definitions", function (done) {
9898
});
9999

100100
it("should return CSV", function (done) {
101-
this.timeout(10000);
102-
request(settings.host)
101+
this.timeout(10000);
102+
request(settings.host)
103103
.get("/defs/measurements?measurement_type=geochronological&format=csv")
104104
.expect(validators.aSuccessfulRequest)
105105
.expect(validators.csv)

api-tests/v2Tests/tiles.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ var request = require("supertest"),
33
settings = require("../settings");
44
//TODO need to modify these tests to work with the tileserver api
55

6-
76
const baseURL = "https://tiles.dev.macrostrat.org";
87
const tilePath = "/maps/bounds/3/2/4";
98

109
describe("Tileserver API", function () {
11-
this.timeout(10000)
12-
it("should return a valid tile response", function (done) {
10+
this.timeout(10000);
11+
it("should return a valid tile response", function (done) {
1312
request(baseURL)
1413
.get(tilePath)
1514
.expect(200)
1615
.expect("content-type", /application\/x-protobuf/)
1716
.end(function (err, res) {
1817
if (err) return done(err);
19-
if (!res.headers["content-length"] || res.headers["content-length"] < 100) {
18+
if (
19+
!res.headers["content-length"] ||
20+
res.headers["content-length"] < 100
21+
) {
2022
return done(new Error("Tile is empty or too small"));
2123
}
2224
done();
@@ -34,7 +36,11 @@ describe("Tileserver API", function () {
3436
return done(new Error(`Expected gzip compression, got: ${encoding}`));
3537
}
3638
if (!/application\/x-protobuf/.test(res.headers["content-type"])) {
37-
return done(new Error(`Unexpected content-type: ${res.headers["content-type"]}`));
39+
return done(
40+
new Error(
41+
`Unexpected content-type: ${res.headers["content-type"]}`,
42+
),
43+
);
3844
}
3945
done();
4046
});
@@ -58,4 +64,4 @@ describe("Tileserver API", function () {
5864
done();
5965
});
6066
});
61-
});
67+
});

api-tests/v2Tests/units.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ it("should accept a response parameter", function (done) {
109109
});
110110

111111
it("should accept a lith parameter", function (done) {
112-
this.timeout(10000);
113-
request(settings.host)
112+
this.timeout(10000);
113+
request(settings.host)
114114
.get("/units?lith=sandstone")
115115
.expect(validators.aSuccessfulRequest)
116116
.expect(validators.json)
@@ -127,8 +127,8 @@ it("should accept a lith parameter", function (done) {
127127
});
128128

129129
it("should accept a lith_type parameter", function (done) {
130-
this.timeout(10000);
131-
request(settings.host)
130+
this.timeout(10000);
131+
request(settings.host)
132132
.get("/units?lith_type=organic")
133133
.expect(validators.aSuccessfulRequest)
134134
.expect(validators.json)
@@ -147,8 +147,8 @@ it("should accept a lith_type parameter", function (done) {
147147
});
148148

149149
it("should accept a lith_class parameter", function (done) {
150-
this.timeout(10000);
151-
request(settings.host)
150+
this.timeout(10000);
151+
request(settings.host)
152152
.get("/units?lith_class=metamorphic")
153153
.expect(validators.aSuccessfulRequest)
154154
.expect(validators.json)
@@ -167,8 +167,8 @@ it("should accept a lith_class parameter", function (done) {
167167
});
168168

169169
it("should accept a environ parameter", function (done) {
170-
this.timeout(10000);
171-
request(settings.host)
170+
this.timeout(10000);
171+
request(settings.host)
172172
.get("/units?environ=reef")
173173
.expect(validators.aSuccessfulRequest)
174174
.expect(validators.json)
@@ -187,8 +187,8 @@ it("should accept a environ parameter", function (done) {
187187
});
188188

189189
it("should accept a environ_type parameter", function (done) {
190-
this.timeout(10000);
191-
request(settings.host)
190+
this.timeout(10000);
191+
request(settings.host)
192192
.get("/units?environ_type=carbonate")
193193
.expect(validators.aSuccessfulRequest)
194194
.expect(validators.json)
@@ -207,8 +207,8 @@ it("should accept a environ_type parameter", function (done) {
207207
});
208208

209209
it("should accept a environ_class parameter", function (done) {
210-
this.timeout(15000);
211-
request(settings.host)
210+
this.timeout(15000);
211+
request(settings.host)
212212
.get("/units?environ_class=marine")
213213
.expect(validators.aSuccessfulRequest)
214214
.expect(validators.json)
@@ -227,8 +227,8 @@ it("should accept a environ_class parameter", function (done) {
227227
});
228228

229229
it("should accept a project_id", function (done) {
230-
this.timeout(15000);
231-
request(settings.host)
230+
this.timeout(15000);
231+
request(settings.host)
232232
.get("/units?project_id=4")
233233
.expect(validators.aSuccessfulRequest)
234234
.expect(validators.json)

api-tests/validators.ts

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ function extractArrayData(payload) {
66
if (!payload || !payload.success) return null;
77
const data = payload.success.data;
88
if (Array.isArray(data)) return data;
9-
if (data && data.type === "FeatureCollection" && Array.isArray(data.features)) {
9+
if (
10+
data &&
11+
data.type === "FeatureCollection" &&
12+
Array.isArray(data.features)
13+
) {
1014
return data.features;
1115
}
1216
return null;
@@ -17,7 +21,8 @@ function extractArrayData(payload) {
1721
// Returns the object to scan for keys (GeoJSON Feature.properties if present)
1822
function surfaceForIdScan(item) {
1923
if (!item) return null;
20-
if (item.properties && typeof item.properties === "object") return item.properties;
24+
if (item.properties && typeof item.properties === "object")
25+
return item.properties;
2126
return item;
2227
}
2328

@@ -26,7 +31,7 @@ function firstStarIdKey(item) {
2631
const base = surfaceForIdScan(item);
2732
if (!base || typeof base !== "object") return null;
2833
for (const k of Object.keys(base)) {
29-
if (/_id$/i.test(k)) return k; // first *_id encountered wins
34+
if (/_id$/i.test(k)) return k; // first *_id encountered wins
3035
}
3136
if (Object.prototype.hasOwnProperty.call(base, "id")) return "id";
3237
return null;
@@ -38,9 +43,12 @@ function arrayExposesKey(arr, key, sampleSize = 50) {
3843
for (let i = 0; i < n; i++) {
3944
const it = arr[i];
4045
if (!it) continue;
41-
const props = it.properties && typeof it.properties === "object" ? it.properties : null;
42-
if ((props && Object.prototype.hasOwnProperty.call(props, key)) ||
43-
Object.prototype.hasOwnProperty.call(it, key)) {
46+
const props =
47+
it.properties && typeof it.properties === "object" ? it.properties : null;
48+
if (
49+
(props && Object.prototype.hasOwnProperty.call(props, key)) ||
50+
Object.prototype.hasOwnProperty.call(it, key)
51+
) {
4452
return true;
4553
}
4654
}
@@ -61,15 +69,17 @@ function chooseCommonIdKey(localArr, prodArr) {
6169
return null;
6270
}
6371

64-
6572
// Build a set of unique IDs from an array given a chosen id key.
6673
// Supports both flat objects and GeoJSON Feature properties.
6774
function uniqueIds(arr, idKey) {
6875
const out = new Set();
6976
for (const item of arr) {
7077
if (!item) continue;
7178
// Prefer .properties[idKey] if available (GeoJSON Feature)
72-
const props = item.properties && typeof item.properties === "object" ? item.properties : null;
79+
const props =
80+
item.properties && typeof item.properties === "object"
81+
? item.properties
82+
: null;
7383
if (props && Object.prototype.hasOwnProperty.call(props, idKey)) {
7484
out.add(props[idKey]);
7585
continue;
@@ -86,8 +96,6 @@ function uniqueIds(arr, idKey) {
8696
return out;
8797
}
8898

89-
90-
9199
module.exports = {
92100
aSuccessfulRequest: function (res: {
93101
statusCode: number;
@@ -288,7 +296,6 @@ module.exports = {
288296
);
289297
},
290298

291-
292299
async compareWithProduction(queryParams = "", localResponse) {
293300
const prodUrl = `https://www.macrostrat.org/api/v2${queryParams}`;
294301
const { data: prodData } = await axios.get(prodUrl);
@@ -300,26 +307,31 @@ module.exports = {
300307

301308
// Lenient path for array-like payloads
302309
const localArr = extractArrayData(localResponse.body);
303-
const prodArr = extractArrayData(prodData);
304-
305-
if (Array.isArray(localArr) && Array.isArray(prodArr) && localArr.length && prodArr.length) {
310+
const prodArr = extractArrayData(prodData);
311+
312+
if (
313+
Array.isArray(localArr) &&
314+
Array.isArray(prodArr) &&
315+
localArr.length &&
316+
prodArr.length
317+
) {
306318
// Auto-detect a shared *_id (or "id") to compare by counts
307319
const idKey = chooseCommonIdKey(localArr, prodArr);
308320

309321
if (idKey) {
310322
console.info(`[compareWithProduction] Using id key: ${idKey}`);
311323
const localIds = uniqueIds(localArr, idKey);
312-
const prodIds = uniqueIds(prodArr, idKey);
324+
const prodIds = uniqueIds(prodArr, idKey);
313325
const localCount = localIds.size;
314-
const prodCount = prodIds.size;
326+
const prodCount = prodIds.size;
315327

316328
if (localCount !== prodCount) {
317329
console.warn(
318330
[
319331
`⚠️ ${idKey} count mismatch for endpoint: ${queryParams}`,
320332
` - Dev (current host) ${idKey} count: ${localCount}`,
321333
` - Prod (host_prod) ${idKey} count: ${prodCount}`,
322-
].join("\n")
334+
].join("\n"),
323335
);
324336

325337
return;
@@ -332,8 +344,8 @@ module.exports = {
332344
// Strict mismatch error with helpful diff
333345
throw new Error(
334346
`Mismatch for endpoint: ${queryParams}\n` +
335-
`Local: ${JSON.stringify(localResponse.body, null, 2)}\n` +
336-
`Production: ${JSON.stringify(prodData, null, 2)}`
347+
`Local: ${JSON.stringify(localResponse.body, null, 2)}\n` +
348+
`Production: ${JSON.stringify(prodData, null, 2)}`,
337349
);
338350
},
339351
};

v2/definitions/projects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ module.exports = function (req, res, next, cb) {
9292
);
9393
}
9494
});
95-
};
95+
};

0 commit comments

Comments
 (0)