ark-runtime-kernel 1.0.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.
@@ -0,0 +1,149 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ // src/eslint/index.ts
6
+ function stringValue(node) {
7
+ return typeof node?.value === "string" ? node.value : void 0;
8
+ }
9
+ function propertyName(node) {
10
+ return node?.name ?? stringValue(node);
11
+ }
12
+ function calleePropertyName(node) {
13
+ return propertyName(node.callee?.property);
14
+ }
15
+ function objectProperty(node, name) {
16
+ return node?.properties?.find((property) => propertyName(property.key) === name);
17
+ }
18
+ function objectHasProperty(node, name) {
19
+ return objectProperty(node, name) !== void 0;
20
+ }
21
+ function objectHasMetadataSource(node) {
22
+ const metadata = objectProperty(node, "metadata")?.value;
23
+ return objectHasProperty(metadata, "source");
24
+ }
25
+ function looksLikeIntent(value) {
26
+ return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(value);
27
+ }
28
+ function isDomainFile(context) {
29
+ const filename = context.getFilename?.() ?? "";
30
+ const normalized = filename.split("\\").join("/").toLowerCase();
31
+ return normalized.includes("/domain/") || normalized.endsWith("/domain.ts");
32
+ }
33
+ function isInfraImport(specifier) {
34
+ const normalized = specifier.toLowerCase();
35
+ return [
36
+ "adapter",
37
+ "adapters",
38
+ "infrastructure",
39
+ "persistence",
40
+ "repository",
41
+ "repositories",
42
+ "integration",
43
+ "database",
44
+ "db"
45
+ ].some((token) => normalized.includes(token));
46
+ }
47
+ function isPublishCall(node) {
48
+ return calleePropertyName(node) === "publish";
49
+ }
50
+ var noDomainInfraImports = {
51
+ meta: {
52
+ type: "problem",
53
+ docs: {
54
+ description: "Disallow importing infrastructure or adapters from domain files."
55
+ },
56
+ messages: {
57
+ forbiddenImport: "Domain code must not import infrastructure, adapters, repositories, or database modules."
58
+ },
59
+ schema: []
60
+ },
61
+ create(context) {
62
+ const check = (node) => {
63
+ if (!isDomainFile(context)) return;
64
+ const source = stringValue(node.source);
65
+ if (source && isInfraImport(source)) {
66
+ context.report({ node, messageId: "forbiddenImport" });
67
+ }
68
+ };
69
+ return {
70
+ ImportDeclaration: check,
71
+ ExportNamedDeclaration: check,
72
+ ExportAllDeclaration: check
73
+ };
74
+ }
75
+ };
76
+ var noRawEventPublish = {
77
+ meta: {
78
+ type: "problem",
79
+ docs: {
80
+ description: "Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings."
81
+ },
82
+ messages: {
83
+ rawPublish: "Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts."
84
+ },
85
+ schema: []
86
+ },
87
+ create(context) {
88
+ return {
89
+ CallExpression(node) {
90
+ if (!isPublishCall(node)) return;
91
+ const firstArg = node.arguments?.[0];
92
+ const firstValue = stringValue(firstArg);
93
+ if (firstValue && looksLikeIntent(firstValue) || objectHasProperty(firstArg, "intent")) {
94
+ context.report({ node, messageId: "rawPublish" });
95
+ }
96
+ }
97
+ };
98
+ }
99
+ };
100
+ var requirePublishSource = {
101
+ meta: {
102
+ type: "problem",
103
+ docs: {
104
+ description: "Require event bus publish calls to include source metadata."
105
+ },
106
+ messages: {
107
+ missingSource: "Strict Ark publish calls must include metadata.source."
108
+ },
109
+ schema: []
110
+ },
111
+ create(context) {
112
+ return {
113
+ CallExpression(node) {
114
+ if (!isPublishCall(node)) return;
115
+ const firstArg = node.arguments?.[0];
116
+ const metadataArg = node.arguments?.[2];
117
+ if (objectHasMetadataSource(firstArg) || objectHasProperty(metadataArg, "source")) {
118
+ return;
119
+ }
120
+ context.report({ node, messageId: "missingSource" });
121
+ }
122
+ };
123
+ }
124
+ };
125
+ var rules = {
126
+ "no-domain-infra-imports": noDomainInfraImports,
127
+ "no-raw-event-publish": noRawEventPublish,
128
+ "require-publish-source": requirePublishSource
129
+ };
130
+ var plugin = { rules };
131
+ plugin.configs = {
132
+ recommended: {
133
+ plugins: { ark: plugin },
134
+ rules: {
135
+ "ark/no-domain-infra-imports": "error",
136
+ "ark/no-raw-event-publish": "error",
137
+ "ark/require-publish-source": "error"
138
+ }
139
+ }
140
+ };
141
+ var eslint_default = plugin;
142
+
143
+ exports.default = eslint_default;
144
+ exports.noDomainInfraImports = noDomainInfraImports;
145
+ exports.noRawEventPublish = noRawEventPublish;
146
+ exports.plugin = plugin;
147
+ exports.requirePublishSource = requirePublishSource;
148
+ //# sourceMappingURL=index.cjs.map
149
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/eslint/index.ts"],"names":[],"mappings":";;;;;AAkCA,SAAS,YAAY,IAAA,EAA+C;AAClE,EAAA,OAAO,OAAO,IAAA,EAAM,KAAA,KAAU,QAAA,GAAW,KAAK,KAAA,GAAQ,MAAA;AACxD;AAEA,SAAS,aAAa,IAAA,EAA+C;AACnE,EAAA,OAAO,IAAA,EAAM,IAAA,IAAQ,WAAA,CAAY,IAAI,CAAA;AACvC;AAEA,SAAS,mBAAmB,IAAA,EAAmC;AAC7D,EAAA,OAAO,YAAA,CAAa,IAAA,CAAK,MAAA,EAAQ,QAAQ,CAAA;AAC3C;AAEA,SAAS,cAAA,CAAe,MAA2B,IAAA,EAAmC;AACpF,EAAA,OAAO,IAAA,EAAM,YAAY,IAAA,CAAK,CAAC,aAAa,YAAA,CAAa,QAAA,CAAS,GAAG,CAAA,KAAM,IAAI,CAAA;AACjF;AAEA,SAAS,iBAAA,CAAkB,MAA2B,IAAA,EAAuB;AAC3E,EAAA,OAAO,cAAA,CAAe,IAAA,EAAM,IAAI,CAAA,KAAM,MAAA;AACxC;AAEA,SAAS,wBAAwB,IAAA,EAAoC;AACnE,EAAA,MAAM,QAAA,GAAW,cAAA,CAAe,IAAA,EAAM,UAAU,CAAA,EAAG,KAAA;AACnD,EAAA,OAAO,iBAAA,CAAkB,UAAU,QAAQ,CAAA;AAC7C;AAEA,SAAS,gBAAgB,KAAA,EAAw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,OAAO;AAAA,MACL,eAAe,IAAA,EAAM;AACnB,QAAA,IAAI,CAAC,aAAA,CAAc,IAAI,CAAA,EAAG;AAC1B,QAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,GAAY,CAAC,CAAA;AACnC,QAAA,MAAM,WAAA,GAAc,IAAA,CAAK,SAAA,GAAY,CAAC,CAAA;AACtC,QAAA,IAAI,wBAAwB,QAAQ,CAAA,IAAK,iBAAA,CAAkB,WAAA,EAAa,QAAQ,CAAA,EAAG;AACjF,UAAA;AAAA,QACF;AACA,QAAA,OAAA,CAAQ,MAAA,CAAO,EAAE,IAAA,EAAM,SAAA,EAAW,iBAAiB,CAAA;AAAA,MACrD;AAAA,KACF;AAAA,EACF;AACF;AAEA,IAAM,KAAA,GAAQ;AAAA,EACZ,yBAAA,EAA2B,oBAAA;AAAA,EAC3B,sBAAA,EAAwB,iBAAA;AAAA,EACxB,wBAAA,EAA0B;AAC5B,CAAA;AAEA,IAAM,MAAA,GAA0B,EAAE,KAAA;AAElC,MAAA,CAAO,OAAA,GAAU;AAAA,EACf,WAAA,EAAa;AAAA,IACX,OAAA,EAAS,EAAE,GAAA,EAAK,MAAA,EAAO;AAAA,IACvB,KAAA,EAAO;AAAA,MACL,6BAAA,EAA+B,OAAA;AAAA,MAC/B,0BAAA,EAA4B,OAAA;AAAA,MAC5B,4BAAA,EAA8B;AAAA;AAChC;AAEJ,CAAA;AAGA,IAAO,cAAA,GAAQ","file":"index.cjs","sourcesContent":["type RuleContext = {\n report(descriptor: Record<string, unknown>): void;\n getFilename?: () => string;\n};\n\ntype RuleListener = Record<string, (node: AstNode) => void>;\n\ntype AstNode = {\n type?: string;\n name?: string;\n value?: unknown;\n source?: AstNode;\n callee?: AstNode;\n property?: AstNode;\n key?: AstNode;\n arguments?: AstNode[];\n properties?: AstNode[];\n};\n\ntype ArkRule = {\n meta: {\n type: 'problem';\n docs: { description: string };\n messages: Record<string, string>;\n schema: unknown[];\n };\n create(context: RuleContext): RuleListener;\n};\n\ntype ArkEslintPlugin = {\n rules: Record<string, ArkRule>;\n configs?: Record<string, unknown>;\n};\n\nfunction stringValue(node: AstNode | undefined): string | undefined {\n return typeof node?.value === 'string' ? node.value : undefined;\n}\n\nfunction propertyName(node: AstNode | undefined): string | undefined {\n return node?.name ?? stringValue(node);\n}\n\nfunction calleePropertyName(node: AstNode): string | undefined {\n return propertyName(node.callee?.property);\n}\n\nfunction objectProperty(node: AstNode | undefined, name: string): AstNode | undefined {\n return node?.properties?.find((property) => propertyName(property.key) === name);\n}\n\nfunction objectHasProperty(node: AstNode | undefined, name: string): boolean {\n return objectProperty(node, name) !== undefined;\n}\n\nfunction objectHasMetadataSource(node: AstNode | undefined): boolean {\n const metadata = objectProperty(node, 'metadata')?.value as AstNode | undefined;\n return objectHasProperty(metadata, 'source');\n}\n\nfunction looksLikeIntent(value: string): boolean {\n return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\\.[A-Za-z0-9_.]+$/.test(value);\n}\n\nfunction isDomainFile(context: RuleContext): boolean {\n const filename = context.getFilename?.() ?? '';\n const normalized = filename.split('\\\\').join('/').toLowerCase();\n return normalized.includes('/domain/') || normalized.endsWith('/domain.ts');\n}\n\nfunction isInfraImport(specifier: string): boolean {\n const normalized = specifier.toLowerCase();\n return [\n 'adapter',\n 'adapters',\n 'infrastructure',\n 'persistence',\n 'repository',\n 'repositories',\n 'integration',\n 'database',\n 'db',\n ].some((token) => normalized.includes(token));\n}\n\nfunction isPublishCall(node: AstNode): boolean {\n return calleePropertyName(node) === 'publish';\n}\n\nexport const noDomainInfraImports: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow importing infrastructure or adapters from domain files.',\n },\n messages: {\n forbiddenImport: 'Domain code must not import infrastructure, adapters, repositories, or database modules.',\n },\n schema: [],\n },\n create(context) {\n const check = (node: AstNode) => {\n if (!isDomainFile(context)) return;\n const source = stringValue(node.source);\n if (source && isInfraImport(source)) {\n context.report({ node, messageId: 'forbiddenImport' });\n }\n };\n\n return {\n ImportDeclaration: check,\n ExportNamedDeclaration: check,\n ExportAllDeclaration: check,\n };\n },\n};\n\nexport const noRawEventPublish: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings.',\n },\n messages: {\n rawPublish: 'Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const firstValue = stringValue(firstArg);\n if (\n firstValue && looksLikeIntent(firstValue) ||\n objectHasProperty(firstArg, 'intent')\n ) {\n context.report({ node, messageId: 'rawPublish' });\n }\n },\n };\n },\n};\n\nexport const requirePublishSource: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to include source metadata.',\n },\n messages: {\n missingSource: 'Strict Ark publish calls must include metadata.source.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const metadataArg = node.arguments?.[2];\n if (objectHasMetadataSource(firstArg) || objectHasProperty(metadataArg, 'source')) {\n return;\n }\n context.report({ node, messageId: 'missingSource' });\n },\n };\n },\n};\n\nconst rules = {\n 'no-domain-infra-imports': noDomainInfraImports,\n 'no-raw-event-publish': noRawEventPublish,\n 'require-publish-source': requirePublishSource,\n};\n\nconst plugin: ArkEslintPlugin = { rules };\n\nplugin.configs = {\n recommended: {\n plugins: { ark: plugin },\n rules: {\n 'ark/no-domain-infra-imports': 'error',\n 'ark/no-raw-event-publish': 'error',\n 'ark/require-publish-source': 'error',\n },\n },\n};\n\nexport { plugin };\nexport default plugin;\n"]}
@@ -0,0 +1,37 @@
1
+ type RuleContext = {
2
+ report(descriptor: Record<string, unknown>): void;
3
+ getFilename?: () => string;
4
+ };
5
+ type RuleListener = Record<string, (node: AstNode) => void>;
6
+ type AstNode = {
7
+ type?: string;
8
+ name?: string;
9
+ value?: unknown;
10
+ source?: AstNode;
11
+ callee?: AstNode;
12
+ property?: AstNode;
13
+ key?: AstNode;
14
+ arguments?: AstNode[];
15
+ properties?: AstNode[];
16
+ };
17
+ type ArkRule = {
18
+ meta: {
19
+ type: 'problem';
20
+ docs: {
21
+ description: string;
22
+ };
23
+ messages: Record<string, string>;
24
+ schema: unknown[];
25
+ };
26
+ create(context: RuleContext): RuleListener;
27
+ };
28
+ type ArkEslintPlugin = {
29
+ rules: Record<string, ArkRule>;
30
+ configs?: Record<string, unknown>;
31
+ };
32
+ declare const noDomainInfraImports: ArkRule;
33
+ declare const noRawEventPublish: ArkRule;
34
+ declare const requirePublishSource: ArkRule;
35
+ declare const plugin: ArkEslintPlugin;
36
+
37
+ export { plugin as default, noDomainInfraImports, noRawEventPublish, plugin, requirePublishSource };
@@ -0,0 +1,37 @@
1
+ type RuleContext = {
2
+ report(descriptor: Record<string, unknown>): void;
3
+ getFilename?: () => string;
4
+ };
5
+ type RuleListener = Record<string, (node: AstNode) => void>;
6
+ type AstNode = {
7
+ type?: string;
8
+ name?: string;
9
+ value?: unknown;
10
+ source?: AstNode;
11
+ callee?: AstNode;
12
+ property?: AstNode;
13
+ key?: AstNode;
14
+ arguments?: AstNode[];
15
+ properties?: AstNode[];
16
+ };
17
+ type ArkRule = {
18
+ meta: {
19
+ type: 'problem';
20
+ docs: {
21
+ description: string;
22
+ };
23
+ messages: Record<string, string>;
24
+ schema: unknown[];
25
+ };
26
+ create(context: RuleContext): RuleListener;
27
+ };
28
+ type ArkEslintPlugin = {
29
+ rules: Record<string, ArkRule>;
30
+ configs?: Record<string, unknown>;
31
+ };
32
+ declare const noDomainInfraImports: ArkRule;
33
+ declare const noRawEventPublish: ArkRule;
34
+ declare const requirePublishSource: ArkRule;
35
+ declare const plugin: ArkEslintPlugin;
36
+
37
+ export { plugin as default, noDomainInfraImports, noRawEventPublish, plugin, requirePublishSource };
@@ -0,0 +1,141 @@
1
+ // src/eslint/index.ts
2
+ function stringValue(node) {
3
+ return typeof node?.value === "string" ? node.value : void 0;
4
+ }
5
+ function propertyName(node) {
6
+ return node?.name ?? stringValue(node);
7
+ }
8
+ function calleePropertyName(node) {
9
+ return propertyName(node.callee?.property);
10
+ }
11
+ function objectProperty(node, name) {
12
+ return node?.properties?.find((property) => propertyName(property.key) === name);
13
+ }
14
+ function objectHasProperty(node, name) {
15
+ return objectProperty(node, name) !== void 0;
16
+ }
17
+ function objectHasMetadataSource(node) {
18
+ const metadata = objectProperty(node, "metadata")?.value;
19
+ return objectHasProperty(metadata, "source");
20
+ }
21
+ function looksLikeIntent(value) {
22
+ return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(value);
23
+ }
24
+ function isDomainFile(context) {
25
+ const filename = context.getFilename?.() ?? "";
26
+ const normalized = filename.split("\\").join("/").toLowerCase();
27
+ return normalized.includes("/domain/") || normalized.endsWith("/domain.ts");
28
+ }
29
+ function isInfraImport(specifier) {
30
+ const normalized = specifier.toLowerCase();
31
+ return [
32
+ "adapter",
33
+ "adapters",
34
+ "infrastructure",
35
+ "persistence",
36
+ "repository",
37
+ "repositories",
38
+ "integration",
39
+ "database",
40
+ "db"
41
+ ].some((token) => normalized.includes(token));
42
+ }
43
+ function isPublishCall(node) {
44
+ return calleePropertyName(node) === "publish";
45
+ }
46
+ var noDomainInfraImports = {
47
+ meta: {
48
+ type: "problem",
49
+ docs: {
50
+ description: "Disallow importing infrastructure or adapters from domain files."
51
+ },
52
+ messages: {
53
+ forbiddenImport: "Domain code must not import infrastructure, adapters, repositories, or database modules."
54
+ },
55
+ schema: []
56
+ },
57
+ create(context) {
58
+ const check = (node) => {
59
+ if (!isDomainFile(context)) return;
60
+ const source = stringValue(node.source);
61
+ if (source && isInfraImport(source)) {
62
+ context.report({ node, messageId: "forbiddenImport" });
63
+ }
64
+ };
65
+ return {
66
+ ImportDeclaration: check,
67
+ ExportNamedDeclaration: check,
68
+ ExportAllDeclaration: check
69
+ };
70
+ }
71
+ };
72
+ var noRawEventPublish = {
73
+ meta: {
74
+ type: "problem",
75
+ docs: {
76
+ description: "Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings."
77
+ },
78
+ messages: {
79
+ rawPublish: "Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts."
80
+ },
81
+ schema: []
82
+ },
83
+ create(context) {
84
+ return {
85
+ CallExpression(node) {
86
+ if (!isPublishCall(node)) return;
87
+ const firstArg = node.arguments?.[0];
88
+ const firstValue = stringValue(firstArg);
89
+ if (firstValue && looksLikeIntent(firstValue) || objectHasProperty(firstArg, "intent")) {
90
+ context.report({ node, messageId: "rawPublish" });
91
+ }
92
+ }
93
+ };
94
+ }
95
+ };
96
+ var requirePublishSource = {
97
+ meta: {
98
+ type: "problem",
99
+ docs: {
100
+ description: "Require event bus publish calls to include source metadata."
101
+ },
102
+ messages: {
103
+ missingSource: "Strict Ark publish calls must include metadata.source."
104
+ },
105
+ schema: []
106
+ },
107
+ create(context) {
108
+ return {
109
+ CallExpression(node) {
110
+ if (!isPublishCall(node)) return;
111
+ const firstArg = node.arguments?.[0];
112
+ const metadataArg = node.arguments?.[2];
113
+ if (objectHasMetadataSource(firstArg) || objectHasProperty(metadataArg, "source")) {
114
+ return;
115
+ }
116
+ context.report({ node, messageId: "missingSource" });
117
+ }
118
+ };
119
+ }
120
+ };
121
+ var rules = {
122
+ "no-domain-infra-imports": noDomainInfraImports,
123
+ "no-raw-event-publish": noRawEventPublish,
124
+ "require-publish-source": requirePublishSource
125
+ };
126
+ var plugin = { rules };
127
+ plugin.configs = {
128
+ recommended: {
129
+ plugins: { ark: plugin },
130
+ rules: {
131
+ "ark/no-domain-infra-imports": "error",
132
+ "ark/no-raw-event-publish": "error",
133
+ "ark/require-publish-source": "error"
134
+ }
135
+ }
136
+ };
137
+ var eslint_default = plugin;
138
+
139
+ export { eslint_default as default, noDomainInfraImports, noRawEventPublish, plugin, requirePublishSource };
140
+ //# sourceMappingURL=index.js.map
141
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/eslint/index.ts"],"names":[],"mappings":";AAkCA,SAAS,YAAY,IAAA,EAA+C;AAClE,EAAA,OAAO,OAAO,IAAA,EAAM,KAAA,KAAU,QAAA,GAAW,KAAK,KAAA,GAAQ,MAAA;AACxD;AAEA,SAAS,aAAa,IAAA,EAA+C;AACnE,EAAA,OAAO,IAAA,EAAM,IAAA,IAAQ,WAAA,CAAY,IAAI,CAAA;AACvC;AAEA,SAAS,mBAAmB,IAAA,EAAmC;AAC7D,EAAA,OAAO,YAAA,CAAa,IAAA,CAAK,MAAA,EAAQ,QAAQ,CAAA;AAC3C;AAEA,SAAS,cAAA,CAAe,MAA2B,IAAA,EAAmC;AACpF,EAAA,OAAO,IAAA,EAAM,YAAY,IAAA,CAAK,CAAC,aAAa,YAAA,CAAa,QAAA,CAAS,GAAG,CAAA,KAAM,IAAI,CAAA;AACjF;AAEA,SAAS,iBAAA,CAAkB,MAA2B,IAAA,EAAuB;AAC3E,EAAA,OAAO,cAAA,CAAe,IAAA,EAAM,IAAI,CAAA,KAAM,MAAA;AACxC;AAEA,SAAS,wBAAwB,IAAA,EAAoC;AACnE,EAAA,MAAM,QAAA,GAAW,cAAA,CAAe,IAAA,EAAM,UAAU,CAAA,EAAG,KAAA;AACnD,EAAA,OAAO,iBAAA,CAAkB,UAAU,QAAQ,CAAA;AAC7C;AAEA,SAAS,gBAAgB,KAAA,EAAwB;AAC/C,EAAA,OAAO,iIAAA,CAAkI,KAAK,KAAK,CAAA;AACrJ;AAEA,SAAS,aAAa,OAAA,EAA+B;AACnD,EAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,WAAA,IAAc,IAAK,EAAA;AAC5C,EAAA,MAAM,UAAA,GAAa,SAAS,KAAA,CAAM,IAAI,EAAE,IAAA,CAAK,GAAG,EAAE,WAAA,EAAY;AAC9D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IAAK,iBAAA,CAAkB,WAAA,EAAa,QAAQ,CAAA,EAAG;AACjF,UAAA;AAAA,QACF;AACA,QAAA,OAAA,CAAQ,MAAA,CAAO,EAAE,IAAA,EAAM,SAAA,EAAW,iBAAiB,CAAA;AAAA,MACrD;AAAA,KACF;AAAA,EACF;AACF;AAEA,IAAM,KAAA,GAAQ;AAAA,EACZ,yBAAA,EAA2B,oBAAA;AAAA,EAC3B,sBAAA,EAAwB,iBAAA;AAAA,EACxB,wBAAA,EAA0B;AAC5B,CAAA;AAEA,IAAM,MAAA,GAA0B,EAAE,KAAA;AAElC,MAAA,CAAO,OAAA,GAAU;AAAA,EACf,WAAA,EAAa;AAAA,IACX,OAAA,EAAS,EAAE,GAAA,EAAK,MAAA,EAAO;AAAA,IACvB,KAAA,EAAO;AAAA,MACL,6BAAA,EAA+B,OAAA;AAAA,MAC/B,0BAAA,EAA4B,OAAA;AAAA,MAC5B,4BAAA,EAA8B;AAAA;AAChC;AAEJ,CAAA;AAGA,IAAO,cAAA,GAAQ","file":"index.js","sourcesContent":["type RuleContext = {\n report(descriptor: Record<string, unknown>): void;\n getFilename?: () => string;\n};\n\ntype RuleListener = Record<string, (node: AstNode) => void>;\n\ntype AstNode = {\n type?: string;\n name?: string;\n value?: unknown;\n source?: AstNode;\n callee?: AstNode;\n property?: AstNode;\n key?: AstNode;\n arguments?: AstNode[];\n properties?: AstNode[];\n};\n\ntype ArkRule = {\n meta: {\n type: 'problem';\n docs: { description: string };\n messages: Record<string, string>;\n schema: unknown[];\n };\n create(context: RuleContext): RuleListener;\n};\n\ntype ArkEslintPlugin = {\n rules: Record<string, ArkRule>;\n configs?: Record<string, unknown>;\n};\n\nfunction stringValue(node: AstNode | undefined): string | undefined {\n return typeof node?.value === 'string' ? node.value : undefined;\n}\n\nfunction propertyName(node: AstNode | undefined): string | undefined {\n return node?.name ?? stringValue(node);\n}\n\nfunction calleePropertyName(node: AstNode): string | undefined {\n return propertyName(node.callee?.property);\n}\n\nfunction objectProperty(node: AstNode | undefined, name: string): AstNode | undefined {\n return node?.properties?.find((property) => propertyName(property.key) === name);\n}\n\nfunction objectHasProperty(node: AstNode | undefined, name: string): boolean {\n return objectProperty(node, name) !== undefined;\n}\n\nfunction objectHasMetadataSource(node: AstNode | undefined): boolean {\n const metadata = objectProperty(node, 'metadata')?.value as AstNode | undefined;\n return objectHasProperty(metadata, 'source');\n}\n\nfunction looksLikeIntent(value: string): boolean {\n return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\\.[A-Za-z0-9_.]+$/.test(value);\n}\n\nfunction isDomainFile(context: RuleContext): boolean {\n const filename = context.getFilename?.() ?? '';\n const normalized = filename.split('\\\\').join('/').toLowerCase();\n return normalized.includes('/domain/') || normalized.endsWith('/domain.ts');\n}\n\nfunction isInfraImport(specifier: string): boolean {\n const normalized = specifier.toLowerCase();\n return [\n 'adapter',\n 'adapters',\n 'infrastructure',\n 'persistence',\n 'repository',\n 'repositories',\n 'integration',\n 'database',\n 'db',\n ].some((token) => normalized.includes(token));\n}\n\nfunction isPublishCall(node: AstNode): boolean {\n return calleePropertyName(node) === 'publish';\n}\n\nexport const noDomainInfraImports: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow importing infrastructure or adapters from domain files.',\n },\n messages: {\n forbiddenImport: 'Domain code must not import infrastructure, adapters, repositories, or database modules.',\n },\n schema: [],\n },\n create(context) {\n const check = (node: AstNode) => {\n if (!isDomainFile(context)) return;\n const source = stringValue(node.source);\n if (source && isInfraImport(source)) {\n context.report({ node, messageId: 'forbiddenImport' });\n }\n };\n\n return {\n ImportDeclaration: check,\n ExportNamedDeclaration: check,\n ExportAllDeclaration: check,\n };\n },\n};\n\nexport const noRawEventPublish: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings.',\n },\n messages: {\n rawPublish: 'Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const firstValue = stringValue(firstArg);\n if (\n firstValue && looksLikeIntent(firstValue) ||\n objectHasProperty(firstArg, 'intent')\n ) {\n context.report({ node, messageId: 'rawPublish' });\n }\n },\n };\n },\n};\n\nexport const requirePublishSource: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to include source metadata.',\n },\n messages: {\n missingSource: 'Strict Ark publish calls must include metadata.source.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const metadataArg = node.arguments?.[2];\n if (objectHasMetadataSource(firstArg) || objectHasProperty(metadataArg, 'source')) {\n return;\n }\n context.report({ node, messageId: 'missingSource' });\n },\n };\n },\n};\n\nconst rules = {\n 'no-domain-infra-imports': noDomainInfraImports,\n 'no-raw-event-publish': noRawEventPublish,\n 'require-publish-source': requirePublishSource,\n};\n\nconst plugin: ArkEslintPlugin = { rules };\n\nplugin.configs = {\n recommended: {\n plugins: { ark: plugin },\n rules: {\n 'ark/no-domain-infra-imports': 'error',\n 'ark/no-raw-event-publish': 'error',\n 'ark/require-publish-source': 'error',\n },\n },\n};\n\nexport { plugin };\nexport default plugin;\n"]}