weave-typescript 0.47.1 → 0.49.0

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listAgentRunEventsQuery = exports.insertAgentRunEventQuery = exports.updateAgentRunStatusQuery = exports.listAgentRunsQuery = exports.getAgentRunQuery = exports.createAgentRunQuery = exports.listAgentDefinitionVersionsQuery = exports.getAgentDefinitionVersionByIDQuery = exports.getAgentDefinitionVersionByNumberQuery = exports.setAgentDefinitionLatestVersionQuery = exports.insertAgentDefinitionVersionQuery = exports.insertAgentDraftPatchQuery = exports.updateAgentDraftQuery = exports.updateAgentDefinitionStatusQuery = exports.updateAgentDefinitionDraftMetadataQuery = exports.listAgentDefinitionsQuery = exports.getAgentDefinitionDraftQuery = exports.getAgentDefinitionBySlugQuery = exports.getAgentDefinitionByIDQuery = exports.createAgentDefinitionDraftQuery = exports.createAgentDefinitionQuery = void 0;
3
+ exports.listAgentRunEventsQuery = exports.insertAgentRunEventQuery = exports.updateAgentRunStatusQuery = exports.listAgentRunsQuery = exports.getAgentRunQuery = exports.createAgentRunQuery = exports.listAgentDefinitionVersionsQuery = exports.getAgentDefinitionVersionByIDQuery = exports.getAgentDefinitionVersionByNumberQuery = exports.setAgentDefinitionLatestVersionQuery = exports.insertAgentDefinitionVersionQuery = exports.listAgentDraftEventsQuery = exports.insertAgentDraftEventQuery = exports.insertAgentDraftPatchQuery = exports.updateAgentDraftQuery = exports.updateAgentDefinitionStatusQuery = exports.updateAgentDefinitionDraftMetadataQuery = exports.listAgentDefinitionsQuery = exports.getAgentDefinitionDraftQuery = exports.getAgentDefinitionBySlugQuery = exports.getAgentDefinitionByIDQuery = exports.createAgentDefinitionDraftQuery = exports.createAgentDefinitionQuery = void 0;
4
4
  exports.createAgentDefinition = createAgentDefinition;
5
5
  exports.createAgentDefinitionDraft = createAgentDefinitionDraft;
6
6
  exports.getAgentDefinitionByID = getAgentDefinitionByID;
@@ -11,6 +11,8 @@ exports.updateAgentDefinitionDraftMetadata = updateAgentDefinitionDraftMetadata;
11
11
  exports.updateAgentDefinitionStatus = updateAgentDefinitionStatus;
12
12
  exports.updateAgentDraft = updateAgentDraft;
13
13
  exports.insertAgentDraftPatch = insertAgentDraftPatch;
14
+ exports.insertAgentDraftEvent = insertAgentDraftEvent;
15
+ exports.listAgentDraftEvents = listAgentDraftEvents;
14
16
  exports.insertAgentDefinitionVersion = insertAgentDefinitionVersion;
15
17
  exports.setAgentDefinitionLatestVersion = setAgentDefinitionLatestVersion;
16
18
  exports.getAgentDefinitionVersionByNumber = getAgentDefinitionVersionByNumber;
@@ -410,6 +412,103 @@ async function insertAgentDraftPatch(client, args) {
410
412
  createdAt: row[6]
411
413
  };
412
414
  }
