Skip to content

Commit a1f7d66

Browse files
authored
Merge branch 'main' into chore/renovateBaseBranch
2 parents 9d1b089 + 53c6e8a commit a1f7d66

File tree

25 files changed

+174
-73
lines changed

25 files changed

+174
-73
lines changed

.eslintrc.cjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,20 @@ module.exports = {
5151
files: ['specs/**/*.yml'],
5252
rules: {
5353
'automation-custom/end-with-dot': 'error',
54+
'automation-custom/no-big-int': 'error',
5455
'automation-custom/no-final-dot': 'error',
5556
'automation-custom/single-quote-ref': 'error',
5657
},
5758
overrides: [
5859
{
5960
files: ['!specs/bundled/*.yml'],
6061
rules: {
61-
'automation-custom/out-of-line-enum': 'error',
62-
'automation-custom/out-of-line-one-of': 'error',
6362
'automation-custom/out-of-line-all-of': 'error',
6463
'automation-custom/out-of-line-any-of': 'error',
65-
'automation-custom/valid-acl': 'error',
64+
'automation-custom/out-of-line-enum': 'error',
65+
'automation-custom/out-of-line-one-of': 'error',
6666
'automation-custom/ref-common': 'error',
67+
'automation-custom/valid-acl': 'error',
6768
'automation-custom/valid-inline-title': 'error',
6869
},
6970
},

eslint/src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { endWithDot } from './rules/endWithDot.js';
2+
import { noBigInt } from './rules/noBigInt.js';
23
import { noFinalDot } from './rules/noFinalDot.js';
34
import { noNewLine } from './rules/noNewLine.js';
45
import { createOutOfLineRule } from './rules/outOfLineRule.js';
@@ -9,15 +10,16 @@ import { validInlineTitle } from './rules/validInlineTitle.js';
910

1011
const rules = {
1112
'end-with-dot': endWithDot,
13+
'no-big-int': noBigInt,
1214
'no-final-dot': noFinalDot,
13-
'out-of-line-enum': createOutOfLineRule({ property: 'enum' }),
14-
'out-of-line-one-of': createOutOfLineRule({ property: 'oneOf' }),
15+
'no-new-line': noNewLine,
1516
'out-of-line-all-of': createOutOfLineRule({ property: 'allOf' }),
1617
'out-of-line-any-of': createOutOfLineRule({ property: 'anyOf' }),
18+
'out-of-line-enum': createOutOfLineRule({ property: 'enum' }),
19+
'out-of-line-one-of': createOutOfLineRule({ property: 'oneOf' }),
20+
'ref-common': refCommon,
1721
'single-quote-ref': singleQuoteRef,
1822
'valid-acl': validACL,
19-
'no-new-line': noNewLine,
20-
'ref-common': refCommon,
2123
'valid-inline-title': validInlineTitle,
2224
};
2325

eslint/src/rules/noBigInt.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { createRule } from 'eslint-plugin-yml/lib/utils';
2+
3+
import { isPairWithKey, isScalar } from '../utils.js';
4+
5+
// type: number with format: int64 will generate a BigInteger which is not nice to use, most of the time we only need int, long, float or double.
6+
export const noBigInt = createRule('noBigInt', {
7+
meta: {
8+
docs: {
9+
description: 'type big integer is forbidden, did you mean type: integer ?',
10+
categories: null,
11+
extensionRule: false,
12+
layout: false,
13+
},
14+
messages: {
15+
noBigInt: 'type big integer is forbidden, did you mean type: integer ?',
16+
},
17+
type: 'layout',
18+
schema: [],
19+
},
20+
create(context) {
21+
if (!context.getSourceCode().parserServices.isYAML) {
22+
return {};
23+
}
24+
25+
return {
26+
YAMLPair(node): void {
27+
if (!isPairWithKey(node, 'type')) {
28+
return;
29+
}
30+
31+
if (!isScalar(node.value) || node.value.value !== 'number') {
32+
return;
33+
}
34+
35+
// check the format next to the type
36+
node.parent.pairs.find((pair) => {
37+
if (isPairWithKey(pair, 'format') && isScalar(pair.value) && (pair.value.value === 'int32' || pair.value.value === 'int64')) {
38+
context.report({
39+
node: pair.value as any,
40+
messageId: 'noBigInt',
41+
});
42+
}
43+
});
44+
},
45+
};
46+
},
47+
});

eslint/tests/noBigInt.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { runClassic } from 'eslint-vitest-rule-tester';
2+
import yamlParser from 'yaml-eslint-parser';
3+
import { noBigInt } from '../src/rules/noBigInt.js';
4+
5+
6+
runClassic(
7+
'no-big-int',
8+
noBigInt,
9+
{
10+
valid: [`
11+
type: object
12+
properties:
13+
id:
14+
type: number
15+
format: float
16+
url:
17+
type: string
18+
format: uri
19+
`, `
20+
prop:
21+
type: integer
22+
format: int32
23+
`],
24+
invalid: [
25+
{
26+
code: `
27+
type: object
28+
properties:
29+
id:
30+
type: number
31+
format: int64
32+
url:
33+
type: string
34+
format: uri
35+
`,
36+
errors: [{ messageId: 'noBigInt' }],
37+
},
38+
{
39+
code: `
40+
prop:
41+
type: number
42+
format: int32
43+
`,
44+
errors: [{ messageId: 'noBigInt' }],
45+
},
46+
],
47+
},
48+
{
49+
parser: yamlParser,
50+
},
51+
);

tests/output/csharp/src/generated/e2e/Insights.test.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public async Task PushEventsTest1()
6363
Index = "products",
6464
UserToken = "user-123456",
6565
AuthenticatedUserToken = "user-123456",
66-
Timestamp = 1730937600000L,
66+
Timestamp = 1731196800000L,
6767
ObjectIDs = new List<string> { "9780545139700", "9780439784542" },
6868
QueryID = "43b15df305339e827f0ac0bdc5ebcaa7",
6969
}
@@ -76,7 +76,7 @@ public async Task PushEventsTest1()
7676
Index = "products",
7777
UserToken = "user-123456",
7878
AuthenticatedUserToken = "user-123456",
79-
Timestamp = 1730937600000L,
79+
Timestamp = 1731196800000L,
8080
ObjectIDs = new List<string> { "9780545139700", "9780439784542" },
8181
}
8282
),

