react-obsidian 2.2.0 → 2.3.0-rc.1

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 (49) hide show
  1. package/dist/eslint/undefinedDependencies/ASTFunctions.d.ts +16 -0
  2. package/dist/eslint/undefinedDependencies/ASTFunctions.d.ts.map +1 -0
  3. package/dist/eslint/undefinedDependencies/ASTFunctions.js +136 -0
  4. package/dist/eslint/undefinedDependencies/ASTFunctions.js.map +1 -0
  5. package/dist/eslint/undefinedDependencies/createFunction.d.ts +6 -0
  6. package/dist/eslint/undefinedDependencies/createFunction.d.ts.map +1 -0
  7. package/dist/eslint/undefinedDependencies/createFunction.js +39 -0
  8. package/dist/eslint/undefinedDependencies/createFunction.js.map +1 -0
  9. package/dist/eslint/undefinedDependencies/invalidGraphs.d.ts +3 -0
  10. package/dist/eslint/undefinedDependencies/invalidGraphs.d.ts.map +1 -0
  11. package/dist/eslint/undefinedDependencies/invalidGraphs.js +27 -0
  12. package/dist/eslint/undefinedDependencies/invalidGraphs.js.map +1 -0
  13. package/dist/eslint/undefinedDependencies/ruleConfiguration.d.ts +3 -0
  14. package/dist/eslint/undefinedDependencies/ruleConfiguration.d.ts.map +1 -0
  15. package/dist/eslint/undefinedDependencies/ruleConfiguration.js +23 -0
  16. package/dist/eslint/undefinedDependencies/ruleConfiguration.js.map +1 -0
  17. package/dist/eslint/undefinedDependencies/testUtils/subgraph.d.ts +6 -0
  18. package/dist/eslint/undefinedDependencies/testUtils/subgraph.d.ts.map +1 -0
  19. package/dist/eslint/undefinedDependencies/testUtils/subgraph.js +38 -0
  20. package/dist/eslint/undefinedDependencies/testUtils/subgraph.js.map +1 -0
  21. package/dist/eslint/undefinedDependencies/testUtils/validGraphs.d.ts +3 -0
  22. package/dist/eslint/undefinedDependencies/testUtils/validGraphs.d.ts.map +1 -0
  23. package/dist/eslint/undefinedDependencies/testUtils/validGraphs.js +29 -0
  24. package/dist/eslint/undefinedDependencies/testUtils/validGraphs.js.map +1 -0
  25. package/dist/src/graph/registry/GraphRegistry.d.ts +1 -0
  26. package/dist/src/graph/registry/GraphRegistry.d.ts.map +1 -1
  27. package/dist/src/graph/registry/GraphRegistry.js +21 -1
  28. package/dist/src/graph/registry/GraphRegistry.js.map +1 -1
  29. package/dist/test/fixtures/UniqueNumberGraph.d.ts.map +1 -1
  30. package/dist/test/fixtures/UniqueNumberGraph.js +1 -0
  31. package/dist/test/fixtures/UniqueNumberGraph.js.map +1 -1
  32. package/dist/testkit/mockGraphs.d.ts.map +1 -1
  33. package/dist/testkit/mockGraphs.js +6 -0
  34. package/dist/testkit/mockGraphs.js.map +1 -1
  35. package/dist/testkit/mockModel.d.ts +2 -1
  36. package/dist/testkit/mockModel.d.ts.map +1 -1
  37. package/dist/testkit/mockModel.js +6 -1
  38. package/dist/testkit/mockModel.js.map +1 -1
  39. package/eslint/undefinedDependencies/ASTFunctions.ts +115 -0
  40. package/eslint/undefinedDependencies/createFunction.ts +45 -0
  41. package/eslint/undefinedDependencies/invalidGraphs.ts +24 -0
  42. package/eslint/undefinedDependencies/ruleConfiguration.ts +24 -0
  43. package/eslint/undefinedDependencies/testUtils/subgraph.ts +15 -0
  44. package/eslint/undefinedDependencies/testUtils/validGraphs.ts +26 -0
  45. package/package.json +21 -10
  46. package/src/graph/registry/GraphRegistry.ts +21 -1
  47. package/testkit/mockGraphs.ts +10 -0
  48. package/testkit/mockModel.ts +8 -1
  49. package/wallaby.js +9 -0
@@ -0,0 +1,16 @@
1
+ import { TSESTree } from '@typescript-eslint/typescript-estree';
2
+ import { TSESLint } from '@typescript-eslint/utils';
3
+ export type MessageIds = 'undefinedDependency';
4
+ export declare function getSubGraphs(decorators: TSESTree.Decorator[]): string[];
5
+ export declare function getDependenciesFromSubgraphs(imports: TSESTree.ImportDeclaration[], subGraphs: string[], context: Readonly<TSESLint.RuleContext<MessageIds, []>>): string[];
6
+ export declare function mapFunctions(node: TSESTree.ClassDeclaration): string[];
7
+ export declare function checkDependencies(node: TSESTree.ClassDeclaration, existingDependencies: string[]): {
8
+ value: boolean;
9
+ param: string;
10
+ } | {
11
+ value: boolean;
12
+ param?: undefined;
13
+ };
14
+ export declare function getDecoratorName(decorator: TSESTree.Decorator): string;
15
+ export declare function getPropertyDeclarations(node: TSESTree.ClassDeclaration): string[];
16
+ //# sourceMappingURL=ASTFunctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ASTFunctions.d.ts","sourceRoot":"","sources":["../../../eslint/undefinedDependencies/ASTFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAIhE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAE/C,wBAAgB,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,SAAS,EAAE,YAkB5D;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,QAAQ,CAAC,iBAAiB,EAAE,EACrC,SAAS,EAAC,MAAM,EAAE,EAClB,OAAO,EAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,YAqCvD;AACD,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,gBAAgB,YAc3D;AACD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE;;;;;;EAmBhG;AACD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,UAE7D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAC,QAAQ,CAAC,gBAAgB,YAMrE"}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getPropertyDeclarations = exports.getDecoratorName = exports.checkDependencies = exports.mapFunctions = exports.getDependenciesFromSubgraphs = exports.getSubGraphs = void 0;
27
+ const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
28
+ const fs = __importStar(require("fs"));
29
+ const parser_1 = require("@typescript-eslint/parser");
30
+ const path = require("path");
31
+ function getSubGraphs(decorators) {
32
+ const args = decorators[0].expression.arguments;
33
+ if (args) {
34
+ for (let i = 0; i < args.length; i++) {
35
+ if (args[i].type === typescript_estree_1.TSESTree.AST_NODE_TYPES.ObjectExpression) {
36
+ const { properties } = args[i];
37
+ if (properties) {
38
+ for (let j = 0; j < properties.length; j++) {
39
+ if (properties[j].key.name === 'subgraphs') {
40
+ return properties[j].value
41
+ .elements.map((subGraph) => subGraph.name);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ return [];
49
+ }
50
+ exports.getSubGraphs = getSubGraphs;
51
+ function getDependenciesFromSubgraphs(imports, subGraphs, context) {
52
+ const paths = [];
53
+ const dependencies = [];
54
+ imports.forEach((el) => {
55
+ el.specifiers.forEach((specifier) => {
56
+ if (subGraphs.includes(specifier.local.name)) {
57
+ paths.push({ path: el.source.value, import: specifier.local.name });
58
+ }
59
+ });
60
+ });
61
+ paths.forEach((el) => {
62
+ const filePath = path.join(path.dirname(context.getFilename()), `${el['path']}.ts`);
63
+ const fileContent = fs.readFileSync(filePath, 'utf8');
64
+ const fileAST = (0, parser_1.parse)(fileContent, {
65
+ ecmaVersion: 9,
66
+ ecmaFeatures: {
67
+ globalReturn: false,
68
+ jsx: true,
69
+ },
70
+ sourceType: 'module',
71
+ comment: true,
72
+ attachComment: true,
73
+ tokens: true,
74
+ loc: true,
75
+ range: true,
76
+ filePath,
77
+ });
78
+ dependencies.push(...mapFunctions(fileAST.body[fileAST.body.length - 1]
79
+ .declaration));
80
+ });
81
+ return dependencies;
82
+ }
83
+ exports.getDependenciesFromSubgraphs = getDependenciesFromSubgraphs;
84
+ function mapFunctions(node) {
85
+ const { body } = node.body;
86
+ const existingDependencies = [];
87
+ body.forEach((el) => {
88
+ var _a;
89
+ if (el.type === typescript_estree_1.TSESTree.AST_NODE_TYPES.MethodDefinition) {
90
+ const decorators = (_a = (el)) === null || _a === void 0 ? void 0 : _a.decorators;
91
+ if (decorators) {
92
+ if (decorators.map((decorator) => getDecoratorName(decorator)).includes('Provides')) {
93
+ existingDependencies.push(el.key.name);
94
+ }
95
+ }
96
+ }
97
+ });
98
+ return existingDependencies;
99
+ }
100
+ exports.mapFunctions = mapFunctions;
101
+ function checkDependencies(node, existingDependencies) {
102
+ var _a, _b;
103
+ const body = (_a = node === null || node === void 0 ? void 0 : node.body) === null || _a === void 0 ? void 0 : _a.body;
104
+ for (let j = 0; j < body.length; j++) {
105
+ if (body[j].type === typescript_estree_1.TSESTree.AST_NODE_TYPES.MethodDefinition
106
+ && body[j].key.name !== 'constructor') {
107
+ const params = (_b = body[j].value) === null || _b === void 0 ? void 0 : _b.params;
108
+ if (params) {
109
+ for (let i = 0; i < params.length; i++) {
110
+ if (!existingDependencies.includes(params[i].name)) {
111
+ return {
112
+ value: false,
113
+ param: params[i].name,
114
+ };
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ return { value: true };
121
+ }
122
+ exports.checkDependencies = checkDependencies;
123
+ function getDecoratorName(decorator) {
124
+ var _a, _b;
125
+ return (_b = (_a = decorator === null || decorator === void 0 ? void 0 : decorator.expression) === null || _a === void 0 ? void 0 : _a.callee) === null || _b === void 0 ? void 0 : _b.name;
126
+ }
127
+ exports.getDecoratorName = getDecoratorName;
128
+ function getPropertyDeclarations(node) {
129
+ const classBody = node.body.body;
130
+ const properties = classBody.map((method) => {
131
+ return method.key.name;
132
+ });
133
+ return properties;
134
+ }
135
+ exports.getPropertyDeclarations = getPropertyDeclarations;
136
+ //# sourceMappingURL=ASTFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ASTFunctions.js","sourceRoot":"","sources":["../../../eslint/undefinedDependencies/ASTFunctions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAgE;AAChE,uCAAyB;AACzB,sDAAkD;AAClD,6BAA8B;AAK9B,SAAgB,YAAY,CAAC,UAAgC;IAC3D,MAAM,IAAI,GAAI,UAAU,CAAC,CAAC,CAAC,CAAC,UAAsC,CAAC,SAAS,CAAC;IAC7E,IAAI,IAAI,EAAE;QACR,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,4BAAQ,CAAC,cAAc,CAAC,gBAAgB,EAAE;gBAC7D,MAAM,EAAE,UAAU,EAAE,GAAI,IAAI,CAAC,CAAC,CAA+B,CAAC;gBAC9D,IAAI,UAAU,EAAE;oBACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBAC1C,IAAM,UAAU,CAAC,CAAC,CAA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,0 +1,6 @@
1
+ import { TSESTree } from '@typescript-eslint/typescript-estree';
2
+ export declare function create(context: any): {
3
+ ImportDeclaration(node: TSESTree.ImportDeclaration): void;
4
+ ClassDeclaration(node: TSESTree.ClassDeclaration): void;
5
+ };
6
+ //# sourceMappingURL=createFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFunction.d.ts","sourceRoot":"","sources":["../../../eslint/undefinedDependencies/createFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAWhE,wBAAgB,MAAM,CAAC,OAAO,EAAE,GAAG;4BAKR,SAAS,iBAAiB;2BAG3B,SAAS,gBAAgB;EAyBlD"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const ASTFunctions_1 = require("./ASTFunctions");
5
+ function create(context) {
6
+ const imports = [];
7
+ const dependencies = [];
8
+ return {
9
+ ImportDeclaration(node) {
10
+ imports.push(node);
11
+ },
12
+ ClassDeclaration(node) {
13
+ const { decorators } = node;
14
+ if (decorators) {
15
+ const decoratorNames = decorators.map((decorator) => (0, ASTFunctions_1.getDecoratorName)(decorator));
16
+ if (decoratorNames.includes('Graph')) {
17
+ const subGraphs = (0, ASTFunctions_1.getSubGraphs)(decorators);
18
+ if (subGraphs.length > 0) {
19
+ dependencies.push(...(0, ASTFunctions_1.getDependenciesFromSubgraphs)(imports, subGraphs, context));
20
+ }
21
+ dependencies.push(...(0, ASTFunctions_1.mapFunctions)(node));
22
+ dependencies.push(...(0, ASTFunctions_1.getPropertyDeclarations)(node));
23
+ const check = (0, ASTFunctions_1.checkDependencies)(node, dependencies);
24
+ if (!(check === null || check === void 0 ? void 0 : check.value)) {
25
+ context.report({
26
+ node,
27
+ messageId: 'undefinedDependency',
28
+ data: {
29
+ dependencyName: check.param,
30
+ },
31
+ });
32
+ }
33
+ }
34
+ }
35
+ },
36
+ };
37
+ }
38
+ exports.create = create;
39
+ //# sourceMappingURL=createFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFunction.js","sourceRoot":"","sources":["../../../eslint/undefinedDependencies/createFunction.ts"],"names":[],"mappings":";;;AAEA,iDAOwB;AAExB,SAAgB,MAAM,CAAC,OAAY;IACjC,MAAM,OAAO,GAAgC,EAAE,CAAC;IAChD,MAAM,YAAY,GAAY,EAAE,CAAC;IAEjC,OAAO;QACL,iBAAiB,CAAC,IAA+B;YAC/C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;QACD,gBAAgB,CAAC,IAA8B;YAC7C,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YAC5B,IAAI,UAAU,EAAE;gBACd,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAA,+BAAgB,EAAC,SAAS,CAAC,CAAC,CAAC;gBAClF,IAAI,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;oBACpC,MAAM,SAAS,GAAG,IAAA,2BAAY,EAAC,UAAU,CAAC,CAAC;oBAC3C,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;wBACxB,YAAY,CAAC,IAAI,CAAC,GAAG,IAAA,2CAA4B,EAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;qBACjF;oBACD,YAAY,CAAC,IAAI,CAAC,GAAG,IAAA,2BAAY,EAAC,IAAI,CAAC,CAAC,CAAC;oBACzC,YAAY,CAAC,IAAI,CAAC,GAAG,IAAA,sCAAuB,EAAC,IAAI,CAAC,CAAC,CAAC;oBACpD,MAAM,KAAK,GAAG,IAAA,gCAAiB,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC;oBACpD,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAA,EAAE;wBACjB,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,qBAAqB;4BAChC,IAAI,EAAE;gCACJ,cAAc,EAAE,KAAK,CAAC,KAAK;6BAC5B;yBACF,CAAC,CAAC;qBACJ;iBACF;aACF;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAjCD,wBAiCC"}
@@ -0,0 +1,3 @@
1
+ export declare const invalidGraph = "import { Graph, ObjectGraph, Provides } from 'src';\n\n@Graph()\nexport default class SimpleGraph extends ObjectGraph {\n @Provides()\n instanceId(id:string): string {\n return id;\n }\n}";
2
+ export declare const invalidGraphWithSubgraph = "import {\n Graph,\n ObjectGraph,\n Provides,\n} from 'src';\nimport Subgraph from './subgraph';\n\n@Graph({ subgraphs: [Subgraph] })\nexport default class SimpleGraphWithSubgraph extends ObjectGraph {\n @Provides()\n someClass(wrongDep:string): string {\n return wrongDep;\n }\n}";
3
+ //# sourceMappingURL=invalidGraphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidGraphs.d.ts","sourceRoot":"","sources":["../../../eslint/undefinedDependencies/invalidGraphs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,sMAQvB,CAAC;AAEH,eAAO,MAAM,wBAAwB,sSAanC,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.invalidGraphWithSubgraph = exports.invalidGraph = void 0;
4
+ exports.invalidGraph = `import { Graph, ObjectGraph, Provides } from 'src';
5
+
6
+ @Graph()
7
+ export default class SimpleGraph extends ObjectGraph {
8
+ @Provides()
9
+ instanceId(id:string): string {
10
+ return id;
11
+ }
12
+ }`;
13
+ exports.invalidGraphWithSubgraph = `import {
14
+ Graph,
15
+ ObjectGraph,
16
+ Provides,
17
+ } from 'src';
18
+ import Subgraph from './subgraph';
19
+
20
+ @Graph({ subgraphs: [Subgraph] })
21
+ export default class SimpleGraphWithSubgraph extends ObjectGraph {
22
+ @Provides()
23
+ someClass(wrongDep:string): string {
24
+ return wrongDep;
25
+ }
26
+ }`;
27
+ //# sourceMappingURL=invalidGraphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidGraphs.js","sourceRoot":"","sources":["../../../eslint/undefinedDependencies/invalidGraphs.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;;;;;;;;EAQ1B,CAAC;AAEU,QAAA,wBAAwB,GAAG;;;;;;;;;;;;;EAatC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { RuleModule } from '@typescript-eslint/utils/ts-eslint';
2
+ export declare const undefinedDependencies: RuleModule<'undefinedDependency'>;
3
+ //# sourceMappingURL=ruleConfiguration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ruleConfiguration.d.ts","sourceRoot":"","sources":["../../../eslint/undefinedDependencies/ruleConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAOhE,eAAO,MAAM,qBAAqB,EAAE,UAAU,CAAC,qBAAqB,CAelE,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.undefinedDependencies = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ const createFunction_1 = require("./createFunction");
6
+ const createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://example.com/rule/${name}`);
7
+ exports.undefinedDependencies = createRule({
8
+ create: createFunction_1.create,
9
+ name: 'undefined-dependency',
10
+ meta: {
11
+ docs: {
12
+ description: 'The dependency must be defined',
13
+ recommended: 'strict',
14
+ },
15
+ messages: {
16
+ undefinedDependency: 'Dependency {{ dependencyName }} is undefined',
17
+ },
18
+ schema: [],
19
+ type: 'problem',
20
+ },
21
+ defaultOptions: [],
22
+ });
23
+ //# sourceMappingURL=ruleConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ruleConfiguration.js","sourceRoot":"","sources":["../../../eslint/undefinedDependencies/ruleConfiguration.ts"],"names":[],"mappings":";;;AAAA,oDAAuD;AAEvD,qDAA0C;AAE1C,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,4BAA4B,IAAI,EAAE,CAC7C,CAAC;AAEW,QAAA,qBAAqB,GAAsC,UAAU,CAAC;IACjF,MAAM,EAAN,uBAAM;IACN,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,gCAAgC;YAC7C,WAAW,EAAE,QAAQ;SACtB;QACD,QAAQ,EAAE;YACR,mBAAmB,EAAE,8CAA8C;SACpE;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAChB;IACD,cAAc,EAAE,EAAQ;CACzB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ObjectGraph } from 'src';
2
+ export default class Subgraph extends ObjectGraph {
3
+ unusedDependency(): string;
4
+ instanceId(): string;
5
+ }
6
+ //# sourceMappingURL=subgraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../../eslint/undefinedDependencies/testUtils/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,WAAW,EAAY,MAAM,KAAK,CAAC;AAGnD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,WAAW;IAE/C,gBAAgB,IAAI,MAAM;IAK1B,UAAU,IAAI,MAAM;CAGrB"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const lodash_1 = require("lodash");
13
+ const src_1 = require("src");
14
+ let Subgraph = class Subgraph extends src_1.ObjectGraph {
15
+ unusedDependency() {
16
+ throw Error('This dependency should not have been resolved since it is not required by anyone.');
17
+ }
18
+ instanceId() {
19
+ return (0, lodash_1.uniqueId)('graph');
20
+ }
21
+ };
22
+ __decorate([
23
+ (0, src_1.Provides)(),
24
+ __metadata("design:type", Function),
25
+ __metadata("design:paramtypes", []),
26
+ __metadata("design:returntype", String)
27
+ ], Subgraph.prototype, "unusedDependency", null);
28
+ __decorate([
29
+ (0, src_1.Provides)(),
30
+ __metadata("design:type", Function),
31
+ __metadata("design:paramtypes", []),
32
+ __metadata("design:returntype", String)
33
+ ], Subgraph.prototype, "instanceId", null);
34
+ Subgraph = __decorate([
35
+ (0, src_1.Graph)()
36
+ ], Subgraph);
37
+ exports.default = Subgraph;
38
+ //# sourceMappingURL=subgraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../../eslint/undefinedDependencies/testUtils/subgraph.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAkC;AAClC,6BAAmD;AAGpC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,iBAAW;IAE/C,gBAAgB;QACd,MAAM,KAAK,CAAC,mFAAmF,CAAC,CAAC;IACnG,CAAC;IAGD,UAAU;QACR,OAAO,IAAA,iBAAQ,EAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF,CAAA;AATC;IAAC,IAAA,cAAQ,GAAE;;;;gDAGV;AAED;IAAC,IAAA,cAAQ,GAAE;;;;0CAGV;AATkB,QAAQ;IAD5B,IAAA,WAAK,GAAE;GACa,QAAQ,CAU5B;kBAVoB,QAAQ"}
@@ -0,0 +1,3 @@
1
+ export declare const validGraphSimple = "import { uniqueId } from 'lodash';\nimport { Graph, ObjectGraph, Provides } from 'src';\n\n@Graph()\nexport default class SimpleGraph extends ObjectGraph {\n @Provides()\n instanceId(): string {\n return 'graph';\n }\n}";
2
+ export declare const validGraphWithSubgraph = "import {\n Graph,\n ObjectGraph,\n Provides,\n} from 'src';\nimport Subgraph from './subgraph';\n\n\n@Graph({ subgraphs: [Subgraph] })\nexport default class SimpleGraphWithSubgraph extends ObjectGraph {\n @Provides()\n someClass(instanceId:string): string {\n return instanceId;\n }\n}";
3
+ //# sourceMappingURL=validGraphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validGraphs.d.ts","sourceRoot":"","sources":["../../../../eslint/undefinedDependencies/testUtils/validGraphs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,sOAS3B,CAAC;AAEH,eAAO,MAAM,sBAAsB,4SAcjC,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validGraphWithSubgraph = exports.validGraphSimple = void 0;
4
+ exports.validGraphSimple = `import { uniqueId } from 'lodash';
5
+ import { Graph, ObjectGraph, Provides } from 'src';
6
+
7
+ @Graph()
8
+ export default class SimpleGraph extends ObjectGraph {
9
+ @Provides()
10
+ instanceId(): string {
11
+ return 'graph';
12
+ }
13
+ }`;
14
+ exports.validGraphWithSubgraph = `import {
15
+ Graph,
16
+ ObjectGraph,
17
+ Provides,
18
+ } from 'src';
19
+ import Subgraph from './subgraph';
20
+
21
+
22
+ @Graph({ subgraphs: [Subgraph] })
23
+ export default class SimpleGraphWithSubgraph extends ObjectGraph {
24
+ @Provides()
25
+ someClass(instanceId:string): string {
26
+ return instanceId;
27
+ }
28
+ }`;
29
+ //# sourceMappingURL=validGraphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validGraphs.js","sourceRoot":"","sources":["../../../../eslint/undefinedDependencies/testUtils/validGraphs.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;;;;;;;;;EAS9B,CAAC;AAEU,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;EAcpC,CAAC"}
@@ -17,6 +17,7 @@ export declare class GraphRegistry {
17
17
  private set;
18
18
  private isSingleton;
19
19
  private isBoundToReactLifecycle;
20
+ clearGraphAfterItWasMockedInTests(graphName: string): void;
20
21
  clear(graph: Graph): void;
21
22
  addGraphMiddleware(middleware: Middleware<Graph>): void;
22
23
  clearGraphMiddlewares(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"GraphRegistry.d.ts","sourceRoot":"","sources":["../../../../src/graph/registry/GraphRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA+C;IACrF,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA0C;IAChF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAC3D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA8D;IAC/F,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA8B;IAE/D,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,GAAE,aAAa,CAAC,KAAK,CAAC,EAAO;IAIlF,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAK7B,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE;IAMnC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAIrC,OAAO,CAAC,CAAC,SAAS,KAAK,EACrB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,MAAM,GAAE,gBAAgB,GAAG,g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CAAC,GAAG;IAIX,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,GAAG;IAQX,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,uBAAuB;IAI/B,iCAAiC,CAAC,SAAS,EAAE,MAAM;IAgBnD,KAAK,CAAC,KAAK,EAAE,KAAK;IAQlB,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC;IAIhD,qBAAqB;IAIrB,QAAQ;CAKT;;AAKD,wBAAqD"}
@@ -65,6 +65,22 @@ class GraphRegistry {
65
65
  var _a;
66
66
  return (_a = Reflect.getMetadata('isLifecycleBound', Graph)) !== null && _a !== void 0 ? _a : false;
67
67
  }
68
+ clearGraphAfterItWasMockedInTests(graphName) {
69
+ const graphNames = this.nameToInstance.keys();
70
+ for (const name of graphNames) {
71
+ if (name.match(graphName)) {
72
+ const graph = this.nameToInstance.get(name);
73
+ if (!graph)
74
+ return;
75
+ const Graph = this.instanceToConstructor.get(graph);
76
+ if (!Graph)
77
+ return;
78
+ this.instanceToConstructor.delete(graph);
79
+ this.constructorToInstance.get(Graph).delete(graph);
80
+ this.nameToInstance.delete(graph.name);
81
+ }
82
+ }
83
+ }
68
84
  clear(graph) {
69
85
  const Graph = this.instanceToConstructor.get(graph);
70
86
  if (!Graph || this.isSingleton(Graph))
@@ -86,5 +102,9 @@ class GraphRegistry {
86
102
  }
87
103
  }
88
104
  exports.GraphRegistry = GraphRegistry;
89
- exports.default = new GraphRegistry();
105
+ // @ts-ignore
106
+ global.graphRegistry = global.graphRegistry || new GraphRegistry();
107
+ // @ts-ignore
108
+ exports.default = global.graphRegistry;
109
+ // export default new GraphRegistry();
90
110
  //# sourceMappingURL=GraphRegistry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GraphRegistry.js","sourceRoot":"","sources":["../../../../src/graph/registry/GraphRegistry.ts"],"names":[],"mappings":";;;;;;AAGA,kFAA0D;AAC1D,6FAA0F;AAE1F,MAAa,aAAa;IAA1B;QACmB,0BAAqB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AK,CAAC,CAAC;QACrD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,kBAAkB,CAAC,UAA6B;QAC9C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,qBAAqB;QACnB,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF;AAvGD,sCAuGC;AAED,aAAa;AACb,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,IAAI,aAAa,EAAE,CAAC;AACnE,aAAa;AACb,kBAAe,MAAM,CAAC,aAA8B,CAAC;AACrD,sCAAsC"}
@@ -1 +1 @@
1
- {"version":3,"file":"UniqueNumberGraph.d.ts","sourceRoot":"","sources":["../../../test/fixtures/UniqueNumberGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAGZ,MAAM,WAAW,CAAC;AAEnB,qBACa,iBAAkB,SAAQ,WAAW;IACpC,OAAO,CAAC,qBAAqB;gBAArB,qBAAqB,EAAE,MAAM,MAAM;IAKvD,eAAe,IAAI,MAAM;IAKzB,cAAc,IAAI,MAAM;CAGzB"}
1
+ {"version":3,"file":"UniqueNumberGraph.d.ts","sourceRoot":"","sources":["../../../test/fixtures/UniqueNumberGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAGZ,MAAM,WAAW,CAAC;AAEnB,qBACa,iBAAkB,SAAQ,WAAW;IAEpC,OAAO,CAAC,qBAAqB;gBAArB,qBAAqB,EAAE,MAAM,MAAM;IAKvD,eAAe,IAAI,MAAM;IAKzB,cAAc,IAAI,MAAM;CAGzB"}
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UniqueNumberGraph = void 0;
13
13
  const src_1 = require("../../src");
14
14
  let UniqueNumberGraph = class UniqueNumberGraph extends src_1.ObjectGraph {
15
+ // eslint-disable-next-line unused-imports/no-unused-vars, no-unused-vars
15
16
  constructor(uniqueNumberGenerator) {
16
17
  super();
17
18
  this.uniqueNumberGenerator = uniqueNumberGenerator;
@@ -1 +1 @@
1
- {"version":3,"file":"UniqueNumberGraph.js","sourceRoot":"","sources":["../../../test/fixtures/UniqueNumberGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAKmB;AAGZ,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,iBAAW;IAChD,YAAoB,qBAAmC;QACrD,KAAK,EAAE,CAAC;QADU,0BAAqB,GAArB,qBAAqB,CAAc;IAEvD,CAAC;IAGD,eAAe;QACb,OAAO,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACtC,CAAC;IAGD,cAAc;QACZ,OAAO,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACtC,CAAC;CACF,CAAA;AATC;IAAC,IAAA,cAAQ,GAAE;IAAE,IAAA,eAAS,GAAE;;;;wDAGvB;AAED;IAAC,IAAA,cAAQ,GAAE;;;;uDAGV;AAbU,iBAAiB;IAD7B,IAAA,WAAK,GAAE;;GACK,iBAAiB,CAc7B;AAdY,8CAAiB"}
1
+ {"version":3,"file":"UniqueNumberGraph.js","sourceRoot":"","sources":["../../../test/fixtures/UniqueNumberGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAKmB;AAGZ,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,iBAAW;IAChD,yEAAyE;IACzE,YAAoB,qBAAmC;QACrD,KAAK,EAAE,CAAC;QADU,0BAAqB,GAArB,qBAAqB,CAAc;IAEvD,CAAC;IAGD,eAAe;QACb,OAAO,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACtC,CAAC;IAGD,cAAc;QACZ,OAAO,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACtC,CAAC;CACF,CAAA;AATC;IAAC,IAAA,cAAQ,GAAE;IAAE,IAAA,eAAS,GAAE;;;;wDAGvB;AAED;IAAC,IAAA,cAAQ,GAAE;;;;uDAGV;AAdU,iBAAiB;IAD7B,IAAA,WAAK,GAAE;;GACK,iBAAiB,CAe7B;AAfY,8CAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"mockGraphs.d.ts","sourceRoot":"","sources":["../../testkit/mockGraphs.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,wBAAgB,UAAU,CACxB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC,QAY7F"}
1
+ {"version":3,"file":"mockGraphs.d.ts","sourceRoot":"","sources":["../../testkit/mockGraphs.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,wBAAgB,UAAU,CACxB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC,QAc7F"}
@@ -17,7 +17,13 @@ function mockGraphs(graphNameToGraph) {
17
17
  return resolveChain.proceed(Graph, props);
18
18
  }
19
19
  }();
20
+ clearRegisteredGraphs(graphNameToGraph);
20
21
  GraphRegistry_1.default.addGraphMiddleware(graphMiddleware);
21
22
  }
22
23
  exports.mockGraphs = mockGraphs;
24
+ function clearRegisteredGraphs(graphNameToGraph) {
25
+ for (const graphName of Object.keys(graphNameToGraph)) {
26
+ GraphRegistry_1.default.clearGraphAfterItWasMockedInTests(graphName);
27
+ }
28
+ }
23
29
  //# sourceMappingURL=mockGraphs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mockGraphs.js","sourceRoot":"","sources":["../../testkit/mockGraphs.ts"],"names":[],"mappings":";;;;;;AACA,0DAAgE;AAChE,2EAAwE;AAExE,wFAAgE;AAEhE,SAAgB,UAAU,CACxB,gBAA4F;IAE5F,MAAM,eAAe,GAAG,IAAI,KAAM,SAAQ,iCAAe;QACvD,OAAO,CAAQ,YAA+B,EAAE,KAAiC,EAAE,KAAa;YAC9F,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAChC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACtD,OAAO,IAAA,qBAAO,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;aAC1F;YACD,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC;KACF,EAAE,CAAC;IACJ,uBAAa,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;AACpD,CAAC;AAbD,gCAaC"}
1
+ {"version":3,"file":"mockGraphs.js","sourceRoot":"","sources":["../../testkit/mockGraphs.ts"],"names":[],"mappings":";;;;;;AACA,0DAAgE;AAChE,2EAAwE;AAExE,wFAAgE;AAEhE,SAAgB,UAAU,CACxB,gBAA4F;IAE5F,MAAM,eAAe,GAAG,IAAI,KAAM,SAAQ,iCAAe;QACvD,OAAO,CAAQ,YAA+B,EAAE,KAAiC,EAAE,KAAa;YAC9F,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAChC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACtD,OAAO,IAAA,qBAAO,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;aAC1F;YACD,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC;KACF,EAAE,CAAC;IAEJ,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACxC,uBAAa,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;AACpD,CAAC;AAfD,gCAeC;AAED,SAAS,qBAAqB,CAC5B,gBAA4F;IAE5F,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE;QACrD,uBAAa,CAAC,iCAAiC,CAAC,SAAS,CAAC,CAAC;KAC5D;AACH,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { Constructable } from '../src/types';
1
2
  import { Model } from '../src/model/Model';
2
- export declare function mockModel<T extends Model, S extends Partial<T>>(mock: S): T;
3
+ export declare function mockModel<T extends Model, S extends Partial<T>>(mock: S, BaseClass?: Constructable<T>): T;
3
4
  //# sourceMappingURL=mockModel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mockModel.d.ts","sourceRoot":"","sources":["../../testkit/mockModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAO3E"}
1
+ {"version":3,"file":"mockModel.d.ts","sourceRoot":"","sources":["../../testkit/mockModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAazG"}
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mockModel = void 0;
4
4
  const Model_1 = require("../src/model/Model");
5
- function mockModel(mock) {
5
+ function mockModel(mock, BaseClass) {
6
+ if (BaseClass) {
7
+ const bc = new BaseClass();
8
+ Object.assign(bc, mock);
9
+ return bc;
10
+ }
6
11
  return new class extends Model_1.Model {
7
12
  constructor() {
8
13
  super();
@@ -1 +1 @@
1
- {"version":3,"file":"mockModel.js","sourceRoot":"","sources":["../../testkit/mockModel.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAE3C,SAAgB,SAAS,CAAwC,IAAO;IACtE,OAAO,IAAI,KAAM,SAAQ,aAAK;QAC5B;YACE,KAAK,EAAE,CAAC;YACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;KACF,EAAO,CAAC;AACX,CAAC;AAPD,8BAOC"}
1
+ {"version":3,"file":"mockModel.js","sourceRoot":"","sources":["../../testkit/mockModel.ts"],"names":[],"mappings":";;;AACA,8CAA2C;AAE3C,SAAgB,SAAS,CAAwC,IAAO,EAAE,SAA4B;IACpG,IAAI,SAAS,EAAE;QACb,MAAM,EAAE,GAAG,IAAI,SAAS,EAAE,CAAC;QAC3B,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACxB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,IAAI,KAAM,SAAQ,aAAK;QAC5B;YACE,KAAK,EAAE,CAAC;YACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;KACF,EAAO,CAAC;AACX,CAAC;AAbD,8BAaC"}
@@ -0,0 +1,115 @@
1
+ import { TSESTree } from '@typescript-eslint/typescript-estree';
2
+ import * as fs from 'fs';
3
+ import { parse } from '@typescript-eslint/parser';
4
+ import path= require('path') ;
5
+ import { TSESLint } from '@typescript-eslint/utils';
6
+
7
+ export type MessageIds = 'undefinedDependency';
8
+
9
+ export function getSubGraphs(decorators: TSESTree.Decorator[]) {
10
+ const args = (decorators[0].expression as TSESTree.CallExpression).arguments;
11
+ if (args) {
12
+ for (let i = 0; i < args.length; i++) {
13
+ if (args[i].type === TSESTree.AST_NODE_TYPES.ObjectExpression) {
14
+ const { properties } = (args[i] as TSESTree.ObjectExpression);
15
+ if (properties) {
16
+ for (let j = 0; j < properties.length; j++) {
17
+ if (((properties[j] as TSESTree.Property).key as TSESTree.Identifier).name === 'subgraphs') {
18
+ return ((properties[j] as TSESTree.Property).value as TSESTree.ArrayExpression)
19
+ .elements.map((subGraph) => (subGraph as TSESTree.Identifier).name);
20
+ }
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ return [];
27
+ }
28
+
29
+ export function getDependenciesFromSubgraphs(
30
+ imports: TSESTree.ImportDeclaration[],
31
+ subGraphs:string[],
32
+ context:Readonly<TSESLint.RuleContext<MessageIds, []>>,
33
+ ) {
34
+ const paths:Record<string, string>[] = [];
35
+ const dependencies: string[] = [];
36
+ imports.forEach((el) => {
37
+ el.specifiers.forEach((specifier) => {
38
+ if (subGraphs.includes(specifier.local.name)) {
39
+ paths.push({ path: el.source.value, import: specifier.local.name });
40
+ }
41
+ });
42
+ });
43
+ paths.forEach((el) => {
44
+ const filePath = path.join(path.dirname(context.getFilename()), `${el['path']}.ts`);
45
+ const fileContent = fs.readFileSync(filePath, 'utf8');
46
+ const fileAST = parse(
47
+ fileContent,
48
+ {
49
+ ecmaVersion: 9,
50
+ ecmaFeatures: {
51
+ globalReturn: false,
52
+ jsx: true,
53
+ },
54
+ sourceType: 'module',
55
+ comment: true,
56
+ attachComment: true,
57
+ tokens: true,
58
+ loc: true,
59
+ range: true,
60
+ filePath,
61
+ },
62
+ );
63
+ dependencies.push(...mapFunctions(
64
+ (fileAST.body[fileAST.body.length - 1] as TSESTree.ExportDefaultDeclaration)
65
+ .declaration as TSESTree.ClassDeclaration,
66
+ ));
67
+ });
68
+ return dependencies;
69
+ }
70
+ export function mapFunctions(node: TSESTree.ClassDeclaration) {
71
+ const { body } = node.body;
72
+ const existingDependencies: string[] = [];
73
+ body.forEach((el) => {
74
+ if (el.type === TSESTree.AST_NODE_TYPES.MethodDefinition) {
75
+ const decorators = (el)?.decorators;
76
+ if (decorators) {
77
+ if (decorators.map((decorator) => getDecoratorName(decorator)).includes('Provides')) {
78
+ existingDependencies.push(((el as TSESTree.MethodDefinition).key as TSESTree.Identifier).name);
79
+ }
80
+ }
81
+ }
82
+ });
83
+ return existingDependencies;
84
+ }
85
+ export function checkDependencies(node: TSESTree.ClassDeclaration, existingDependencies: string[]) {
86
+ const body = node?.body?.body;
87
+ for (let j = 0; j < body.length; j++) {
88
+ if (body[j].type === TSESTree.AST_NODE_TYPES.MethodDefinition
89
+ && ((body[j] as TSESTree.MethodDefinition).key as TSESTree.Identifier).name !== 'constructor') {
90
+ const params = (body[j] as TSESTree.MethodDefinition).value?.params;
91
+ if (params) {
92
+ for (let i = 0; i < params.length; i++) {
93
+ if (!existingDependencies.includes((params[i] as TSESTree.Identifier).name)) {
94
+ return {
95
+ value: false,
96
+ param: (params[i] as TSESTree.Identifier).name,
97
+ };
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ return { value: true };
104
+ }
105
+ export function getDecoratorName(decorator: TSESTree.Decorator) {
106
+ return ((decorator?.expression as TSESTree.CallExpression)?.callee as TSESTree.Identifier)?.name;
107
+ }
108
+
109
+ export function getPropertyDeclarations(node:TSESTree.ClassDeclaration) {
110
+ const classBody = node.body.body;
111
+ const properties = classBody.map((method) => {
112
+ return ((method as (TSESTree.PropertyDefinition | TSESTree.MethodDefinition)).key as TSESTree.Identifier).name;
113
+ });
114
+ return properties;
115
+ }
@@ -0,0 +1,45 @@
1
+ import { TSESTree } from '@typescript-eslint/typescript-estree';
2
+
3
+ import {
4
+ getSubGraphs,
5
+ getDependenciesFromSubgraphs,
6
+ mapFunctions,
7
+ checkDependencies,
8
+ getDecoratorName,
9
+ getPropertyDeclarations,
10
+ } from './ASTFunctions';
11
+
12
+ export function create(context: any) {
13
+ const imports:TSESTree.ImportDeclaration[] = [];
14
+ const dependencies:string[] = [];
15
+
16
+ return {
17
+ ImportDeclaration(node:TSESTree.ImportDeclaration) {
18
+ imports.push(node);
19
+ },
20
+ ClassDeclaration(node:TSESTree.ClassDeclaration) {
21
+ const { decorators } = node;
22
+ if (decorators) {
23
+ const decoratorNames = decorators.map((decorator) => getDecoratorName(decorator));
24
+ if (decoratorNames.includes('Graph')) {
25
+ const subGraphs = getSubGraphs(decorators);
26
+ if (subGraphs.length > 0) {
27
+ dependencies.push(...getDependenciesFromSubgraphs(imports, subGraphs, context));
28
+ }
29
+ dependencies.push(...mapFunctions(node));
30
+ dependencies.push(...getPropertyDeclarations(node));
31
+ const check = checkDependencies(node, dependencies);
32
+ if (!check?.value) {
33
+ context.report({
34
+ node,
35
+ messageId: 'undefinedDependency',
36
+ data: {
37
+ dependencyName: check.param,
38
+ },
39
+ });
40
+ }
41
+ }
42
+ }
43
+ },
44
+ };
45
+ }
@@ -0,0 +1,24 @@
1
+ export const invalidGraph = `import { Graph, ObjectGraph, Provides } from 'src';
2
+
3
+ @Graph()
4
+ export default class SimpleGraph extends ObjectGraph {
5
+ @Provides()
6
+ instanceId(id:string): string {
7
+ return id;
8
+ }
9
+ }`;
10
+
11
+ export const invalidGraphWithSubgraph = `import {
12
+ Graph,
13
+ ObjectGraph,
14
+ Provides,
15
+ } from 'src';
16
+ import Subgraph from './subgraph';
17
+
18
+ @Graph({ subgraphs: [Subgraph] })
19
+ export default class SimpleGraphWithSubgraph extends ObjectGraph {
20
+ @Provides()
21
+ someClass(wrongDep:string): string {
22
+ return wrongDep;
23
+ }
24
+ }`;
@@ -0,0 +1,24 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import { RuleModule } from '@typescript-eslint/utils/ts-eslint';
3
+ import { create } from './createFunction';
4
+
5
+ const createRule = ESLintUtils.RuleCreator(
6
+ (name) => `https://example.com/rule/${name}`,
7
+ );
8
+
9
+ export const undefinedDependencies: RuleModule<'undefinedDependency'> = createRule({
10
+ create,
11
+ name: 'undefined-dependency',
12
+ meta: {
13
+ docs: {
14
+ description: 'The dependency must be defined',
15
+ recommended: 'strict',
16
+ },
17
+ messages: {
18
+ undefinedDependency: 'Dependency {{ dependencyName }} is undefined',
19
+ },
20
+ schema: [],
21
+ type: 'problem',
22
+ },
23
+ defaultOptions: [] as [],
24
+ });
@@ -0,0 +1,15 @@
1
+ import { uniqueId } from 'lodash';
2
+ import { Graph, ObjectGraph, Provides } from 'src';
3
+
4
+ @Graph()
5
+ export default class Subgraph extends ObjectGraph {
6
+ @Provides()
7
+ unusedDependency(): string {
8
+ throw Error('This dependency should not have been resolved since it is not required by anyone.');
9
+ }
10
+
11
+ @Provides()
12
+ instanceId(): string {
13
+ return uniqueId('graph');
14
+ }
15
+ }
@@ -0,0 +1,26 @@
1
+ export const validGraphSimple = `import { uniqueId } from 'lodash';
2
+ import { Graph, ObjectGraph, Provides } from 'src';
3
+
4
+ @Graph()
5
+ export default class SimpleGraph extends ObjectGraph {
6
+ @Provides()
7
+ instanceId(): string {
8
+ return 'graph';
9
+ }
10
+ }`;
11
+
12
+ export const validGraphWithSubgraph = `import {
13
+ Graph,
14
+ ObjectGraph,
15
+ Provides,
16
+ } from 'src';
17
+ import Subgraph from './subgraph';
18
+
19
+
20
+ @Graph({ subgraphs: [Subgraph] })
21
+ export default class SimpleGraphWithSubgraph extends ObjectGraph {
22
+ @Provides()
23
+ someClass(instanceId:string): string {
24
+ return instanceId;
25
+ }
26
+ }`;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "react-obsidian",
3
- "version": "2.2.0",
3
+ "version": "2.3.0-rc.1",
4
4
  "description": "Dependency injection framework for React and React Native applications",
5
5
  "scripts": {
6
6
  "prepack": "npm run lint && tsc --project tsconfig.prod.json",
7
7
  "lint": "npx eslint src transformers test --ignore-pattern '*.d.ts' --ext .ts,.tsx,.js",
8
- "pretest": "tsc",
8
+ "build-local": "tsc --project tsconfig.json",
9
+ "pretest": "tsc --project tsconfig.json",
9
10
  "test": "npx jest"
10
11
  },
11
12
  "main": "dist/src/index.js",
@@ -14,6 +15,7 @@
14
15
  },
15
16
  "dependencies": {
16
17
  "hoist-non-react-statics": "3.x.x",
18
+ "jest-cli": "^29.5.0",
17
19
  "reflect-metadata": "~0.1.13"
18
20
  },
19
21
  "peerDependencies": {
@@ -21,6 +23,7 @@
21
23
  },
22
24
  "devDependencies": {
23
25
  "@babel/core": "7.22.x",
26
+ "@babel/eslint-parser": "7.22.x",
24
27
  "@babel/plugin-proposal-decorators": "7.22.x",
25
28
  "@babel/plugin-transform-class-properties": "7.22.x",
26
29
  "@babel/preset-env": "7.22.x",
@@ -29,31 +32,39 @@
29
32
  "@babel/types": "7.22.x",
30
33
  "@johanblumenberg/ts-mockito": "1.x.x",
31
34
  "@testing-library/react": "14.x.x",
35
+ "@types/eslint": "8.4.9",
32
36
  "@types/hoist-non-react-statics": "^3.3.1",
33
37
  "@types/jest": "29.5.x",
34
38
  "@types/lodash": "^4.14.176",
35
39
  "@types/react": "18.2.x",
36
40
  "@types/react-dom": "18.2.x",
37
- "@types/react-test-renderer": "17.0.1",
38
- "@typescript-eslint/eslint-plugin": "^5.3.0",
39
- "@typescript-eslint/parser": "^5.3.0",
41
+ "@typescript-eslint/eslint-plugin": "6.6.x",
42
+ "@typescript-eslint/parser": "6.6.x",
43
+ "@typescript-eslint/types": "6.6.x",
44
+ "@typescript-eslint/rule-tester": "6.6.x",
45
+ "@typescript-eslint/typescript-estree": "6.6.x",
46
+ "@typescript-eslint/utils": "6.6.x",
47
+ "babel-eslint": "^10.1.0",
40
48
  "babel-plugin-parameter-decorator": "1.x.x",
41
- "eslint": "8.x.x",
42
- "eslint-config-airbnb-typescript": "17.x.x",
49
+ "class-validator": "^0.14.0",
50
+ "eslint": "^8.36.0",
43
51
  "eslint-plugin-import": "^2.25.2",
44
52
  "eslint-plugin-import-newlines": "^1.1.5",
45
- "eslint-plugin-jsx-a11y": "^6.4.1",
53
+ "eslint-plugin-local-rules": "^1.3.2",
46
54
  "eslint-plugin-react": "^7.26.1",
47
55
  "eslint-plugin-react-hooks": "^4.2.0",
48
- "eslint-plugin-unused-imports": "2.x.x",
56
+ "eslint-plugin-unused-imports": "3.1.x",
57
+ "husky": "8.0.1",
49
58
  "jest": "29.5.x",
59
+ "jest-create-mock-instance": "2.0.0",
50
60
  "jest-environment-jsdom": "^29.5.0",
51
61
  "jest-extended": "^4.0.0",
52
62
  "lodash": "^4.17.21",
53
63
  "react": "18.2.x",
54
64
  "react-dom": "18.2.x",
55
65
  "setimmediate": "^1.0.5",
56
- "typescript": "^4.5.4"
66
+ "typescript": "^4.5.4",
67
+ "eslint-config-airbnb-typescript": "17.x.x"
57
68
  },
58
69
  "repository": {
59
70
  "type": "git",
@@ -70,6 +70,22 @@ export class GraphRegistry {
70
70
  return Reflect.getMetadata('isLifecycleBound', Graph) ?? false;
71
71
  }
72
72
 
73
+ clearGraphAfterItWasMockedInTests(graphName: string) {
74
+ const graphNames = this.nameToInstance.keys();
75
+ for (const name of graphNames) {
76
+ if (name.match(graphName)) {
77
+ const graph = this.nameToInstance.get(name);
78
+ if (!graph) return;
79
+ const Graph = this.instanceToConstructor.get(graph);
80
+ if (!Graph) return;
81
+
82
+ this.instanceToConstructor.delete(graph);
83
+ this.constructorToInstance.get(Graph)!.delete(graph);
84
+ this.nameToInstance.delete(graph.name);
85
+ }
86
+ }
87
+ }
88
+
73
89
  clear(graph: Graph) {
74
90
  const Graph = this.instanceToConstructor.get(graph);
75
91
  if (!Graph || this.isSingleton(Graph)) return;
@@ -93,4 +109,8 @@ export class GraphRegistry {
93
109
  }
94
110
  }
95
111
 
96
- export default new GraphRegistry();
112
+ // @ts-ignore
113
+ global.graphRegistry = global.graphRegistry || new GraphRegistry();
114
+ // @ts-ignore
115
+ export default global.graphRegistry as GraphRegistry;
116
+ // export default new GraphRegistry();
@@ -16,5 +16,15 @@ export function mockGraphs(
16
16
  return resolveChain.proceed(Graph, props);
17
17
  }
18
18
  }();
19
+
20
+ clearRegisteredGraphs(graphNameToGraph);
19
21
  graphRegistry.addGraphMiddleware(graphMiddleware);
20
22
  }
23
+
24
+ function clearRegisteredGraphs(
25
+ graphNameToGraph: Record<string, Constructable<ObjectGraph> | ((props: any) => ObjectGraph)>,
26
+ ) {
27
+ for (const graphName of Object.keys(graphNameToGraph)) {
28
+ graphRegistry.clearGraphAfterItWasMockedInTests(graphName);
29
+ }
30
+ }
@@ -1,6 +1,13 @@
1
+ import { Constructable } from '../src/types';
1
2
  import { Model } from '../src/model/Model';
2
3
 
3
- export function mockModel<T extends Model, S extends Partial<T>>(mock: S): T {
4
+ export function mockModel<T extends Model, S extends Partial<T>>(mock: S, BaseClass?: Constructable<T>): T {
5
+ if (BaseClass) {
6
+ const bc = new BaseClass();
7
+ Object.assign(bc, mock);
8
+ return bc;
9
+ }
10
+
4
11
  return new class extends Model {
5
12
  constructor() {
6
13
  super();
package/wallaby.js ADDED
@@ -0,0 +1,9 @@
1
+ module.exports = () => {
2
+ return {
3
+ autoDetect: true,
4
+ testFramework: {
5
+ configFile: './node_modules/@wix/shono-testjs/dist/src/jestConfig.js',
6
+ },
7
+ env: {params: {env: 'NODE_OPTIONS="--max_old_space_size=4096"'}},
8
+ };
9
+ };