@pgflow/core 0.0.0-add-workerconfig-to-context--20250905094004-b98e1fec-20250905074005 → 0.0.0-test-snapshot-releases-8d5d9bc1-20250922101013
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/package.json +2 -2
- package/dist/ATLAS.md +0 -32
- package/dist/CHANGELOG.md +0 -639
- package/dist/PgflowSqlClient.d.ts +0 -17
- package/dist/PgflowSqlClient.d.ts.map +0 -1
- package/dist/PgflowSqlClient.js +0 -70
- package/dist/README.md +0 -393
- package/dist/database-types.d.ts +0 -828
- package/dist/database-types.d.ts.map +0 -1
- package/dist/database-types.js +0 -8
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/package.json +0 -32
- package/dist/supabase/migrations/20250429164909_pgflow_initial.sql +0 -579
- package/dist/supabase/migrations/20250517072017_pgflow_fix_poll_for_tasks_to_use_separate_statement_for_polling.sql +0 -101
- package/dist/supabase/migrations/20250609105135_pgflow_add_start_tasks_and_started_status.sql +0 -371
- package/dist/supabase/migrations/20250610180554_pgflow_add_set_vt_batch_and_use_it_in_start_tasks.sql +0 -127
- package/dist/supabase/migrations/20250614124241_pgflow_add_realtime.sql +0 -501
- package/dist/supabase/migrations/20250619195327_pgflow_fix_fail_task_missing_realtime_event.sql +0 -185
- package/dist/supabase/migrations/20250627090700_pgflow_fix_function_search_paths.sql +0 -6
- package/dist/supabase/migrations/20250707210212_pgflow_add_opt_start_delay.sql +0 -103
- package/dist/supabase/migrations/20250719205006_pgflow_worker_deprecation.sql +0 -2
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
- package/dist/types.d.ts +0 -94
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -1
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
-- Modify "steps" table
|
|
2
|
-
ALTER TABLE "pgflow"."steps" ADD CONSTRAINT "opt_start_delay_is_nonnegative" CHECK ((opt_start_delay IS NULL) OR (opt_start_delay >= 0)), ADD COLUMN "opt_start_delay" integer NULL;
|
|
3
|
-
-- Modify "start_ready_steps" function
|
|
4
|
-
CREATE OR REPLACE FUNCTION "pgflow"."start_ready_steps" ("run_id" uuid) RETURNS void LANGUAGE sql SET "search_path" = '' AS $$
|
|
5
|
-
WITH ready_steps AS (
|
|
6
|
-
SELECT *
|
|
7
|
-
FROM pgflow.step_states AS step_state
|
|
8
|
-
WHERE step_state.run_id = start_ready_steps.run_id
|
|
9
|
-
AND step_state.status = 'created'
|
|
10
|
-
AND step_state.remaining_deps = 0
|
|
11
|
-
ORDER BY step_state.step_slug
|
|
12
|
-
FOR UPDATE
|
|
13
|
-
),
|
|
14
|
-
started_step_states AS (
|
|
15
|
-
UPDATE pgflow.step_states
|
|
16
|
-
SET status = 'started',
|
|
17
|
-
started_at = now()
|
|
18
|
-
FROM ready_steps
|
|
19
|
-
WHERE pgflow.step_states.run_id = start_ready_steps.run_id
|
|
20
|
-
AND pgflow.step_states.step_slug = ready_steps.step_slug
|
|
21
|
-
RETURNING pgflow.step_states.*
|
|
22
|
-
),
|
|
23
|
-
sent_messages AS (
|
|
24
|
-
SELECT
|
|
25
|
-
started_step.flow_slug,
|
|
26
|
-
started_step.run_id,
|
|
27
|
-
started_step.step_slug,
|
|
28
|
-
pgmq.send(
|
|
29
|
-
started_step.flow_slug,
|
|
30
|
-
jsonb_build_object(
|
|
31
|
-
'flow_slug', started_step.flow_slug,
|
|
32
|
-
'run_id', started_step.run_id,
|
|
33
|
-
'step_slug', started_step.step_slug,
|
|
34
|
-
'task_index', 0
|
|
35
|
-
),
|
|
36
|
-
COALESCE(step.opt_start_delay, 0)
|
|
37
|
-
) AS msg_id
|
|
38
|
-
FROM started_step_states AS started_step
|
|
39
|
-
JOIN pgflow.steps AS step
|
|
40
|
-
ON step.flow_slug = started_step.flow_slug
|
|
41
|
-
AND step.step_slug = started_step.step_slug
|
|
42
|
-
),
|
|
43
|
-
broadcast_events AS (
|
|
44
|
-
SELECT
|
|
45
|
-
realtime.send(
|
|
46
|
-
jsonb_build_object(
|
|
47
|
-
'event_type', 'step:started',
|
|
48
|
-
'run_id', started_step.run_id,
|
|
49
|
-
'step_slug', started_step.step_slug,
|
|
50
|
-
'status', 'started',
|
|
51
|
-
'started_at', started_step.started_at,
|
|
52
|
-
'remaining_tasks', 1,
|
|
53
|
-
'remaining_deps', started_step.remaining_deps
|
|
54
|
-
),
|
|
55
|
-
concat('step:', started_step.step_slug, ':started'),
|
|
56
|
-
concat('pgflow:run:', started_step.run_id),
|
|
57
|
-
false
|
|
58
|
-
)
|
|
59
|
-
FROM started_step_states AS started_step
|
|
60
|
-
)
|
|
61
|
-
INSERT INTO pgflow.step_tasks (flow_slug, run_id, step_slug, message_id)
|
|
62
|
-
SELECT
|
|
63
|
-
sent_messages.flow_slug,
|
|
64
|
-
sent_messages.run_id,
|
|
65
|
-
sent_messages.step_slug,
|
|
66
|
-
sent_messages.msg_id
|
|
67
|
-
FROM sent_messages;
|
|
68
|
-
$$;
|
|
69
|
-
-- Create "add_step" function
|
|
70
|
-
CREATE FUNCTION "pgflow"."add_step" ("flow_slug" text, "step_slug" text, "deps_slugs" text[], "max_attempts" integer DEFAULT NULL::integer, "base_delay" integer DEFAULT NULL::integer, "timeout" integer DEFAULT NULL::integer, "start_delay" integer DEFAULT NULL::integer) RETURNS "pgflow"."steps" LANGUAGE sql SET "search_path" = '' AS $$
|
|
71
|
-
WITH
|
|
72
|
-
next_index AS (
|
|
73
|
-
SELECT COALESCE(MAX(step_index) + 1, 0) as idx
|
|
74
|
-
FROM pgflow.steps
|
|
75
|
-
WHERE flow_slug = add_step.flow_slug
|
|
76
|
-
),
|
|
77
|
-
create_step AS (
|
|
78
|
-
INSERT INTO pgflow.steps (flow_slug, step_slug, step_index, deps_count, opt_max_attempts, opt_base_delay, opt_timeout, opt_start_delay)
|
|
79
|
-
SELECT add_step.flow_slug, add_step.step_slug, idx, COALESCE(array_length(deps_slugs, 1), 0), max_attempts, base_delay, timeout, start_delay
|
|
80
|
-
FROM next_index
|
|
81
|
-
ON CONFLICT (flow_slug, step_slug)
|
|
82
|
-
DO UPDATE SET step_slug = pgflow.steps.step_slug
|
|
83
|
-
RETURNING *
|
|
84
|
-
),
|
|
85
|
-
insert_deps AS (
|
|
86
|
-
INSERT INTO pgflow.deps (flow_slug, dep_slug, step_slug)
|
|
87
|
-
SELECT add_step.flow_slug, d.dep_slug, add_step.step_slug
|
|
88
|
-
FROM unnest(deps_slugs) AS d(dep_slug)
|
|
89
|
-
ON CONFLICT (flow_slug, dep_slug, step_slug) DO NOTHING
|
|
90
|
-
RETURNING 1
|
|
91
|
-
)
|
|
92
|
-
-- Return the created step
|
|
93
|
-
SELECT * FROM create_step;
|
|
94
|
-
$$;
|
|
95
|
-
-- Drop "add_step" function
|
|
96
|
-
DROP FUNCTION "pgflow"."add_step" (text, text, integer, integer, integer);
|
|
97
|
-
-- Drop "add_step" function
|
|
98
|
-
DROP FUNCTION "pgflow"."add_step" (text, text, text[], integer, integer, integer);
|
|
99
|
-
-- Create "add_step" function
|
|
100
|
-
CREATE FUNCTION "pgflow"."add_step" ("flow_slug" text, "step_slug" text, "max_attempts" integer DEFAULT NULL::integer, "base_delay" integer DEFAULT NULL::integer, "timeout" integer DEFAULT NULL::integer, "start_delay" integer DEFAULT NULL::integer) RETURNS "pgflow"."steps" LANGUAGE sql SET "search_path" = '' AS $$
|
|
101
|
-
-- Call the original function with an empty array
|
|
102
|
-
SELECT * FROM pgflow.add_step(flow_slug, step_slug, ARRAY[]::text[], max_attempts, base_delay, timeout, start_delay);
|
|
103
|
-
$$;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"5.8.3"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { ExtractFlowSteps, StepInput, Simplify, AnyFlow, ExtractFlowInput } from '@pgflow/dsl';
|
|
2
|
-
import type { Database } from './database-types.js';
|
|
3
|
-
export type Json = string | number | boolean | null | {
|
|
4
|
-
[key: string]: Json | undefined;
|
|
5
|
-
} | Json[];
|
|
6
|
-
/**
|
|
7
|
-
* Record representing a task from pgflow.start_tasks
|
|
8
|
-
*
|
|
9
|
-
* Same as pgflow.step_task_record type, but with not-null fields and type argument for payload.
|
|
10
|
-
* The input type is automatically inferred based on the step_slug using a discriminated union.
|
|
11
|
-
* This ensures that each step only receives inputs from its declared dependencies and the flow's run input.
|
|
12
|
-
*/
|
|
13
|
-
export type StepTaskRecord<TFlow extends AnyFlow> = {
|
|
14
|
-
[StepSlug in Extract<keyof ExtractFlowSteps<TFlow>, string>]: {
|
|
15
|
-
flow_slug: string;
|
|
16
|
-
run_id: string;
|
|
17
|
-
step_slug: StepSlug;
|
|
18
|
-
input: Simplify<StepInput<TFlow, StepSlug>>;
|
|
19
|
-
msg_id: number;
|
|
20
|
-
};
|
|
21
|
-
}[Extract<keyof ExtractFlowSteps<TFlow>, string>];
|
|
22
|
-
/**
|
|
23
|
-
* Composite key that is enough to find a particular step task
|
|
24
|
-
* Contains only the minimum fields needed to identify a task
|
|
25
|
-
*/
|
|
26
|
-
export type StepTaskKey = Pick<StepTaskRecord<any>, 'run_id' | 'step_slug'>;
|
|
27
|
-
/**
|
|
28
|
-
* Record representing a message from queue polling
|
|
29
|
-
*/
|
|
30
|
-
export type MessageRecord = {
|
|
31
|
-
msg_id: number;
|
|
32
|
-
read_ct: number;
|
|
33
|
-
enqueued_at: string;
|
|
34
|
-
vt: string;
|
|
35
|
-
message: Json;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Interface for interacting with pgflow database functions
|
|
39
|
-
*/
|
|
40
|
-
export interface IPgflowClient<TFlow extends AnyFlow = AnyFlow> {
|
|
41
|
-
/**
|
|
42
|
-
* Start a flow with optional run_id
|
|
43
|
-
*/
|
|
44
|
-
startFlow<TFlow extends AnyFlow>(flow_slug: string, input: ExtractFlowInput<TFlow>, run_id?: string): Promise<RunRow>;
|
|
45
|
-
/**
|
|
46
|
-
* Reads messages from queue without starting tasks (phase 1 of two-phase approach)
|
|
47
|
-
* @param queueName - Name of the queue
|
|
48
|
-
* @param visibilityTimeout - Visibility timeout for messages
|
|
49
|
-
* @param batchSize - Number of messages to fetch
|
|
50
|
-
* @param maxPollSeconds - Maximum time to poll for messages
|
|
51
|
-
* @param pollIntervalMs - Poll interval in milliseconds
|
|
52
|
-
*/
|
|
53
|
-
readMessages(queueName: string, visibilityTimeout: number, batchSize: number, maxPollSeconds?: number, pollIntervalMs?: number): Promise<MessageRecord[]>;
|
|
54
|
-
/**
|
|
55
|
-
* Starts tasks for given message IDs (phase 2 of two-phase approach)
|
|
56
|
-
* @param flowSlug - The flow slug to start tasks from
|
|
57
|
-
* @param msgIds - Array of message IDs from readMessages
|
|
58
|
-
* @param workerId - ID of the worker starting the tasks
|
|
59
|
-
*/
|
|
60
|
-
startTasks(flowSlug: string, msgIds: number[], workerId: string): Promise<StepTaskRecord<TFlow>[]>;
|
|
61
|
-
/**
|
|
62
|
-
* Mark a task as completed with output
|
|
63
|
-
*/
|
|
64
|
-
completeTask(stepTask: StepTaskKey, output?: Json): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Mark a task as failed with error
|
|
67
|
-
*/
|
|
68
|
-
failTask(stepTask: StepTaskKey, error: unknown): Promise<void>;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Record representing a flow from pgflow.flows
|
|
72
|
-
*/
|
|
73
|
-
export type FlowRow = Database['pgflow']['Tables']['flows']['Row'];
|
|
74
|
-
/**
|
|
75
|
-
* Record representing a step from pgflow.steps
|
|
76
|
-
*/
|
|
77
|
-
export type StepRow = Database['pgflow']['Tables']['steps']['Row'];
|
|
78
|
-
/**
|
|
79
|
-
* Record representing a step from pgflow.deps
|
|
80
|
-
*/
|
|
81
|
-
export type DepRow = Database['pgflow']['Tables']['deps']['Row'];
|
|
82
|
-
/**
|
|
83
|
-
* Record representing a step from pgflow.queues
|
|
84
|
-
*/
|
|
85
|
-
export type RunRow = Database['pgflow']['Tables']['runs']['Row'];
|
|
86
|
-
/**
|
|
87
|
-
* Record representing a step from pgflow.step_states
|
|
88
|
-
*/
|
|
89
|
-
export type StepStateRow = Database['pgflow']['Tables']['step_states']['Row'];
|
|
90
|
-
/**
|
|
91
|
-
* Record representing a step from pgflow.step_tasks
|
|
92
|
-
*/
|
|
93
|
-
export type StepTaskRow = Database['pgflow']['Tables']['step_tasks']['Row'];
|
|
94
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,gBAAgB,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,IAAI,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GACnC,IAAI,EAAE,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,OAAO,IAAI;KACjD,QAAQ,IAAI,OAAO,CAAC,MAAM,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG;QAC5D,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,QAAQ,CAAC;QACpB,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC5C,MAAM,EAAE,MAAM,CAAC;KAChB;CACF,CAAC,OAAO,CAAC,MAAM,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAElD;;;GAGG;AAC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