415
+ exports.insertAgentDraftEventQuery = `-- name: InsertAgentDraftEvent :one
416
+ INSERT INTO weave.agent_definition_draft_events (
417
+ id,
418
+ definition_id,
419
+ organization_id,
420
+ draft_id,
421
+ sequence,
422
+ kind,
423
+ base_revision,
424
+ result_revision,
425
+ changed_fields,
426
+ source,
427
+ client_request_id,
428
+ conflict,
429
+ created_by_user_id
430
+ ) VALUES (
431
+ $1,
432
+ $2,
433
+ $3,
434
+ $4,
435
+ COALESCE(
436
+ (
437
+ SELECT max(sequence) + 1
438
+ FROM weave.agent_definition_draft_events
439
+ WHERE definition_id = $2
440
+ ),
441
+ 1
442
+ ),
443
+ $5,
444
+ $6,
445
+ $7::integer,
446
+ $8::text[],
447
+ $9,
448
+ $10,
449
+ $11::jsonb,
450
+ $12
451
+ )
452
+ RETURNING id, organization_id, definition_id, draft_id, sequence, kind, base_revision, result_revision, changed_fields, source, client_request_id, conflict, created_by_user_id, created_at`;
453
+ async function insertAgentDraftEvent(client, args) {
454
+ const result = await client.query({
455
+ text: exports.insertAgentDraftEventQuery,
456
+ values: [args.id, args.definitionId, args.organizationId, args.draftId, args.kind, args.baseRevision, args.resultRevision, args.changedFields, args.source, args.clientRequestId, args.conflict, args.createdByUserId],
457
+ rowMode: "array"
458
+ });
459
+ if (result.rows.length !== 1) {
460
+ return null;
461
+ }
462
+ const row = result.rows[0];
463
+ return {
464
+ id: row[0],
465
+ organizationId: row[1],
466
+ definitionId: row[2],
467
+ draftId: row[3],
468
+ sequence: row[4],
469
+ kind: row[5],
470
+ baseRevision: row[6],
471
+ resultRevision: row[7],
472
+ changedFields: row[8],
473
+ source: row[9],
474
+ clientRequestId: row[10],
475
+ conflict: row[11],
476
+ createdByUserId: row[12],
477
+ createdAt: row[13]
478
+ };
479
+ }
480
+ exports.listAgentDraftEventsQuery = `-- name: ListAgentDraftEvents :many
481
+ SELECT id, organization_id, definition_id, draft_id, sequence, kind, base_revision, result_revision, changed_fields, source, client_request_id, conflict, created_by_user_id, created_at FROM weave.agent_definition_draft_events
482
+ WHERE organization_id = $1
483
+ AND definition_id = $2
484
+ AND sequence > $3
485
+ ORDER BY sequence
486
+ LIMIT $4`;
487
+ async function listAgentDraftEvents(client, args) {
488
+ const result = await client.query({
489
+ text: exports.listAgentDraftEventsQuery,
490
+ values: [args.organizationId, args.definitionId, args.afterSequence, args.pageSize],
491
+ rowMode: "array"
492
+ });
493
+ return result.rows.map(row => {
494
+ return {
495
+ id: row[0],
496
+ organizationId: row[1],
497
+ definitionId: row[2],
498
+ draftId: row[3],
499
+ sequence: row[4],
500
+ kind: row[5],
501
+ baseRevision: row[6],
502
+ resultRevision: row[7],
503
+ changedFields: row[8],
504
+ source: row[9],
505
+ clientRequestId: row[10],
506
+ conflict: row[11],
507
+ createdByUserId: row[12],
508
+ createdAt: row[13]
509
+ };
510
+ });
511
+ }
413
512
  exports.insertAgentDefinitionVersionQuery = `-- name: InsertAgentDefinitionVersion :one
414
513
  INSERT INTO weave.agent_definition_versions (
415
514
  id,
@@ -13,6 +13,18 @@ export interface CreateUserRow {
13
13
  updatedAt: Date;
14
14
  }
15
15
  export declare function createUser(client: Client, args: CreateUserArgs): Promise<CreateUserRow | null>;
16
+ export declare const createUserWithIDQuery = "-- name: CreateUserWithID :one\nINSERT INTO weave.users (\n id,\n status\n) VALUES (\n $1,\n $2\n)\nON CONFLICT (id) DO NOTHING\nRETURNING id, status, created_at, updated_at";
17
+ export interface CreateUserWithIDArgs {
18
+ id: string;
19
+ status: string;
20
+ }
21
+ export interface CreateUserWithIDRow {
22
+ id: string;
23
+ status: string;
24
+ createdAt: Date;
25
+ updatedAt: Date;
26
+ }
27
+ export declare function createUserWithID(client: Client, args: CreateUserWithIDArgs): Promise<CreateUserWithIDRow | null>;
16
28
  export declare const getUserByIDQuery = "-- name: GetUserByID :one\nSELECT id, status, created_at, updated_at\nFROM weave.users\nWHERE id = $1";
17
29
  export interface GetUserByIDArgs {
18
30
  id: string;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listOrgTeamsQuery = exports.getOrgTeamQuery = exports.createOrgTeamQuery = exports.deleteExpiredAuthInviteSessionsQuery = exports.revokeAuthInviteSessionsByMemberQuery = exports.markAuthInviteSessionRecoveryRequiredQuery = exports.markAuthInviteSessionCompletedQuery = exports.setAuthInviteSessionOAuthStateQuery = exports.getAuthInviteSessionQuery = exports.createAuthInviteSessionQuery = exports.deleteExpiredApplicationSessionsQuery = exports.markApplicationSessionOrganizationSessionStateQuery = exports.listApplicationSessionOrganizationSessionStatesQuery = exports.getApplicationSessionOrganizationSessionQuery = exports.upsertApplicationSessionOrganizationSessionQuery = exports.revokeApplicationSessionQuery = exports.setApplicationSessionActiveOrganizationQuery = exports.getApplicationSessionQuery = exports.createApplicationSessionQuery = exports.listAuthorizationDecisionEventsByOrganizationQuery = exports.insertAuthorizationDecisionEventQuery = exports.insertAuthAuditEventQuery = exports.endSupportAccessSessionQuery = exports.createSupportAccessSessionQuery = exports.createPlatformAdminGrantQuery = exports.listActivePlatformAdminGrantsForUserQuery = exports.getOrganizationMemberAdminRecordQuery = exports.listOrganizationMembersQuery = exports.listOrganizationMembershipsForUserQuery = exports.getOrganizationMembershipQuery = exports.upsertOrganizationMembershipQuery = exports.upsertOrganizationAuthLinkQuery = exports.getOrganizationAuthLinkByOrganizationIDQuery = exports.getOrganizationAuthLinkByStytchIDQuery = exports.upsertIdentityLinkQuery = exports.getIdentityLinkByStytchMemberQuery = exports.getUserProfileQuery = exports.upsertUserProfileQuery = exports.deleteOrganizationAuthDomainQuery = exports.listOrganizationAuthDomainsQuery = exports.upsertOrganizationAuthDomainQuery = exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = exports.updateUserProfileThemeQuery = exports.setUserOrganizationPagePositionQuery = exports.setUserLastOrganizationQuery = exports.getUserAuthPreferencesQuery = exports.getUserPrimaryOrganizationAuthLinkQuery = exports.setUserPrimaryOrganizationQuery = exports.getUserByIDQuery = exports.createUserQuery = void 0;
4
- exports.deleteOrgTeamMembershipsForOrganizationMemberQuery = exports.listEffectiveOrganizationRoleIDsQuery = exports.listOrgTeamRoleGrantsQuery = exports.listOrgTeamMembersQuery = exports.addOrgTeamRoleGrantQuery = exports.deleteOrgTeamRoleGrantsQuery = exports.addOrgTeamMembershipQuery = exports.deleteOrgTeamMembershipsQuery = exports.deleteOrgTeamQuery = exports.updateOrgTeamQuery = void 0;
3
+ exports.getOrgTeamQuery = exports.createOrgTeamQuery = exports.deleteExpiredAuthInviteSessionsQuery = exports.revokeAuthInviteSessionsByMemberQuery = exports.markAuthInviteSessionRecoveryRequiredQuery = exports.markAuthInviteSessionCompletedQuery = exports.setAuthInviteSessionOAuthStateQuery = exports.getAuthInviteSessionQuery = exports.createAuthInviteSessionQuery = exports.deleteExpiredApplicationSessionsQuery = exports.markApplicationSessionOrganizationSessionStateQuery = exports.listApplicationSessionOrganizationSessionStatesQuery = exports.getApplicationSessionOrganizationSessionQuery = exports.upsertApplicationSessionOrganizationSessionQuery = exports.revokeApplicationSessionQuery = exports.setApplicationSessionActiveOrganizationQuery = exports.getApplicationSessionQuery = exports.createApplicationSessionQuery = exports.listAuthorizationDecisionEventsByOrganizationQuery = exports.insertAuthorizationDecisionEventQuery = exports.insertAuthAuditEventQuery = exports.endSupportAccessSessionQuery = exports.createSupportAccessSessionQuery = exports.createPlatformAdminGrantQuery = exports.listActivePlatformAdminGrantsForUserQuery = exports.getOrganizationMemberAdminRecordQuery = exports.listOrganizationMembersQuery = exports.listOrganizationMembershipsForUserQuery = exports.getOrganizationMembershipQuery = exports.upsertOrganizationMembershipQuery = exports.upsertOrganizationAuthLinkQuery = exports.getOrganizationAuthLinkByOrganizationIDQuery = exports.getOrganizationAuthLinkByStytchIDQuery = exports.upsertIdentityLinkQuery = exports.getIdentityLinkByStytchMemberQuery = exports.getUserProfileQuery = exports.upsertUserProfileQuery = exports.deleteOrganizationAuthDomainQuery = exports.listOrganizationAuthDomainsQuery = exports.upsertOrganizationAuthDomainQuery = exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = exports.updateUserProfileThemeQuery = exports.setUserOrganizationPagePositionQuery = exports.setUserLastOrganizationQuery = exports.getUserAuthPreferencesQuery = exports.getUserPrimaryOrganizationAuthLinkQuery = exports.setUserPrimaryOrganizationQuery = exports.getUserByIDQuery = exports.createUserWithIDQuery = exports.createUserQuery = void 0;
4
+ exports.deleteOrgTeamMembershipsForOrganizationMemberQuery = exports.listEffectiveOrganizationRoleIDsQuery = exports.listOrgTeamRoleGrantsQuery = exports.listOrgTeamMembersQuery = exports.addOrgTeamRoleGrantQuery = exports.deleteOrgTeamRoleGrantsQuery = exports.addOrgTeamMembershipQuery = exports.deleteOrgTeamMembershipsQuery = exports.deleteOrgTeamQuery = exports.updateOrgTeamQuery = exports.listOrgTeamsQuery = void 0;
5
5
  exports.createUser = createUser;
6
+ exports.createUserWithID = createUserWithID;
6
7
  exports.getUserByID = getUserByID;
7
8
  exports.setUserPrimaryOrganization = setUserPrimaryOrganization;
8
9
  exports.getUserPrimaryOrganizationAuthLink = getUserPrimaryOrganizationAuthLink;
@@ -73,6 +74,33 @@ async function createUser(client, args) {
73
74
  updatedAt: row[3]
74
75
  };
75
76
  }
77
+ exports.createUserWithIDQuery = `-- name: CreateUserWithID :one
78
+ INSERT INTO weave.users (
79
+ id,
80
+ status
81
+ ) VALUES (
82
+ $1,
83
+ $2
84
+ )
85
+ ON CONFLICT (id) DO NOTHING
86
+ RETURNING id, status, created_at, updated_at`;
87
+ async function createUserWithID(client, args) {
88
+ const result = await client.query({
89
+ text: exports.createUserWithIDQuery,
90
+ values: [args.id, args.status],
91
+ rowMode: "array"
92
+ });
93
+ if (result.rows.length !== 1) {
94
+ return null;
95
+ }
96
+ const row = result.rows[0];
97
+ return {
98
+ id: row[0],
99
+ status: row[1],
100
+ createdAt: row[2],
101
+ updatedAt: row[3]
102
+ };
103
+ }
76
104
  exports.getUserByIDQuery = `-- name: GetUserByID :one
