indexwright 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/LICENSE +201 -0
- package/README.md +184 -0
- package/SPEC.md +386 -0
- package/dist/args.d.ts +26 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +170 -0
- package/dist/args.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +96 -0
- package/dist/cli.js.map +1 -0
- package/dist/collections.d.ts +6 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +25 -0
- package/dist/collections.js.map +1 -0
- package/dist/format/github.d.ts +13 -0
- package/dist/format/github.d.ts.map +1 -0
- package/dist/format/github.js +63 -0
- package/dist/format/github.js.map +1 -0
- package/dist/format/inline.d.ts +11 -0
- package/dist/format/inline.d.ts.map +1 -0
- package/dist/format/inline.js +15 -0
- package/dist/format/inline.js.map +1 -0
- package/dist/format/json.d.ts +7 -0
- package/dist/format/json.d.ts.map +1 -0
- package/dist/format/json.js +25 -0
- package/dist/format/json.js.map +1 -0
- package/dist/format/text.d.ts +3 -0
- package/dist/format/text.d.ts.map +1 -0
- package/dist/format/text.js +65 -0
- package/dist/format/text.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/key.d.ts +35 -0
- package/dist/key.d.ts.map +1 -0
- package/dist/key.js +76 -0
- package/dist/key.js.map +1 -0
- package/dist/lint.d.ts +22 -0
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +110 -0
- package/dist/lint.js.map +1 -0
- package/dist/parse.d.ts +11 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +88 -0
- package/dist/parse.js.map +1 -0
- package/dist/rules/explicit-name-field.d.ts +13 -0
- package/dist/rules/explicit-name-field.d.ts.map +1 -0
- package/dist/rules/explicit-name-field.js +35 -0
- package/dist/rules/explicit-name-field.js.map +1 -0
- package/dist/rules/field-order-variant.d.ts +10 -0
- package/dist/rules/field-order-variant.d.ts.map +1 -0
- package/dist/rules/field-order-variant.js +60 -0
- package/dist/rules/field-order-variant.js.map +1 -0
- package/dist/rules/index.d.ts +13 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +25 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/quota-headroom.d.ts +10 -0
- package/dist/rules/quota-headroom.d.ts.map +1 -0
- package/dist/rules/quota-headroom.js +40 -0
- package/dist/rules/quota-headroom.js.map +1 -0
- package/dist/rules/scope-mismatch.d.ts +10 -0
- package/dist/rules/scope-mismatch.d.ts.map +1 -0
- package/dist/rules/scope-mismatch.js +45 -0
- package/dist/rules/scope-mismatch.js.map +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/package.json +54 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes indexwright reads and produces.
|
|
3
|
+
*
|
|
4
|
+
* The input types mirror `firestore.indexes.json` loosely on purpose: unknown keys are carried
|
|
5
|
+
* through rather than rejected, so a field added by a future Firebase release does not break
|
|
6
|
+
* linting (SPEC §9).
|
|
7
|
+
*/
|
|
8
|
+
/** One entry of an index's `fields` array. */
|
|
9
|
+
export interface IndexField {
|
|
10
|
+
fieldPath: string;
|
|
11
|
+
/** `ASCENDING` or `DESCENDING` in practice; not validated against an enumeration. */
|
|
12
|
+
order?: string;
|
|
13
|
+
/** `CONTAINS` in practice; not validated against an enumeration. */
|
|
14
|
+
arrayConfig?: string;
|
|
15
|
+
vectorConfig?: Record<string, unknown>;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
/** One entry of the document's `indexes` array. */
|
|
19
|
+
export interface CompositeIndex {
|
|
20
|
+
collectionGroup: string;
|
|
21
|
+
/** `COLLECTION` or `COLLECTION_GROUP` in practice; not validated against an enumeration. */
|
|
22
|
+
queryScope: string;
|
|
23
|
+
fields: IndexField[];
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
/** A parsed and validated `firestore.indexes.json`. */
|
|
27
|
+
export interface IndexDocument {
|
|
28
|
+
indexes: CompositeIndex[];
|
|
29
|
+
fieldOverrides?: unknown[];
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** A field reduced to the two things the canonical key is built from. */
|
|
33
|
+
export interface CanonicalField {
|
|
34
|
+
fieldPath: string;
|
|
35
|
+
/** `ASCENDING`, `DESCENDING`, `CONTAINS`, or `VECTOR(<dimension>)`. */
|
|
36
|
+
direction: string;
|
|
37
|
+
}
|
|
38
|
+
/** An index with its canonical form precomputed, so every rule shares one interpretation. */
|
|
39
|
+
export interface AnalysedIndex {
|
|
40
|
+
/** The declaration as written, including any keys indexwright does not understand. */
|
|
41
|
+
readonly source: CompositeIndex;
|
|
42
|
+
/** Position within the document's `indexes` array, for messages that need to point at one. */
|
|
43
|
+
readonly position: number;
|
|
44
|
+
readonly collectionGroup: string;
|
|
45
|
+
readonly queryScope: string;
|
|
46
|
+
/** Canonicalised fields: a trailing implicit `__name__` has been removed. */
|
|
47
|
+
readonly fields: readonly CanonicalField[];
|
|
48
|
+
readonly key: string;
|
|
49
|
+
/**
|
|
50
|
+
* The direction of a trailing `__name__` that matched the implicit default and was therefore
|
|
51
|
+
* removed, or `null` when the declaration had no redundant `__name__`.
|
|
52
|
+
*/
|
|
53
|
+
readonly redundantNameDirection: string | null;
|
|
54
|
+
}
|
|
55
|
+
export declare const RULE_IDS: readonly ["scope-mismatch", "field-order-variant", "explicit-name-field", "quota-headroom"];
|
|
56
|
+
export type RuleId = (typeof RULE_IDS)[number];
|
|
57
|
+
/** A single warning. Never an error: see SPEC §7. */
|
|
58
|
+
export interface Finding {
|
|
59
|
+
rule: RuleId;
|
|
60
|
+
file: string;
|
|
61
|
+
/** `null` when the finding is about the file rather than about one index. */
|
|
62
|
+
key: string | null;
|
|
63
|
+
message: string;
|
|
64
|
+
/** Other keys in the same finding group, sorted ascending. `[]` when there are none. */
|
|
65
|
+
related: string[];
|
|
66
|
+
}
|
|
67
|
+
/** A file that could not be read or parsed. Distinct from a finding. */
|
|
68
|
+
export interface LintError {
|
|
69
|
+
file: string;
|
|
70
|
+
message: string;
|
|
71
|
+
}
|
|
72
|
+
export interface LintSummary {
|
|
73
|
+
warnings: number;
|
|
74
|
+
errors: number;
|
|
75
|
+
/** One entry per rule that ran, including rules that found nothing. */
|
|
76
|
+
byRule: Record<string, number>;
|
|
77
|
+
}
|
|
78
|
+
export interface LintResult {
|
|
79
|
+
version: string;
|
|
80
|
+
files: string[];
|
|
81
|
+
summary: LintSummary;
|
|
82
|
+
findings: Finding[];
|
|
83
|
+
errors: LintError[];
|
|
84
|
+
}
|
|
85
|
+
export interface RuleOptions {
|
|
86
|
+
/** Per-database composite index limit used by `quota-headroom`. */
|
|
87
|
+
quota: number;
|
|
88
|
+
/** Fraction of `quota` above which `quota-headroom` warns. */
|
|
89
|
+
quotaThreshold: number;
|
|
90
|
+
}
|
|
91
|
+
export interface RuleContext {
|
|
92
|
+
file: string;
|
|
93
|
+
document: IndexDocument;
|
|
94
|
+
indexes: readonly AnalysedIndex[];
|
|
95
|
+
options: RuleOptions;
|
|
96
|
+
}
|
|
97
|
+
export interface Rule {
|
|
98
|
+
readonly id: RuleId;
|
|
99
|
+
/** One line, used by `--help`. */
|
|
100
|
+
readonly description: string;
|
|
101
|
+
check(context: RuleContext): Finding[];
|
|
102
|
+
}
|
|
103
|
+
export type OutputFormat = 'text' | 'json' | 'github';
|
|
104
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,EAAE,CAAC;CACxC;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes indexwright reads and produces.
|
|
3
|
+
*
|
|
4
|
+
* The input types mirror `firestore.indexes.json` loosely on purpose: unknown keys are carried
|
|
5
|
+
* through rather than rejected, so a field added by a future Firebase release does not break
|
|
6
|
+
* linting (SPEC §9).
|
|
7
|
+
*/
|
|
8
|
+
export const RULE_IDS = [
|
|
9
|
+
'scope-mismatch',
|
|
10
|
+
'field-order-variant',
|
|
11
|
+
'explicit-name-field',
|
|
12
|
+
'quota-headroom',
|
|
13
|
+
];
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsDH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,gBAAgB;IAChB,qBAAqB;IACrB,qBAAqB;IACrB,gBAAgB;CACR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,OAAO,EAAE,MAAsB,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
/**
|
|
3
|
+
* Read from package.json rather than duplicated in source, so a release cannot ship a `version`
|
|
4
|
+
* field in the JSON output that disagrees with the package it came from.
|
|
5
|
+
*/
|
|
6
|
+
function readVersion() {
|
|
7
|
+
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
8
|
+
return typeof manifest.version === 'string' ? manifest.version : '0.0.0';
|
|
9
|
+
}
|
|
10
|
+
export const VERSION = readVersion();
|
|
11
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;GAGG;AACH,SAAS,WAAW;IAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACzB,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CACzC,CAAC;IAC3B,OAAO,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAC3E,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAW,WAAW,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "indexwright",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Linter for Firestore composite index declarations (firestore.indexes.json)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"firestore",
|
|
7
|
+
"firebase",
|
|
8
|
+
"index",
|
|
9
|
+
"composite-index",
|
|
10
|
+
"linter",
|
|
11
|
+
"static-analysis"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/uny/indexwright#readme",
|
|
14
|
+
"bugs": "https://github.com/uny/indexwright/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/uny/indexwright.git"
|
|
18
|
+
},
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"author": "Yuki Nagai",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"bin": {
|
|
23
|
+
"indexwright": "dist/cli.js"
|
|
24
|
+
},
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"SPEC.md",
|
|
37
|
+
"CHANGELOG.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=22"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc --build --force",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"test": "npm run build && node --test \"test/*.test.js\"",
|
|
47
|
+
"verify-package": "npm run build && node scripts/verify-package.mjs",
|
|
48
|
+
"prepublishOnly": "npm run build"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^22.10.2",
|
|
52
|
+
"typescript": "^5.7.2"
|
|
53
|
+
}
|
|
54
|
+
}
|