@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.
- package/{CHANGELOG.md → dist/CHANGELOG.md} +6 -0
- package/package.json +8 -5
- package/__tests__/mocks/index.ts +0 -1
- package/__tests__/mocks/postgres.ts +0 -37
- package/__tests__/types/PgflowSqlClient.test-d.ts +0 -59
- package/docs/options_for_flow_and_steps.md +0 -75
- package/docs/pgflow-blob-reference-system.md +0 -179
- package/eslint.config.cjs +0 -22
- package/example-flow.mermaid +0 -5
- package/example-flow.svg +0 -1
- package/flow-lifecycle.mermaid +0 -83
- package/flow-lifecycle.svg +0 -1
- package/out-tsc/vitest/__tests__/mocks/index.d.ts +0 -2
- package/out-tsc/vitest/__tests__/mocks/index.d.ts.map +0 -1
- package/out-tsc/vitest/__tests__/mocks/postgres.d.ts +0 -15
- package/out-tsc/vitest/__tests__/mocks/postgres.d.ts.map +0 -1
- package/out-tsc/vitest/__tests__/types/PgflowSqlClient.test-d.d.ts +0 -2
- package/out-tsc/vitest/__tests__/types/PgflowSqlClient.test-d.d.ts.map +0 -1
- package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +0 -1
- package/out-tsc/vitest/vite.config.d.ts +0 -3
- package/out-tsc/vitest/vite.config.d.ts.map +0 -1
- package/pkgs/core/dist/index.js +0 -54
- package/pkgs/core/dist/pkgs/core/LICENSE.md +0 -660
- package/pkgs/core/dist/pkgs/core/README.md +0 -373
- package/pkgs/dsl/dist/index.js +0 -123
- package/pkgs/dsl/dist/pkgs/dsl/README.md +0 -11
- package/pkgs/edge-worker/dist/index.js +0 -953
- package/pkgs/edge-worker/dist/index.js.map +0 -7
- package/pkgs/edge-worker/dist/pkgs/edge-worker/LICENSE.md +0 -660
- package/pkgs/edge-worker/dist/pkgs/edge-worker/README.md +0 -46
- package/pkgs/example-flows/dist/index.js +0 -152
- package/pkgs/example-flows/dist/pkgs/example-flows/README.md +0 -11
- package/project.json +0 -125
- package/prompts/architect.md +0 -87
- package/prompts/condition.md +0 -33
- package/prompts/declarative_sql.md +0 -15
- package/prompts/deps_in_payloads.md +0 -20
- package/prompts/dsl-multi-arg.ts +0 -48
- package/prompts/dsl-options.md +0 -39
- package/prompts/dsl-single-arg.ts +0 -51
- package/prompts/dsl-two-arg.ts +0 -61
- package/prompts/dsl.md +0 -119
- package/prompts/fanout_steps.md +0 -1
- package/prompts/json_schemas.md +0 -36
- package/prompts/one_shot.md +0 -286
- package/prompts/pgtap.md +0 -229
- package/prompts/sdk.md +0 -59
- package/prompts/step_types.md +0 -62
- package/prompts/versioning.md +0 -16
- package/queries/fail_permanently.sql +0 -17
- package/queries/fail_task.sql +0 -21
- package/queries/sequential.sql +0 -47
- package/queries/two_roots_left_right.sql +0 -59
- package/schema.svg +0 -1
- package/scripts/colorize-pgtap-output.awk +0 -72
- package/scripts/run-test-with-colors +0 -5
- package/scripts/watch-test +0 -7
- package/src/PgflowSqlClient.ts +0 -85
- package/src/database-types.ts +0 -759
- package/src/index.ts +0 -3
- package/src/types.ts +0 -103
- package/supabase/config.toml +0 -32
- package/supabase/seed.sql +0 -202
- package/supabase/tests/add_step/basic_step_addition.test.sql +0 -29
- package/supabase/tests/add_step/circular_dependency.test.sql +0 -21
- package/supabase/tests/add_step/flow_isolation.test.sql +0 -26
- package/supabase/tests/add_step/idempotent_step_addition.test.sql +0 -20
- package/supabase/tests/add_step/invalid_step_slug.test.sql +0 -16
- package/supabase/tests/add_step/nonexistent_dependency.test.sql +0 -16
- package/supabase/tests/add_step/nonexistent_flow.test.sql +0 -13
- package/supabase/tests/add_step/options.test.sql +0 -66
- package/supabase/tests/add_step/step_with_dependency.test.sql +0 -36
- package/supabase/tests/add_step/step_with_multiple_dependencies.test.sql +0 -46
- package/supabase/tests/complete_task/archives_message.test.sql +0 -67
- package/supabase/tests/complete_task/completes_run_if_no_more_remaining_steps.test.sql +0 -62
- package/supabase/tests/complete_task/completes_task_and_updates_dependents.test.sql +0 -64
- package/supabase/tests/complete_task/decrements_remaining_steps_if_completing_step.test.sql +0 -62
- package/supabase/tests/complete_task/saves_output_when_completing_run.test.sql +0 -57
- package/supabase/tests/create_flow/flow_creation.test.sql +0 -27
- package/supabase/tests/create_flow/idempotency_and_duplicates.test.sql +0 -26
- package/supabase/tests/create_flow/invalid_slug.test.sql +0 -13
- package/supabase/tests/create_flow/options.test.sql +0 -57
- package/supabase/tests/fail_task/exponential_backoff.test.sql +0 -70
- package/supabase/tests/fail_task/mark_as_failed_if_no_retries_available.test.sql +0 -49
- package/supabase/tests/fail_task/respects_flow_retry_settings.test.sql +0 -48
- package/supabase/tests/fail_task/respects_step_retry_settings.test.sql +0 -48
- package/supabase/tests/fail_task/retry_task_if_retries_available.test.sql +0 -39
- package/supabase/tests/is_valid_slug.test.sql +0 -72
- package/supabase/tests/poll_for_tasks/builds_proper_input_from_deps_outputs.test.sql +0 -35
- package/supabase/tests/poll_for_tasks/hides_messages.test.sql +0 -35
- package/supabase/tests/poll_for_tasks/increments_attempts_count.test.sql +0 -35
- package/supabase/tests/poll_for_tasks/multiple_task_processing.test.sql +0 -24
- package/supabase/tests/poll_for_tasks/polls_only_queued_tasks.test.sql +0 -35
- package/supabase/tests/poll_for_tasks/reads_messages.test.sql +0 -38
- package/supabase/tests/poll_for_tasks/returns_no_tasks_if_no_step_task_for_message.test.sql +0 -34
- package/supabase/tests/poll_for_tasks/returns_no_tasks_if_queue_is_empty.test.sql +0 -19
- package/supabase/tests/poll_for_tasks/returns_no_tasks_when_qty_set_to_0.test.sql +0 -22
- package/supabase/tests/poll_for_tasks/sets_vt_delay_based_on_opt_timeout.test.sql +0 -41
- package/supabase/tests/poll_for_tasks/tasks_reapppear_if_not_processed_in_time.test.sql +0 -59
- package/supabase/tests/start_flow/creates_run.test.sql +0 -24
- package/supabase/tests/start_flow/creates_step_states_for_all_steps.test.sql +0 -25
- package/supabase/tests/start_flow/creates_step_tasks_only_for_root_steps.test.sql +0 -54
- package/supabase/tests/start_flow/returns_run.test.sql +0 -24
- package/supabase/tests/start_flow/sends_messages_on_the_queue.test.sql +0 -50
- package/supabase/tests/start_flow/starts_only_root_steps.test.sql +0 -21
- package/supabase/tests/step_dsl_is_idempotent.test.sql +0 -34
- package/tsconfig.json +0 -16
- package/tsconfig.lib.json +0 -26
- package/tsconfig.spec.json +0 -35
- 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
|
-
}
|
package/scripts/watch-test
DELETED
package/src/PgflowSqlClient.ts
DELETED
|
@@ -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
|
-
}
|