@pgflow/core 0.0.5 → 0.0.7

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 (110) hide show
  1. package/{CHANGELOG.md → dist/CHANGELOG.md} +6 -0
  2. package/package.json +8 -5
  3. package/__tests__/mocks/index.ts +0 -1
  4. package/__tests__/mocks/postgres.ts +0 -37
  5. package/__tests__/types/PgflowSqlClient.test-d.ts +0 -59
  6. package/docs/options_for_flow_and_steps.md +0 -75
  7. package/docs/pgflow-blob-reference-system.md +0 -179
  8. package/eslint.config.cjs +0 -22
  9. package/example-flow.mermaid +0 -5
  10. package/example-flow.svg +0 -1
  11. package/flow-lifecycle.mermaid +0 -83
  12. package/flow-lifecycle.svg +0 -1
  13. package/out-tsc/vitest/__tests__/mocks/index.d.ts +0 -2
  14. package/out-tsc/vitest/__tests__/mocks/index.d.ts.map +0 -1
  15. package/out-tsc/vitest/__tests__/mocks/postgres.d.ts +0 -15
  16. package/out-tsc/vitest/__tests__/mocks/postgres.d.ts.map +0 -1
  17. package/out-tsc/vitest/__tests__/types/PgflowSqlClient.test-d.d.ts +0 -2
  18. package/out-tsc/vitest/__tests__/types/PgflowSqlClient.test-d.d.ts.map +0 -1
  19. package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +0 -1
  20. package/out-tsc/vitest/vite.config.d.ts +0 -3
  21. package/out-tsc/vitest/vite.config.d.ts.map +0 -1
  22. package/pkgs/core/dist/index.js +0 -54
  23. package/pkgs/core/dist/pkgs/core/LICENSE.md +0 -660
  24. package/pkgs/core/dist/pkgs/core/README.md +0 -373
  25. package/pkgs/dsl/dist/index.js +0 -123
  26. package/pkgs/dsl/dist/pkgs/dsl/README.md +0 -11
  27. package/pkgs/edge-worker/dist/index.js +0 -953
  28. package/pkgs/edge-worker/dist/index.js.map +0 -7
  29. package/pkgs/edge-worker/dist/pkgs/edge-worker/LICENSE.md +0 -660
  30. package/pkgs/edge-worker/dist/pkgs/edge-worker/README.md +0 -46
  31. package/pkgs/example-flows/dist/index.js +0 -152
  32. package/pkgs/example-flows/dist/pkgs/example-flows/README.md +0 -11
  33. package/project.json +0 -125
  34. package/prompts/architect.md +0 -87
  35. package/prompts/condition.md +0 -33
  36. package/prompts/declarative_sql.md +0 -15
  37. package/prompts/deps_in_payloads.md +0 -20
  38. package/prompts/dsl-multi-arg.ts +0 -48
  39. package/prompts/dsl-options.md +0 -39
  40. package/prompts/dsl-single-arg.ts +0 -51
  41. package/prompts/dsl-two-arg.ts +0 -61
  42. package/prompts/dsl.md +0 -119
  43. package/prompts/fanout_steps.md +0 -1
  44. package/prompts/json_schemas.md +0 -36
  45. package/prompts/one_shot.md +0 -286
  46. package/prompts/pgtap.md +0 -229
  47. package/prompts/sdk.md +0 -59
  48. package/prompts/step_types.md +0 -62
  49. package/prompts/versioning.md +0 -16
  50. package/queries/fail_permanently.sql +0 -17
  51. package/queries/fail_task.sql +0 -21
  52. package/queries/sequential.sql +0 -47
  53. package/queries/two_roots_left_right.sql +0 -59
  54. package/schema.svg +0 -1
  55. package/scripts/colorize-pgtap-output.awk +0 -72
  56. package/scripts/run-test-with-colors +0 -5
  57. package/scripts/watch-test +0 -7
  58. package/src/PgflowSqlClient.ts +0 -85
  59. package/src/database-types.ts +0 -759
  60. package/src/index.ts +0 -3
  61. package/src/types.ts +0 -103
  62. package/supabase/config.toml +0 -32
  63. package/supabase/seed.sql +0 -202
  64. package/supabase/tests/add_step/basic_step_addition.test.sql +0 -29
  65. package/supabase/tests/add_step/circular_dependency.test.sql +0 -21
  66. package/supabase/tests/add_step/flow_isolation.test.sql +0 -26
  67. package/supabase/tests/add_step/idempotent_step_addition.test.sql +0 -20
  68. package/supabase/tests/add_step/invalid_step_slug.test.sql +0 -16
  69. package/supabase/tests/add_step/nonexistent_dependency.test.sql +0 -16
  70. package/supabase/tests/add_step/nonexistent_flow.test.sql +0 -13
  71. package/supabase/tests/add_step/options.test.sql +0 -66
  72. package/supabase/tests/add_step/step_with_dependency.test.sql +0 -36
  73. package/supabase/tests/add_step/step_with_multiple_dependencies.test.sql +0 -46
  74. package/supabase/tests/complete_task/archives_message.test.sql +0 -67
  75. package/supabase/tests/complete_task/completes_run_if_no_more_remaining_steps.test.sql +0 -62
  76. package/supabase/tests/complete_task/completes_task_and_updates_dependents.test.sql +0 -64
  77. package/supabase/tests/complete_task/decrements_remaining_steps_if_completing_step.test.sql +0 -62
  78. package/supabase/tests/complete_task/saves_output_when_completing_run.test.sql +0 -57
  79. package/supabase/tests/create_flow/flow_creation.test.sql +0 -27
  80. package/supabase/tests/create_flow/idempotency_and_duplicates.test.sql +0 -26
  81. package/supabase/tests/create_flow/invalid_slug.test.sql +0 -13
  82. package/supabase/tests/create_flow/options.test.sql +0 -57
  83. package/supabase/tests/fail_task/exponential_backoff.test.sql +0 -70
  84. package/supabase/tests/fail_task/mark_as_failed_if_no_retries_available.test.sql +0 -49
  85. package/supabase/tests/fail_task/respects_flow_retry_settings.test.sql +0 -48
  86. package/supabase/tests/fail_task/respects_step_retry_settings.test.sql +0 -48
  87. package/supabase/tests/fail_task/retry_task_if_retries_available.test.sql +0 -39
  88. package/supabase/tests/is_valid_slug.test.sql +0 -72
  89. package/supabase/tests/poll_for_tasks/builds_proper_input_from_deps_outputs.test.sql +0 -35
  90. package/supabase/tests/poll_for_tasks/hides_messages.test.sql +0 -35
  91. package/supabase/tests/poll_for_tasks/increments_attempts_count.test.sql +0 -35
  92. package/supabase/tests/poll_for_tasks/multiple_task_processing.test.sql +0 -24
  93. package/supabase/tests/poll_for_tasks/polls_only_queued_tasks.test.sql +0 -35
  94. package/supabase/tests/poll_for_tasks/reads_messages.test.sql +0 -38
  95. package/supabase/tests/poll_for_tasks/returns_no_tasks_if_no_step_task_for_message.test.sql +0 -34
  96. package/supabase/tests/poll_for_tasks/returns_no_tasks_if_queue_is_empty.test.sql +0 -19
  97. package/supabase/tests/poll_for_tasks/returns_no_tasks_when_qty_set_to_0.test.sql +0 -22
  98. package/supabase/tests/poll_for_tasks/sets_vt_delay_based_on_opt_timeout.test.sql +0 -41
  99. package/supabase/tests/poll_for_tasks/tasks_reapppear_if_not_processed_in_time.test.sql +0 -59
  100. package/supabase/tests/start_flow/creates_run.test.sql +0 -24
  101. package/supabase/tests/start_flow/creates_step_states_for_all_steps.test.sql +0 -25
  102. package/supabase/tests/start_flow/creates_step_tasks_only_for_root_steps.test.sql +0 -54
  103. package/supabase/tests/start_flow/returns_run.test.sql +0 -24
  104. package/supabase/tests/start_flow/sends_messages_on_the_queue.test.sql +0 -50
  105. package/supabase/tests/start_flow/starts_only_root_steps.test.sql +0 -21
  106. package/supabase/tests/step_dsl_is_idempotent.test.sql +0 -34
  107. package/tsconfig.json +0 -16
  108. package/tsconfig.lib.json +0 -26
  109. package/tsconfig.spec.json +0 -35
  110. package/vite.config.ts +0 -57