77
105
  SELECT id, status, created_at, updated_at
78
106
  FROM weave.users
@@ -26,6 +26,31 @@ export interface CreateOrganizationRow {
26
26
  updatedAt: Date;
27
27
  }
28
28
  export declare function createOrganization(client: Client, args: CreateOrganizationArgs): Promise<CreateOrganizationRow | null>;
29
+ export declare const createOrganizationWithIDQuery = "-- name: CreateOrganizationWithID :one\nINSERT INTO weave.organizations (\n id,\n slug,\n name,\n description,\n primary_color,\n logo,\n logo_content_type,\n timezone,\n location\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9\n)\nON CONFLICT (slug) DO NOTHING\nRETURNING\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at";
30
+ export interface CreateOrganizationWithIDArgs {
31
+ id: string;
32
+ slug: string;
33
+ name: string;
34
+ description: string;
35
+ primaryColor: string;
36
+ logo: Buffer | null;
37
+ logoContentType: string | null;
38
+ timezone: string;
39
+ location: string;
40
+ }
41
+ export interface CreateOrganizationWithIDRow {
42
+ id: string;
43
+ slug: string;
44
+ name: string;
45
+ description: string;
46
+ primaryColor: string;
47
+ hasLogo: string | null;
48
+ timezone: string;
49
+ location: string;
50
+ createdAt: Date;
51
+ updatedAt: Date;
52
+ }
53
+ export declare function createOrganizationWithID(client: Client, args: CreateOrganizationWithIDArgs): Promise<CreateOrganizationWithIDRow | null>;
29
54
  export declare const getOrganizationBySlugQuery = "-- name: GetOrganizationBySlug :one\nSELECT\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at\nFROM weave.organizations\nWHERE slug = $1";
