eventmodeler 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/index.js +7133 -34
  2. package/package.json +5 -4
  3. package/dist/api/client-config.js +0 -10
  4. package/dist/api/generated/client/client.gen.js +0 -235
  5. package/dist/api/generated/client/index.js +0 -6
  6. package/dist/api/generated/client/types.gen.js +0 -2
  7. package/dist/api/generated/client/utils.gen.js +0 -228
  8. package/dist/api/generated/client.gen.js +0 -4
  9. package/dist/api/generated/core/auth.gen.js +0 -14
  10. package/dist/api/generated/core/bodySerializer.gen.js +0 -57
  11. package/dist/api/generated/core/params.gen.js +0 -100
  12. package/dist/api/generated/core/pathSerializer.gen.js +0 -106
  13. package/dist/api/generated/core/queryKeySerializer.gen.js +0 -92
  14. package/dist/api/generated/core/serverSentEvents.gen.js +0 -133
  15. package/dist/api/generated/core/types.gen.js +0 -2
  16. package/dist/api/generated/core/utils.gen.js +0 -87
  17. package/dist/api/generated/index.js +0 -2
  18. package/dist/api/generated/sdk.gen.js +0 -4222
  19. package/dist/api/generated/types.gen.js +0 -2
  20. package/dist/api/generated/zod.gen.js +0 -7217
  21. package/dist/commands/add.js +0 -315
  22. package/dist/commands/auth.js +0 -14
  23. package/dist/commands/create.js +0 -192
  24. package/dist/commands/design.js +0 -108
  25. package/dist/commands/guide.js +0 -15
  26. package/dist/commands/init.js +0 -21
  27. package/dist/commands/list-schemas.js +0 -177
  28. package/dist/commands/list.js +0 -39
  29. package/dist/commands/loop.js +0 -101
  30. package/dist/commands/map.js +0 -40
  31. package/dist/commands/mark.js +0 -27
  32. package/dist/commands/move.js +0 -35
  33. package/dist/commands/remove.js +0 -170
  34. package/dist/commands/rename.js +0 -53
  35. package/dist/commands/resize.js +0 -30
  36. package/dist/commands/search.js +0 -14
  37. package/dist/commands/set.js +0 -199
  38. package/dist/commands/show-schemas.js +0 -259
  39. package/dist/commands/show.js +0 -56
  40. package/dist/commands/summary.js +0 -13
  41. package/dist/commands/update.js +0 -240
  42. package/dist/lib/auth.js +0 -331
  43. package/dist/lib/config.js +0 -80
  44. package/dist/lib/excalidraw-schema.js +0 -66
  45. package/dist/lib/globals.js +0 -8
  46. package/dist/lib/model.js +0 -11
  47. package/dist/lib/project-config.js +0 -103
  48. package/dist/lib/resolve.js +0 -59
  49. package/dist/lib/scenario.js +0 -15
  50. package/dist/slices/add-scenario/index.js +0 -103
  51. package/dist/slices/guide/guides/codegen.js +0 -339
  52. package/dist/slices/guide/guides/connect-slices.js +0 -202
  53. package/dist/slices/guide/guides/create-slices.js +0 -273
  54. package/dist/slices/guide/guides/explore.js +0 -238
  55. package/dist/slices/guide/guides/information-flow.js +0 -304
  56. package/dist/slices/guide/guides/scenarios.js +0 -214
  57. package/dist/slices/guide/index.js +0 -40
  58. package/dist/slices/help/index.js +0 -96
  59. package/dist/slices/help/topics/build-codegen.js +0 -109
  60. package/dist/slices/help/topics/build-slice.js +0 -147
  61. package/dist/slices/help/topics/check-completeness.js +0 -57
  62. package/dist/slices/help/topics/connect-slices.js +0 -99
  63. package/dist/slices/help/topics/explore-model.js +0 -112
  64. package/dist/slices/help/topics/json-reference.js +0 -188
  65. package/dist/slices/help/topics/linked-copies.js +0 -89
  66. package/dist/slices/help/topics/manipulate-canvas.js +0 -150
  67. package/dist/slices/help/topics/write-scenarios.js +0 -162
  68. package/dist/slices/init/index.js +0 -86
  69. package/dist/slices/init/loop.js +0 -60
  70. package/dist/slices/login/index.js +0 -20
  71. package/dist/slices/logout/index.js +0 -14
  72. package/dist/slices/open-app/index.js +0 -36
  73. package/dist/slices/whoami/index.js +0 -19
