@ekanos/sdk 0.17.0 → 0.19.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 +2 -2
- package/api-report.md +92 -1
- package/dist/components/base-activation-dialog.js +2 -2
- package/dist/components/base-activation-dialog.js.map +1 -1
- package/dist/components/base-activation-form.js +1 -1
- package/dist/components/base-activation-form.js.map +1 -1
- package/dist/components/base-marketplace-tile.js +1 -1
- package/dist/components/base-marketplace-tile.js.map +1 -1
- package/dist/components/oauth-activation-form.js +1 -1
- package/dist/components/oauth-activation-form.js.map +1 -1
- package/dist/components/widgets/ai-prompt-chip.js +3 -3
- package/dist/components/widgets/ai-prompt-chip.js.map +1 -1
- package/dist/components/widgets/widget-ask-bar.js +2 -2
- package/dist/components/widgets/widget-ask-bar.js.map +1 -1
- package/dist/components/widgets/widget-state-components.js +7 -7
- package/dist/components/widgets/widget-state-components.js.map +1 -1
- package/dist/components/widgets/widget.d.ts +2 -2
- package/dist/components/widgets/widget.js +30 -18
- package/dist/components/widgets/widget.js.map +1 -1
- package/dist/contract/derive-contract.d.ts +14 -0
- package/dist/contract/derive-contract.js +237 -0
- package/dist/contract/derive-contract.js.map +1 -0
- package/dist/contract/index.d.ts +8 -0
- package/dist/contract/index.js +9 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/synthesize-example.d.ts +6 -0
- package/dist/contract/synthesize-example.js +61 -0
- package/dist/contract/synthesize-example.js.map +1 -0
- package/dist/contract/to-json-schema.d.ts +19 -0
- package/dist/contract/to-json-schema.js +300 -0
- package/dist/contract/to-json-schema.js.map +1 -0
- package/dist/contract/types.d.ts +39 -0
- package/dist/contract/types.js +12 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/experience/client.d.ts +55 -0
- package/dist/experience/client.js +125 -0
- package/dist/experience/client.js.map +1 -0
- package/dist/experience/define-experience.d.ts +107 -0
- package/dist/experience/define-experience.js +107 -0
- package/dist/experience/define-experience.js.map +1 -0
- package/dist/experience/index.d.ts +12 -0
- package/dist/experience/index.js +12 -0
- package/dist/experience/index.js.map +1 -0
- package/dist/experience/runtime.d.ts +54 -0
- package/dist/experience/runtime.js +2 -0
- package/dist/experience/runtime.js.map +1 -0
- package/dist/experience/server.d.ts +11 -0
- package/dist/experience/server.js +47 -0
- package/dist/experience/server.js.map +1 -0
- package/dist/experience/types.d.ts +76 -0
- package/dist/experience/types.js +2 -0
- package/dist/experience/types.js.map +1 -0
- package/dist/experience/workflow-template.d.ts +103 -0
- package/dist/experience/workflow-template.js +132 -0
- package/dist/experience/workflow-template.js.map +1 -0
- package/dist/types/workspace-target.d.ts +1 -1
- package/dist/types/workspace-target.js.map +1 -1
- package/eslint.design-preset.mjs +3 -2
- package/eslint.design-rules.mjs +288 -4
- package/eslint.experience-preset.mjs +85 -0
- package/package.json +53 -15
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { TEMPLATE_INSTALLATION_ID, } from '@ekanos/integration-schema';
|
|
2
|
+
export function ref(path) {
|
|
3
|
+
if (path.trim() === '')
|
|
4
|
+
throw new Error('ref(): path must not be empty.');
|
|
5
|
+
return { ref: path };
|
|
6
|
+
}
|
|
7
|
+
const afterOf = (options) => (options === null || options === void 0 ? void 0 : options.after) === undefined
|
|
8
|
+
? {}
|
|
9
|
+
: {
|
|
10
|
+
after: typeof options.after === 'string'
|
|
11
|
+
? [options.after]
|
|
12
|
+
: [...options.after],
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Step constructors for {@link defineWorkflowTemplate}.
|
|
16
|
+
*
|
|
17
|
+
* `step.tool` is typed from the generated registry: the integration, the operation
|
|
18
|
+
* and its `args` are checked against the pinned contract. Whether a tool step
|
|
19
|
+
* reads or writes is NOT authored; it is read from the contract at build, so a
|
|
20
|
+
* template cannot call a write as if it were a read.
|
|
21
|
+
*/
|
|
22
|
+
export const step = {
|
|
23
|
+
tool(id, integration, op, args, options) {
|
|
24
|
+
return Object.assign({ type: 'tool', id,
|
|
25
|
+
integration,
|
|
26
|
+
op, args: args }, afterOf(options));
|
|
27
|
+
},
|
|
28
|
+
ai(id, config, options) {
|
|
29
|
+
var _a;
|
|
30
|
+
return Object.assign({ type: 'ai', id, kind: (_a = config.kind) !== null && _a !== void 0 ? _a : 'draft', instructions: config.instructions, outputSchemaRef: config.outputSchemaRef }, afterOf(options));
|
|
31
|
+
},
|
|
32
|
+
approval(id, config, options) {
|
|
33
|
+
var _a;
|
|
34
|
+
return Object.assign({ type: 'approval', id, summary: config.summary, approverScope: (_a = config.approverScope) !== null && _a !== void 0 ? _a : 'account' }, afterOf(options));
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const TEMPLATE_ID = /^[a-z][a-z0-9-]*$/;
|
|
38
|
+
const STEP_ID = /^[a-z][a-z0-9_]*$/;
|
|
39
|
+
const RESERVED_STEP_IDS = new Set(['trigger', 'item', 'loop', 'run']);
|
|
40
|
+
export function defineWorkflowTemplate(input) {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!TEMPLATE_ID.test(input.id)) {
|
|
43
|
+
throw new Error(`defineWorkflowTemplate: id "${input.id}" must be kebab-case (e.g. "morning-digest").`);
|
|
44
|
+
}
|
|
45
|
+
if (input.name.trim() === '') {
|
|
46
|
+
throw new Error(`defineWorkflowTemplate("${input.id}"): name is required.`);
|
|
47
|
+
}
|
|
48
|
+
if (input.schedule !== undefined &&
|
|
49
|
+
input.schedule.trim().split(/\s+/).length !== 5) {
|
|
50
|
+
throw new Error(`defineWorkflowTemplate("${input.id}"): schedule must be a 5-field cron expression, got "${input.schedule}".`);
|
|
51
|
+
}
|
|
52
|
+
return Object.freeze(Object.assign(Object.assign({ kind: 'workflow-template', id: input.id, name: input.name }, (input.schedule === undefined ? {} : { schedule: input.schedule })), { scope: (_a = input.scope) !== null && _a !== void 0 ? _a : 'account', build: input.build }));
|
|
53
|
+
}
|
|
54
|
+
export { TEMPLATE_INSTALLATION_ID };
|
|
55
|
+
/**
|
|
56
|
+
* Turn a template into the engine's DSL. Pure and deterministic: the same
|
|
57
|
+
* template and contracts always give the same JSON (it is hashed into the
|
|
58
|
+
* manifest digest).
|
|
59
|
+
*/
|
|
60
|
+
export function serializeWorkflowTemplate(template, options) {
|
|
61
|
+
var _a;
|
|
62
|
+
const steps = template.build();
|
|
63
|
+
const installationId = (_a = options.installationId) !== null && _a !== void 0 ? _a : TEMPLATE_INSTALLATION_ID;
|
|
64
|
+
const where = `workflow template "${template.id}"`;
|
|
65
|
+
if (steps.length === 0)
|
|
66
|
+
throw new Error(`${where}: build() returned no steps.`);
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
for (const s of steps) {
|
|
69
|
+
if (!STEP_ID.test(s.id) || RESERVED_STEP_IDS.has(s.id)) {
|
|
70
|
+
throw new Error(`${where}: step id "${s.id}" is invalid or reserved.`);
|
|
71
|
+
}
|
|
72
|
+
if (seen.has(s.id))
|
|
73
|
+
throw new Error(`${where}: step id "${s.id}" is used twice.`);
|
|
74
|
+
seen.add(s.id);
|
|
75
|
+
}
|
|
76
|
+
const edges = [];
|
|
77
|
+
steps.forEach((s, index) => {
|
|
78
|
+
var _a;
|
|
79
|
+
const predecessors = (_a = s.after) !== null && _a !== void 0 ? _a : (index === 0 ? [] : [steps[index - 1].id]);
|
|
80
|
+
for (const from of predecessors) {
|
|
81
|
+
if (!seen.has(from)) {
|
|
82
|
+
throw new Error(`${where}: step "${s.id}" follows unknown step "${from}".`);
|
|
83
|
+
}
|
|
84
|
+
edges.push({ from, to: s.id });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const dslSteps = steps.map((s) => {
|
|
88
|
+
switch (s.type) {
|
|
89
|
+
case 'tool': {
|
|
90
|
+
const effect = options.effectOf(s.integration, s.op);
|
|
91
|
+
if (effect === undefined) {
|
|
92
|
+
throw new Error(`${where}: step "${s.id}" calls ${s.integration} ${s.op}, which the pinned contract does not declare.`);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
id: s.id,
|
|
96
|
+
type: 'fusion_tool',
|
|
97
|
+
tool: s.op,
|
|
98
|
+
installationId,
|
|
99
|
+
slot: s.integration,
|
|
100
|
+
args: s.args,
|
|
101
|
+
effect,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
case 'ai':
|
|
105
|
+
return {
|
|
106
|
+
id: s.id,
|
|
107
|
+
type: 'ai_step',
|
|
108
|
+
kind: s.kind,
|
|
109
|
+
instructions: s.instructions,
|
|
110
|
+
outputSchemaRef: s.outputSchemaRef,
|
|
111
|
+
};
|
|
112
|
+
case 'approval':
|
|
113
|
+
return {
|
|
114
|
+
id: s.id,
|
|
115
|
+
type: 'approval_gate',
|
|
116
|
+
summaryTemplate: s.summary,
|
|
117
|
+
approverScope: s.approverScope,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
version: '1',
|
|
123
|
+
name: template.name,
|
|
124
|
+
scope: template.scope,
|
|
125
|
+
trigger: template.schedule === undefined
|
|
126
|
+
? { type: 'manual' }
|
|
127
|
+
: { type: 'schedule', cron: template.schedule },
|
|
128
|
+
steps: dslSteps,
|
|
129
|
+
edges,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=workflow-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-template.js","sourceRoot":"","sources":["../../src/experience/workflow-template.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AAYpC,MAAM,UAAU,GAAG,CAAC,IAAY;IAC9B,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAE1E,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC;AA8CD,MAAM,OAAO,GAAG,CAAC,OAAgC,EAAE,EAAE,CACnD,CAAA,OAAO,aAAP,OAAO,uBAAP,O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AAG;QACZ,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,OAAO,EACL,QAAQ,CAAC,QAAQ,KAAK,SAAS;YAC7B,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE;YACpB,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE;QACnD,KAAK,EAAE,QAAQ;QACf,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import {\n TEMPLATE_INSTALLATION_ID,\n type WorkflowTemplate as EngineWorkflowTemplate,\n} from '@ekanos/integration-schema';\n\nimport type { OperationInput, OperationKey, IntegrationName } from './types';\n\n/**\n * A reference to an earlier step's output (`{ ref: 'draft.title' }`), the\n * workflow engine's operand shape. Build one with {@link ref}.\n */\nexport interface WorkflowRef {\n readonly ref: string;\n}\n\nexport function ref(path: string): WorkflowRef {\n if (path.trim() === '') throw new Error('ref(): path must not be empty.');\n\n return { ref: path };\n}\n\n/** Each input field may be literal or a reference to an earlier step's output. */\nexport type WithRefs<T> = T extends readonly unknown[]\n ? T | WorkflowRef\n : T extends object\n ? { [P in keyof T]: WithRefs<T[P]> | WorkflowRef }\n : T | WorkflowRef;\n\nexport interface StepOptions {\n /**\n * Step id(s) this step follows. Default: the previous step in `build()`\n * order (the first step follows nothing).\n */\n after?: string | readonly string[];\n}\n\nexport interface ToolStep {\n readonly type: 'tool';\n readonly id: string;\n readonly integration: string;\n /** `tool/<name>` or `action/<name>`; effect comes from the pinned contract. */\n readonly op: string;\n readonly args: Record<string, unknown>;\n readonly after?: readonly string[];\n}\n\nexport interface AiStep {\n readonly type: 'ai';\n readonly id: string;\n readonly kind: string;\n readonly instructions: string;\n readonly outputSchemaRef: string;\n readonly after?: readonly string[];\n}\n\nexport interface ApprovalStep {\n readonly type: 'approval';\n readonly id: string;\n readonly summary: string;\n readonly approverScope: 'account' | 'user';\n readonly after?: readonly string[];\n}\n\nexport type WorkflowStep = ToolStep | AiStep | ApprovalStep;\n\nconst afterOf = (options: StepOptions | undefined) =>\n options?.after === undefined\n ? {}\n : {\n after:\n typeof options.after === 'string'\n ? [options.after]\n : [...options.after],\n };\n\n/**\n * Step constructors for {@link defineWorkflowTemplate}.\n *\n * `step.tool` is typed from the generated registry: the integration, the operation\n * and its `args` are checked against the pinned contract. Whether a tool step\n * reads or writes is NOT authored; it is read from the contract at build, so a\n * template cannot call a write as if it were a read.\n */\nexport const step = {\n tool<S extends IntegrationName, K extends OperationKey<S>>(\n id: string,\n integration: S,\n op: K,\n args: WithRefs<OperationInput<S, K>>,\n options?: StepOptions,\n ): ToolStep {\n return {\n type: 'tool',\n id,\n integration,\n op,\n args: args as Record<string, unknown>,\n ...afterOf(options),\n };\n },\n ai(\n id: string,\n config: { instructions: string; outputSchemaRef: string; kind?: string },\n options?: StepOptions,\n ): AiStep {\n return {\n type: 'ai',\n id,\n kind: config.kind ?? 'draft',\n instructions: config.instructions,\n outputSchemaRef: config.outputSchemaRef,\n ...afterOf(options),\n };\n },\n approval(\n id: string,\n config: { summary: string; approverScope?: 'account' | 'user' },\n options?: StepOptions,\n ): ApprovalStep {\n return {\n type: 'approval',\n id,\n summary: config.summary,\n approverScope: config.approverScope ?? 'account',\n ...afterOf(options),\n };\n },\n};\n\nconst TEMPLATE_ID = /^[a-z][a-z0-9-]*$/;\nconst STEP_ID = /^[a-z][a-z0-9_]*$/;\nconst RESERVED_STEP_IDS = new Set(['trigger', 'item', 'loop', 'run']);\n\nexport interface WorkflowTemplateInput {\n /** kebab-case, unique within the experience. */\n id: string;\n name: string;\n /** A 5-field cron expression. Omit for a template that is started by hand. */\n schedule?: string;\n scope?: 'account' | 'user';\n /** Evaluated at `ekanos build`, never at runtime. */\n build: () => readonly WorkflowStep[];\n}\n\nexport interface WorkflowTemplate {\n readonly kind: 'workflow-template';\n readonly id: string;\n readonly name: string;\n readonly schedule?: string;\n readonly scope: 'account' | 'user';\n readonly build: () => readonly WorkflowStep[];\n}\n\nexport function defineWorkflowTemplate(\n input: WorkflowTemplateInput,\n): WorkflowTemplate {\n if (!TEMPLATE_ID.test(input.id)) {\n throw new Error(\n `defineWorkflowTemplate: id \"${input.id}\" must be kebab-case (e.g. \"morning-digest\").`,\n );\n }\n if (input.name.trim() === '') {\n throw new Error(`defineWorkflowTemplate(\"${input.id}\"): name is required.`);\n }\n if (\n input.schedule !== undefined &&\n input.schedule.trim().split(/\\s+/).length !== 5\n ) {\n throw new Error(\n `defineWorkflowTemplate(\"${input.id}\"): schedule must be a 5-field cron expression, got \"${input.schedule}\".`,\n );\n }\n\n return Object.freeze({\n kind: 'workflow-template' as const,\n id: input.id,\n name: input.name,\n ...(input.schedule === undefined ? {} : { schedule: input.schedule }),\n scope: input.scope ?? 'account',\n build: input.build,\n });\n}\n\n/** The serialized workflow the host's engine runs (validated by `WorkflowTemplateSchema`). */\nexport type WorkflowDsl = EngineWorkflowTemplate;\n\nexport { TEMPLATE_INSTALLATION_ID };\n\nexport interface SerializeWorkflowOptions {\n /**\n * Reads `read`/`write` for an integration operation from the pinned contract. Return\n * `undefined` when the operation is unknown: serialization then throws, so\n * a template can never name an operation the contract lacks.\n */\n effectOf: (integration: string, op: string) => 'read' | 'write' | undefined;\n installationId?: string;\n}\n\n/**\n * Turn a template into the engine's DSL. Pure and deterministic: the same\n * template and contracts always give the same JSON (it is hashed into the\n * manifest digest).\n */\nexport function serializeWorkflowTemplate(\n template: WorkflowTemplate,\n options: SerializeWorkflowOptions,\n): WorkflowDsl {\n const steps = template.build();\n const installationId = options.installationId ?? TEMPLATE_INSTALLATION_ID;\n const where = `workflow template \"${template.id}\"`;\n\n if (steps.length === 0)\n throw new Error(`${where}: build() returned no steps.`);\n\n const seen = new Set<string>();\n for (const s of steps) {\n if (!STEP_ID.test(s.id) || RESERVED_STEP_IDS.has(s.id)) {\n throw new Error(`${where}: step id \"${s.id}\" is invalid or reserved.`);\n }\n if (seen.has(s.id))\n throw new Error(`${where}: step id \"${s.id}\" is used twice.`);\n seen.add(s.id);\n }\n\n const edges: WorkflowDsl['edges'] = [];\n steps.forEach((s, index) => {\n const predecessors = s.after ?? (index === 0 ? [] : [steps[index - 1]!.id]);\n for (const from of predecessors) {\n if (!seen.has(from)) {\n throw new Error(\n `${where}: step \"${s.id}\" follows unknown step \"${from}\".`,\n );\n }\n edges.push({ from, to: s.id });\n }\n });\n\n const dslSteps = steps.map((s): WorkflowDsl['steps'][number] => {\n switch (s.type) {\n case 'tool': {\n const effect = options.effectOf(s.integration, s.op);\n if (effect === undefined) {\n throw new Error(\n `${where}: step \"${s.id}\" calls ${s.integration} ${s.op}, which the pinned contract does not declare.`,\n );\n }\n\n return {\n id: s.id,\n type: 'fusion_tool',\n tool: s.op,\n installationId,\n slot: s.integration,\n args: s.args as Extract<\n WorkflowDsl['steps'][number],\n { type: 'fusion_tool' }\n >['args'],\n effect,\n };\n }\n case 'ai':\n return {\n id: s.id,\n type: 'ai_step',\n kind: s.kind,\n instructions: s.instructions,\n outputSchemaRef: s.outputSchemaRef,\n };\n case 'approval':\n return {\n id: s.id,\n type: 'approval_gate',\n summaryTemplate: s.summary,\n approverScope: s.approverScope,\n };\n }\n });\n\n return {\n version: '1',\n name: template.name,\n scope: template.scope,\n trigger:\n template.schedule === undefined\n ? { type: 'manual' }\n : { type: 'schedule', cron: template.schedule },\n steps: dslSteps,\n edges,\n };\n}\n"]}
|
|
@@ -16,7 +16,7 @@ export interface WorkspaceTargetDefinition {
|
|
|
16
16
|
* alphanumeric with single hyphens between segments. */
|
|
17
17
|
slug: string;
|
|
18
18
|
name: string;
|
|
19
|
-
/** A Font Awesome class string, e.g. `fa-
|
|
19
|
+
/** A Font Awesome class string, e.g. `fa-inbox`. Legacy Lucide
|
|
20
20
|
* names are still translated at render time during the migration, but must
|
|
21
21
|
* not be written. Validated by the host at gate time. */
|
|
22
22
|
icon?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-target.js","sourceRoot":"","sources":["../../src/types/workspace-target.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The contract an integration uses to declare the workspaces it ships with\n * (`BaseIntegration.getWorkspaceTargets()`).\n *\n * The host's canonical definition is `z.input<typeof WorkspaceTargetSchema>`\n * (`@kit/integrations-core`, `schemas/workspace-target.schema.ts`) — the\n * schema validates declarations in CI and at materialization time, including\n * cross-field rules a type cannot carry (icon-name validity, slug format,\n * `inheritsWidgets`/`includedWidgetIds` exclusivity, one inheriting target\n * per set). This structural twin exists so the SDK's root entrypoint owns its\n * types without importing the host schema; the parity test beside these types\n * keeps the two shapes mutually assignable.\n */\nexport interface WorkspaceTargetDefinition {\n /** Stable URL segment — `/workspace/<slug>` routes reference it. Lowercase\n * alphanumeric with single hyphens between segments. */\n slug: string;\n name: string;\n /** A Font Awesome class string, e.g. `fa-
|
|
1
|
+
{"version":3,"file":"workspace-target.js","sourceRoot":"","sources":["../../src/types/workspace-target.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The contract an integration uses to declare the workspaces it ships with\n * (`BaseIntegration.getWorkspaceTargets()`).\n *\n * The host's canonical definition is `z.input<typeof WorkspaceTargetSchema>`\n * (`@kit/integrations-core`, `schemas/workspace-target.schema.ts`) — the\n * schema validates declarations in CI and at materialization time, including\n * cross-field rules a type cannot carry (icon-name validity, slug format,\n * `inheritsWidgets`/`includedWidgetIds` exclusivity, one inheriting target\n * per set). This structural twin exists so the SDK's root entrypoint owns its\n * types without importing the host schema; the parity test beside these types\n * keeps the two shapes mutually assignable.\n */\nexport interface WorkspaceTargetDefinition {\n /** Stable URL segment — `/workspace/<slug>` routes reference it. Lowercase\n * alphanumeric with single hyphens between segments. */\n slug: string;\n name: string;\n /** A Font Awesome class string, e.g. `fa-inbox`. Legacy Lucide\n * names are still translated at render time during the migration, but must\n * not be written. Validated by the host at gate time. */\n icon?: string;\n description?: string;\n /** Defaults to `'masonry'` when omitted. */\n layout?: 'masonry' | 'two-column';\n /**\n * Whether this workspace receives the product's otherwise-unplaced\n * widgets. Exactly one target per product must set it; mutually exclusive\n * with `includedWidgetIds`.\n */\n inheritsWidgets?: boolean;\n /** Limit this workspace to specific widget ids. */\n includedWidgetIds?: string[];\n /**\n * Create this workspace on a Source as soon as the product is made\n * available there, instead of waiting for an admin to add it. Only for a\n * product that works as shipped (`activation: { required: false }`).\n */\n materializeOnEntitlement?: boolean;\n}\n"]}
|
package/eslint.design-preset.mjs
CHANGED
|
@@ -22,10 +22,11 @@
|
|
|
22
22
|
* inputs, selects, textareas and labels, each of which carries accessibility
|
|
23
23
|
* wiring a bare element does not.
|
|
24
24
|
*
|
|
25
|
-
* The other
|
|
25
|
+
* The other thirteen are the host's own `design/*` rules — palette-adjacent
|
|
26
26
|
* white/black utilities, Badge tone variants, overlay widths, rounded row
|
|
27
27
|
* hovers, faded muted text, viewport breakpoints in widgets, tinted chips,
|
|
28
|
-
* toolbar tabs, raw type steps, raw buttons, hand-drawn cards
|
|
28
|
+
* toolbar tabs, raw type steps, raw buttons, hand-drawn cards, motion off the
|
|
29
|
+
* tokens, hover that moves — imported from `./eslint.design-rules.mjs`, the single
|
|
29
30
|
* implementation the host repo's oxlint plugin also loads (through the
|
|
30
31
|
* two-line re-export the host's lint config keeps). There is
|
|
31
32
|
* exactly one copy of each rule, so a partner is held to what the host holds
|
package/eslint.design-rules.mjs
CHANGED
|
@@ -99,6 +99,13 @@ function stringVisitors(test, message) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* A default icon family written before an icon name (plan 251 D44). Icons are
|
|
104
|
+
* written family-less (`fa-gear`) so the theme's icon style reaches every one;
|
|
105
|
+
* `fa-solid` / `fa-duotone` emphasis and `fa-brands` are deliberate and allowed.
|
|
106
|
+
*/
|
|
107
|
+
const DEFAULT_ICON_FAMILY = /(?:^|[\s'"`])fa-(?:light|regular)\s+fa-[a-z0-9]/;
|
|
108
|
+
|
|
102
109
|
const BADGE_TONES = new Set(['success', 'warning', 'info']);
|
|
103
110
|
|
|
104
111
|
const TONE_BADGE_MESSAGE =
|
|
@@ -310,8 +317,9 @@ const TOOLBARS = new Set(['PageToolbar', 'PageToolbarActions']);
|
|
|
310
317
|
|
|
311
318
|
/**
|
|
312
319
|
* Whether a JSX element is the value of a `render` prop —
|
|
313
|
-
* `<Item render={<button type="button" />}>`.
|
|
314
|
-
*
|
|
320
|
+
* `<Item render={<button type="button" />}>`. Not reported here, so the call
|
|
321
|
+
* sites that still do it lint clean, but it is not the sanctioned form: new
|
|
322
|
+
* code uses the kit's `Button`, `ItemButton` or `CardButton`.
|
|
315
323
|
*
|
|
316
324
|
* @param {JsxElement} node the opening element
|
|
317
325
|
*/
|
|
@@ -336,7 +344,7 @@ function isRenderPropValue(node) {
|
|
|
336
344
|
const CARD_FILL = /(?:^|\s)bg-card(?=$|\s)/;
|
|
337
345
|
const CARD_CORNER = /(?:^|\s)rounded(?:-[\w[\]]+)?(?=$|\s)/;
|
|
338
346
|
const CARD_EDGE =
|
|
339
|
-
/(?:^|\s)(?:shadow-(?:card|widget|xs|sm|md)|border(?:-border)?)(?=$|\s)/;
|
|
347
|
+
/(?:^|\s)(?:shadow-(?:ring|card|widget|xs|sm|md)|border(?:-border)?)(?=$|\s)/;
|
|
340
348
|
|
|
341
349
|
/** @param {string} value */
|
|
342
350
|
function isHandDrawnCard(value) {
|
|
@@ -345,9 +353,204 @@ function isHandDrawnCard(value) {
|
|
|
345
353
|
);
|
|
346
354
|
}
|
|
347
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Motion written outside the tokens (plan 253): a raw `duration-<ms>` step
|
|
358
|
+
* or `transition-all`. Durations come from the motion tokens
|
|
359
|
+
* (`duration-(--duration-enter)`, `-exit`, `-colour`, `-press`, `-release`,
|
|
360
|
+
* `-spring`, `-sheet`), so one change re-times the product and the specimen's
|
|
361
|
+
* slow-motion switch reaches every one; `transition-all` animates whatever
|
|
362
|
+
* property changes next, layout included. Prefix variants ride along, and
|
|
363
|
+
* `duration-0` (no motion at all) is allowed.
|
|
364
|
+
*/
|
|
365
|
+
const RAW_MOTION =
|
|
366
|
+
/(?:^|[\s:])(?:transition-all|duration-(?:[1-9]\d*|\[[\d.]*[1-9][\d.]*m?s\]))(?=$|\s)/;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* A hover that moves (plan 251 D42, plan 253): hover changes colour only, so
|
|
370
|
+
* a scale or a translate under `hover:` / `group-hover:` / `peer-hover:` is
|
|
371
|
+
* motion the pointer triggers dozens of times an hour.
|
|
372
|
+
*/
|
|
373
|
+
const HOVER_MOTION =
|
|
374
|
+
/(?:^|\s)(?:[\w\-[\]/]+:)*(?:group-|peer-)?hover(?:\/[\w-]+)?:(?:[\w\-[\]]+:)*-?(?:scale|translate-[xy])-/;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* A focus ring faded with an opacity step (plan 254): `focus-visible:ring-ring/50`
|
|
378
|
+
* and the like. The ring token is solved to 3:1 on every surface at full
|
|
379
|
+
* strength; an opacity step drops it below that, so the keyboard user loses
|
|
380
|
+
* the only mark of where they are. Any variant chain naming `focus` counts.
|
|
381
|
+
*/
|
|
382
|
+
const FADED_FOCUS_RING =
|
|
383
|
+
/(?:^|[\s'"`])(?:[\w\-[\]&>*=]+:)*[\w\-[\]]*focus[\w\-[\]/]*:(?:[\w\-[\]]+:)*(?:ring|outline)-(?!offset-)[a-z][\w-]*\/\d+(?=$|[\s'"`])/;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* A raw Tailwind shadow step (plan 254). Elevation comes from the shadow
|
|
387
|
+
* vocabulary — `shadow-ring`, `-control`, `-popover`, `-modal`, `-sticky`,
|
|
388
|
+
* `-rail` — whose tiers are drawn so a layer on top reads as on top in both
|
|
389
|
+
* modes; `shadow-md` and its siblings are invisible on charcoal and pile on
|
|
390
|
+
* in light. `shadow-none` is allowed.
|
|
391
|
+
*/
|
|
392
|
+
const RAW_SHADOW =
|
|
393
|
+
/(?:^|[\s'"`])(?:[\w\-[\]&>*=/]+:)*!?shadow-(?:2xs|xs|sm|md|lg|xl|2xl|inner|\[[^\s'"`]+\])(?=$|[\s'"`])/;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* The words a steady, healthy state is labelled with. "Healthy" is the
|
|
397
|
+
* `clear` tone, ink and a check (the Quiet All-Clear Rule);
|
|
398
|
+
* `success` is green and stays for an action that just finished ("Saved",
|
|
399
|
+
* "Sent", "Paid"), which none of these words describe. `on` and `live` only
|
|
400
|
+
* count as the label's first word, so "Saved on Friday" is not a health label.
|
|
401
|
+
*/
|
|
402
|
+
const HEALTH_WORDS = new Set([
|
|
403
|
+
'active',
|
|
404
|
+
'connected',
|
|
405
|
+
'current',
|
|
406
|
+
'enabled',
|
|
407
|
+
'granted',
|
|
408
|
+
'healthy',
|
|
409
|
+
'online',
|
|
410
|
+
'operational',
|
|
411
|
+
'passing',
|
|
412
|
+
'ready',
|
|
413
|
+
'valid',
|
|
414
|
+
'verified',
|
|
415
|
+
]);
|
|
416
|
+
const HEALTH_LEADS = new Set([...HEALTH_WORDS, 'live', 'on']);
|
|
417
|
+
|
|
418
|
+
/** @param {string} label */
|
|
419
|
+
function isHealthLabel(label) {
|
|
420
|
+
const words = label.toLowerCase().match(/[a-z]+/g) ?? [];
|
|
421
|
+
const [lead] = words[0] === 'all' ? words.slice(1) : words;
|
|
422
|
+
|
|
423
|
+
return (
|
|
424
|
+
(lead !== undefined && HEALTH_LEADS.has(lead)) ||
|
|
425
|
+
words.some((word) => HEALTH_WORDS.has(word))
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** The keys a status map names a pill's words under, beside its `tone`. */
|
|
430
|
+
const STATUS_LABEL_KEYS = new Set([
|
|
431
|
+
'label',
|
|
432
|
+
'labelDefault',
|
|
433
|
+
'fallback',
|
|
434
|
+
'headline',
|
|
435
|
+
]);
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Every key a status map's entry may carry. An object with any other key
|
|
439
|
+
* (`value`, `total`) is a different component's row, such as a meter, whose
|
|
440
|
+
* tone is not a pill's.
|
|
441
|
+
*/
|
|
442
|
+
const STATUS_ENTRY_KEYS = new Set([
|
|
443
|
+
...STATUS_LABEL_KEYS,
|
|
444
|
+
'tone',
|
|
445
|
+
'icon',
|
|
446
|
+
'className',
|
|
447
|
+
'labelKey',
|
|
448
|
+
'i18nKey',
|
|
449
|
+
'description',
|
|
450
|
+
'detail',
|
|
451
|
+
]);
|
|
452
|
+
|
|
453
|
+
const SUCCESS_HEALTH_MESSAGE =
|
|
454
|
+
'A healthy state is tone="clear", not "success": ink and a check, so green never competes with what needs the owner. Keep success for an action that just finished ("Saved", "Sent", "Paid") (the Quiet All-Clear Rule).';
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* The text a JSX element's children spell, or null when any child is not a
|
|
458
|
+
* literal (a translated label, a variable): the rule only judges words it
|
|
459
|
+
* can read.
|
|
460
|
+
*
|
|
461
|
+
* @param {Array<{ type?: string, value?: unknown, expression?: Expression }>} children
|
|
462
|
+
*/
|
|
463
|
+
function literalChildText(children) {
|
|
464
|
+
let text = '';
|
|
465
|
+
|
|
466
|
+
for (const child of children) {
|
|
467
|
+
if (child.type === 'JSXText' && typeof child.value === 'string') {
|
|
468
|
+
text += child.value;
|
|
469
|
+
} else if (
|
|
470
|
+
child.type === 'JSXExpressionContainer' &&
|
|
471
|
+
child.expression?.type === 'Literal' &&
|
|
472
|
+
typeof child.expression.value === 'string'
|
|
473
|
+
) {
|
|
474
|
+
text += child.expression.value;
|
|
475
|
+
} else if (child.type === 'JSXElement') {
|
|
476
|
+
continue;
|
|
477
|
+
} else {
|
|
478
|
+
return null;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return text.trim() || null;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* @param {{ type?: string, name?: string, value?: unknown }} key
|
|
487
|
+
* @returns {string | null}
|
|
488
|
+
*/
|
|
489
|
+
function propertyName(key) {
|
|
490
|
+
if (key.type === 'Identifier' && typeof key.name === 'string') {
|
|
491
|
+
return key.name;
|
|
492
|
+
}
|
|
493
|
+
if (key.type === 'Literal' && typeof key.value === 'string') {
|
|
494
|
+
return key.value;
|
|
495
|
+
}
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
|
|
348
499
|
export default {
|
|
349
500
|
meta: { name: 'design' },
|
|
350
501
|
rules: {
|
|
502
|
+
'motion-tokens': {
|
|
503
|
+
meta: {
|
|
504
|
+
type: 'problem',
|
|
505
|
+
docs: {
|
|
506
|
+
description:
|
|
507
|
+
'Disallow a raw duration step and transition-all; motion comes from the motion tokens and a named property list.',
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
create: stringVisitors(
|
|
511
|
+
RAW_MOTION,
|
|
512
|
+
'Time motion with a token, not a raw step: duration-(--duration-enter) for an entrance, -exit for an exit, -colour for a colour change, -press / -release for a press, -spring, -sheet; or a press-* recipe for a pressable. Name the properties (transition-colors, transition-[opacity,translate]) instead of transition-all, which also animates layout (plan 253).',
|
|
513
|
+
),
|
|
514
|
+
},
|
|
515
|
+
'no-hover-motion': {
|
|
516
|
+
meta: {
|
|
517
|
+
type: 'problem',
|
|
518
|
+
docs: {
|
|
519
|
+
description:
|
|
520
|
+
'Disallow scale or translate on hover; hover changes colour only.',
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
create: stringVisitors(
|
|
524
|
+
HOVER_MOTION,
|
|
525
|
+
'Hover changes colour only: no scale and no translate under hover:, group-hover: or peer-hover:. An interactive card darkens its ring and steps its surface (cardSurfaceVariants({ interactive: true })); a control answers the press, not the hover, through a press-* recipe (plan 251 D42, plan 253).',
|
|
526
|
+
),
|
|
527
|
+
},
|
|
528
|
+
'no-faded-focus-ring': {
|
|
529
|
+
meta: {
|
|
530
|
+
type: 'problem',
|
|
531
|
+
docs: {
|
|
532
|
+
description:
|
|
533
|
+
'Disallow an opacity step on a focus ring or outline colour; the ring is drawn at full strength.',
|
|
534
|
+
},
|
|
535
|
+
},
|
|
536
|
+
create: stringVisitors(
|
|
537
|
+
FADED_FOCUS_RING,
|
|
538
|
+
'Draw the focus ring at full strength: focus-visible:ring-ring (or outline-ring), never ring-ring/50. The ring token is solved to 3:1 on every surface, and an opacity step drops it below that (the Inputs rule).',
|
|
539
|
+
),
|
|
540
|
+
},
|
|
541
|
+
'shadow-tokens': {
|
|
542
|
+
meta: {
|
|
543
|
+
type: 'problem',
|
|
544
|
+
docs: {
|
|
545
|
+
description:
|
|
546
|
+
'Disallow a raw shadow step; elevation comes from the shadow vocabulary.',
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
create: stringVisitors(
|
|
550
|
+
RAW_SHADOW,
|
|
551
|
+
'Use the shadow vocabulary, not a raw step: shadow-ring for a card or container, shadow-control for a field or button edge, shadow-popover for a menu, popover or tooltip, shadow-modal for a dialog or sheet, shadow-sticky / shadow-rail for one edge. A surface never lifts on hover: darken its ring instead (the Stacking rule).',
|
|
552
|
+
),
|
|
553
|
+
},
|
|
351
554
|
'no-tone-badge-variant': {
|
|
352
555
|
meta: {
|
|
353
556
|
type: 'problem',
|
|
@@ -389,6 +592,74 @@ export default {
|
|
|
389
592
|
};
|
|
390
593
|
},
|
|
391
594
|
},
|
|
595
|
+
'no-success-health-label': {
|
|
596
|
+
meta: {
|
|
597
|
+
type: 'problem',
|
|
598
|
+
docs: {
|
|
599
|
+
description:
|
|
600
|
+
'Disallow the success tone on a health label; a healthy state is StatusBadge tone="clear".',
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
/** @param {RuleContext} context */
|
|
604
|
+
create(context) {
|
|
605
|
+
return {
|
|
606
|
+
/**
|
|
607
|
+
* `<StatusBadge tone="success">Connected</StatusBadge>`.
|
|
608
|
+
*
|
|
609
|
+
* @param {JsxElement & { children?: Array<{ type?: string, value?: unknown, expression?: Expression }> }} node
|
|
610
|
+
*/
|
|
611
|
+
JSXElement(node) {
|
|
612
|
+
const opening = node.openingElement;
|
|
613
|
+
if (jsxName(opening?.name) !== 'StatusBadge') return;
|
|
614
|
+
|
|
615
|
+
const tone = (opening?.attributes ?? []).find(
|
|
616
|
+
(attribute) =>
|
|
617
|
+
attribute.type === 'JSXAttribute' &&
|
|
618
|
+
attribute.name?.name === 'tone',
|
|
619
|
+
);
|
|
620
|
+
if (!tone || literalValue(tone.value) !== 'success') return;
|
|
621
|
+
|
|
622
|
+
const label = literalChildText(node.children ?? []);
|
|
623
|
+
if (label && isHealthLabel(label)) {
|
|
624
|
+
context.report({ node: tone, message: SUCCESS_HEALTH_MESSAGE });
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
/**
|
|
628
|
+
* A status map's entry: `{ label: 'Healthy', tone: 'success' }`.
|
|
629
|
+
*
|
|
630
|
+
* @param {{ properties?: Array<{ type?: string, key?: { type?: string, name?: string, value?: unknown }, value?: Expression }> }} node
|
|
631
|
+
*/
|
|
632
|
+
ObjectExpression(node) {
|
|
633
|
+
let tone = null;
|
|
634
|
+
let label = null;
|
|
635
|
+
|
|
636
|
+
for (const property of node.properties ?? []) {
|
|
637
|
+
if (property.type !== 'Property' || !property.key) continue;
|
|
638
|
+
|
|
639
|
+
const name = propertyName(property.key);
|
|
640
|
+
if (!name || !STATUS_ENTRY_KEYS.has(name)) return;
|
|
641
|
+
|
|
642
|
+
const value = property.value;
|
|
643
|
+
const literal =
|
|
644
|
+
value?.type === 'TSAsExpression'
|
|
645
|
+
? value.expression?.value
|
|
646
|
+
: value?.type === 'Literal'
|
|
647
|
+
? value.value
|
|
648
|
+
: undefined;
|
|
649
|
+
|
|
650
|
+
if (name === 'tone' && literal === 'success') tone = property;
|
|
651
|
+
if (STATUS_LABEL_KEYS.has(name) && typeof literal === 'string') {
|
|
652
|
+
label = literal;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
if (tone && label && isHealthLabel(label)) {
|
|
657
|
+
context.report({ node: tone, message: SUCCESS_HEALTH_MESSAGE });
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
};
|
|
661
|
+
},
|
|
662
|
+
},
|
|
392
663
|
'no-faded-muted-text': {
|
|
393
664
|
meta: {
|
|
394
665
|
type: 'problem',
|
|
@@ -415,6 +686,19 @@ export default {
|
|
|
415
686
|
'white/black color utilities ignore the theme, dark mode and Source branding. Use a token: bg-card or bg-background for surfaces, text-foreground / text-primary-foreground for text. A modal scrim may stay black with a disable comment saying so (design-system theming rule).',
|
|
416
687
|
),
|
|
417
688
|
},
|
|
689
|
+
'no-default-icon-family': {
|
|
690
|
+
meta: {
|
|
691
|
+
type: 'problem',
|
|
692
|
+
docs: {
|
|
693
|
+
description:
|
|
694
|
+
'Disallow fa-light / fa-regular in an icon name; write it family-less so the theme decides.',
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
create: stringVisitors(
|
|
698
|
+
DEFAULT_ICON_FAMILY,
|
|
699
|
+
'Write the icon family-less (`fa-gear`, not `fa-light fa-gear`): the theme decides the family, regular by default or a Source’s icon style, so a family written here is one more icon a re-brand cannot reach. `fa-solid` / `fa-duotone` for deliberate emphasis and `fa-brands` stay (plan 251 D44).',
|
|
700
|
+
),
|
|
701
|
+
},
|
|
418
702
|
'no-overlay-width-class': {
|
|
419
703
|
meta: {
|
|
420
704
|
type: 'problem',
|
|
@@ -579,7 +863,7 @@ export default {
|
|
|
579
863
|
context.report({
|
|
580
864
|
node,
|
|
581
865
|
message:
|
|
582
|
-
'A raw <button> misses the focus ring, disabled and loading states, the size scale and the per-Source retint. Use Button (variant="ghost" or "link", size="xs" for a quiet text action),
|
|
866
|
+
'A raw <button> misses the focus ring, disabled and loading states, the size scale and the per-Source retint. Use Button (variant="ghost" or "link", size="xs" for a quiet text action), ItemButton for a row or CardButton for a card that acts on press (design-system buttons rule).',
|
|
583
867
|
});
|
|
584
868
|
},
|
|
585
869
|
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ekanos/sdk/eslint/experience — keeps integration code out of an experience.
|
|
3
|
+
*
|
|
4
|
+
* An experience reaches integrations ONLY through integrations (`useOperation`,
|
|
5
|
+
* `operation()`, `step.tool`). This preset is the fast, in-editor half of that
|
|
6
|
+
* rule; the authoritative half is `ekanos check` / `ekanos build`
|
|
7
|
+
* (`experience-boundary`), which also resolves real imports and scans the
|
|
8
|
+
* bundle, so a path this preset cannot see (a helper package that re-exports an
|
|
9
|
+
* integration, a computed `import()`) still fails the build.
|
|
10
|
+
*
|
|
11
|
+
* import experiencePreset from '@ekanos/sdk/eslint/experience';
|
|
12
|
+
* export default [...baseConfig, ...experiencePreset];
|
|
13
|
+
*
|
|
14
|
+
* Inline `eslint-disable` is ignored over `src/`, by design: the boundary has
|
|
15
|
+
* no per-line exceptions.
|
|
16
|
+
*/
|
|
17
|
+
const SOURCE_GLOB = ['src/**/*.ts', 'src/**/*.tsx'];
|
|
18
|
+
|
|
19
|
+
const INTEGRATION_REMEDIATION =
|
|
20
|
+
'An experience calls integrations only through integrations: ' +
|
|
21
|
+
"`useOperation('<integration>', '<tool|action>/<name>')` on the client, " +
|
|
22
|
+
'`operation(...)` on the server, `step.tool(...)` in a workflow. Add the ' +
|
|
23
|
+
'integration with `ekanos add <integration>@<line>`; its types come from the ' +
|
|
24
|
+
'pinned contract, not from integration source.';
|
|
25
|
+
|
|
26
|
+
export const restrictedImportPatterns = [
|
|
27
|
+
{
|
|
28
|
+
group: ['@companydotcom/integration-*', '@companydotcom/integration-*/**'],
|
|
29
|
+
message: `Importing an integration package into an experience is forbidden. ${INTEGRATION_REMEDIATION}`,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
group: [
|
|
33
|
+
'**/integrations/*/src/**',
|
|
34
|
+
'**/integrations/*',
|
|
35
|
+
'**/node_modules/@companydotcom/integration-*/**',
|
|
36
|
+
],
|
|
37
|
+
message: `A path into an integration project is forbidden. ${INTEGRATION_REMEDIATION}`,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
group: ['@kit/*', '@kit/**'],
|
|
41
|
+
message:
|
|
42
|
+
'`@kit/*` is host-internal and does not exist for a partner. Build with `@ekanos/ui` and `@ekanos/sdk`.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
group: [
|
|
46
|
+
'@ekanos/harness',
|
|
47
|
+
'@ekanos/harness/**',
|
|
48
|
+
'@ekanos/cli',
|
|
49
|
+
'@ekanos/cli/**',
|
|
50
|
+
],
|
|
51
|
+
message: 'Dev tooling is not a runtime dependency of an experience.',
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
export default [
|
|
56
|
+
{
|
|
57
|
+
name: '@ekanos/sdk/eslint/experience',
|
|
58
|
+
files: SOURCE_GLOB,
|
|
59
|
+
linterOptions: { noInlineConfig: true },
|
|
60
|
+
rules: {
|
|
61
|
+
'no-restricted-imports': [
|
|
62
|
+
'error',
|
|
63
|
+
{ patterns: restrictedImportPatterns },
|
|
64
|
+
],
|
|
65
|
+
'no-restricted-syntax': [
|
|
66
|
+
'error',
|
|
67
|
+
{
|
|
68
|
+
selector: "ImportExpression[source.type!='Literal']",
|
|
69
|
+
message:
|
|
70
|
+
'A computed dynamic import() can name an integration at runtime and cannot be checked. Import a static specifier.',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
selector:
|
|
74
|
+
'ImportExpression[source.value=/^@companydotcom\\/integration-|\\/integrations\\//]',
|
|
75
|
+
message: `Dynamic import of an integration is forbidden. ${INTEGRATION_REMEDIATION}`,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
selector:
|
|
79
|
+
"CallExpression[callee.name='require'][arguments.0.value=/^@companydotcom\\/integration-|\\/integrations\\//]",
|
|
80
|
+
message: `require() of an integration is forbidden. ${INTEGRATION_REMEDIATION}`,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
];
|