@dereekb/firebase 13.11.15 → 13.11.16
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/eslint/index.cjs.default.js +1 -0
- package/eslint/index.cjs.js +2290 -0
- package/eslint/index.cjs.mjs +2 -0
- package/eslint/index.d.ts +1 -0
- package/eslint/index.esm.js +2277 -0
- package/eslint/package.json +24 -0
- package/eslint/src/index.d.ts +1 -0
- package/eslint/src/lib/comments.d.ts +112 -0
- package/eslint/src/lib/dbx-tag-families.d.ts +280 -0
- package/eslint/src/lib/index.d.ts +6 -0
- package/eslint/src/lib/jsdoc-parser.d.ts +116 -0
- package/eslint/src/lib/plugin.d.ts +28 -0
- package/eslint/src/lib/require-dbx-model-firebase-index-companion-tags.rule.d.ts +47 -0
- package/eslint/src/lib/require-dbx-model-firebase-index-query-suffix.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-model-firebase-index-valid-dispatcher.rule.d.ts +54 -0
- package/eslint/src/lib/require-tagged-firestore-constraints.rule.d.ts +46 -0
- package/eslint/src/lib/util.d.ts +107 -0
- package/package.json +11 -5
- package/test/package.json +6 -6
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type AstNode } from './util';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the require-dbx-model-firebase-index-valid-dispatcher rule.
|
|
4
|
+
*/
|
|
5
|
+
export interface FirebaseRequireDbxModelFirebaseIndexValidDispatcherRuleOptions {
|
|
6
|
+
readonly constraintNames?: readonly string[];
|
|
7
|
+
readonly allowedImportSources?: readonly string[];
|
|
8
|
+
readonly markerTag?: string;
|
|
9
|
+
readonly dispatcherTag?: string;
|
|
10
|
+
readonly presumedTaggedSuffix?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ESLint rule definition for require-dbx-model-firebase-index-valid-dispatcher.
|
|
14
|
+
*/
|
|
15
|
+
export interface FirebaseRequireDbxModelFirebaseIndexValidDispatcherRuleDefinition {
|
|
16
|
+
readonly meta: {
|
|
17
|
+
readonly type: 'problem';
|
|
18
|
+
readonly fixable: undefined;
|
|
19
|
+
readonly docs: {
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly recommended: boolean;
|
|
22
|
+
};
|
|
23
|
+
readonly messages: Readonly<Record<string, string>>;
|
|
24
|
+
readonly schema: readonly object[];
|
|
25
|
+
};
|
|
26
|
+
create(context: {
|
|
27
|
+
options: FirebaseRequireDbxModelFirebaseIndexValidDispatcherRuleOptions[];
|
|
28
|
+
report: (descriptor: {
|
|
29
|
+
node: AstNode;
|
|
30
|
+
messageId: string;
|
|
31
|
+
data?: Record<string, string>;
|
|
32
|
+
}) => void;
|
|
33
|
+
sourceCode: AstNode;
|
|
34
|
+
}): Record<string, (node: AstNode) => void>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* ESLint rule enforcing that `@dbxModelFirebaseIndexDispatcher`-tagged factories delegate to
|
|
38
|
+
* other `@dbxModelFirebaseIndex`-tagged query factories instead of building constraints directly.
|
|
39
|
+
*
|
|
40
|
+
* A dispatcher must never:
|
|
41
|
+
*
|
|
42
|
+
* 1. Call a `@dereekb/firebase` constraint factory (`where`/`orderBy`/`limit`/...) directly.
|
|
43
|
+
* 2. Construct its own `FirestoreQueryConstraint[]` array via `[].push(...)`-style assembly.
|
|
44
|
+
*
|
|
45
|
+
* Permitted bodies return another tagged factory's result directly, spread several tagged
|
|
46
|
+
* factories' results into a return array, or use a conditional to pick between tagged
|
|
47
|
+
* factories — matching the dispatcher pattern documented at
|
|
48
|
+
* `packages/dbx-components-mcp/src/tools/validate-app-model-firebase-index.tool.ts`.
|
|
49
|
+
*
|
|
50
|
+
* Not auto-fixable: extracting an inline constraint into a sibling tagged factory requires
|
|
51
|
+
* choosing a name + signature + call-site replacement that is outside the safe scope of an
|
|
52
|
+
* ESLint autofix.
|
|
53
|
+
*/
|
|
54
|
+
export declare const FIREBASE_REQUIRE_DBX_MODEL_FIREBASE_INDEX_VALID_DISPATCHER_RULE: FirebaseRequireDbxModelFirebaseIndexValidDispatcherRuleDefinition;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type AstNode } from './util';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the require-tagged-firestore-constraints rule.
|
|
4
|
+
*/
|
|
5
|
+
export interface FirebaseRequireTaggedFirestoreConstraintsRuleOptions {
|
|
6
|
+
readonly constraintNames?: readonly string[];
|
|
7
|
+
readonly additionalConstraintNames?: readonly string[];
|
|
8
|
+
readonly allowedImportSources?: readonly string[];
|
|
9
|
+
readonly markerTag?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* ESLint rule definition for require-tagged-firestore-constraints.
|
|
13
|
+
*/
|
|
14
|
+
export interface FirebaseRequireTaggedFirestoreConstraintsRuleDefinition {
|
|
15
|
+
readonly meta: {
|
|
16
|
+
readonly type: 'problem';
|
|
17
|
+
readonly fixable: undefined;
|
|
18
|
+
readonly docs: {
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly recommended: boolean;
|
|
21
|
+
};
|
|
22
|
+
readonly messages: Readonly<Record<string, string>>;
|
|
23
|
+
readonly schema: readonly object[];
|
|
24
|
+
};
|
|
25
|
+
create(context: {
|
|
26
|
+
options: FirebaseRequireTaggedFirestoreConstraintsRuleOptions[];
|
|
27
|
+
report: (descriptor: {
|
|
28
|
+
node: AstNode;
|
|
29
|
+
messageId: string;
|
|
30
|
+
data?: Record<string, string>;
|
|
31
|
+
}) => void;
|
|
32
|
+
sourceCode: AstNode;
|
|
33
|
+
}): Record<string, (node: AstNode) => void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ESLint rule that forbids inline `@dereekb/firebase` Firestore constraint factory calls
|
|
37
|
+
* (`where`, `orderBy`, `limit`, ...) outside a function whose leading JSDoc carries the
|
|
38
|
+
* `@dbxModelFirebaseIndex` marker. The dbx-components-mcp index extractor only sees
|
|
39
|
+
* constraints inside tagged factories — anything else is invisible to index generation
|
|
40
|
+
* and must be extracted into a dedicated `*Query` factory.
|
|
41
|
+
*
|
|
42
|
+
* Not auto-fixable: extracting an inline constraint into a new function requires choosing
|
|
43
|
+
* a name, signature, and call-site replacement that are outside the safe scope of an ESLint
|
|
44
|
+
* autofix.
|
|
45
|
+
*/
|
|
46
|
+
export declare const FIREBASE_REQUIRE_TAGGED_FIRESTORE_CONSTRAINTS_RULE: FirebaseRequireTaggedFirestoreConstraintsRuleDefinition;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Maybe } from '@dereekb/util';
|
|
2
|
+
/**
|
|
3
|
+
* Module that publishes the `@dereekb/firebase` Firestore constraint factories (`where`, `orderBy`, etc.).
|
|
4
|
+
*/
|
|
5
|
+
export declare const FIREBASE_MODULE = "@dereekb/firebase";
|
|
6
|
+
/**
|
|
7
|
+
* JSDoc tag name that marks an exported query factory whose body should be scanned by
|
|
8
|
+
* `dbx-components-mcp`'s index extractor (`packages/dbx-components-mcp/src/scan/model-firebase-index-extract.ts`).
|
|
9
|
+
*/
|
|
10
|
+
export declare const DBX_MODEL_FIREBASE_INDEX_MARKER = "dbxModelFirebaseIndex";
|
|
11
|
+
/**
|
|
12
|
+
* The canonical suffix expected on every `@dbxModelFirebaseIndex`-tagged factory name.
|
|
13
|
+
*/
|
|
14
|
+
export declare const QUERY_SUFFIX = "Query";
|
|
15
|
+
/**
|
|
16
|
+
* Index-affecting Firestore constraint factory identifiers exported from `@dereekb/firebase`
|
|
17
|
+
* (see `packages/firebase/src/lib/common/firestore/query/constraint.ts`). These shape the
|
|
18
|
+
* composite index Firestore needs to satisfy the query — calls to them must originate inside
|
|
19
|
+
* a `@dbxModelFirebaseIndex`-tagged function so the dbx-components-mcp index extractor can
|
|
20
|
+
* collect them.
|
|
21
|
+
*
|
|
22
|
+
* `where` and `orderBy` are the only constraint factories that influence composite indexes;
|
|
23
|
+
* pagination/cursor factories (`limit`, `limitToLast`, `whereDocumentId`, `startAt`/`After`,
|
|
24
|
+
* `endAt`/`Before`) only narrow the cursor/window of an already-indexed query and may be
|
|
25
|
+
* composed freely outside tagged factories — see {@link DEFAULT_PAGINATION_CONSTRAINT_NAMES}.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DEFAULT_INDEX_AFFECTING_CONSTRAINT_NAMES: readonly string[];
|
|
28
|
+
/**
|
|
29
|
+
* Pagination/cursor Firestore constraint factory identifiers exported from `@dereekb/firebase`.
|
|
30
|
+
* These do not influence composite indexes and may be composed externally — e.g. a generic
|
|
31
|
+
* pagination helper that appends `limit` + `startAfter` onto a caller-supplied tagged-query
|
|
32
|
+
* constraint array. The "tagged-firestore-constraints" rule does not flag calls to these by
|
|
33
|
+
* default.
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_PAGINATION_CONSTRAINT_NAMES: readonly string[];
|
|
36
|
+
/**
|
|
37
|
+
* Combined list of every Firestore constraint factory exported from `@dereekb/firebase`. Used
|
|
38
|
+
* by the body-coherence rule to ensure a tagged factory body contains at least one constraint
|
|
39
|
+
* call of any kind (index-affecting or pagination) before warning that the marker is orphaned.
|
|
40
|
+
*/
|
|
41
|
+
export declare const DEFAULT_CONSTRAINT_FACTORY_NAMES: readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* Loose AST node alias used by the rule implementations.
|
|
44
|
+
*/
|
|
45
|
+
export type AstNode = any;
|
|
46
|
+
/**
|
|
47
|
+
* Per-file registry of import information used by the firebase-eslint rules.
|
|
48
|
+
*
|
|
49
|
+
* `localToImported` maps the local binding name (which may be a rename, e.g. `fbWhere` from
|
|
50
|
+
* `import { where as fbWhere }`) back to the imported name (`where`) — the rules check the
|
|
51
|
+
* imported name against the firestore-constraint allowlist.
|
|
52
|
+
*/
|
|
53
|
+
export interface ImportRegistry {
|
|
54
|
+
readonly bySource: Map<string, Set<string>>;
|
|
55
|
+
readonly localToSource: Map<string, string>;
|
|
56
|
+
readonly localToImported: Map<string, string>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates an empty {@link ImportRegistry}.
|
|
60
|
+
*
|
|
61
|
+
* @returns A fresh empty registry.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createImportRegistry(): ImportRegistry;
|
|
64
|
+
/**
|
|
65
|
+
* Records an `ImportDeclaration` node in the registry.
|
|
66
|
+
*
|
|
67
|
+
* @param registry - The registry to mutate.
|
|
68
|
+
* @param node - The ImportDeclaration AST node.
|
|
69
|
+
*/
|
|
70
|
+
export declare function trackImportDeclaration(registry: ImportRegistry, node: AstNode): void;
|
|
71
|
+
/**
|
|
72
|
+
* Returns true when the given local identifier name was imported from the given module.
|
|
73
|
+
*
|
|
74
|
+
* @param registry - The import registry built from the file's import declarations.
|
|
75
|
+
* @param localName - The local identifier (as it appears in code).
|
|
76
|
+
* @param fromSource - The expected source-module string.
|
|
77
|
+
* @returns True when the local name maps to the given source.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isImportedFrom(registry: ImportRegistry, localName: string, fromSource: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the statement-level anchor node that ESLint attaches leading comments to for the
|
|
82
|
+
* given function-like node. For function declarations this is the declaration (or its
|
|
83
|
+
* `Export*Declaration` wrapper); for arrow/function expressions assigned to a variable, it
|
|
84
|
+
* is the variable declaration (or its `Export*Declaration` wrapper); otherwise `null`.
|
|
85
|
+
*
|
|
86
|
+
* @param node - The function-like AST node (FunctionDeclaration / FunctionExpression / ArrowFunctionExpression).
|
|
87
|
+
* @returns The anchor statement node, or null when the function has no JSDoc-anchorable container.
|
|
88
|
+
*/
|
|
89
|
+
export declare function getFunctionJsdocAnchor(node: AstNode): Maybe<AstNode>;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the function name when resolvable: `node.id.name` for declarations, or the
|
|
92
|
+
* containing `VariableDeclarator.id.name` for arrow/function expressions. Returns `null`
|
|
93
|
+
* when the function is anonymous in an unrecognized context.
|
|
94
|
+
*
|
|
95
|
+
* @param node - The function-like AST node.
|
|
96
|
+
* @returns The function name, or null when anonymous.
|
|
97
|
+
*/
|
|
98
|
+
export declare function getFunctionName(node: AstNode): Maybe<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Returns the name-bearing AST node for reporting on a function: the `id` for a
|
|
101
|
+
* declaration, the `VariableDeclarator.id` for an arrow assignment, or the function node
|
|
102
|
+
* itself as a last resort.
|
|
103
|
+
*
|
|
104
|
+
* @param node - The function-like AST node.
|
|
105
|
+
* @returns The node to attach a `context.report` location to.
|
|
106
|
+
*/
|
|
107
|
+
export declare function getFunctionNameNode(node: AstNode): AstNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.16",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"exports": {
|
|
6
6
|
"./test": {
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
"import": "./test/index.cjs.mjs",
|
|
10
10
|
"default": "./test/index.cjs.js"
|
|
11
11
|
},
|
|
12
|
+
"./eslint": {
|
|
13
|
+
"module": "./eslint/index.esm.js",
|
|
14
|
+
"types": "./eslint/index.d.ts",
|
|
15
|
+
"import": "./eslint/index.cjs.mjs",
|
|
16
|
+
"default": "./eslint/index.cjs.js"
|
|
17
|
+
},
|
|
12
18
|
"./package.json": "./package.json",
|
|
13
19
|
".": {
|
|
14
20
|
"module": "./index.esm.js",
|
|
@@ -18,10 +24,10 @@
|
|
|
18
24
|
}
|
|
19
25
|
},
|
|
20
26
|
"peerDependencies": {
|
|
21
|
-
"@dereekb/util": "13.11.
|
|
22
|
-
"@dereekb/date": "13.11.
|
|
23
|
-
"@dereekb/model": "13.11.
|
|
24
|
-
"@dereekb/rxjs": "13.11.
|
|
27
|
+
"@dereekb/util": "13.11.16",
|
|
28
|
+
"@dereekb/date": "13.11.16",
|
|
29
|
+
"@dereekb/model": "13.11.16",
|
|
30
|
+
"@dereekb/rxjs": "13.11.16",
|
|
25
31
|
"@firebase/rules-unit-testing": "5.0.0",
|
|
26
32
|
"arktype": "^2.2.0",
|
|
27
33
|
"date-fns": "^4.1.0",
|
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/test",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.16",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/date": "13.11.
|
|
6
|
-
"@dereekb/firebase": "13.11.
|
|
7
|
-
"@dereekb/model": "13.11.
|
|
8
|
-
"@dereekb/rxjs": "13.11.
|
|
9
|
-
"@dereekb/util": "13.11.
|
|
5
|
+
"@dereekb/date": "13.11.16",
|
|
6
|
+
"@dereekb/firebase": "13.11.16",
|
|
7
|
+
"@dereekb/model": "13.11.16",
|
|
8
|
+
"@dereekb/rxjs": "13.11.16",
|
|
9
|
+
"@dereekb/util": "13.11.16",
|
|
10
10
|
"@firebase/rules-unit-testing": "5.0.0",
|
|
11
11
|
"date-fns": "^4.1.0",
|
|
12
12
|
"firebase": "^12.12.1",
|