30
55
  export interface GetOrganizationBySlugArgs {
31
56
  slug: string;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clearOrganizationLogoQuery = exports.setOrganizationLogoQuery = exports.getOrganizationLogoQuery = exports.deleteOrganizationQuery = exports.updateOrganizationQuery = exports.listOrganizationsQuery = exports.getOrganizationByIDQuery = exports.getOrganizationBySlugQuery = exports.createOrganizationQuery = void 0;
3
+ exports.clearOrganizationLogoQuery = exports.setOrganizationLogoQuery = exports.getOrganizationLogoQuery = exports.deleteOrganizationQuery = exports.updateOrganizationQuery = exports.listOrganizationsQuery = exports.getOrganizationByIDQuery = exports.getOrganizationBySlugQuery = exports.createOrganizationWithIDQuery = exports.createOrganizationQuery = void 0;
4
4
  exports.createOrganization = createOrganization;
5
+ exports.createOrganizationWithID = createOrganizationWithID;
5
6
  exports.getOrganizationBySlug = getOrganizationBySlug;
6
7
  exports.getOrganizationByID = getOrganizationByID;
7
8
  exports.listOrganizations = listOrganizations;
@@ -62,6 +63,63 @@ async function createOrganization(client, args) {
62
63
  updatedAt: row[9]
63
64
  };
64
65
  }