@@ -1,66 +0,0 @@
1
- import { z } from 'zod';
2
- const FillStyle = z.enum(['solid', 'hachure', 'cross-hatch', 'zigzag']);
3
- const StrokeStyle = z.enum(['solid', 'dashed', 'dotted']);
4
- const TextAlign = z.enum(['left', 'center', 'right']);
5
- const VerticalAlign = z.enum(['top', 'middle', 'bottom']);
6
- const StyleFields = {
7
- strokeColor: z.string().optional(),
8
- backgroundColor: z.string().optional(),
9
- fillStyle: FillStyle.optional(),
10
- strokeStyle: StrokeStyle.optional(),
11
- strokeWidth: z.number().nonnegative().optional(),
12
- roughness: z.number().nonnegative().optional(),
13
- opacity: z.number().min(0).max(100).optional(),
14
- angle: z.number().optional(),
15
- };
16
- const BoxFields = {
17
- id: z.string().min(1),
18
- x: z.number(),
19
- y: z.number(),
20
- width: z.number(),
21
- height: z.number(),
22
- ...StyleFields,
23
- };
24
- const ShapeElement = z.object({
25
- type: z.enum(['rectangle', 'ellipse', 'diamond', 'frame', 'magicframe', 'iframe', 'embeddable', 'image', 'freedraw']),
26
- ...BoxFields,
27
- }).passthrough();
28
- const LineElement = z.object({
29
- type: z.enum(['line', 'arrow']),
30
- ...BoxFields,
31
- points: z.array(z.tuple([z.number(), z.number()])).optional(),
32
- }).passthrough();
33
- const TextElement = z.object({
34
- type: z.literal('text'),
35
- id: z.string().min(1),
36
- x: z.number(),
37
- y: z.number(),
38
- width: z.number().optional(),
39
- height: z.number().optional(),
40
- text: z.string(),
41
- fontSize: z.number().positive(),
42
- fontFamily: z.number().int().positive().optional(),
43
- textAlign: TextAlign.optional(),
44
- verticalAlign: VerticalAlign.optional(),
45
- ...StyleFields,
46
- }).passthrough();
47
- const Element = z.discriminatedUnion('type', [ShapeElement, LineElement, TextElement]);
48
- export const ExcalidrawDesign = z.array(Element).superRefine((elements, ctx) => {
49
- const seen = new Set();
50
- elements.forEach((el, i) => {
51
- if (seen.has(el.id)) {
52
- ctx.addIssue({
53
- code: 'custom',
54
- path: [i, 'id'],
55
- message: `duplicate id "${el.id}"`,
56
- });
57
- }
58
- seen.add(el.id);
59
- });
60
- });
61
- export function formatZodError(error) {
62
- return error.issues.map(issue => {
63
- const path = issue.path.length > 0 ? issue.path.join('.') : '(root)';
64
- return `${path}: ${issue.message}`;
65
- });
66
- }
@@ -1,8 +0,0 @@
1
- let _program;
2
- export function setProgram(program) {
3
- _program = program;
4
- }
5
- /** Get the global --id option value. */
6
- export function getGlobalId() {
7
- return _program?.opts()?.id;
8
- }
package/dist/lib/model.js DELETED
@@ -1,11 +0,0 @@
1
- import { loadProjectConfig } from './project-config';
2
- /** Load modelId from .eventmodeler.json or exit with error. */
3
- export function requireModelId() {
4
- const config = loadProjectConfig();
5
- if (!config || config.type !== 'cloud') {
6
- console.error('Error: No project configured.');
7
- console.error('Run "eventmodeler init" to connect this directory to a model.');
8
- process.exit(1);
9
- }
10
- return config.modelId;
11
- }
@@ -1,103 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as path from 'node:path';
3
- const PROJECT_CONFIG_FILENAME = '.eventmodeler.json';
4
- /**
5
- * Find .eventmodeler.json by walking up from cwd to find the repo root.
6
- * Returns the path to the config file if found, null otherwise.
7
- */
8
- export function findProjectConfigPath(startDir = process.cwd()) {
9
- let dir = path.resolve(startDir);
10
- const root = path.parse(dir).root;
11
- while (dir !== root) {
12
- const configPath = path.join(dir, PROJECT_CONFIG_FILENAME);
13
- if (fs.existsSync(configPath)) {
14
- return configPath;
15
- }
16
- // Also check if we're at a git repo root (stop searching)
17
- const gitDir = path.join(dir, '.git');
18
- if (fs.existsSync(gitDir)) {
19
- // We're at the git root but no config found
20
- return null;
21
- }
22
- dir = path.dirname(dir);
23
- }
24
- return null;
25
- }
26
- /**
27
- * Load the project config from the nearest .eventmodeler.json file.
28
- */
29
- export function loadProjectConfig(startDir) {
30
- const configPath = findProjectConfigPath(startDir);
31
- if (!configPath)
32
- return null;
33
- try {
34
- const content = fs.readFileSync(configPath, 'utf-8');
35
- const config = JSON.parse(content);
36
- // Validate config structure
37
- if (config.type === 'cloud' && config.modelId && config.modelName) {
38
- return { type: 'cloud', modelId: config.modelId, modelName: config.modelName };
39
- }
40
- return null;
41
- }
42
- catch {
43
- return null;
44
- }
45
- }
46
- /**
47
- * Save a project config to the current directory or specified path.
48
- */
49
- export function saveProjectConfig(config, targetDir = process.cwd()) {
50
- const configPath = path.join(targetDir, PROJECT_CONFIG_FILENAME);
51
- const content = { type: 'cloud', modelId: config.modelId, modelName: config.modelName };
52
- fs.writeFileSync(configPath, JSON.stringify(content, null, 2) + '\n');
53
- return configPath;
54
- }
55
- /**
56
- * Get the project root directory (where .eventmodeler.json is or should be).
57
- * Falls back to git root or current directory.
58
- */
59
- export function getProjectRoot(startDir = process.cwd()) {
60
- // First try to find existing config
61
- const configPath = findProjectConfigPath(startDir);
62
- if (configPath) {
63
- return path.dirname(configPath);
64
- }
65
- // Otherwise find git root
66
- let dir = path.resolve(startDir);
67
- const root = path.parse(dir).root;
68
- while (dir !== root) {
69
- const gitDir = path.join(dir, '.git');
70
- if (fs.existsSync(gitDir)) {
71
- return dir;
72
- }
73
- dir = path.dirname(dir);
74
- }
75
- // Fall back to current directory
76
- return process.cwd();
77
- }
78
- /**
79
- * Check if the current directory is within a project with .eventmodeler.json.
80
- */
81
- export function isInProject(startDir) {
82
- return findProjectConfigPath(startDir) !== null;
83
- }
84
- /**
85
- * Load the `loop` block from .eventmodeler.json, if present.
86
- */
87
- export function loadLoopConfig(startDir) {
88
- const configPath = findProjectConfigPath(startDir);
89
- if (!configPath)
90
- return null;
91
- try {
92
- const content = fs.readFileSync(configPath, 'utf-8');
93
- const config = JSON.parse(content);
94
- const loop = config.loop;
95
- if (loop && typeof loop.command === 'string' && typeof loop.interval === 'number') {
96
- return { command: loop.command, interval: loop.interval };
97
- }
98
- return null;
99
- }
100
- catch {
101
- return null;
102
- }
103
- }
@@ -1,59 +0,0 @@
1
- import * as sdk from '../api/generated/sdk.gen';
2
- const FIELD_BEARING_TYPES = ['command', 'event', 'readmodel', 'screen', 'processor', 'external-event'];
3
- /** Map element type to the body key name used by the SDK. */
4
- export function elementIdKey(type) {
5
- switch (type) {
6
- case 'command': return 'commandStickyId';
7
- case 'event': return 'eventStickyId';
8
- case 'readmodel': return 'readModelStickyId';
9
- case 'external-event': return 'externalEventId';
10
- case 'swimlane': return 'swimLaneId';
11
- default: return `${type}Id`;
12
- }
13
- }
14
- /** Unwrap SDK response — throw on error, return data on success. */
15
- export function unwrap(result) {
16
- if (result.error) {
17
- const err = result.error;
18
- const message = err?.error ?? err?.message ?? err?.detail ?? JSON.stringify(err);
19
- throw new Error(String(message));
20
- }
21
- if (result.data === undefined) {
22
- throw new Error(`Empty response (HTTP ${result.response.status})`);
23
- }
24
- return result.data;
25
- }
26
- /**
27
- * Resolve an element name to its UUID via the CLI resolver.
28
- * If idOverride is provided, skip resolution and return it directly.
29
- */
30
- export async function resolve(modelId, elementType, name, idOverride) {
31
- if (idOverride)
32
- return idOverride;
33
- const result = unwrap(await sdk.resolveElement({
34
- query: { modelId, elementType, name }
35
- }));
36
- const elementId = result.elementId;
37
- if (!elementId) {
38
- throw new Error(`${elementType} "${name}" not found`);
39
- }
40
- return String(elementId);
41
- }
42
- /** Resolve an element name to its UUID, trying all field-bearing types. */
43
- export async function resolveAnyElement(modelId, name, idOverride) {
44
- if (idOverride) {
45
- return { elementId: idOverride, elementType: 'unknown' };
46
- }
47
- for (const t of FIELD_BEARING_TYPES) {
48
- try {
49
- const id = await resolve(modelId, t, name);
50
- return { elementId: id, elementType: t };
51
- }
52
- catch { /* try next */ }
53
- }
54
- throw new Error(`Element "${name}" not found`);
55
- }
56
- /** Pretty-print JSON to stdout. */
57
- export function out(data) {
58
- console.log(JSON.stringify(data, null, 2));
59
- }
@@ -1,15 +0,0 @@
1
- import * as sdk from '../api/generated/sdk.gen';
2
- import { unwrap } from './resolve';
3
- /** Resolve a scenario name to its UUID. If idOverride is provided, skip resolution. */
4
- export async function resolveScenarioId(modelId, name, idOverride) {
5
- if (idOverride)
6
- return idOverride;
7
- const result = unwrap(await sdk.resolveScenario({
8
- query: { modelId, name }
9
- }));
10
- const scenarioId = result.scenarioId;
11
- if (!scenarioId) {
12
- throw new Error(`Scenario "${name}" not found`);
13
- }
14
- return String(scenarioId);
15
- }
@@ -1,103 +0,0 @@
1
- function asRecord(value, context) {
2
- if (!value || typeof value !== 'object' || Array.isArray(value)) {
3
- throw new Error(`${context} must be an object`);
4
- }
5
- return value;
6
- }
7
- function parseEventInput(value, context) {
8
- if (typeof value === 'string') {
9
- return { event: value };
10
- }
11
- const map = asRecord(value, context);
12
- const eventName = map.event ?? map.name ?? map.eventName;
13
- if (typeof eventName !== 'string' || eventName.trim() === '') {
14
- throw new Error(`${context} must include an event name`);
15
- }
16
- const fieldValues = map.fieldValues ?? map.fields;
17
- if (fieldValues === undefined) {
18
- return { event: eventName };
19
- }
20
- if (!fieldValues || typeof fieldValues !== 'object' || Array.isArray(fieldValues)) {
21
- throw new Error(`${context}.fieldValues must be an object`);
22
- }
23
- return { event: eventName, fieldValues: fieldValues };
24
- }
25
- function parseEventInputs(value, context) {
26
- if (value === undefined || value === null)
27
- return undefined;
28
- if (!Array.isArray(value)) {
29
- throw new Error(`${context} must be an array`);
30
- }
31
- return value.map((entry, index) => parseEventInput(entry, `${context}[${index}]`));
32
- }
33
- function parseCommandName(value, context) {
34
- if (value === undefined || value === null)
35
- return undefined;
36
- if (typeof value === 'string')
37
- return value;
38
- const map = asRecord(value, context);
39
- const name = map.name ?? map.command;
40
- if (typeof name !== 'string' || name.trim() === '') {
41
- throw new Error(`${context} must include a command name`);
42
- }
43
- return name;
44
- }
45
- function parseObjectValue(value, context) {
46
- if (value === undefined || value === null)
47
- return undefined;
48
- if (typeof value !== 'object' || Array.isArray(value)) {
49
- throw new Error(`${context} must be an object`);
50
- }
51
- return value;
52
- }
53
- export function parseScenarioInput(input) {
54
- const raw = asRecord(JSON.parse(input.trim()), 'scenario');
55
- const name = raw.name;
56
- if (typeof name !== 'string' || name.trim() === '') {
57
- throw new Error('scenario.name is required');
58
- }
59
- const given = Array.isArray(raw.given)
60
- ? parseEventInputs(raw.given, 'scenario.given')
61
- : raw.given && typeof raw.given === 'object'
62
- ? parseEventInputs(raw.given.events, 'scenario.given.events')
63
- : undefined;
64
- const whenRaw = raw.when && typeof raw.when === 'object'
65
- ? raw.when
66
- : undefined;
67
- const whenCommand = parseCommandName(whenRaw?.command, 'scenario.when.command');
68
- const whenCommandFieldValues = parseObjectValue(whenRaw?.commandFieldValues ?? whenRaw?.command?.fieldValues, 'scenario.when.commandFieldValues');
69
- const whenEvents = parseEventInputs(whenRaw?.events, 'scenario.when.events');
70
- const thenRaw = asRecord(raw.then, 'scenario.then');
71
- const thenType = thenRaw.type;
72
- if (thenType !== 'error' &&
73
- thenType !== 'events' &&
74
- thenType !== 'readModelAssertion' &&
75
- thenType !== 'command' &&
76
- thenType !== 'noCommand') {
77
- throw new Error('scenario.then.type must be one of: error, events, readModelAssertion, command, noCommand');
78
- }
79
- const readModelAssertionRaw = thenRaw.readModelAssertion && typeof thenRaw.readModelAssertion === 'object'
80
- ? thenRaw.readModelAssertion
81
- : undefined;
82
- const then = {
83
- type: thenType,
84
- errorMessage: typeof thenRaw.errorMessage === 'string' ? thenRaw.errorMessage : undefined,
85
- errorType: typeof thenRaw.errorType === 'string' ? thenRaw.errorType : undefined,
86
- events: parseEventInputs(thenRaw.events, 'scenario.then.events'),
87
- command: parseCommandName(thenRaw.command, 'scenario.then.command'),
88
- commandFieldValues: parseObjectValue(thenRaw.commandFieldValues ?? thenRaw.command?.fieldValues, 'scenario.then.commandFieldValues'),
89
- readModel: (thenRaw.readModel
90
- ?? readModelAssertionRaw?.readModel
91
- ?? readModelAssertionRaw?.readModelName
92
- ?? readModelAssertionRaw?.readModelStickyId),
93
- givenEvents: parseEventInputs(thenRaw.givenEvents ?? readModelAssertionRaw?.givenEvents, 'scenario.then.givenEvents'),
94
- expected: parseObjectValue(thenRaw.expected ?? thenRaw.expectedFieldValues ?? readModelAssertionRaw?.expectedFieldValues, 'scenario.then.expected'),
95
- };
96
- return {
97
- name,
98
- description: typeof raw.description === 'string' ? raw.description : undefined,
99
- given,
100
- when: whenRaw ? { command: whenCommand, commandFieldValues: whenCommandFieldValues, events: whenEvents } : undefined,
101
- then,
102
- };
103
- }