tests/output/csharp/src/generated/requests/Insights.test.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ await client.PushEventsAsync(
580580
Index = "products",
581581
UserToken = "user-123456",
582582
AuthenticatedUserToken = "user-123456",
583-
Timestamp = 1730937600000L,
583+
Timestamp = 1731196800000L,
584584
ObjectIDs = new List<string> { "9780545139700", "9780439784542" },
585585
QueryID = "43b15df305339e827f0ac0bdc5ebcaa7",
586586
}
@@ -593,7 +593,7 @@ await client.PushEventsAsync(
593593
Index = "products",
594594
UserToken = "user-123456",
595595
AuthenticatedUserToken = "user-123456",
596-
Timestamp = 1730937600000L,
596+
Timestamp = 1731196800000L,
597597
ObjectIDs = new List<string> { "9780545139700", "9780439784542" },
598598
}
599599
),
@@ -605,7 +605,7 @@ await client.PushEventsAsync(
605605
Assert.Equal("/1/events", req.Path);
606606
Assert.Equal("POST", req.Method.ToString());
607607
JsonAssert.EqualOverrideDefault(
608-
"{\"events\":[{\"eventType\":\"conversion\",\"eventName\":\"Product Purchased\",\"index\":\"products\",\"userToken\":\"user-123456\",\"authenticatedUserToken\":\"user-123456\",\"timestamp\":1730937600000,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\"},{\"eventType\":\"view\",\"eventName\":\"Product Detail Page Viewed\",\"index\":\"products\",\"userToken\":\"user-123456\",\"authenticatedUserToken\":\"user-123456\",\"timestamp\":1730937600000,\"objectIDs\":[\"9780545139700\",\"9780439784542\"]}]}",
608+
"{\"events\":[{\"eventType\":\"conversion\",\"eventName\":\"Product Purchased\",\"index\":\"products\",\"userToken\":\"user-123456\",\"authenticatedUserToken\":\"user-123456\",\"timestamp\":1731196800000,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\"},{\"eventType\":\"view\",\"eventName\":\"Product Detail Page Viewed\",\"index\":\"products\",\"userToken\":\"user-123456\",\"authenticatedUserToken\":\"user-123456\",\"timestamp\":1731196800000,\"objectIDs\":[\"9780545139700\",\"9780439784542\"]}]}",
609609
req.Body,
610610
new JsonDiffConfig(false)
611611
);

tests/output/dart/test/requests/insights_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ void main() {
635635
index: "products",
636636
userToken: "user-123456",
637637
authenticatedUserToken: "user-123456",
638-
timestamp: 1730937600000,
638+
timestamp: 1731196800000,
639639
objectIDs: [
640640
"9780545139700",
641641
"9780439784542",
@@ -648,7 +648,7 @@ void main() {
648648
index: "products",
649649
userToken: "user-123456",
650650
authenticatedUserToken: "user-123456",
651-
timestamp: 1730937600000,
651+
timestamp: 1731196800000,
652652
objectIDs: [
653653
"9780545139700",
654654
"9780439784542",
@@ -661,7 +661,7 @@ void main() {
661661
expectPath(request.path, '/1/events');
662662
expect(request.method, 'post');
663663
expectBody(request.body,
664-
"""{"events":[{"eventType":"conversion","eventName":"Product Purchased","index":"products","userToken":"user-123456","authenticatedUserToken":"user-123456","timestamp":1730937600000,"objectIDs":["9780545139700","9780439784542"],"queryID":"43b15df305339e827f0ac0bdc5ebcaa7"},{"eventType":"view","eventName":"Product Detail Page Viewed","index":"products","userToken":"user-123456","authenticatedUserToken":"user-123456","timestamp":1730937600000,"objectIDs":["9780545139700","9780439784542"]}]}""");
664+
"""{"events":[{"eventType":"conversion","eventName":"Product Purchased","index":"products","userToken":"user-123456","authenticatedUserToken":"user-123456","timestamp":1731196800000,"objectIDs":["9780545139700","9780439784542"],"queryID":"43b15df305339e827f0ac0bdc5ebcaa7"},{"eventType":"view","eventName":"Product Detail Page Viewed","index":"products","userToken":"user-123456","authenticatedUserToken":"user-123456","timestamp":1731196800000,"objectIDs":["9780545139700","9780439784542"]}]}""");
665665
},
666666
),
667667
);

tests/output/go/tests/e2e/insights_test.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/output/go/tests/requests/insights_test.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/output/java/src/test/java/com/algolia/e2e/Insights.test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void pushEventsTest1() {
5050
.setIndex("products")
5151
.setUserToken("user-123456")
5252
.setAuthenticatedUserToken("user-123456")
53-
.setTimestamp(1730937600000L)
53+
.setTimestamp(1731196800000L)
5454
.setObjectIDs(Arrays.asList("9780545139700", "9780439784542"))
5555
.setQueryID("43b15df305339e827f0ac0bdc5ebcaa7"),
5656
new ViewedObjectIDs()
@@ -59,7 +59,7 @@ void pushEventsTest1() {
5959
.setIndex("products")
6060
.setUserToken("user-123456")
6161
.setAuthenticatedUserToken("user-123456")
62-
.setTimestamp(1730937600000L)
62+
.setTimestamp(1731196800000L)
6363
.setObjectIDs(Arrays.asList("9780545139700", "9780439784542"))
6464
)
6565
)

tests/output/java/src/test/java/com/algolia/requests/Insights.test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ void pushEventsTest1() {
720720
.setIndex("products")
721721
.setUserToken("user-123456")
722722
.setAuthenticatedUserToken("user-123456")
723-
.setTimestamp(1730937600000L)
723+
.setTimestamp(1731196800000L)
724724
.setObjectIDs(Arrays.asList("9780545139700", "9780439784542"))
725725
.setQueryID("43b15df305339e827f0ac0bdc5ebcaa7"),
726726
new ViewedObjectIDs()
@@ -729,7 +729,7 @@ void pushEventsTest1() {
729729
.setIndex("products")
730730
.setUserToken("user-123456")
731731
.setAuthenticatedUserToken("user-123456")
732-
.setTimestamp(1730937600000L)
732+
.setTimestamp(1731196800000L)
733733
.setObjectIDs(Arrays.asList("9780545139700", "9780439784542"))
734734
)
735735
)
@@ -741,9 +741,9 @@ void pushEventsTest1() {
741741
assertDoesNotThrow(() ->
742742
JSONAssert.assertEquals(
743743
"{\"events\":[{\"eventType\":\"conversion\",\"eventName\":\"Product" +
744-
" Purchased\",\"index\":\"products\",\"userToken\":\"user-123456\",\"authenticatedUserToken\":\"user-123456\",\"timestamp\":1730937600000,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\"},{\"eventType\":\"view\",\"eventName\":\"Product" +
744+
" Purchased\",\"index\":\"products\",\"userToken\":\"user-123456\",\"authenticatedUserToken\":\"user-123456\",\"timestamp\":1731196800000,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\"},{\"eventType\":\"view\",\"eventName\":\"Product" +
745745
" Detail Page" +
746-
" Viewed\",\"index\":\"products\",\"userToken\":\"user-123456\",\"authenticatedUserToken\":\"user-123456\",\"timestamp\":1730937600000,\"objectIDs\":[\"9780545139700\",\"9780439784542\"]}]}",
746+
" Viewed\",\"index\":\"products\",\"userToken\":\"user-123456\",\"authenticatedUserToken\":\"user-123456\",\"timestamp\":1731196800000,\"objectIDs\":[\"9780545139700\",\"9780439784542\"]}]}",
747747
req.body,
748748
JSONCompareMode.STRICT
749749
)

tests/output/javascript/src/e2e/insights.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('pushEvents', () => {
3030
index: 'products',
3131
userToken: 'user-123456',
3232
authenticatedUserToken: 'user-123456',
33-
timestamp: 1730937600000,
33+
timestamp: 1731196800000,
3434
objectIDs: ['9780545139700', '9780439784542'],
3535
queryID: '43b15df305339e827f0ac0bdc5ebcaa7',
3636
},
@@ -40,7 +40,7 @@ describe('pushEvents', () => {
4040
index: 'products',
4141
userToken: 'user-123456',
4242
authenticatedUserToken: 'user-123456',
43-
timestamp: 1730937600000,
43+
timestamp: 1731196800000,
4444
objectIDs: ['9780545139700', '9780439784542'],
4545
},
4646
],

tests/output/javascript/src/requests/insights.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ describe('pushEvents', () => {
311311
index: 'products',
312312
userToken: 'user-123456',
313313
authenticatedUserToken: 'user-123456',
314-
timestamp: 1730937600000,
314+
timestamp: 1731196800000,
315315
objectIDs: ['9780545139700', '9780439784542'],
316316
queryID: '43b15df305339e827f0ac0bdc5ebcaa7',
317317
},
@@ -321,7 +321,7 @@ describe('pushEvents', () => {
321321
index: 'products',
322322
userToken: 'user-123456',
323323
authenticatedUserToken: 'user-123456',
324-
timestamp: 1730937600000,
324+
timestamp: 1731196800000,
325325
objectIDs: ['9780545139700', '9780439784542'],
326326
},
327327
],
@@ -337,7 +337,7 @@ describe('pushEvents', () => {
337337
index: 'products',
338338
userToken: 'user-123456',
339339
authenticatedUserToken: 'user-123456',
340-
timestamp: 1730937600000,
340+
timestamp: 1731196800000,
341341
objectIDs: ['9780545139700', '9780439784542'],
342342
queryID: '43b15df305339e827f0ac0bdc5ebcaa7',
343343
},
@@ -347,7 +347,7 @@ describe('pushEvents', () => {
347347
index: 'products',
348348
userToken: 'user-123456',
349349
authenticatedUserToken: 'user-123456',
350-
timestamp: 1730937600000,
350+
timestamp: 1731196800000,
351351
objectIDs: ['9780545139700', '9780439784542'],
352352
},
353353
],

tests/output/kotlin/src/commonTest/kotlin/com/algolia/e2e/InsightsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class InsightsTest {
4141
index = "products",
4242
userToken = "user-123456",
4343
authenticatedUserToken = "user-123456",
44-
timestamp = 1730937600000L,
44+
timestamp = 1731196800000L,
4545
objectIDs = listOf("9780545139700", "9780439784542"),
4646
queryID = "43b15df305339e827f0ac0bdc5ebcaa7",
4747
),
@@ -51,7 +51,7 @@ class InsightsTest {
5151
index = "products",
5252
userToken = "user-123456",
5353
authenticatedUserToken = "user-123456",
54-
timestamp = 1730937600000L,
54+
timestamp = 1731196800000L,
5555
objectIDs = listOf("9780545139700", "9780439784542"),
5656
),
5757
),

0 commit comments

Comments
 (0)