66
+ exports.createOrganizationWithIDQuery = `-- name: CreateOrganizationWithID :one
67
+ INSERT INTO weave.organizations (
68
+ id,
69
+ slug,
70
+ name,
71
+ description,
72
+ primary_color,
73
+ logo,
74
+ logo_content_type,
75
+ timezone,
76
+ location
77
+ ) VALUES (
78
+ $1,
79
+ $2,
80
+ $3,
81
+ $4,
82
+ $5,
83
+ $6,
84
+ $7,
85
+ $8,
86
+ $9
87
+ )
88
+ ON CONFLICT (slug) DO NOTHING
89
+ RETURNING
90
+ id,
91
+ slug,
92
+ name,
93
+ description,
94
+ primary_color,
95
+ (logo IS NOT NULL) AS has_logo,
96
+ timezone,
97
+ location,
98
+ created_at,
99
+ updated_at`;
100
+ async function createOrganizationWithID(client, args) {
101
+ const result = await client.query({
102
+ text: exports.createOrganizationWithIDQuery,
103
+ values: [args.id, args.slug, args.name, args.description, args.primaryColor, args.logo, args.logoContentType, args.timezone, args.location],
104
+ rowMode: "array"
105
+ });
106
+ if (result.rows.length !== 1) {
107
+ return null;
108
+ }
109
+ const row = result.rows[0];
110
+ return {
111
+ id: row[0],
112
+ slug: row[1],
113
+ name: row[2],
114
+ description: row[3],
115
+ primaryColor: row[4],
116
+ hasLogo: row[5],
117
+ timezone: row[6],
118
+ location: row[7],
119
+ createdAt: row[8],
120
+ updatedAt: row[9]
121
+ };
122
+ }
65
123
  exports.getOrganizationBySlugQuery = `-- name: GetOrganizationBySlug :one
66
124
  SELECT
67
125
  id,
@@ -237,6 +237,62 @@ export interface InsertWorkflowDraftPatchRow {
237
237
  createdAt: Date;
238
238
  }
239
239
  export declare function insertWorkflowDraftPatch(client: Client, args: InsertWorkflowDraftPatchArgs): Promise<InsertWorkflowDraftPatchRow | null>;
240
+ export declare const insertWorkflowDraftEventQuery = "-- name: InsertWorkflowDraftEvent :one\nINSERT INTO weave.workflow_definition_draft_events (\n id,\n definition_id,\n organization_id,\n draft_id,\n sequence,\n kind,\n base_revision,\n result_revision,\n changed_fields,\n source,\n client_request_id,\n conflict,\n created_by_user_id\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n COALESCE(\n (\n SELECT max(sequence) + 1\n FROM weave.workflow_definition_draft_events\n WHERE definition_id = $2\n ),\n 1\n ),\n $5,\n $6,\n $7::integer,\n $8::text[],\n $9,\n $10,\n $11::jsonb,\n $12\n)\nRETURNING id, organization_id, definition_id, draft_id, sequence, kind, base_revision, result_revision, changed_fields, source, client_request_id, conflict, created_by_user_id, created_at";
241
+ export interface InsertWorkflowDraftEventArgs {
242
+ id: string;
243
+ definitionId: string;
244
+ organizationId: string;
245
+ draftId: string;
246
+ kind: string;
247
+ baseRevision: number;
248
+ resultRevision: number | null;
249
+ changedFields: string[];
250
+ source: string;
251
+ clientRequestId: string;
252
+ conflict: any | null;
253
+ createdByUserId: string;
254
+ }
255
+ export interface InsertWorkflowDraftEventRow {
256
+ id: string;
257
+ organizationId: string;
258
+ definitionId: string;
259
+ draftId: string;
260
+ sequence: string;
261
+ kind: string;
262
+ baseRevision: number;
263
+ resultRevision: number | null;
264
+ changedFields: string[];
265
+ source: string;
266
+ clientRequestId: string;
267
+ conflict: any | null;
268
+ createdByUserId: string;
269
+ createdAt: Date;
270
+ }
271
+ export declare function insertWorkflowDraftEvent(client: Client, args: InsertWorkflowDraftEventArgs): Promise<InsertWorkflowDraftEventRow | null>;
272
+ export declare const listWorkflowDraftEventsQuery = "-- name: ListWorkflowDraftEvents :many\nSELECT id, organization_id, definition_id, draft_id, sequence, kind, base_revision, result_revision, changed_fields, source, client_request_id, conflict, created_by_user_id, created_at FROM weave.workflow_definition_draft_events\nWHERE organization_id = $1\n AND definition_id = $2\n AND sequence > $3\nORDER BY sequence\nLIMIT $4";
273
+ export interface ListWorkflowDraftEventsArgs {
274
+ organizationId: string;
275
+ definitionId: string;
276
+ afterSequence: string;
277
+ pageSize: string;
278
+ }
279
+ export interface ListWorkflowDraftEventsRow {
280
+ id: string;
281
+ organizationId: string;
282
+ definitionId: string;
283
+ draftId: string;
284
+ sequence: string;
285
+ kind: string;
286
+ baseRevision: number;
287
+ resultRevision: number | null;
288
+ changedFields: string[];
289
+ source: string;
290
+ clientRequestId: string;
291
+ conflict: any | null;
292
+ createdByUserId: string;
293
+ createdAt: Date;
294
+ }
295
+ export declare function listWorkflowDraftEvents(client: Client, args: ListWorkflowDraftEventsArgs): Promise<ListWorkflowDraftEventsRow[]>;
240
296
  export declare const insertWorkflowDefinitionVersionQuery = "-- name: InsertWorkflowDefinitionVersion :one\nINSERT INTO weave.workflow_definition_versions (\n id,\n definition_id,\n organization_id,\n version,\n source_draft_revision,\n name,\n description,\n graph,\n input_schema,\n output_schema,\n metadata,\n published_by_user_id\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $12\n)\nRETURNING id, definition_id, organization_id, version, source_draft_revision, name, description, graph, input_schema, output_schema, metadata, published_by_user_id, published_at";
241
297
  export interface InsertWorkflowDefinitionVersionArgs {
242
298
  id: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listToolCallEventsQuery = exports.insertToolCallEventQuery = exports.listWorkflowRunEventsQuery = exports.insertWorkflowRunEventQuery = exports.updateWorkflowStepRunStatusQuery = exports.listWorkflowStepRunsQuery = exports.createWorkflowStepRunQuery = exports.updateWorkflowRunStatusQuery = exports.listWorkflowRunsQuery = exports.getWorkflowRunQuery = exports.createWorkflowRunQuery = exports.listWorkflowDefinitionVersionsQuery = exports.getWorkflowDefinitionVersionByIDQuery = exports.getWorkflowDefinitionVersionByNumberQuery = exports.setWorkflowDefinitionLatestVersionQuery = exports.insertWorkflowDefinitionVersionQuery = exports.insertWorkflowDraftPatchQuery = exports.updateWorkflowDraftQuery = exports.updateWorkflowDefinitionStatusQuery = exports.updateWorkflowDefinitionDraftMetadataQuery = exports.listWorkflowDefinitionsQuery = exports.getWorkflowDefinitionDraftQuery = exports.getWorkflowDefinitionBySlugQuery = exports.getWorkflowDefinitionByIDQuery = exports.createWorkflowDefinitionDraftQuery = exports.createWorkflowDefinitionQuery = void 0;
3
+ exports.listToolCallEventsQuery = exports.insertToolCallEventQuery = exports.listWorkflowRunEventsQuery = exports.insertWorkflowRunEventQuery = exports.updateWorkflowStepRunStatusQuery = exports.listWorkflowStepRunsQuery = exports.createWorkflowStepRunQuery = exports.updateWorkflowRunStatusQuery = exports.listWorkflowRunsQuery = exports.getWorkflowRunQuery = exports.createWorkflowRunQuery = exports.listWorkflowDefinitionVersionsQuery = exports.getWorkflowDefinitionVersionByIDQuery = exports.getWorkflowDefinitionVersionByNumberQuery = exports.setWorkflowDefinitionLatestVersionQuery = exports.insertWorkflowDefinitionVersionQuery = exports.listWorkflowDraftEventsQuery = exports.insertWorkflowDraftEventQuery = exports.insertWorkflowDraftPatchQuery = exports.updateWorkflowDraftQuery = exports.updateWorkflowDefinitionStatusQuery = exports.updateWorkflowDefinitionDraftMetadataQuery = exports.listWorkflowDefinitionsQuery = exports.getWorkflowDefinitionDraftQuery = exports.getWorkflowDefinitionBySlugQuery = exports.getWorkflowDefinitionByIDQuery = exports.createWorkflowDefinitionDraftQuery = exports.createWorkflowDefinitionQuery = void 0;
4
4
  exports.createWorkflowDefinition = createWorkflowDefinition;
5
5
  exports.createWorkflowDefinitionDraft = createWorkflowDefinitionDraft;
6
6
  exports.getWorkflowDefinitionByID = getWorkflowDefinitionByID;
@@ -11,6 +11,8 @@ exports.updateWorkflowDefinitionDraftMetadata = updateWorkflowDefinitionDraftMet
11
11
  exports.updateWorkflowDefinitionStatus = updateWorkflowDefinitionStatus;
12
12
  exports.updateWorkflowDraft = updateWorkflowDraft;
13
13
  exports.insertWorkflowDraftPatch = insertWorkflowDraftPatch;
14
+ exports.insertWorkflowDraftEvent = insertWorkflowDraftEvent;
15
+ exports.listWorkflowDraftEvents = listWorkflowDraftEvents;
14
16
  exports.insertWorkflowDefinitionVersion = insertWorkflowDefinitionVersion;
15
17
  exports.setWorkflowDefinitionLatestVersion = setWorkflowDefinitionLatestVersion;
16
18
  exports.getWorkflowDefinitionVersionByNumber = getWorkflowDefinitionVersionByNumber;
@@ -397,6 +399,103 @@ async function insertWorkflowDraftPatch(client, args) {
397
399
  createdAt: row[6]
398
400
  };
399
401
  }
402
+ exports.insertWorkflowDraftEventQuery = `-- name: InsertWorkflowDraftEvent :one
403
+ INSERT INTO weave.workflow_definition_draft_events (
404
+ id,
405
+ definition_id,
406
+ organization_id,
407
+ draft_id,
408
+ sequence,
409
+ kind,
410
+ base_revision,
411
+ result_revision,
412
+ changed_fields,
413
+ source,
414
+ client_request_id,
415
+ conflict,
416
+ created_by_user_id
417
+ ) VALUES (
418
+ $1,
419
+ $2,
420
+ $3,
421
+ $4,
422
+ COALESCE(
423
+ (
424
+ SELECT max(sequence) + 1
425
+ FROM weave.workflow_definition_draft_events
426
+ WHERE definition_id = $2
427
+ ),
428
+ 1
429
+ ),
430
+ $5,
431
+ $6,
432
+ $7::integer,
433
+ $8::text[],
434
+ $9,
435
+ $10,
436
+ $11::jsonb,
437
+ $12
438
+ )
439
+ RETURNING id, organization_id, definition_id, draft_id, sequence, kind, base_revision, result_revision, changed_fields, source, client_request_id, conflict, created_by_user_id, created_at`;
440
+ async function insertWorkflowDraftEvent(client, args) {
441
+ const result = await client.query({
442
+ text: exports.insertWorkflowDraftEventQuery,
443
+ values: [args.id, args.definitionId, args.organizationId, args.draftId, args.kind, args.baseRevision, args.resultRevision, args.changedFields, args.source, args.clientRequestId, args.conflict, args.createdByUserId],
444
+ rowMode: "array"
445
+ });
446
+ if (result.rows.length !== 1) {
447
+ return null;
448
+ }
449
+ const row = result.rows[0];
450
+ return {
451
+ id: row[0],
452
+ organizationId: row[1],
453
+ definitionId: row[2],
454
+ draftId: row[3],
455
+ sequence: row[4],
456
+ kind: row[5],
457
+ baseRevision: row[6],
458
+ resultRevision: row[7],
459
+ changedFields: row[8],
460
+ source: row[9],
461
+ clientRequestId: row[10],
462
+ conflict: row[11],
463
+ createdByUserId: row[12],
464
+ createdAt: row[13]
465
+ };
466
+ }
467
+ exports.listWorkflowDraftEventsQuery = `-- name: ListWorkflowDraftEvents :many
468
+ SELECT id, organization_id, definition_id, draft_id, sequence, kind, base_revision, result_revision, changed_fields, source, client_request_id, conflict, created_by_user_id, created_at FROM weave.workflow_definition_draft_events
469
+ WHERE organization_id = $1
470
+ AND definition_id = $2
471
+ AND sequence > $3
472
+ ORDER BY sequence
473
+ LIMIT $4`;
474
+ async function listWorkflowDraftEvents(client, args) {
475
+ const result = await client.query({
476
+ text: exports.listWorkflowDraftEventsQuery,
477
+ values: [args.organizationId, args.definitionId, args.afterSequence, args.pageSize],
478
+ rowMode: "array"
479
+ });
480
+ return result.rows.map(row => {
481
+ return {
482
+ id: row[0],
483
+ organizationId: row[1],
484
+ definitionId: row[2],
485
+ draftId: row[3],
486
+ sequence: row[4],
487
+ kind: row[5],
488
+ baseRevision: row[6],
489
+ resultRevision: row[7],
490
+ changedFields: row[8],
491
+ source: row[9],
492
+ clientRequestId: row[10],
493
+ conflict: row[11],
494
+ createdByUserId: row[12],
495
+ createdAt: row[13]
496
+ };
497
+ });
498
+ }
400
499
  exports.insertWorkflowDefinitionVersionQuery = `-- name: InsertWorkflowDefinitionVersion :one
401
500
  INSERT INTO weave.workflow_definition_versions (
402
501
  id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weave-typescript",
3
- "version": "0.47.1",
3
+ "version": "0.49.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [