@pgflow/dsl 0.0.5 → 0.0.6

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 (71) hide show
  1. package/package.json +4 -1
  2. package/CHANGELOG.md +0 -7
  3. package/__tests__/runtime/flow.test.ts +0 -121
  4. package/__tests__/runtime/steps.test.ts +0 -183
  5. package/__tests__/runtime/utils.test.ts +0 -149
  6. package/__tests__/types/dsl-types.test-d.ts +0 -103
  7. package/__tests__/types/example-flow.test-d.ts +0 -76
  8. package/__tests__/types/extract-flow-input.test-d.ts +0 -71
  9. package/__tests__/types/extract-flow-steps.test-d.ts +0 -74
  10. package/__tests__/types/getStepDefinition.test-d.ts +0 -65
  11. package/__tests__/types/step-input.test-d.ts +0 -212
  12. package/__tests__/types/step-output.test-d.ts +0 -55
  13. package/brainstorming/condition/condition-alternatives.md +0 -219
  14. package/brainstorming/condition/condition-with-flexibility.md +0 -303
  15. package/brainstorming/condition/condition.md +0 -139
  16. package/brainstorming/condition/implementation-plan.md +0 -372
  17. package/brainstorming/dsl/cli-json-schema.md +0 -225
  18. package/brainstorming/dsl/cli.md +0 -179
  19. package/brainstorming/dsl/create-compilator.md +0 -25
  20. package/brainstorming/dsl/dsl-analysis-2.md +0 -166
  21. package/brainstorming/dsl/dsl-analysis.md +0 -512
  22. package/brainstorming/dsl/dsl-critique.md +0 -41
  23. package/brainstorming/fanouts/fanout-subflows-flattened-vs-subruns.md +0 -213
  24. package/brainstorming/fanouts/fanouts-task-index.md +0 -150
  25. package/brainstorming/fanouts/fanouts-with-conditions-and-subflows.md +0 -239
  26. package/brainstorming/subflows/branching.ts.md +0 -38
  27. package/brainstorming/subflows/subflows-callbacks.ts.md +0 -124
  28. package/brainstorming/subflows/subflows-classes.ts.md +0 -83
  29. package/brainstorming/subflows/subflows-flattening-versioned.md +0 -119
  30. package/brainstorming/subflows/subflows-flattening.md +0 -138
  31. package/brainstorming/subflows/subflows.md +0 -118
  32. package/brainstorming/subflows/subruns-table.md +0 -282
  33. package/brainstorming/subflows/subruns.md +0 -315
  34. package/brainstorming/versioning/breaking-and-non-breaking-flow-changes.md +0 -259
  35. package/docs/refactor-edge-worker.md +0 -146
  36. package/docs/versioning.md +0 -19
  37. package/eslint.config.cjs +0 -22
  38. package/out-tsc/vitest/__tests__/runtime/flow.test.d.ts +0 -2
  39. package/out-tsc/vitest/__tests__/runtime/flow.test.d.ts.map +0 -1
  40. package/out-tsc/vitest/__tests__/runtime/steps.test.d.ts +0 -2
  41. package/out-tsc/vitest/__tests__/runtime/steps.test.d.ts.map +0 -1
  42. package/out-tsc/vitest/__tests__/runtime/utils.test.d.ts +0 -2
  43. package/out-tsc/vitest/__tests__/runtime/utils.test.d.ts.map +0 -1
  44. package/out-tsc/vitest/__tests__/types/dsl-types.test-d.d.ts +0 -2
  45. package/out-tsc/vitest/__tests__/types/dsl-types.test-d.d.ts.map +0 -1
  46. package/out-tsc/vitest/__tests__/types/example-flow.test-d.d.ts +0 -2
  47. package/out-tsc/vitest/__tests__/types/example-flow.test-d.d.ts.map +0 -1
  48. package/out-tsc/vitest/__tests__/types/extract-flow-input.test-d.d.ts +0 -2
  49. package/out-tsc/vitest/__tests__/types/extract-flow-input.test-d.d.ts.map +0 -1
  50. package/out-tsc/vitest/__tests__/types/extract-flow-steps.test-d.d.ts +0 -2
  51. package/out-tsc/vitest/__tests__/types/extract-flow-steps.test-d.d.ts.map +0 -1
  52. package/out-tsc/vitest/__tests__/types/getStepDefinition.test-d.d.ts +0 -2
  53. package/out-tsc/vitest/__tests__/types/getStepDefinition.test-d.d.ts.map +0 -1
  54. package/out-tsc/vitest/__tests__/types/step-input.test-d.d.ts +0 -2
  55. package/out-tsc/vitest/__tests__/types/step-input.test-d.d.ts.map +0 -1
  56. package/out-tsc/vitest/__tests__/types/step-output.test-d.d.ts +0 -2
  57. package/out-tsc/vitest/__tests__/types/step-output.test-d.d.ts.map +0 -1
  58. package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +0 -1
  59. package/out-tsc/vitest/vite.config.d.ts +0 -3
  60. package/out-tsc/vitest/vite.config.d.ts.map +0 -1
  61. package/project.json +0 -28
  62. package/prompts/edge-worker-refactor.md +0 -105
  63. package/src/dsl.ts +0 -318
  64. package/src/example-flow.ts +0 -67
  65. package/src/index.ts +0 -1
  66. package/src/utils.ts +0 -84
  67. package/tsconfig.json +0 -13
  68. package/tsconfig.lib.json +0 -26
  69. package/tsconfig.spec.json +0 -35
  70. package/typecheck.log +0 -120
  71. package/vite.config.ts +0 -57
@@ -1,67 +0,0 @@
1
- import { Flow } from './dsl.ts';
2
-
3
- // Provide a type for the input of the Flow
4
- type Input = {
5
- url: string;
6
- };
7
-
8
- export const AnalyzeWebsite = new Flow<Input>({
9
- slug: 'analyze_website',
10
- maxAttempts: 3,
11
- baseDelay: 5,
12
- timeout: 10,
13
- })
14
- .step(
15
- { slug: 'website' },
16
- async (input) => await scrapeWebsite(input.run.url)
17
- )
18
- .step(
19
- { slug: 'sentiment', dependsOn: ['website'], timeout: 30, maxAttempts: 5 },
20
- async (input) => await analyzeSentiment(input.website.content)
21
- )
22
- .step(
23
- { slug: 'summary', dependsOn: ['website'] },
24
- async (input) => await summarizeWithAI(input.website.content)
25
- )
26
- .step(
27
- { slug: 'saveToDb', dependsOn: ['sentiment', 'summary'] },
28
- async (input) => {
29
- const results = await saveToDb({
30
- websiteUrl: input.run.url,
31
- sentiment: input.sentiment.score,
32
- summary: input.summary.aiSummary,
33
- });
34
- return results.status;
35
- }
36
- );
37
-
38
- /***********************************************************************
39
- ****** functions *******************************************************
40
- ***********************************************************************/
41
-
42
- async function scrapeWebsite(url: string) {
43
- return {
44
- content: `Lorem ipsum ${url.length}`,
45
- };
46
- }
47
-
48
- const analyzeSentiment = async (_content: string) => {
49
- return {
50
- score: Math.random(),
51
- };
52
- };
53
- const summarizeWithAI = async (content: string) => {
54
- return {
55
- aiSummary: `Lorem ipsum ${content.length}`,
56
- };
57
- };
58
-
59
- const saveToDb = async (_input: {
60
- websiteUrl: string;
61
- sentiment: number;
62
- summary: string;
63
- }) => {
64
- return {
65
- status: 'success',
66
- };
67
- };
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dsl.ts';
package/src/utils.ts DELETED
@@ -1,84 +0,0 @@
1
- /**
2
- * Validates a slug string according to the following rules:
3
- * - Cannot start with a number
4
- * - Cannot start with an underscore
5
- * - Cannot contain spaces
6
- * - Cannot contain special characters like /, :, ?, #
7
- * - Cannot be longer than 128 characters
8
- *
9
- * @param slug The slug string to validate
10
- * @throws Error if the slug is invalid
11
- */
12
- export function validateSlug(slug: string): void {
13
- if (slug.length > 128) {
14
- throw new Error(`Slug cannot be longer than 128 characters`);
15
- }
16
-
17
- if (/^\d/.test(slug)) {
18
- throw new Error(`Slug cannot start with a number`);
19
- }
20
-
21
- if (/^_/.test(slug)) {
22
- throw new Error(`Slug cannot start with an underscore`);
23
- }
24
-
25
- if (/\s/.test(slug)) {
26
- throw new Error(`Slug cannot contain spaces`);
27
- }
28
-
29
- if (/[/:#\-?]/.test(slug)) {
30
- throw new Error(
31
- `Slug cannot contain special characters like /, :, ?, #, -`
32
- );
33
- }
34
- }
35
-
36
- /**
37
- * Options for validating runtime options
38
- */
39
- export interface ValidateRuntimeOptionsOpts {
40
- optional?: boolean;
41
- }
42
-
43
- /**
44
- * Validates runtime options according to the following rules:
45
- * - maxAttempts should be >= 1
46
- * - baseDelay should be >= 1
47
- * - timeout should be >= 3
48
- *
49
- * @param options The runtime options to validate
50
- * @param opts Configuration options for validation
51
- * @param opts.optional If true, allows options to be null or undefined
52
- * @throws Error if any runtime option is invalid
53
- */
54
- export function validateRuntimeOptions(
55
- options: { maxAttempts?: number; baseDelay?: number; timeout?: number },
56
- opts: ValidateRuntimeOptionsOpts = { optional: false }
57
- ): void {
58
- const { maxAttempts, baseDelay, timeout } = options;
59
-
60
- // If optional is true, skip validation for undefined/null values
61
- if (maxAttempts !== undefined && maxAttempts !== null) {
62
- if (maxAttempts < 1) {
63
- throw new Error('maxAttempts must be greater than or equal to 1');
64
- }
65
- } else if (!opts.optional) {
66
- throw new Error('maxAttempts is required');
67
- }
68
-
69
- if (baseDelay !== undefined && baseDelay !== null) {
70
- if (baseDelay < 1) {
71
- throw new Error('baseDelay must be greater than or equal to 1');
72
- }
73
- } else if (!opts.optional) {
74
- throw new Error('baseDelay is required');
75
- }
76
-
77
- if (timeout !== undefined && timeout !== null) {
78
- if (timeout < 3) {
79
- throw new Error('timeout must be greater than or equal to 3');
80
- }
81
- } else if (!opts.optional) {
82
- throw new Error('timeout is required');
83
- }
84
- }
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "files": [],
4
- "include": [],
5
- "references": [
6
- {
7
- "path": "./tsconfig.lib.json"
8
- },
9
- {
10
- "path": "./tsconfig.spec.json"
11
- }
12
- ]
13
- }
package/tsconfig.lib.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
6
- "emitDeclarationOnly": false,
7
- "types": ["node", "vite/client"],
8
- "allowImportingTsExtensions": true
9
- },
10
- "include": ["src/**/*.ts"],
11
- "references": [],
12
- "exclude": [
13
- "vite.config.ts",
14
- "vite.config.mts",
15
- "vitest.config.ts",
16
- "vitest.config.mts",
17
- "src/**/*.test.ts",
18
- "src/**/*.spec.ts",
19
- "src/**/*.test.tsx",
20
- "src/**/*.spec.tsx",
21
- "src/**/*.test.js",
22
- "src/**/*.spec.js",
23
- "src/**/*.test.jsx",
24
- "src/**/*.spec.jsx"
25
- ]
26
- }
@@ -1,35 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "./out-tsc/vitest",
5
- "types": [
6
- "vitest/globals",
7
- "vitest/importMeta",
8
- "vite/client",
9
- "node",
10
- "vitest"
11
- ],
12
- "allowImportingTsExtensions": true
13
- },
14
- "include": [
15
- "vite.config.ts",
16
- "vite.config.mts",
17
- "vitest.config.ts",
18
- "vitest.config.mts",
19
- "src/**/*.test.ts",
20
- "src/**/*.spec.ts",
21
- "src/**/*.test.tsx",
22
- "src/**/*.spec.tsx",
23
- "src/**/*.test.js",
24
- "src/**/*.spec.js",
25
- "src/**/*.test.jsx",
26
- "src/**/*.spec.jsx",
27
- "src/**/*.d.ts",
28
- "__tests__/**/*.ts"
29
- ],
30
- "references": [
31
- {
32
- "path": "./tsconfig.lib.json"
33
- }
34
- ]
35
- }
package/typecheck.log DELETED
@@ -1,120 +0,0 @@
1
-
2
- > nx run dsl:typecheck
3
-
4
- > tsc --build --emitDeclarationOnly --pretty --verbose
5
-
6
- [9:57:14 PM] Projects in this build:
7
- * tsconfig.lib.json
8
- * tsconfig.spec.json
9
- * tsconfig.json
10
-
11
- [9:57:14 PM] Project 'tsconfig.lib.json' is up to date because newest input 'src/dsl.ts' is older than output 'dist/tsconfig.lib.tsbuildinfo'
12
-
13
- [9:57:14 PM] Project 'tsconfig.spec.json' is out of date because buildinfo file 'out-tsc/vitest/tsconfig.spec.tsbuildinfo' indicates that program needs to report errors.
14
-
15
- [9:57:14 PM] Building project '/home/jumski/Code/pgflow-dev/pgflow/pkgs/dsl/tsconfig.spec.json'...
16
-
17
- __tests__/types/dsl-types.test-d.ts:112:37 - error TS2344: Type 'Flow<{ input: string; }, EmptySteps & { step1: { value: number; text: string; }; } & { step2: { flag: true; }; } & { step3: "plain string"; }, EmptyDeps & { step1: never[]; } & { ...; } & { ...; }>' does not satisfy the constraint 'AnyFlow'.
18
- The types returned by 'getStepDefinition(...)' are incompatible between these types.
19
- Type 'StepDefinition<{ [x: string]: any; run: { input: string; }; }, any>' is not assignable to type 'StepDefinition<{ [x: string]: Json; run: Json; }, Json>'.
20
- Type '{ [x: string]: Json; run: Json; }' is not assignable to type '{ [x: string]: any; run: { input: string; }; }'.
21
- Types of property 'run' are incompatible.
22
- Type 'Json' is not assignable to type '{ input: string; }'.
23
- Type 'null' is not assignable to type '{ input: string; }'.
24
-
25
- 112 type Step1Output = StepOutput<typeof flow, 'step1'>;
26
-    ~~~~~~~~~~~
27
-
28
- __tests__/types/dsl-types.test-d.ts:113:49 - error TS2344: Type '{ value: number; text: string; }' does not satisfy the constraint '"Expected: ..., Actual: never"'.
29
-
30
- 113 expectTypeOf<Step1Output>().toMatchTypeOf<{
31
-    ~
32
- 114 value: number;
33
-   ~~~~~~~~~~~~~~~~~~~~~~
34
- 115 text: string;
35
-   ~~~~~~~~~~~~~~~~~~~~~
36
- 116 }>();
37
-   ~~~~~~~
38
-
39
- __tests__/types/dsl-types.test-d.ts:118:37 - error TS2344: Type 'Flow<{ input: string; }, EmptySteps & { step1: { value: number; text: string; }; } & { step2: { flag: true; }; } & { step3: "plain string"; }, EmptyDeps & { step1: never[]; } & { ...; } & { ...; }>' does not satisfy the constraint 'AnyFlow'.
40
- The types returned by 'getStepDefinition(...)' are incompatible between these types.
41
- Type 'StepDefinition<{ [x: string]: any; run: { input: string; }; }, any>' is not assignable to type 'StepDefinition<{ [x: string]: Json; run: Json; }, Json>'.
42
- Type '{ [x: string]: Json; run: Json; }' is not assignable to type '{ [x: string]: any; run: { input: string; }; }'.
43
- Types of property 'run' are incompatible.
44
- Type 'Json' is not assignable to type '{ input: string; }'.
45
- Type 'null' is not assignable to type '{ input: string; }'.
46
-
47
- 118 type Step2Output = StepOutput<typeof flow, 'step2'>;
48
-    ~~~~~~~~~~~
49
-
50
- __tests__/types/dsl-types.test-d.ts:119:49 - error TS2344: Type '{ flag: boolean; }' does not satisfy the constraint '"Expected: ..., Actual: never"'.
51
-
52
- 119 expectTypeOf<Step2Output>().toMatchTypeOf<{ flag: boolean }>();
53
-    ~~~~~~~~~~~~~~~~~
54
-
55
- __tests__/types/dsl-types.test-d.ts:121:37 - error TS2344: Type 'Flow<{ input: string; }, EmptySteps & { step1: { value: number; text: string; }; } & { step2: { flag: true; }; } & { step3: "plain string"; }, EmptyDeps & { step1: never[]; } & { ...; } & { ...; }>' does not satisfy the constraint 'AnyFlow'.
56
- The types returned by 'getStepDefinition(...)' are incompatible between these types.
57
- Type 'StepDefinition<{ [x: string]: any; run: { input: string; }; }, any>' is not assignable to type 'StepDefinition<{ [x: string]: Json; run: Json; }, Json>'.
58
- Type '{ [x: string]: Json; run: Json; }' is not assignable to type '{ [x: string]: any; run: { input: string; }; }'.
59
- Types of property 'run' are incompatible.
60
- Type 'Json' is not assignable to type '{ input: string; }'.
61
- Type 'null' is not assignable to type '{ input: string; }'.
62
-
63
- 121 type Step3Output = StepOutput<typeof flow, 'step3'>;
64
-    ~~~~~~~~~~~
65
-
66
- __tests__/types/dsl-types.test-d.ts:122:49 - error TS2344: Type 'string' does not satisfy the constraint '"Expected: string, Actual: never"'.
67
-
68
- 122 expectTypeOf<Step3Output>().toMatchTypeOf<string>();
69
-    ~~~~~~
70
-
71
- __tests__/types/dsl-types.test-d.ts:124:43 - error TS2344: Type 'Flow<{ input: string; }, EmptySteps & { step1: { value: number; text: string; }; } & { step2: { flag: true; }; } & { step3: "plain string"; }, EmptyDeps & { step1: never[]; } & { ...; } & { ...; }>' does not satisfy the constraint 'AnyFlow'.
72
- The types returned by 'getStepDefinition(...)' are incompatible between these types.
73
- Type 'StepDefinition<{ [x: string]: any; run: { input: string; }; }, any>' is not assignable to type 'StepDefinition<{ [x: string]: Json; run: Json; }, Json>'.
74
- Type '{ [x: string]: Json; run: Json; }' is not assignable to type '{ [x: string]: any; run: { input: string; }; }'.
75
- Types of property 'run' are incompatible.
76
- Type 'Json' is not assignable to type '{ input: string; }'.
77
- Type 'null' is not assignable to type '{ input: string; }'.
78
-
79
- 124 type NonExistentOutput = StepOutput<typeof flow, 'nonExistentStep'>;
80
-    ~~~~~~~~~~~
81
-
82
- __tests__/types/dsl-types.test-d.ts:144:43 - error TS2344: Type 'Flow<{ id: number; }, EmptySteps & { complexStep: { data: { items: { id: number; name: string; }[]; metadata: { count: number; lastUpdated: string; }; }; }; }, EmptyDeps & { complexStep: never[]; }>' does not satisfy the constraint 'AnyFlow'.
83
- The types returned by 'getStepDefinition(...)' are incompatible between these types.
84
- Type 'StepDefinition<{ [x: string]: any; run: { id: number; }; }, any>' is not assignable to type 'StepDefinition<{ [x: string]: Json; run: Json; }, Json>'.
85
- Type '{ [x: string]: Json; run: Json; }' is not assignable to type '{ [x: string]: any; run: { id: number; }; }'.
86
- Types of property 'run' are incompatible.
87
- Type 'Json' is not assignable to type '{ id: number; }'.
88
- Type 'null' is not assignable to type '{ id: number; }'.
89
-
90
- 144 type ComplexStepOutput = StepOutput<typeof complexFlow, 'complexStep'>;
91
-    ~~~~~~~~~~~~~~~~~~
92
-
93
- __tests__/types/dsl-types.test-d.ts:145:55 - error TS2344: Type '{ data: { items: { id: number; name: string; }[]; metadata: { count: number; lastUpdated: string; }; }; }' does not satisfy the constraint '"Expected: ..., Actual: never"'.
94
-
95
- 145 expectTypeOf<ComplexStepOutput>().toMatchTypeOf<{
96
-    ~
97
- 146 data: {
98
-   ~~~~~~~~~~~~~~~
99
- ...
100
- 152 };
101
-   ~~~~~~~~~~
102
- 153 }>();
103
-   ~~~~~~~
104
-
105
-
106
- Found 9 errors.
107
-
108
-
109
-
110
-
111
- NX Running target typecheck for project dsl failed
112
-
113
- Failed tasks:
114
-
115
- - dsl:typecheck
116
-
117
- Hint: run the command with --verbose for more details.
118
-
119
- View structured, searchable error logs at https://nx.app/runs/7SrNf6iuVJ
120
-
package/vite.config.ts DELETED
@@ -1,57 +0,0 @@
1
- /// <reference types='vitest' />
2
- import { defineConfig } from 'vite';
3
- import dts from 'vite-plugin-dts';
4
- import * as path from 'path';
5
- import tsconfigPaths from 'vite-tsconfig-paths';
6
-
7
- export default defineConfig({
8
- root: __dirname,
9
- cacheDir: '../../node_modules/.vite/pkgs/dsl',
10
- plugins: [
11
- tsconfigPaths(),
12
- dts({
13
- entryRoot: 'src',
14
- tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
15
- }),
16
- ],
17
- // Uncomment this if you are using workers.
18
- // worker: {
19
- // plugins: [ nxViteTsPaths() ],
20
- // },
21
- // Configuration for building your library.
22
- // See: https://vitejs.dev/guide/build.html#library-mode
23
- build: {
24
- outDir: './dist',
25
- emptyOutDir: true,
26
- reportCompressedSize: true,
27
- commonjsOptions: {
28
- transformMixedEsModules: true,
29
- },
30
- lib: {
31
- // Could also be a dictionary or array of multiple entry points.
32
- entry: 'src/index.ts',
33
- name: '@pgflow/dsl',
34
- fileName: 'index',
35
- // Change this to the formats you want to support.
36
- // Don't forget to update your package.json as well.
37
- formats: ['es'],
38
- },
39
- rollupOptions: {
40
- // External packages that should not be bundled into your library.
41
- external: [],
42
- },
43
- },
44
- test: {
45
- watch: false,
46
- globals: true,
47
- environment: 'node',
48
- include: [
49
- '{src,__tests__}/**/*.{test,spec,test-d,spec-d}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
50
- ],
51
- reporters: ['default'],
52
- coverage: {
53
- reportsDirectory: './test-output/vitest/coverage',
54
- provider: 'v8',
55
- },
56
- },
57
- });