@@ -1,72 +0,0 @@
1
- BEGIN {
2
- # ANSI color codes
3
- RED="\033[31m";
4
- GREEN="\033[32m";
5
- YELLOW="\033[33m";
6
- GRAY="\033[90m";
7
- BOLD="\033[1m";
8
- RESET="\033[0m";
9
- }
10
-
11
- /Dubious|Failed|error|exit 1|Result: FAIL/ {
12
- print RED $0 RESET;
13
- next;
14
- }
15
-
16
- # Match any line containing ERROR: (PostgreSQL error messages)
17
- /ERROR:/ {
18
- print RED $0 RESET;
19
- next;
20
- }
21
-
22
- # Match DETAIL: and CONTEXT: lines that are part of PostgreSQL error messages
23
- /DETAIL:|CONTEXT:/ {
24
- print RED $0 RESET;
25
- next;
26
- }
27
-
28
- /ok$/ {
29
- print GREEN $0 RESET;
30
- next;
31
- }
32
-
33
- /\.\.\.+/ {
34
- test = $1;
35
- result = $NF;
36
- if (result == "ok") {
37
- printf "%s %s %s\n", test, GRAY RESET, GREEN result RESET;
38
- } else {
39
- printf "%s %s %s\n", RED test RESET, GRAY RESET, RED result RESET;
40
- }
41
- next;
42
- }
43
-
44
- /Test Summary Report|-------------------/ {
45
- print YELLOW BOLD $0 RESET;
46
- next;
47
- }
48
-
49
- /\(Wstat:.*/ {
50
- sub(/^[[:space:]]+/, "");
51
- filename = $1;
52
- print YELLOW " " RED filename RESET YELLOW $2 $3 $4 $5 $6 RESET;
53
- next;
54
- }
55
-
56
- /^Files=|^Result:/ {
57
- if ($0 ~ /FAIL/) {
58
- print RED BOLD $0 RESET;
59
- } else {
60
- print YELLOW $0 RESET;
61
- }
62
- next;
63
- }
64
-
65
- /Try rerunning/ {
66
- print YELLOW $0 RESET;
67
- next;
68
- }
69
-
70
- {
71
- print;
72
- }
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Run the Supabase tests and colorize the output
4
- pnpm supabase db test "$@" 2>&1 | awk -f ./scripts/colorize-pgtap-output.awk
5
- exit ${PIPESTATUS[0]}
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Get all arguments passed to this script
4
- args="$@"
5
-
6
- # Watch for changes in SQL files and run the test with the provided arguments
7
- find -iname '*.sql' | entr -r -c sh -c "scripts/run-test-with-colors $args"
@@ -1,85 +0,0 @@
1
- import type postgres from 'postgres';
2
- import type {
3
- StepTaskRecord,
4
- IPgflowClient,
5
- StepTaskKey,
6
- RunRow,
7
- } from './types.ts';
8
- import type { Json } from './types.ts';
9
- import type { AnyFlow, ExtractFlowInput } from '@pgflow/dsl';
10
-
11
- /**
12
- * Implementation of IPgflowClient that uses direct SQL calls to pgflow functions
13
- */
14
- export class PgflowSqlClient<TFlow extends AnyFlow>
15
- implements IPgflowClient<TFlow>
16
- {
17
- constructor(private readonly sql: postgres.Sql) {}
18
-
19
- async pollForTasks(
20
- queueName: string,
21
- batchSize = 20,
22
- visibilityTimeout = 2,
23
- maxPollSeconds = 5,
24
- pollIntervalMs = 200
25
- ): Promise<StepTaskRecord<TFlow>[]> {
26
- return await this.sql<StepTaskRecord<TFlow>[]>`
27
- SELECT *
28
- FROM pgflow.poll_for_tasks(
29
- queue_name => ${queueName},
30
- vt => ${visibilityTimeout},
31
- qty => ${batchSize},
32
- max_poll_seconds => ${maxPollSeconds},
33
- poll_interval_ms => ${pollIntervalMs}
34
- );
35
- `;
36
- }
37
-
38
- async completeTask(stepTask: StepTaskKey, output?: Json): Promise<void> {
39
- await this.sql`
40
- SELECT pgflow.complete_task(
41
- run_id => ${stepTask.run_id}::uuid,
42
- step_slug => ${stepTask.step_slug}::text,
43
- task_index => ${0}::int,
44
- output => ${this.sql.json(output || null)}::jsonb
45
- );
46
- `;
47
- }
48
-
49
- async failTask(stepTask: StepTaskKey, error: unknown): Promise<void> {
50
- const errorString =
51
- typeof error === 'string'
52
- ? error
53
- : error instanceof Error
54
- ? error.message
55
- : JSON.stringify(error);
56
-
57
- await this.sql`
58
- SELECT pgflow.fail_task(
59
- run_id => ${stepTask.run_id}::uuid,
60
- step_slug => ${stepTask.step_slug}::text,
61
- task_index => ${0}::int,
62
- error_message => ${errorString}::text
63
- );
64
- `;
65
- }
66
-
67
- async startFlow<TFlow extends AnyFlow>(
68
- flow: TFlow,
69
- input: ExtractFlowInput<TFlow>
70
- ): Promise<RunRow> {
71
- const results = await this.sql<RunRow[]>`
72
- SELECT * FROM pgflow.start_flow(${flow.slug}::text, ${this.sql.json(
73
- input
74
- )}::jsonb);
75
- `;
76
-
77
- if (results.length === 0) {
78
- throw new Error(`Failed to start flow ${flow.slug}`);
79
- }
80
-
81
- const [flowRun] = results;
82
-
83
- return flowRun;
84
- }
85
- }