@ddd-ts-kit/eslint-plugin 0.14.0 → 0.16.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/README.md +1 -0
- package/dist/project/config.d.ts +2 -0
- package/dist/project/config.d.ts.map +1 -1
- package/dist/project/parse-config.d.ts.map +1 -1
- package/dist/project/parse-config.js +2 -0
- package/dist/project/parse-config.js.map +1 -1
- package/dist/rules/domain-value-object-class.d.ts +4 -0
- package/dist/rules/domain-value-object-class.d.ts.map +1 -0
- package/dist/rules/domain-value-object-class.js +85 -0
- package/dist/rules/domain-value-object-class.js.map +1 -0
- package/dist/rules/rules.d.ts.map +1 -1
- package/dist/rules/rules.js +2 -0
- package/dist/rules/rules.js.map +1 -1
- package/dist/support/values/answered-objects.d.ts +8 -0
- package/dist/support/values/answered-objects.d.ts.map +1 -0
- package/dist/support/values/answered-objects.js +34 -0
- package/dist/support/values/answered-objects.js.map +1 -0
- package/dist/support/values/entry-role.d.ts +11 -0
- package/dist/support/values/entry-role.d.ts.map +1 -0
- package/dist/support/values/entry-role.js +45 -0
- package/dist/support/values/entry-role.js.map +1 -0
- package/dist/support/values/exported-bindings.d.ts +21 -0
- package/dist/support/values/exported-bindings.d.ts.map +1 -0
- package/dist/support/values/exported-bindings.js +76 -0
- package/dist/support/values/exported-bindings.js.map +1 -0
- package/dist/support/values/extends-value-object.d.ts +10 -0
- package/dist/support/values/extends-value-object.d.ts.map +1 -0
- package/dist/support/values/extends-value-object.js +36 -0
- package/dist/support/values/extends-value-object.js.map +1 -0
- package/dist/support/values/is-model-path.d.ts +8 -0
- package/dist/support/values/is-model-path.d.ts.map +1 -0
- package/dist/support/values/is-model-path.js +16 -0
- package/dist/support/values/is-model-path.js.map +1 -0
- package/dist/support/values/is-value-object-path.d.ts +7 -0
- package/dist/support/values/is-value-object-path.d.ts.map +1 -0
- package/dist/support/values/is-value-object-path.js +15 -0
- package/dist/support/values/is-value-object-path.js.map +1 -0
- package/dist/support/values/javascript-globals.d.ts +3 -0
- package/dist/support/values/javascript-globals.d.ts.map +1 -0
- package/dist/support/values/javascript-globals.js +22 -0
- package/dist/support/values/javascript-globals.js.map +1 -0
- package/dist/support/values/local-binding.d.ts +5 -0
- package/dist/support/values/local-binding.d.ts.map +1 -0
- package/dist/support/values/local-binding.js +23 -0
- package/dist/support/values/local-binding.js.map +1 -0
- package/dist/support/values/returns-package-type.d.ts +9 -0
- package/dist/support/values/returns-package-type.d.ts.map +1 -0
- package/dist/support/values/returns-package-type.js +28 -0
- package/dist/support/values/returns-package-type.js.map +1 -0
- package/dist/support/values/root-name.d.ts +4 -0
- package/dist/support/values/root-name.d.ts.map +1 -0
- package/dist/support/values/root-name.js +23 -0
- package/dist/support/values/root-name.js.map +1 -0
- package/dist/support/values/stands-for-a-value.d.ts +10 -0
- package/dist/support/values/stands-for-a-value.d.ts.map +1 -0
- package/dist/support/values/stands-for-a-value.js +31 -0
- package/dist/support/values/stands-for-a-value.js.map +1 -0
- package/dist/support/values/unwrapped.d.ts +4 -0
- package/dist/support/values/unwrapped.d.ts.map +1 -0
- package/dist/support/values/unwrapped.js +11 -0
- package/dist/support/values/unwrapped.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/rules/domain-value-object-class.md +165 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,6 +105,7 @@ is an error whatever the configured limit). `strict` sets every rule to `error`.
|
|
|
105
105
|
| [`clean/formatted`](docs/rules/clean-formatted.md) | none: Biome (`npm run format:check`) | every file is laid out by the formatter, at a line width of 120 | none | formatter |
|
|
106
106
|
| [`domain/aggregate-encapsulation`](docs/rules/domain-aggregate-encapsulation.md) | `ddd-ts-kit/domain-aggregate-encapsulation` | aggregates and entities: no public constructor, no public mutable property, no setter | `error` | custom |
|
|
107
107
|
| [`domain/value-object-immutability`](docs/rules/domain-value-object-immutability.md) | `ddd-ts-kit/domain-value-object-immutability` | value objects: every property `readonly`, no setter, no write to `this` | `error` | custom |
|
|
108
|
+
| [`domain/value-object-class`](docs/rules/domain-value-object-class.md) | `ddd-ts-kit/domain-value-object-class` | under `"stack.values": "classes"`: a value object file exports one class extending `ValueObject`, private or protected constructor, static factories, no function nor object literal; no exported function of `domain/` or of the shared kernel answers a record of data | `error` | custom |
|
|
108
109
|
| [`domain/no-generic-error`](docs/rules/domain-no-generic-error.md) | `ddd-ts-kit/domain-no-generic-error` | no `throw new Error(...)` in `domain/` and `application/` | `error` | custom |
|
|
109
110
|
| [`errors/through-factory`](docs/rules/errors-through-factory.md) | `ddd-ts-kit/errors-through-factory` | under `"stack.refusals": "factories"`, no `new` of a class imported from `domain/errors/`: a refusal is built by a static factory of its concept class | `error` | custom |
|
|
110
111
|
| [`errors/constructor-not-public`](docs/rules/errors-constructor-not-public.md) | `ddd-ts-kit/errors-constructor-not-public` | under `"stack.refusals": "factories"`, an error class of `domain/errors/` has no public constructor, declared or inherited from `DomainError` | `error` | custom |
|
package/dist/project/config.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface Stack {
|
|
|
24
24
|
readonly schemas: 'shared' | 'per-route';
|
|
25
25
|
/** `named`: a value of a declared vocabulary and a number of the model are read through a name. A config that does not say is `free`, and both rules are silent. */
|
|
26
26
|
readonly literals: 'named' | 'free';
|
|
27
|
+
/** `classes`: a value of the model is a value object class, never a function that builds a plain object. A config that does not say is `free`, and `domain/value-object-class` is silent. */
|
|
28
|
+
readonly values: 'classes' | 'free';
|
|
27
29
|
/** Kept as written: with `prisma` the generated client under `generated/` has an import alias of its own. */
|
|
28
30
|
readonly orm: string;
|
|
29
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/project/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEhD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-config.d.ts","sourceRoot":"","sources":["../../src/project/parse-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAQV,MAAM,EAEP,MAAM,aAAa,CAAC;AAOrB,+GAA+G;AAC/G,eAAO,MAAM,sBAAsB,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-config.d.ts","sourceRoot":"","sources":["../../src/project/parse-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAQV,MAAM,EAEP,MAAM,aAAa,CAAC;AAOrB,+GAA+G;AAC/G,eAAO,MAAM,sBAAsB,MAAM,CAAC;AA2B1C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CA0BhD"}
|
|
@@ -10,6 +10,7 @@ const DEPENDENCY_STATEMENTS = ['signature', 'listed'];
|
|
|
10
10
|
const REFUSAL_FORMS = ['factories', 'classes'];
|
|
11
11
|
const SCHEMA_FORMS = ['shared', 'per-route'];
|
|
12
12
|
const LITERAL_FORMS = ['named', 'free'];
|
|
13
|
+
const VALUE_FORMS = ['classes', 'free'];
|
|
13
14
|
const KERNEL = ['@ddd-ts-kit/kernel'];
|
|
14
15
|
/** The package name of a client when "sdk" does not give one, as the CLI writes it. */
|
|
15
16
|
const DEFAULT_SDK_NAME = '{project}-{document}-client';
|
|
@@ -63,6 +64,7 @@ function parseStack(value) {
|
|
|
63
64
|
refusals: oneOf(REFUSAL_FORMS, raw['refusals'], 'classes'),
|
|
64
65
|
schemas: oneOf(SCHEMA_FORMS, raw['schemas'], 'per-route'),
|
|
65
66
|
literals: oneOf(LITERAL_FORMS, raw['literals'], 'free'),
|
|
67
|
+
values: oneOf(VALUE_FORMS, raw['values'], 'free'),
|
|
66
68
|
orm: text(raw['orm'], 'drizzle'),
|
|
67
69
|
};
|
|
68
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-config.js","sourceRoot":"","sources":["../../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S,IAAI,CAAC,KAAc,EAAE,QAAgB;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type MessageId = 'noClass' | 'secondClass' | 'notValueObject' | 'publicConstructor' | 'noFactory' | 'exportedFunction' | 'exportedLiteral' | 'plainValue';
|
|
2
|
+
export declare const domainValueObjectClass: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageId, [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
|
+
export {};
|
|
4
|
+
//# sourceMappingURL=domain-value-object-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-value-object-class.d.ts","sourceRoot":"","sources":["../../src/rules/domain-value-object-class.ts"],"names":[],"mappings":"AAeA,KAAK,SAAS,GACV,SAAS,GACT,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,WAAW,GACX,kBAAkB,GAClB,iBAAiB,GACjB,YAAY,CAAC;AAIjB,eAAO,MAAM,sBAAsB,mKAqCjC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { className } from '../support/classes/class-name.js';
|
|
3
|
+
import { constructorOf } from '../support/classes/constructor-of.js';
|
|
4
|
+
import { exportedClasses } from '../support/classes/exported-classes.js';
|
|
5
|
+
import { visibilityOf } from '../support/classes/visibility-of.js';
|
|
6
|
+
import { defineRule } from '../support/rule/define-rule.js';
|
|
7
|
+
import { answeredObjects } from '../support/values/answered-objects.js';
|
|
8
|
+
import { exportedBindings } from '../support/values/exported-bindings.js';
|
|
9
|
+
import { extendsValueObject } from '../support/values/extends-value-object.js';
|
|
10
|
+
import { isModelPath } from '../support/values/is-model-path.js';
|
|
11
|
+
import { isValueObjectPath } from '../support/values/is-value-object-path.js';
|
|
12
|
+
import { returnsPackageType } from '../support/values/returns-package-type.js';
|
|
13
|
+
import { standsForAValue } from '../support/values/stands-for-a-value.js';
|
|
14
|
+
const GENERATE = '`npx ddd-ts-kit generate value-object <context> <Name>`';
|
|
15
|
+
export const domainValueObjectClass = defineRule({
|
|
16
|
+
id: 'domain/value-object-class',
|
|
17
|
+
type: 'problem',
|
|
18
|
+
recommended: 'error',
|
|
19
|
+
description: 'Under "stack.values": "classes", a value object is a class: a file of domain/value-objects/ (or a *.vo.ts of the shared kernel) exports one class extending ValueObject, with a private or protected constructor and static factories, and no function or object literal; no exported function of domain/ or of the shared kernel answers a record of data (no spread, nothing a call of the model built).',
|
|
20
|
+
messages: {
|
|
21
|
+
noClass: `The value object file exports no class. Write the value as a class, \`export class <Name> extends ValueObject<<Name>Props>\`, with a private constructor and a static factory that checks its rules (${GENERATE} writes one): a function or an object literal gives no equality by value, no single place for the invariants and nothing \`instanceof\` can recognise.`,
|
|
22
|
+
secondClass: 'The value object file exports a second class, {{className}}. Move it to a *.vo.ts of its own: one value object per file, named after it.',
|
|
23
|
+
notValueObject: '{{className}} does not extend ValueObject. Extend ValueObject of @ddd-ts-kit/kernel, or another value object of the project: it gives equality by value (`equals`), frozen props and `toJSON`.',
|
|
24
|
+
publicConstructor: 'The constructor of {{className}} is public. Make it private (protected on a base other value objects extend) and build the value through a static factory, `{{className}}.create(..)`, that checks its rules: a {{className}} that exists is a valid one.',
|
|
25
|
+
noFactory: '{{className}} has no static factory. Add `static create(..): {{className}}`, which checks the rules and returns `new {{className}}(..)`; name the other ones after what they build (`{{className}}.closed()`, `{{className}}.between(..)`).',
|
|
26
|
+
exportedFunction: 'The value object file exports the function {{name}}. Make it a static factory or a method of the value object class: what builds or reads the value lives next to its data.',
|
|
27
|
+
exportedLiteral: 'The value object file exports the object literal {{name}}. Make it a static factory of the class, `static {{name}}()`, which builds a checked instance; a closed list of values is a vocabulary (domain/vocabularies/*.vocabulary.ts).',
|
|
28
|
+
plainValue: `{{name}} builds a plain object: a value of the model written as a function. Write it as a value object class (${GENERATE}): its rules checked once in a static factory, \`equals\` to compare two of them, its operations as methods next to its data. A domain service, a state machine, a specification, a function that answers value objects it builds or derives a record with a spread stays as it is.`,
|
|
29
|
+
},
|
|
30
|
+
create({ file, report }) {
|
|
31
|
+
const { path, location, config } = file;
|
|
32
|
+
if (config.stack.values !== 'classes') {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
if (isValueObjectPath(path, location, config.sharedKernelDir)) {
|
|
36
|
+
return { Program: (program) => judgeValueObjectFile(file, program, report) };
|
|
37
|
+
}
|
|
38
|
+
return isModelPath(path, location, config.sharedKernelDir)
|
|
39
|
+
? { Program: (program) => judgeModelFunctions(file, program, report) }
|
|
40
|
+
: {};
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
function judgeValueObjectFile(file, program, report) {
|
|
44
|
+
const [main, ...others] = exportedClasses(program);
|
|
45
|
+
if (main === undefined) {
|
|
46
|
+
report({ loc: { line: 1, column: 0 }, messageId: 'noClass' });
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
judgeClass(main, extendsValueObject(file, program, main), report);
|
|
50
|
+
}
|
|
51
|
+
for (const other of others) {
|
|
52
|
+
report({ node: other.id ?? other, messageId: 'secondClass', data: { className: className(other) } });
|
|
53
|
+
}
|
|
54
|
+
for (const binding of exportedBindings(program)) {
|
|
55
|
+
const messageId = binding.kind === 'function' ? 'exportedFunction' : 'exportedLiteral';
|
|
56
|
+
report({ node: binding.at, messageId, data: { name: binding.name } });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function judgeClass(node, isValueObject, report) {
|
|
60
|
+
const data = { className: className(node) };
|
|
61
|
+
const constructor = constructorOf(node.body);
|
|
62
|
+
if (!isValueObject) {
|
|
63
|
+
report({ node: node.id ?? node, messageId: 'notValueObject', data });
|
|
64
|
+
}
|
|
65
|
+
if (constructor !== undefined && visibilityOf(constructor) === 'public') {
|
|
66
|
+
report({ node: constructor.key, messageId: 'publicConstructor', data });
|
|
67
|
+
}
|
|
68
|
+
if (!node.abstract && !node.body.body.some(isFactory)) {
|
|
69
|
+
report({ node: node.id ?? node, messageId: 'noFactory', data });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function isFactory(member) {
|
|
73
|
+
return member.type === AST_NODE_TYPES.MethodDefinition && member.static && visibilityOf(member) !== 'private';
|
|
74
|
+
}
|
|
75
|
+
function judgeModelFunctions(file, program, report) {
|
|
76
|
+
for (const binding of exportedBindings(program)) {
|
|
77
|
+
if (binding.kind !== 'function' || returnsPackageType(file, program, binding.node)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (answeredObjects(binding.node).some((object) => standsForAValue(object, program))) {
|
|
81
|
+
report({ node: binding.at, messageId: 'plainValue', data: { name: binding.name } });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=domain-value-object-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-value-object-class.js","sourceRoot":"","sources":["../../src/rules/domain-value-object-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAe,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,o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AAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;YACrF,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/rules/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/rules/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AA8IlE,+HAA+H;AAC/H,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEnD,CAAC"}
|
package/dist/rules/rules.js
CHANGED
|
@@ -32,6 +32,7 @@ import { eventSourcingUpcasterRequired } from './event-sourcing-upcaster-require
|
|
|
32
32
|
import { errorsConstructorNotPublic } from './errors-constructor-not-public.js';
|
|
33
33
|
import { errorsFactoryName } from './errors-factory-name.js';
|
|
34
34
|
import { errorsThroughFactory } from './errors-through-factory.js';
|
|
35
|
+
import { domainValueObjectClass } from './domain-value-object-class.js';
|
|
35
36
|
import { domainValueObjectImmutability } from './domain-value-object-immutability.js';
|
|
36
37
|
import { eventsConsumerIdempotent } from './events-consumer-idempotent.js';
|
|
37
38
|
import { eventsNameFormat } from './events-name-format.js';
|
|
@@ -87,6 +88,7 @@ const ALL = [
|
|
|
87
88
|
cleanNoMagicNumber,
|
|
88
89
|
domainAggregateEncapsulation,
|
|
89
90
|
domainValueObjectImmutability,
|
|
91
|
+
domainValueObjectClass,
|
|
90
92
|
domainNoGenericError,
|
|
91
93
|
errorsThroughFactory,
|
|
92
94
|
errorsConstructorNotPublic,
|
package/dist/rules/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/rules/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MA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TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { FunctionNode } from '../functions/function-node.js';
|
|
3
|
+
/**
|
|
4
|
+
* The object literals a function answers by itself: the expression of an arrow, or what a
|
|
5
|
+
* `return` of its own body gives back. A `return` of a function nested in it answers for that one.
|
|
6
|
+
*/
|
|
7
|
+
export declare function answeredObjects(node: FunctionNode): TSESTree.ObjectExpression[];
|
|
8
|
+
//# sourceMappingURL=answered-objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answered-objects.d.ts","sourceRoot":"","sources":["../../../src/support/values/answered-objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AASlE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC,gBAAgB,EAAE,CAQ/E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { descendants } from '../descendants.js';
|
|
3
|
+
import { unwrapped } from './unwrapped.js';
|
|
4
|
+
const FUNCTIONS = new Set([
|
|
5
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
6
|
+
AST_NODE_TYPES.FunctionDeclaration,
|
|
7
|
+
AST_NODE_TYPES.FunctionExpression,
|
|
8
|
+
]);
|
|
9
|
+
/**
|
|
10
|
+
* The object literals a function answers by itself: the expression of an arrow, or what a
|
|
11
|
+
* `return` of its own body gives back. A `return` of a function nested in it answers for that one.
|
|
12
|
+
*/
|
|
13
|
+
export function answeredObjects(node) {
|
|
14
|
+
const { body } = node;
|
|
15
|
+
if (body.type !== AST_NODE_TYPES.BlockStatement) {
|
|
16
|
+
return objectOf(body);
|
|
17
|
+
}
|
|
18
|
+
return ownReturns(body).flatMap((statement) => (statement.argument === null ? [] : objectOf(statement.argument)));
|
|
19
|
+
}
|
|
20
|
+
function ownReturns(body) {
|
|
21
|
+
return [...descendants(body)].filter((node) => node.type === AST_NODE_TYPES.ReturnStatement && enclosingFunction(node) === body.parent);
|
|
22
|
+
}
|
|
23
|
+
function enclosingFunction(node) {
|
|
24
|
+
let current = node.parent;
|
|
25
|
+
while (current !== undefined && !FUNCTIONS.has(current.type)) {
|
|
26
|
+
current = current.parent;
|
|
27
|
+
}
|
|
28
|
+
return current;
|
|
29
|
+
}
|
|
30
|
+
function objectOf(expression) {
|
|
31
|
+
const inner = unwrapped(expression);
|
|
32
|
+
return inner.type === AST_NODE_TYPES.ObjectExpression ? [inner] : [];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=answered-objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answered-objects.js","sourceRoot":"","sources":["../../../src/support/values/answered-objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAS;IAChC,cAAc,CAAC,uBAAuB;IACtC,cAAc,CAAC,mBAAmB;IAClC,cAAc,CAAC,kBAAkB;CAClC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAkB;IAChD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAEtB,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc,EAAE,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACpH,CAAC;AAED,SAAS,UAAU,CAAC,IAA6B;IAC/C,OAAO,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAClC,CAAC,IAAI,EAAoC,EAAE,CACzC,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAC1F,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAmB;IAC5C,IAAI,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;IAE1B,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,UAA+B;IAC/C,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAEpC,OAAO,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
/**
|
|
3
|
+
* What an entry of an object literal holds: `behaviour`, a function; `built`, what a call or
|
|
4
|
+
* `new` of the model built (`Money.of(1)`, `total.add(tax)`, `new Slot(..)`), a call of the
|
|
5
|
+
* language aside (`Math.round(..)`, `new Date(..)`); `data`, anything else: a literal, a
|
|
6
|
+
* parameter, an operation on them.
|
|
7
|
+
*/
|
|
8
|
+
export type EntryRole = 'behaviour' | 'built' | 'data';
|
|
9
|
+
/** The role of an expression; a name is read from its declaration in the module, found by name. */
|
|
10
|
+
export declare function expressionRole(expression: TSESTree.Expression, program: TSESTree.Program, seen?: ReadonlySet<string>): EntryRole;
|
|
11
|
+
//# sourceMappingURL=entry-role.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-role.d.ts","sourceRoot":"","sources":["../../../src/support/values/entry-role.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAMzE;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAEvD,mGAAmG;AACnG,wBAAgB,cAAc,CAC5B,UAAU,EAAE,QAAQ,CAAC,UAAU,EAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO,EACzB,IAAI,GAAE,WAAW,CAAC,MAAM,CAAa,GACpC,SAAS,CAoBX"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { descendants } from '../descendants.js';
|
|
3
|
+
import { JAVASCRIPT_GLOBALS } from './javascript-globals.js';
|
|
4
|
+
import { rootName } from './root-name.js';
|
|
5
|
+
import { unwrapped } from './unwrapped.js';
|
|
6
|
+
/** The role of an expression; a name is read from its declaration in the module, found by name. */
|
|
7
|
+
export function expressionRole(expression, program, seen = new Set()) {
|
|
8
|
+
const inner = unwrapped(expression);
|
|
9
|
+
switch (inner.type) {
|
|
10
|
+
case AST_NODE_TYPES.ArrowFunctionExpression:
|
|
11
|
+
case AST_NODE_TYPES.FunctionExpression: {
|
|
12
|
+
return 'behaviour';
|
|
13
|
+
}
|
|
14
|
+
case AST_NODE_TYPES.CallExpression:
|
|
15
|
+
case AST_NODE_TYPES.NewExpression:
|
|
16
|
+
case AST_NODE_TYPES.ChainExpression: {
|
|
17
|
+
return calledRole(rootName(inner));
|
|
18
|
+
}
|
|
19
|
+
case AST_NODE_TYPES.Identifier: {
|
|
20
|
+
return seen.has(inner.name) ? 'data' : boundRole(program, inner.name, new Set([...seen, inner.name]));
|
|
21
|
+
}
|
|
22
|
+
default: {
|
|
23
|
+
return 'data';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** A call or `new` of the language builds data; any other one, a value of the model. */
|
|
28
|
+
function calledRole(root) {
|
|
29
|
+
return JAVASCRIPT_GLOBALS.has(root ?? '') ? 'data' : 'built';
|
|
30
|
+
}
|
|
31
|
+
/** The role of what the first declaration of `name` in the module binds: a parameter, declared nowhere, is data. */
|
|
32
|
+
function boundRole(program, name, seen) {
|
|
33
|
+
for (const node of descendants(program)) {
|
|
34
|
+
if (node.type === AST_NODE_TYPES.FunctionDeclaration && node.id?.name === name) {
|
|
35
|
+
return 'behaviour';
|
|
36
|
+
}
|
|
37
|
+
if (node.type === AST_NODE_TYPES.VariableDeclarator && node.id.type === AST_NODE_TYPES.Identifier) {
|
|
38
|
+
if (node.id.name === name && node.init !== null) {
|
|
39
|
+
return expressionRole(node.init, program, seen);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return 'data';
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=entry-role.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-role.js","sourceRoot":"","sources":["../../../src/support/values/entry-role.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAU3C,mGAAmG;AACnG,MAAM,UAAU,cAAc,CAC5B,UAA+B,EAC/B,OAAyB,EACzB,IAAI,GAAwB,IAAI,GAAG,EAAE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C;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,kBAAkB,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,EAAE,CAAC;YAClG,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBAChD,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { FunctionNode } from '../functions/function-node.js';
|
|
3
|
+
/** A function or a constant a module exports, with the node it is reported on. */
|
|
4
|
+
export type ExportedBinding = {
|
|
5
|
+
readonly kind: 'function';
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly at: TSESTree.Node;
|
|
8
|
+
readonly node: FunctionNode;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'object';
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly at: TSESTree.Node;
|
|
13
|
+
readonly node: TSESTree.ObjectExpression;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The functions (declared, or arrows and function expressions bound to a constant) and object
|
|
17
|
+
* literals a module exports: inline, by `export { name }` and by `export default`, a name
|
|
18
|
+
* exported after its declaration being read from that declaration.
|
|
19
|
+
*/
|
|
20
|
+
export declare function exportedBindings(program: TSESTree.Program): ExportedBinding[];
|
|
21
|
+
//# sourceMappingURL=exported-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exported-bindings.d.ts","sourceRoot":"","sources":["../../../src/support/values/exported-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGlE,kFAAkF;AAClF,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GAC7G;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,gBAAgB,CAAC;CAC1C,CAAC;AAEN;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,GAAG,eAAe,EAAE,CAU7E"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { localBinding } from './local-binding.js';
|
|
3
|
+
/**
|
|
4
|
+
* The functions (declared, or arrows and function expressions bound to a constant) and object
|
|
5
|
+
* literals a module exports: inline, by `export { name }` and by `export default`, a name
|
|
6
|
+
* exported after its declaration being read from that declaration.
|
|
7
|
+
*/
|
|
8
|
+
export function exportedBindings(program) {
|
|
9
|
+
return program.body.flatMap((statement) => {
|
|
10
|
+
if (statement.type === AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
11
|
+
return defaultExport(program, statement.declaration);
|
|
12
|
+
}
|
|
13
|
+
return statement.type === AST_NODE_TYPES.ExportNamedDeclaration && statement.exportKind !== 'type'
|
|
14
|
+
? namedExport(program, statement)
|
|
15
|
+
: [];
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** `export function ..`, `export const ..`, and the names of `export { .. }` without a source. */
|
|
19
|
+
function namedExport(program, statement) {
|
|
20
|
+
const { declaration } = statement;
|
|
21
|
+
if (declaration === null) {
|
|
22
|
+
return statement.source === null ? statement.specifiers.flatMap((specifier) => listed(program, specifier)) : [];
|
|
23
|
+
}
|
|
24
|
+
if (declaration.type === AST_NODE_TYPES.FunctionDeclaration) {
|
|
25
|
+
return bound(declaration, declaration.id?.name ?? 'default', declaration.id ?? declaration);
|
|
26
|
+
}
|
|
27
|
+
return declaration.type === AST_NODE_TYPES.VariableDeclaration ? declaration.declarations.flatMap(boundTo) : [];
|
|
28
|
+
}
|
|
29
|
+
/** `export { money }`, `export { money as of }`: what the local declaration binds, reported on the export. */
|
|
30
|
+
function listed(program, specifier) {
|
|
31
|
+
const { local, exported } = specifier;
|
|
32
|
+
if (specifier.exportKind === 'type' || local.type !== AST_NODE_TYPES.Identifier) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const name = exported.type === AST_NODE_TYPES.Identifier ? exported.name : exported.value;
|
|
36
|
+
return bound(localBinding(program, local.name), name, specifier);
|
|
37
|
+
}
|
|
38
|
+
/** `export default (..) => ..`, `export default function (..) {}`, `export default { .. }`, `export default money`. */
|
|
39
|
+
function defaultExport(program, declaration) {
|
|
40
|
+
if (declaration.type === AST_NODE_TYPES.FunctionDeclaration) {
|
|
41
|
+
return [{ kind: 'function', name: 'default', at: declaration.id ?? declaration, node: declaration }];
|
|
42
|
+
}
|
|
43
|
+
return declaration.type === AST_NODE_TYPES.Identifier
|
|
44
|
+
? bound(localBinding(program, declaration.name), 'default', declaration)
|
|
45
|
+
: bound(declaration, 'default', declaration);
|
|
46
|
+
}
|
|
47
|
+
function boundTo(declarator) {
|
|
48
|
+
const name = declarator.id.type === AST_NODE_TYPES.Identifier ? declarator.id.name : 'a binding';
|
|
49
|
+
return bound(declarator.init ?? undefined, name, declarator.id);
|
|
50
|
+
}
|
|
51
|
+
/** What a binding holds when it is a function or an object literal; nothing else is judged. */
|
|
52
|
+
function bound(value, name, at) {
|
|
53
|
+
const inner = value === undefined ? undefined : peeled(value);
|
|
54
|
+
switch (inner?.type) {
|
|
55
|
+
case AST_NODE_TYPES.FunctionDeclaration:
|
|
56
|
+
case AST_NODE_TYPES.ArrowFunctionExpression:
|
|
57
|
+
case AST_NODE_TYPES.FunctionExpression: {
|
|
58
|
+
return [{ kind: 'function', name, at, node: inner }];
|
|
59
|
+
}
|
|
60
|
+
case AST_NODE_TYPES.ObjectExpression: {
|
|
61
|
+
return [{ kind: 'object', name, at, node: inner }];
|
|
62
|
+
}
|
|
63
|
+
default: {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** The node under `as ..`, `satisfies ..` and `!`. */
|
|
69
|
+
function peeled(node) {
|
|
70
|
+
return node.type === AST_NODE_TYPES.TSAsExpression ||
|
|
71
|
+
node.type === AST_NODE_TYPES.TSSatisfiesExpression ||
|
|
72
|
+
node.type === AST_NODE_TYPES.TSNonNullExpression
|
|
73
|
+
? peeled(node.expression)
|
|
74
|
+
: node;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=exported-bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exported-bindings.js","sourceRoot":"","sources":["../../../src/support/values/exported-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAYlD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAyB;IACxD,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,EAAqB,EAAE;QAC3D,IAAI,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,wBAAwB,EAAE,CAAC;YAC/D,OAAO,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,SAAS,CAAC,IAAI,KAAK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C;IAE9D,QAAQ,KAAK,EAAE,IAAI,EAAE,CAAC;QACpB,KAAK,cAAc,CAAC,mBAAmB,CAAC;QACxC,KAAK,cAAc,CAAC,uBAAuB,CAAC;QAC5C,KAAK,cAAc,CAAC,kBAAkB,EAAE,CAAC;YACvC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,KAAK,cAAc,CAAC,gBAAgB,EAAE,CAAC;YACrC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,SAAS,CAAC;YACR,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC;AAED,sDAAsD;AACtD,SAAS,MAAM,CAAC,IAAmB;IACjC,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc;QAChD,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,qBAAqB;QAClD,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,mBAAmB;QAChD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { LintedFile } from '../../project/linted-file.js';
|
|
3
|
+
import type { ClassNode } from '../classes/class-name.js';
|
|
4
|
+
/**
|
|
5
|
+
* Whether a class is a value object: it extends `ValueObject` of the kernel, a class of its own
|
|
6
|
+
* module that does, or a class imported from a value object file of the project, whose own file
|
|
7
|
+
* is judged on its own.
|
|
8
|
+
*/
|
|
9
|
+
export declare function extendsValueObject(file: LintedFile, program: TSESTree.Program, node: ClassNode): boolean;
|
|
10
|
+
//# sourceMappingURL=extends-value-object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extends-value-object.d.ts","sourceRoot":"","sources":["../../../src/support/values/extends-value-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAK1D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAsBxG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { topLevelClasses } from '../classes/top-level-classes.js';
|
|
3
|
+
import { importedBindings } from '../ports/imported-bindings.js';
|
|
4
|
+
import { isValueObjectPath } from './is-value-object-path.js';
|
|
5
|
+
/**
|
|
6
|
+
* Whether a class is a value object: it extends `ValueObject` of the kernel, a class of its own
|
|
7
|
+
* module that does, or a class imported from a value object file of the project, whose own file
|
|
8
|
+
* is judged on its own.
|
|
9
|
+
*/
|
|
10
|
+
export function extendsValueObject(file, program, node) {
|
|
11
|
+
const imported = importedBindings(file, program);
|
|
12
|
+
const seen = new Set();
|
|
13
|
+
let current = node;
|
|
14
|
+
while (current !== undefined && !seen.has(current)) {
|
|
15
|
+
const parent = parentName(current.superClass);
|
|
16
|
+
const target = parent === undefined ? undefined : imported.get(parent)?.target;
|
|
17
|
+
if (parent === 'ValueObject') {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (target?.kind === 'file') {
|
|
21
|
+
return isValueObjectPath(target.path, target.location, file.config.sharedKernelDir);
|
|
22
|
+
}
|
|
23
|
+
seen.add(current);
|
|
24
|
+
current = topLevelClasses(program).find((candidate) => parent !== undefined && candidate.id?.name === parent);
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
function parentName(superClass) {
|
|
29
|
+
if (superClass?.type === AST_NODE_TYPES.Identifier) {
|
|
30
|
+
return superClass.name;
|
|
31
|
+
}
|
|
32
|
+
return superClass?.type === AST_NODE_TYPES.MemberExpression && superClass.property.type === AST_NODE_TYPES.Identifier
|
|
33
|
+
? superClass.property.name
|
|
34
|
+
: undefined;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=extends-value-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extends-value-object.js","sourceRoot":"","sources":["../../../src/support/values/extends-value-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAGzE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAgB,EAAE,OAAyB,EAAE,IAAe;IAC7F,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAa,CAAC;IAClC,IAAI,OAAO,GAA0B,IAAI,CAAC;IAE1C,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAE/E,IAAI,MAAM,KAAK,aAAa,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,MAAM,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;YAC5B,OAAO,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClB,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,IAAI,SAAS,CAAC,EAAE,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC;IAChH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,UAAkD;IACpE,IAAI,UAAU,EAAE,IAAI,KAAK,cAAc,CAAC,UAAU,EAAE,CAAC;QACnD,OAAO,UAAU,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,UAAU,EAAE,IAAI,KAAK,cAAc,CAAC,gBAAgB,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU;QACnH,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI;QAC1B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Location } from '../../project/location.js';
|
|
2
|
+
/**
|
|
3
|
+
* Where a value of the model may be written as a function and is looked for: `domain/` of a
|
|
4
|
+
* context, and the shared kernel outside its `presentation/`. Specs are never judged. Same table
|
|
5
|
+
* as the checker of the CLI.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isModelPath(file: string, location: Location, sharedKernelDir: string): boolean;
|
|
8
|
+
//# sourceMappingURL=is-model-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-model-path.d.ts","sourceRoot":"","sources":["../../../src/support/values/is-model-path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAU9F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isTestFile } from '../../project/is-test-file.js';
|
|
2
|
+
/**
|
|
3
|
+
* Where a value of the model may be written as a function and is looked for: `domain/` of a
|
|
4
|
+
* context, and the shared kernel outside its `presentation/`. Specs are never judged. Same table
|
|
5
|
+
* as the checker of the CLI.
|
|
6
|
+
*/
|
|
7
|
+
export function isModelPath(file, location, sharedKernelDir) {
|
|
8
|
+
if (isTestFile(file, location)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (location.area === 'context') {
|
|
12
|
+
return location.layer === 'domain';
|
|
13
|
+
}
|
|
14
|
+
return location.area === 'shared-kernel' && !file.startsWith(`${sharedKernelDir}/presentation/`);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=is-model-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-model-path.js","sourceRoot":"","sources":["../../../src/support/values/is-model-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,QAAkB,EAAE,eAAuB;IACnF,IAAI,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAC;IACrC,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,KAAK,eAAe,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,eAAe,gBAAgB,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Location } from '../../project/location.js';
|
|
2
|
+
/**
|
|
3
|
+
* Where a value object is declared: `domain/value-objects/` of a context, or a `*.vo.ts` of the
|
|
4
|
+
* shared kernel outside its `presentation/`. Same table as the checker of the CLI.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isValueObjectPath(file: string, location: Location, sharedKernelDir: string): boolean;
|
|
7
|
+
//# sourceMappingURL=is-value-object-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-value-object-path.d.ts","sourceRoot":"","sources":["../../../src/support/values/is-value-object-path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAYpG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isTestFile } from '../../project/is-test-file.js';
|
|
2
|
+
/**
|
|
3
|
+
* Where a value object is declared: `domain/value-objects/` of a context, or a `*.vo.ts` of the
|
|
4
|
+
* shared kernel outside its `presentation/`. Same table as the checker of the CLI.
|
|
5
|
+
*/
|
|
6
|
+
export function isValueObjectPath(file, location, sharedKernelDir) {
|
|
7
|
+
if (isTestFile(file, location)) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (location.area === 'context') {
|
|
11
|
+
return location.layer === 'domain' && location.inside[0] === 'value-objects';
|
|
12
|
+
}
|
|
13
|
+
return (location.area === 'shared-kernel' && file.endsWith('.vo.ts') && !file.startsWith(`${sharedKernelDir}/presentation/`));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=is-value-object-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-value-object-path.js","sourceRoot":"","sources":["../../../src/support/values/is-value-object-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,QAAkB,EAAE,eAAuB;IACzF,IAAI,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC;IAC/E,CAAC;IAED,OAAO,CACL,QAAQ,CAAC,IAAI,KAAK,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,eAAe,gBAAgB,CAAC,CACrH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-globals.d.ts","sourceRoot":"","sources":["../../../src/support/values/javascript-globals.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAmBjD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** What a call of the language itself builds: a number, a string, a date, never a value of the model. Same list as the checker of the CLI. */
|
|
2
|
+
export const JAVASCRIPT_GLOBALS = new Set([
|
|
3
|
+
'Array',
|
|
4
|
+
'BigInt',
|
|
5
|
+
'Boolean',
|
|
6
|
+
'Date',
|
|
7
|
+
'Intl',
|
|
8
|
+
'JSON',
|
|
9
|
+
'Map',
|
|
10
|
+
'Math',
|
|
11
|
+
'Number',
|
|
12
|
+
'Object',
|
|
13
|
+
'RegExp',
|
|
14
|
+
'Set',
|
|
15
|
+
'String',
|
|
16
|
+
'Symbol',
|
|
17
|
+
'URL',
|
|
18
|
+
'parseFloat',
|
|
19
|
+
'parseInt',
|
|
20
|
+
'structuredClone',
|
|
21
|
+
]);
|
|
22
|
+
//# sourceMappingURL=javascript-globals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-globals.js","sourceRoot":"","sources":["../../../src/support/values/javascript-globals.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,MAAM,CAAC,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IAC7D,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,YAAY;IACZ,UAAU;IACV,iBAAiB;CAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { FunctionNode } from '../functions/function-node.js';
|
|
3
|
+
/** What a name declared at the top of a module binds: its function, or the value of its constant. */
|
|
4
|
+
export declare function localBinding(program: TSESTree.Program, name: string): FunctionNode | TSESTree.Expression | undefined;
|
|
5
|
+
//# sourceMappingURL=local-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-binding.d.ts","sourceRoot":"","sources":["../../../src/support/values/local-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,QAAQ,CAAC,UAAU,GAAG,SAAS,CAWpH"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
/** What a name declared at the top of a module binds: its function, or the value of its constant. */
|
|
3
|
+
export function localBinding(program, name) {
|
|
4
|
+
for (const statement of program.body) {
|
|
5
|
+
const declaration = statement.type === AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
6
|
+
const binding = declaration === null ? undefined : bindingOf(declaration, name);
|
|
7
|
+
if (binding !== undefined) {
|
|
8
|
+
return binding;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
function bindingOf(declaration, name) {
|
|
14
|
+
if (declaration.type === AST_NODE_TYPES.FunctionDeclaration) {
|
|
15
|
+
return declaration.id?.name === name ? declaration : undefined;
|
|
16
|
+
}
|
|
17
|
+
if (declaration.type !== AST_NODE_TYPES.VariableDeclaration) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const declarator = declaration.declarations.find(({ id }) => id.type === AST_NODE_TYPES.Identifier && id.name === name);
|
|
21
|
+
return declarator?.init ?? undefined;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=local-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-binding.js","sourceRoot":"","sources":["../../../src/support/values/local-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAGzE,qGAAqG;AACrG,MAAM,UAAU,YAAY,CAAC,OAAyB,EAAE,IAAY;IAClE,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;QACjH,MAAM,OAAO,GAAG,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAEhF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,WAA0B,EAAE,IAAY;IACzD,IAAI,WAAW,CAAC,IAAI,KAAK,cAAc,CAAC,mBAAmB,EAAE,CAAC;QAC5D,OAAO,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC;IAED,IAAI,WAAW,CAAC,IAAI,KAAK,cAAc,CAAC,mBAAmB,EAAE,CAAC;QAC5D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,IAAI,CAC9C,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,IAAI,EAAE,CAAC,IAAI,KAAK,IAAI,CACtE,CAAC;IAEF,OAAO,UAAU,EAAE,IAAI,IAAI,SAAS,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { LintedFile } from '../../project/linted-file.js';
|
|
3
|
+
import type { FunctionNode } from '../functions/function-node.js';
|
|
4
|
+
/**
|
|
5
|
+
* Whether a function declares that it returns a type of a package (`): EventStamp` of the kernel):
|
|
6
|
+
* the shape is the one of the library, which the project cannot make a class of its own.
|
|
7
|
+
*/
|
|
8
|
+
export declare function returnsPackageType(file: LintedFile, program: TSESTree.Program, node: FunctionNode): boolean;
|
|
9
|
+
//# sourceMappingURL=returns-package-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returns-package-type.d.ts","sourceRoot":"","sources":["../../../src/support/values/returns-package-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGlE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAU3G"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { importedBindings } from '../ports/imported-bindings.js';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a function declares that it returns a type of a package (`): EventStamp` of the kernel):
|
|
5
|
+
* the shape is the one of the library, which the project cannot make a class of its own.
|
|
6
|
+
*/
|
|
7
|
+
export function returnsPackageType(file, program, node) {
|
|
8
|
+
const annotation = node.returnType?.typeAnnotation;
|
|
9
|
+
if (annotation?.type !== AST_NODE_TYPES.TSTypeReference) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const name = leftmost(annotation.typeName);
|
|
13
|
+
return importedBindings(file, program).get(name)?.target.kind === 'package';
|
|
14
|
+
}
|
|
15
|
+
function leftmost(name) {
|
|
16
|
+
switch (name.type) {
|
|
17
|
+
case AST_NODE_TYPES.Identifier: {
|
|
18
|
+
return name.name;
|
|
19
|
+
}
|
|
20
|
+
case AST_NODE_TYPES.TSQualifiedName: {
|
|
21
|
+
return leftmost(name.left);
|
|
22
|
+
}
|
|
23
|
+
default: {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=returns-package-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returns-package-type.js","sourceRoot":"","sources":["../../../src/support/values/returns-package-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAgB,EAAE,OAAyB,EAAE,IAAkB;IAChG,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC;IAEnD,IAAI,UAAU,EAAE,IAAI,KAAK,cAAc,CAAC,eAAe,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE3C,OAAO,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AAC9E,CAAC;AAED,SAAS,QAAQ,CAAC,IAAyB;IACzC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,cAAc,CAAC,UAAU,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;QACD,KAAK,cAAc,CAAC,eAAe,EAAE,CAAC;YACpC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,SAAS,CAAC;YACR,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
/** The name a chain of calls and members starts from: `Money` in `Money.of(1).add(tax)`; undefined when it starts from `this` or an expression. */
|
|
3
|
+
export declare function rootName(node: TSESTree.Node): string | undefined;
|
|
4
|
+
//# sourceMappingURL=root-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-name.d.ts","sourceRoot":"","sources":["../../../src/support/values/root-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzE,mJAAmJ;AACnJ,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS,CAmBhE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
/** The name a chain of calls and members starts from: `Money` in `Money.of(1).add(tax)`; undefined when it starts from `this` or an expression. */
|
|
3
|
+
export function rootName(node) {
|
|
4
|
+
switch (node.type) {
|
|
5
|
+
case AST_NODE_TYPES.Identifier: {
|
|
6
|
+
return node.name;
|
|
7
|
+
}
|
|
8
|
+
case AST_NODE_TYPES.MemberExpression: {
|
|
9
|
+
return rootName(node.object);
|
|
10
|
+
}
|
|
11
|
+
case AST_NODE_TYPES.CallExpression:
|
|
12
|
+
case AST_NODE_TYPES.NewExpression: {
|
|
13
|
+
return rootName(node.callee);
|
|
14
|
+
}
|
|
15
|
+
case AST_NODE_TYPES.ChainExpression: {
|
|
16
|
+
return rootName(node.expression);
|
|
17
|
+
}
|
|
18
|
+
default: {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=root-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-name.js","sourceRoot":"","sources":["../../../src/support/values/root-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,mJAAmJ;AACnJ,MAAM,UAAU,QAAQ,CAAC,IAAmB;IAC1C,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,cAAc,CAAC,UAAU,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;QACD,KAAK,cAAc,CAAC,gBAAgB,EAAE,CAAC;YACrC,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;QACD,KAAK,cAAc,CAAC,cAAc,CAAC;QACnC,KAAK,cAAc,CAAC,aAAa,EAAE,CAAC;YAClC,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;QACD,KAAK,cAAc,CAAC,eAAe,EAAE,CAAC;YACpC,OAAO,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC;QACD,SAAS,CAAC;YACR,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Whether an object literal answered by a function is a value of the model written as a record:
|
|
4
|
+
* it holds data (an entry that is not a function), nothing a call or `new` of the model built,
|
|
5
|
+
* and no spread. A record of value objects the function builds (`{ first: Money.of(1), rest }`)
|
|
6
|
+
* is an operation of the model; a spread (`{ ...state, status }`) derives a record that exists;
|
|
7
|
+
* an object of functions only is behaviour, a specification or a strategy.
|
|
8
|
+
*/
|
|
9
|
+
export declare function standsForAValue(object: TSESTree.ObjectExpression, program: TSESTree.Program): boolean;
|
|
10
|
+
//# sourceMappingURL=stands-for-a-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stands-for-a-value.d.ts","sourceRoot":"","sources":["../../../src/support/values/stands-for-a-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAWzE;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAUrG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { expressionRole } from './entry-role.js';
|
|
3
|
+
/**
|
|
4
|
+
* Whether an object literal answered by a function is a value of the model written as a record:
|
|
5
|
+
* it holds data (an entry that is not a function), nothing a call or `new` of the model built,
|
|
6
|
+
* and no spread. A record of value objects the function builds (`{ first: Money.of(1), rest }`)
|
|
7
|
+
* is an operation of the model; a spread (`{ ...state, status }`) derives a record that exists;
|
|
8
|
+
* an object of functions only is behaviour, a specification or a strategy.
|
|
9
|
+
*/
|
|
10
|
+
export function standsForAValue(object, program) {
|
|
11
|
+
const roles = object.properties.map((property) => {
|
|
12
|
+
if (property.type === AST_NODE_TYPES.SpreadElement) {
|
|
13
|
+
return 'spread';
|
|
14
|
+
}
|
|
15
|
+
return property.method || property.kind !== 'init' ? 'behaviour' : valueRole(property.value, program);
|
|
16
|
+
});
|
|
17
|
+
return roles.includes('data') && !roles.includes('built') && !roles.includes('spread');
|
|
18
|
+
}
|
|
19
|
+
function valueRole(value, program) {
|
|
20
|
+
if (isNotAnExpression(value)) {
|
|
21
|
+
return value.type === AST_NODE_TYPES.TSEmptyBodyFunctionExpression ? 'behaviour' : 'data';
|
|
22
|
+
}
|
|
23
|
+
return expressionRole(value, program);
|
|
24
|
+
}
|
|
25
|
+
function isNotAnExpression(value) {
|
|
26
|
+
return (value.type === AST_NODE_TYPES.AssignmentPattern ||
|
|
27
|
+
value.type === AST_NODE_TYPES.ArrayPattern ||
|
|
28
|
+
value.type === AST_NODE_TYPES.ObjectPattern ||
|
|
29
|
+
value.type === AST_NODE_TYPES.TSEmptyBodyFunctionExpression);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=stands-for-a-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stands-for-a-value.js","sourceRoot":"","sources":["../../../src/support/values/stands-for-a-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,cAA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|
1
|
+
import { type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
/** The expression under `as ..`, `satisfies ..` and `!`, which change its type and not what it is. */
|
|
3
|
+
export declare function unwrapped(expression: TSESTree.Expression): TSESTree.Expression;
|
|
4
|
+
//# sourceMappingURL=unwrapped.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unwrapped.d.ts","sourceRoot":"","sources":["../../../src/support/values/unwrapped.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzE,sGAAsG;AACtG,wBAAgB,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAU9E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
/** The expression under `as ..`, `satisfies ..` and `!`, which change its type and not what it is. */
|
|
3
|
+
export function unwrapped(expression) {
|
|
4
|
+
if (expression.type === AST_NODE_TYPES.TSAsExpression ||
|
|
5
|
+
expression.type === AST_NODE_TYPES.TSSatisfiesExpression ||
|
|
6
|
+
expression.type === AST_NODE_TYPES.TSNonNullExpression) {
|
|
7
|
+
return unwrapped(expression.expression);
|
|
8
|
+
}
|
|
9
|
+
return expression;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=unwrapped.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unwrapped.js","sourceRoot":"","sources":["../../../src/support/values/unwrapped.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,sGAAsG;AACtG,MAAM,UAAU,SAAS,CAAC,UAA+B;IACvD,IACE,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc;QACjD,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,qBAAqB;QACxD,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,mBAAmB,EACtD,CAAC;QACD,OAAO,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.16.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.16.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# ddd-ts-kit/domain-value-object-class
|
|
2
|
+
|
|
3
|
+
Architecture id: `domain/value-object-class`. Default severity: `error` in `recommended`, `error` in `strict`.
|
|
4
|
+
|
|
5
|
+
Applies to: a project whose config says `"stack.values": "classes"`, which `init` writes (a
|
|
6
|
+
config that does not say is `free`, and the rule is silent: [CONFIG.md](../../../../docs/CONFIG.md#stack)
|
|
7
|
+
gives the steps to move). There, the value object files, `domain/value-objects/*` of a context
|
|
8
|
+
and the `*.vo.ts` of the shared kernel outside its `presentation/`, and every other file of
|
|
9
|
+
`domain/` of a context and of the shared kernel outside its `presentation/`, specs aside.
|
|
10
|
+
|
|
11
|
+
## Why
|
|
12
|
+
|
|
13
|
+
A value of the model is a class extending `ValueObject` of `@ddd-ts-kit/kernel`, never a function
|
|
14
|
+
that builds a plain object. The class gives what the function cannot:
|
|
15
|
+
|
|
16
|
+
- **equality without identity**: `equals` compares the props, two equal values are interchangeable;
|
|
17
|
+
- **invariants checked once**: the constructor is private, the static factory is the only way in,
|
|
18
|
+
so a value that exists is a valid one and no caller validates it again;
|
|
19
|
+
- **behaviour next to the data**: `add`, `overlaps`, `isWithin` are methods of the type they
|
|
20
|
+
concern, not helpers repeated wherever two fields meet;
|
|
21
|
+
- **refusals from static factories**: `Money.of(..)` throws (or returns) the refusal of the concept,
|
|
22
|
+
`InvoiceError.invalidAmount(..)`;
|
|
23
|
+
- **immutability**: the props are frozen, an operation returns a new instance;
|
|
24
|
+
- **`instanceof` in the boundary mappers**: a mapper or a serializer recognises the value and
|
|
25
|
+
writes it, which a structural object never allows.
|
|
26
|
+
|
|
27
|
+
## Reported
|
|
28
|
+
|
|
29
|
+
In a value object file:
|
|
30
|
+
|
|
31
|
+
- no exported class, or a second one;
|
|
32
|
+
- an exported class that extends neither `ValueObject` nor another value object of the project
|
|
33
|
+
(a class of the same file that does, or a class imported from a value object file);
|
|
34
|
+
- a public constructor, declared without `private` or `protected` (a class that declares none
|
|
35
|
+
inherits the protected constructor of `ValueObject`);
|
|
36
|
+
- a concrete class without a static method that is not private: nothing can build it;
|
|
37
|
+
- an exported function, an exported constant bound to an arrow or a function expression, and an
|
|
38
|
+
exported object literal (parenthesized, `as const` and `satisfies` included), whether exported
|
|
39
|
+
inline, by an export list (`export { zero }`) or by default.
|
|
40
|
+
|
|
41
|
+
The exported types and interfaces of its props are allowed.
|
|
42
|
+
|
|
43
|
+
In the other files of `domain/` and of the shared kernel: an exported function (declared, bound
|
|
44
|
+
to a constant, exported by a list or by default) that answers a **record of data**, in the
|
|
45
|
+
expression of an arrow or in a `return` of its own body. Each entry of the object literal is
|
|
46
|
+
read for what it holds:
|
|
47
|
+
|
|
48
|
+
| Entry | Reads as | Examples |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| a literal, a parameter, an operation on them, a call of the language | data | `amount`, `'EUR'`, `cents * 100`, `Math.round(cents)`, `new Date(at)` |
|
|
51
|
+
| any other call or `new`, or a name bound to one in the module | built by the model | `Money.of(1)`, `total.add(tax)`, `new Slot(..)` |
|
|
52
|
+
| a function, a method, or a name bound to one in the module | behaviour | `isSatisfiedBy: (x) => ..`, `describe() {}`, `{ isSatisfiedBy }` |
|
|
53
|
+
| `...state` | derived | `{ ...state, status }` |
|
|
54
|
+
|
|
55
|
+
The object is a record of data, and the function is reported, when it holds data, nothing built
|
|
56
|
+
by the model and no spread. A function that declares a return type of a package
|
|
57
|
+
(`): EventStamp` of the kernel) is not judged: the shape is the library's.
|
|
58
|
+
|
|
59
|
+
Incorrect:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// domain/value-objects/money.vo.ts
|
|
63
|
+
export type Money = { readonly amount: number; readonly currency: string };
|
|
64
|
+
|
|
65
|
+
export const money = (amount: number, currency: string): Money => ({ amount, currency });
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Correct:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
// domain/value-objects/money.vo.ts (npx ddd-ts-kit generate value-object billing Money)
|
|
72
|
+
import { ValueObject } from '@ddd-ts-kit/kernel';
|
|
73
|
+
|
|
74
|
+
export type MoneyProps = { readonly amount: number; readonly currency: string };
|
|
75
|
+
|
|
76
|
+
export class Money extends ValueObject<MoneyProps> {
|
|
77
|
+
private constructor(props: MoneyProps) {
|
|
78
|
+
super(props);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static of(amount: number, currency: string): Money {
|
|
82
|
+
if (!Number.isInteger(amount)) {
|
|
83
|
+
throw InvoiceError.invalidAmount(amount);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return new Money({ amount, currency });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
add(other: Money): Money {
|
|
90
|
+
return Money.of(this.props.amount + other.props.amount, this.props.currency);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Details
|
|
96
|
+
|
|
97
|
+
What is not reported:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
// a state machine: the result of a call, not a function
|
|
101
|
+
export const invoiceLifecycle = defineStateMachine({ states: ['draft', 'issued'] /* .. */ });
|
|
102
|
+
|
|
103
|
+
// a domain service: a class
|
|
104
|
+
export class InvoiceTotalService {
|
|
105
|
+
total(lines: readonly Money[]): Money { /* .. */ }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// a specification: a boolean, or functions only, literal or local closures
|
|
109
|
+
export const isOverdue = (invoice: Invoice, now: Date): boolean => invoice.dueAt < now;
|
|
110
|
+
export const dueBefore = (day: Date) => {
|
|
111
|
+
const isSatisfiedBy = (invoice: Invoice): boolean => invoice.dueAt < day;
|
|
112
|
+
|
|
113
|
+
return { isSatisfiedBy };
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// an operation of the model: value objects it builds
|
|
117
|
+
export const split = (total: Money) => ({ first: Money.of(1), rest: total.subtract(Money.of(1)) });
|
|
118
|
+
|
|
119
|
+
// a reducer: derives a record that exists
|
|
120
|
+
export const evolve = (state: InvoiceState, status: string): InvoiceState => ({ ...state, status });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
What is reported, and decided so:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
// a decision answered as a record: throw the refusal from a factory
|
|
127
|
+
// (`throw InvoiceError.refused(reason)`), or make it a value object (`Decision.refused(reason)`)
|
|
128
|
+
export const decide = (reason: string) => ({ kind: 'refused' as const, reason });
|
|
129
|
+
|
|
130
|
+
// a record of data with closures: a value with behaviour, which is a class
|
|
131
|
+
export const money = (cents: number) => ({ cents, doubled: (): number => cents * 2 });
|
|
132
|
+
|
|
133
|
+
// a record that only gathers parameters, value objects included: a pair that means something
|
|
134
|
+
// is a value with a name
|
|
135
|
+
export const period = (start: Instant, end: Instant) => ({ start, end });
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Options
|
|
139
|
+
|
|
140
|
+
None.
|
|
141
|
+
|
|
142
|
+
`rules."domain/value-object-class"` in `ddd-ts-kit.config.json` set to `warn` or `off` relaxes the
|
|
143
|
+
rule, and `// ddd-ts-kit-disable-next-line domain/value-object-class -- <reason>` silences one
|
|
144
|
+
line, exactly as for `ddd-ts-kit check`. The rule defaults to `error`: relaxing it is a deviation,
|
|
145
|
+
recorded under `deviations` with the ADR that says why and until when
|
|
146
|
+
(`governance/recorded-deviation`). A project not ready for the rule keeps `"stack.values": "free"`
|
|
147
|
+
instead, which records nothing.
|
|
148
|
+
|
|
149
|
+
## Limits
|
|
150
|
+
|
|
151
|
+
The rule reads the text and the syntax of one file, without the types. What it does not follow:
|
|
152
|
+
|
|
153
|
+
- an object built in a variable first, then returned (`const value = { .. }; return value;`);
|
|
154
|
+
- an object answered through a condition (`cond ? { .. } : { .. }`), inside an array, or as the
|
|
155
|
+
argument of a call;
|
|
156
|
+
- a name is resolved by its first declaration in the module, whatever its scope: a parameter
|
|
157
|
+
named like a function of the module reads as that function;
|
|
158
|
+
- a call is read by the name it starts from: `name.trim()` on a parameter reads as built by the
|
|
159
|
+
model, so a record holding it is not reported;
|
|
160
|
+
- the package exemption reads the name the declared return type starts with, not an inferred one;
|
|
161
|
+
- a superclass imported from a value object file is trusted: that file is judged on its own.
|
|
162
|
+
|
|
163
|
+
## With the CLI checker
|
|
164
|
+
|
|
165
|
+
`ddd-ts-kit check` reports the same id from the text of the files, with the same table of files.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "AST-accurate ESLint rules for DDD and Clean Architecture in TypeScript: layer and context isolation, domain purity, clean code ordering.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|