@sixb/pg 0.0.1

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 (152) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/agents/agent-storage.d.ts +20 -0
  4. package/dist/agents/agent-storage.d.ts.map +1 -0
  5. package/dist/agents/index.d.ts +6 -0
  6. package/dist/agents/index.d.ts.map +1 -0
  7. package/dist/agents/messages.d.ts +13 -0
  8. package/dist/agents/messages.d.ts.map +1 -0
  9. package/dist/agents/rows.d.ts +77 -0
  10. package/dist/agents/rows.d.ts.map +1 -0
  11. package/dist/agents/runs.d.ts +25 -0
  12. package/dist/agents/runs.d.ts.map +1 -0
  13. package/dist/agents/threads.d.ts +13 -0
  14. package/dist/agents/threads.d.ts.map +1 -0
  15. package/dist/auth-storage/access-tokens.d.ts +33 -0
  16. package/dist/auth-storage/access-tokens.d.ts.map +1 -0
  17. package/dist/auth-storage/auth-storage.d.ts +41 -0
  18. package/dist/auth-storage/auth-storage.d.ts.map +1 -0
  19. package/dist/auth-storage/group-memberships.d.ts +21 -0
  20. package/dist/auth-storage/group-memberships.d.ts.map +1 -0
  21. package/dist/auth-storage/identities.d.ts +17 -0
  22. package/dist/auth-storage/identities.d.ts.map +1 -0
  23. package/dist/auth-storage/index.d.ts +3 -0
  24. package/dist/auth-storage/index.d.ts.map +1 -0
  25. package/dist/auth-storage/invitations.d.ts +29 -0
  26. package/dist/auth-storage/invitations.d.ts.map +1 -0
  27. package/dist/auth-storage/magic-links.d.ts +28 -0
  28. package/dist/auth-storage/magic-links.d.ts.map +1 -0
  29. package/dist/auth-storage/oidc-attempts.d.ts +18 -0
  30. package/dist/auth-storage/oidc-attempts.d.ts.map +1 -0
  31. package/dist/auth-storage/rows.d.ts +138 -0
  32. package/dist/auth-storage/rows.d.ts.map +1 -0
  33. package/dist/auth-storage/service-account-group-memberships.d.ts +17 -0
  34. package/dist/auth-storage/service-account-group-memberships.d.ts.map +1 -0
  35. package/dist/auth-storage/service-accounts.d.ts +14 -0
  36. package/dist/auth-storage/service-accounts.d.ts.map +1 -0
  37. package/dist/auth-storage/sessions.d.ts +55 -0
  38. package/dist/auth-storage/sessions.d.ts.map +1 -0
  39. package/dist/auth-storage/shared.d.ts +159 -0
  40. package/dist/auth-storage/shared.d.ts.map +1 -0
  41. package/dist/auth-storage/users.d.ts +19 -0
  42. package/dist/auth-storage/users.d.ts.map +1 -0
  43. package/dist/index.d.ts +127 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +11957 -0
  46. package/dist/index.js.map +55 -0
  47. package/dist/latest-run-query.d.ts +24 -0
  48. package/dist/latest-run-query.d.ts.map +1 -0
  49. package/dist/migrations.d.ts +20 -0
  50. package/dist/migrations.d.ts.map +1 -0
  51. package/dist/ontology-storage/commits.d.ts +11 -0
  52. package/dist/ontology-storage/commits.d.ts.map +1 -0
  53. package/dist/ontology-storage/index.d.ts +22 -0
  54. package/dist/ontology-storage/index.d.ts.map +1 -0
  55. package/dist/ontology-storage/materialization-session.d.ts +63 -0
  56. package/dist/ontology-storage/materialization-session.d.ts.map +1 -0
  57. package/dist/ontology-storage/materialization-state.d.ts +69 -0
  58. package/dist/ontology-storage/materialization-state.d.ts.map +1 -0
  59. package/dist/ontology-storage/materialization-writer.d.ts +15 -0
  60. package/dist/ontology-storage/materialization-writer.d.ts.map +1 -0
  61. package/dist/ontology-storage/materializations.d.ts +33 -0
  62. package/dist/ontology-storage/materializations.d.ts.map +1 -0
  63. package/dist/ontology-storage/outbox.d.ts +12 -0
  64. package/dist/ontology-storage/outbox.d.ts.map +1 -0
  65. package/dist/ontology-storage/shared.d.ts +95 -0
  66. package/dist/ontology-storage/shared.d.ts.map +1 -0
  67. package/dist/ontology-storage/sources.d.ts +25 -0
  68. package/dist/ontology-storage/sources.d.ts.map +1 -0
  69. package/dist/pg-action-run-storage.d.ts +21 -0
  70. package/dist/pg-action-run-storage.d.ts.map +1 -0
  71. package/dist/pg-client.d.ts +58 -0
  72. package/dist/pg-client.d.ts.map +1 -0
  73. package/dist/pg-object-query-compiler.d.ts +55 -0
  74. package/dist/pg-object-query-compiler.d.ts.map +1 -0
  75. package/dist/pg-object-storage.d.ts +90 -0
  76. package/dist/pg-object-storage.d.ts.map +1 -0
  77. package/dist/pg-pipeline-run-storage.d.ts +18 -0
  78. package/dist/pg-pipeline-run-storage.d.ts.map +1 -0
  79. package/dist/pg-projection-run-storage.d.ts +19 -0
  80. package/dist/pg-projection-run-storage.d.ts.map +1 -0
  81. package/dist/pg-rules-storage.d.ts +25 -0
  82. package/dist/pg-rules-storage.d.ts.map +1 -0
  83. package/dist/pg-sync-run-storage.d.ts +15 -0
  84. package/dist/pg-sync-run-storage.d.ts.map +1 -0
  85. package/dist/pg-timeseries-storage.d.ts +32 -0
  86. package/dist/pg-timeseries-storage.d.ts.map +1 -0
  87. package/dist/pg-webhook-delivery-storage.d.ts +17 -0
  88. package/dist/pg-webhook-delivery-storage.d.ts.map +1 -0
  89. package/dist/pg-webhook-run-storage.d.ts +14 -0
  90. package/dist/pg-webhook-run-storage.d.ts.map +1 -0
  91. package/dist/pg-workflow-intervention-storage.d.ts +16 -0
  92. package/dist/pg-workflow-intervention-storage.d.ts.map +1 -0
  93. package/dist/pg-workflow-run-storage.d.ts +49 -0
  94. package/dist/pg-workflow-run-storage.d.ts.map +1 -0
  95. package/dist/run-list-query.d.ts +30 -0
  96. package/dist/run-list-query.d.ts.map +1 -0
  97. package/dist/storage-errors.d.ts +16 -0
  98. package/dist/storage-errors.d.ts.map +1 -0
  99. package/dist/transactions.d.ts +10 -0
  100. package/dist/transactions.d.ts.map +1 -0
  101. package/dist/tsconfig.json +5 -0
  102. package/package.json +60 -0
  103. package/src/agents/agent-storage.ts +26 -0
  104. package/src/agents/index.ts +5 -0
  105. package/src/agents/messages.ts +144 -0
  106. package/src/agents/rows.ts +227 -0
  107. package/src/agents/runs.ts +330 -0
  108. package/src/agents/threads.ts +116 -0
  109. package/src/auth-storage/access-tokens.ts +254 -0
  110. package/src/auth-storage/auth-storage.ts +798 -0
  111. package/src/auth-storage/group-memberships.ts +47 -0
  112. package/src/auth-storage/identities.ts +85 -0
  113. package/src/auth-storage/index.ts +2 -0
  114. package/src/auth-storage/invitations.ts +280 -0
  115. package/src/auth-storage/magic-links.ts +140 -0
  116. package/src/auth-storage/oidc-attempts.ts +93 -0
  117. package/src/auth-storage/rows.ts +352 -0
  118. package/src/auth-storage/service-account-group-memberships.ts +150 -0
  119. package/src/auth-storage/service-accounts.ts +154 -0
  120. package/src/auth-storage/sessions.ts +193 -0
  121. package/src/auth-storage/shared.ts +799 -0
  122. package/src/auth-storage/users.ts +196 -0
  123. package/src/index.ts +367 -0
  124. package/src/latest-run-query.ts +42 -0
  125. package/src/migrations/001-initial-schema.sql +1195 -0
  126. package/src/migrations.ts +280 -0
  127. package/src/ontology-storage/commits.ts +115 -0
  128. package/src/ontology-storage/index.ts +35 -0
  129. package/src/ontology-storage/materialization-session.ts +426 -0
  130. package/src/ontology-storage/materialization-state.ts +1109 -0
  131. package/src/ontology-storage/materialization-writer.ts +509 -0
  132. package/src/ontology-storage/materializations.ts +939 -0
  133. package/src/ontology-storage/outbox.ts +216 -0
  134. package/src/ontology-storage/shared.ts +293 -0
  135. package/src/ontology-storage/sources.ts +658 -0
  136. package/src/pg-action-run-storage.ts +657 -0
  137. package/src/pg-client.ts +124 -0
  138. package/src/pg-object-query-compiler.ts +1545 -0
  139. package/src/pg-object-storage.ts +638 -0
  140. package/src/pg-pipeline-run-storage.ts +457 -0
  141. package/src/pg-projection-run-storage.ts +526 -0
  142. package/src/pg-rules-storage.ts +308 -0
  143. package/src/pg-sync-run-storage.ts +263 -0
  144. package/src/pg-timeseries-storage.ts +180 -0
  145. package/src/pg-webhook-delivery-storage.ts +180 -0
  146. package/src/pg-webhook-run-storage.ts +185 -0
  147. package/src/pg-workflow-intervention-storage.ts +339 -0
  148. package/src/pg-workflow-run-storage.ts +1065 -0
  149. package/src/run-list-query.ts +108 -0
  150. package/src/sql.d.ts +4 -0
  151. package/src/storage-errors.ts +72 -0
  152. package/src/transactions.ts +58 -0
@@ -0,0 +1,138 @@
1
+ import type { AccessTokenRecord, GroupMembershipRecord, GroupMembershipSource, InvitationRecord, InvitationStatus, MagicLinkRecord, OidcAuthorizationAttemptRecord, ServiceAccountGroupMembershipRecord, ServiceAccountRecord, ServiceAccountStatus, SessionRecord, UserIdentityRecord, UserRecord, UserStatus } from "@sixb/core/storage";
2
+ type PgDate = Date | string;
3
+ export interface PgAuthUserRow {
4
+ readonly project_id: string;
5
+ readonly id: string;
6
+ readonly email: string;
7
+ readonly display_name: string | null;
8
+ readonly avatar_url: string | null;
9
+ readonly status: UserStatus;
10
+ readonly created_at: PgDate;
11
+ readonly updated_at: PgDate;
12
+ }
13
+ export interface PgAuthUserIdentityRow {
14
+ readonly project_id: string;
15
+ readonly strategy_id: string;
16
+ readonly subject: string;
17
+ readonly user_id: string;
18
+ readonly claims: Readonly<Record<string, unknown>> | string | null;
19
+ readonly created_at: PgDate;
20
+ readonly updated_at: PgDate;
21
+ }
22
+ export interface PgAuthServiceAccountRow {
23
+ readonly project_id: string;
24
+ readonly id: string;
25
+ readonly name: string;
26
+ readonly description: string | null;
27
+ readonly status: ServiceAccountStatus;
28
+ readonly created_by_user_id: string | null;
29
+ readonly created_by_service_account_id: string | null;
30
+ readonly created_by_system_id: string | null;
31
+ readonly created_by_session_id: string | null;
32
+ readonly created_at: PgDate;
33
+ readonly updated_at: PgDate;
34
+ }
35
+ export interface PgAuthServiceAccountGroupMembershipRow {
36
+ readonly project_id: string;
37
+ readonly service_account_id: string;
38
+ readonly group_id: string;
39
+ readonly source: GroupMembershipSource;
40
+ readonly created_at: PgDate;
41
+ }
42
+ export interface PgAuthSessionRow {
43
+ readonly project_id: string;
44
+ readonly id: string;
45
+ readonly user_id: string;
46
+ readonly strategy_id: string;
47
+ readonly audience: SessionRecord["audience"];
48
+ readonly token_hash: string;
49
+ readonly created_at: PgDate;
50
+ readonly expires_at: PgDate;
51
+ readonly absolute_expires_at: PgDate | null;
52
+ readonly revoked_at: PgDate | null;
53
+ readonly last_seen_at: PgDate | null;
54
+ readonly user_agent: string | null;
55
+ readonly ip_address: string | null;
56
+ }
57
+ export interface PgAuthAccessTokenRow {
58
+ readonly project_id: string;
59
+ readonly id: string;
60
+ readonly name: string;
61
+ readonly kind: AccessTokenRecord["kind"];
62
+ readonly subject_type: AccessTokenRecord["subjectType"];
63
+ readonly subject_id: string;
64
+ readonly token_hash: string;
65
+ readonly group_ids: readonly string[] | string | null;
66
+ readonly created_by_user_id: string | null;
67
+ readonly created_by_service_account_id: string | null;
68
+ readonly created_by_system_id: string | null;
69
+ readonly created_by_session_id: string | null;
70
+ readonly created_at: PgDate;
71
+ readonly expires_at: PgDate;
72
+ readonly revoked_at: PgDate | null;
73
+ readonly last_used_at: PgDate | null;
74
+ readonly last_used_user_agent: string | null;
75
+ readonly last_used_ip_address: string | null;
76
+ }
77
+ export interface PgAuthInvitationRow {
78
+ readonly project_id: string;
79
+ readonly id: string;
80
+ readonly email: string;
81
+ readonly status: InvitationStatus;
82
+ readonly created_by_user_id: string | null;
83
+ readonly created_by_service_account_id: string | null;
84
+ readonly created_by_system_id: string | null;
85
+ readonly created_by_session_id: string | null;
86
+ readonly created_at: PgDate;
87
+ readonly updated_at: PgDate;
88
+ readonly expires_at: PgDate;
89
+ readonly accepted_at: PgDate | null;
90
+ readonly revoked_at: PgDate | null;
91
+ }
92
+ export interface PgAuthGroupMembershipRow {
93
+ readonly project_id: string;
94
+ readonly user_id: string;
95
+ readonly group_id: string;
96
+ readonly source: GroupMembershipSource;
97
+ readonly created_at: PgDate;
98
+ }
99
+ export interface PgAuthMagicLinkRow {
100
+ readonly project_id: string;
101
+ readonly id: string;
102
+ readonly strategy_id: string;
103
+ readonly audience: MagicLinkRecord["audience"];
104
+ readonly email: string;
105
+ readonly token_hash: string;
106
+ readonly return_to: string | null;
107
+ readonly created_at: PgDate;
108
+ readonly expires_at: PgDate;
109
+ readonly consumed_at: PgDate | null;
110
+ readonly revoked_at: PgDate | null;
111
+ }
112
+ export interface PgAuthOidcAttemptRow {
113
+ readonly project_id: string;
114
+ readonly id: string;
115
+ readonly strategy_id: string;
116
+ readonly audience: OidcAuthorizationAttemptRecord["audience"];
117
+ readonly state_hash: string;
118
+ readonly nonce_hash: string;
119
+ readonly code_verifier: string;
120
+ readonly return_to: string | null;
121
+ readonly created_at: PgDate;
122
+ readonly expires_at: PgDate;
123
+ readonly consumed_at: PgDate | null;
124
+ }
125
+ export declare function rowToUserRecord(row: PgAuthUserRow): UserRecord;
126
+ export declare function rowToIdentityRecord(row: PgAuthUserIdentityRow): UserIdentityRecord;
127
+ export declare function rowToServiceAccountRecord(row: PgAuthServiceAccountRow): ServiceAccountRecord;
128
+ export declare function rowToServiceAccountGroupMembershipRecord(row: PgAuthServiceAccountGroupMembershipRow): ServiceAccountGroupMembershipRecord;
129
+ export declare function rowToSessionRecord(row: PgAuthSessionRow): SessionRecord;
130
+ export declare function rowToAccessTokenRecord(row: PgAuthAccessTokenRow): AccessTokenRecord;
131
+ export declare function rowToInvitationRecord(row: PgAuthInvitationRow, groupIds: readonly string[]): InvitationRecord;
132
+ export declare function rowToGroupMembershipRecord(row: PgAuthGroupMembershipRow): GroupMembershipRecord;
133
+ export declare function rowToMagicLinkRecord(row: PgAuthMagicLinkRow): MagicLinkRecord;
134
+ export declare function rowToOidcAuthorizationAttemptRecord(row: PgAuthOidcAttemptRow): OidcAuthorizationAttemptRecord;
135
+ export declare function serializeOptionalRecord(value: Readonly<Record<string, unknown>> | undefined): string | null;
136
+ export declare function serializeOptionalStringArray(value: readonly string[] | undefined): string | null;
137
+ export {};
138
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/auth-storage/rows.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAq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AAM,EAAE,GAC1B,gBAAgB,CAelB;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,wBAAwB,GAAG,qBAAqB,CAQ/F;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,kBAAkB,GAAG,eAAe,CAc7E;AAED,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,oBAAoB,GACxB,8BAA8B,CAchC;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,GACnD,MAAM,GAAG,IAAI,CAEf;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAEhG"}
@@ -0,0 +1,17 @@
1
+ import type { AuthServiceAccountGroupMembershipStore, ReconcileAuthServiceAccountGroupMembershipsInput, ServiceAccountGroupMembershipRecord, UpsertAuthServiceAccountGroupMembershipInput } from "@sixb/core/storage";
2
+ import type { PgStoreClient } from "../transactions";
3
+ export declare class PgAuthServiceAccountGroupMembershipStore implements AuthServiceAccountGroupMembershipStore {
4
+ private readonly sql;
5
+ constructor(sql: PgStoreClient);
6
+ upsert(input: UpsertAuthServiceAccountGroupMembershipInput): Promise<ServiceAccountGroupMembershipRecord>;
7
+ reconcileForServiceAccount(input: ReconcileAuthServiceAccountGroupMembershipsInput): Promise<readonly ServiceAccountGroupMembershipRecord[]>;
8
+ listForServiceAccount(params: {
9
+ readonly projectId: string;
10
+ readonly serviceAccountId: string;
11
+ }): Promise<readonly ServiceAccountGroupMembershipRecord[]>;
12
+ listForGroup(params: {
13
+ readonly projectId: string;
14
+ readonly groupId: string;
15
+ }): Promise<readonly ServiceAccountGroupMembershipRecord[]>;
16
+ }
17
+ //# sourceMappingURL=service-account-group-memberships.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-account-group-memberships.d.ts","sourceRoot":"","sources":["../../src/auth-storage/service-account-group-memberships.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sCAAsC,EACtC,gDAAgD,EAChD,mCAAmC,EACnC,4CAA4C,EAC7C,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAKpD,qBAAa,wCACX,YAAW,sCAAsC;IAErC,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CACV,KAAK,EAAE,4CAA4C,GAClD,OAAO,CAAC,mCAAmC,CAAC;IAuCzC,0BAA0B,CAC9B,KAAK,EAAE,gDAAgD,GACtD,OAAO,CAAC,SAAS,mCAAmC,EAAE,CAAC;IA4DpD,qBAAqB,CAAC,MAAM,EAAE;QAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;KAClC,GAAG,OAAO,CAAC,SAAS,mCAAmC,EAAE,CAAC;IAYrD,YAAY,CAAC,MAAM,EAAE;QACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KACzB,GAAG,OAAO,CAAC,SAAS,mCAAmC,EAAE,CAAC;CAW5D"}
@@ -0,0 +1,14 @@
1
+ import type { AuthServiceAccountStore, CreateAuthServiceAccountInput, ListAuthServiceAccountsInput, ListAuthServiceAccountsResult, ServiceAccountRecord, UpdateAuthServiceAccountInput } from "@sixb/core/storage";
2
+ import type { PgStoreClient } from "../transactions";
3
+ export declare class PgAuthServiceAccountStore implements AuthServiceAccountStore {
4
+ private readonly sql;
5
+ constructor(sql: PgStoreClient);
6
+ create(input: CreateAuthServiceAccountInput): Promise<ServiceAccountRecord>;
7
+ getById(params: {
8
+ readonly projectId: string;
9
+ readonly id: string;
10
+ }): Promise<ServiceAccountRecord | null>;
11
+ update(input: UpdateAuthServiceAccountInput): Promise<ServiceAccountRecord>;
12
+ list(input: ListAuthServiceAccountsInput): Promise<ListAuthServiceAccountsResult>;
13
+ }
14
+ //# sourceMappingURL=service-accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-accounts.d.ts","sourceRoot":"","sources":["../../src/auth-storage/service-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAYpD,qBAAa,yBAA0B,YAAW,uBAAuB;IAC3D,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiD3E,OAAO,CAAC,MAAM,EAAE;QACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KACpB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAUlC,MAAM,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA2B3E,IAAI,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,6BAA6B,CAAC;CAwCxF"}
@@ -0,0 +1,55 @@
1
+ import type { AuthSessionAudience } from "@sixb/core";
2
+ import type { AuthSessionStore, CreateAuthSessionInput, SessionRecord } from "@sixb/core/storage";
3
+ import { type PgStoreClient } from "../transactions";
4
+ export declare class PgAuthSessionStore implements AuthSessionStore {
5
+ private readonly sql;
6
+ constructor(sql: PgStoreClient);
7
+ create(input: CreateAuthSessionInput): Promise<SessionRecord>;
8
+ getById(params: {
9
+ readonly projectId: string;
10
+ readonly id: string;
11
+ }): Promise<SessionRecord | null>;
12
+ getActiveByUserId(params: {
13
+ readonly projectId: string;
14
+ readonly userId: string;
15
+ readonly audience: AuthSessionAudience;
16
+ readonly now: Date;
17
+ }): Promise<SessionRecord | null>;
18
+ listActiveByUserId(params: {
19
+ readonly projectId: string;
20
+ readonly userId: string;
21
+ readonly now: Date;
22
+ }): Promise<readonly SessionRecord[]>;
23
+ findValidByTokenHash(params: {
24
+ readonly projectId: string;
25
+ readonly id: string;
26
+ readonly audience: AuthSessionAudience;
27
+ readonly tokenHash: string;
28
+ readonly now: Date;
29
+ }): Promise<SessionRecord | null>;
30
+ renewIfValid(params: {
31
+ readonly projectId: string;
32
+ readonly id: string;
33
+ readonly audience: AuthSessionAudience;
34
+ readonly tokenHash: string;
35
+ readonly now: Date;
36
+ readonly expiresAt: Date;
37
+ }): Promise<SessionRecord | null>;
38
+ revoke(params: {
39
+ readonly projectId: string;
40
+ readonly id: string;
41
+ readonly revokedAt: Date;
42
+ }): Promise<SessionRecord>;
43
+ revokeActiveForUser(params: {
44
+ readonly projectId: string;
45
+ readonly userId: string;
46
+ readonly audience?: AuthSessionAudience;
47
+ readonly revokedAt: Date;
48
+ }): Promise<readonly SessionRecord[]>;
49
+ touch(params: {
50
+ readonly projectId: string;
51
+ readonly id: string;
52
+ readonly lastSeenAt: Date;
53
+ }): Promise<SessionRecord>;
54
+ }
55
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/auth-storage/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEjG,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,iBAAiB,CAAA;AAWxB,qBAAa,kBAAmB,YAAW,gBAAgB;IAC7C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAA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CAAC,GAAG,EAAE,IAAI,CAAA;QAClB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;KACzB,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAwB3B,MAAM,CAAC,MAAM,EAAE;QACnB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;QACnB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;KACzB,GAAG,OAAO,CAAC,aAAa,CAAC;IAuBpB,mBAAmB,CAAC,MAAM,EAAE;QAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;QACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;QACvC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;KACzB,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC;IAW/B,KAAK,CAAC,MAAM,EAAE;QAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;QACnB,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAA;KAC1B,GAAG,OAAO,CAAC,aAAa,CAAC;CAe3B"}
@@ -0,0 +1,159 @@
1
+ import type { AuthSessionAudience, Principal } from "@sixb/core";
2
+ import type { CompleteAuthSessionInput, CreateAuthSessionInput, GroupMembershipRecord, InvitationRecord, MagicLinkRecord, OidcAuthorizationAttemptRecord, SessionRecord, UpsertAuthGroupMembershipInput, UserRecord } from "@sixb/core/storage";
3
+ import type { SQLClient } from "../pg-client";
4
+ import type { PgAuthMagicLinkRow, PgAuthOidcAttemptRow, PgAuthSessionRow, PgAuthUserIdentityRow, PgAuthUserRow } from "./rows";
5
+ import { rowToSessionRecord } from "./rows";
6
+ export type PgValue = string | number | Date | null;
7
+ export declare function assertNonEmpty(value: string, label: string): string;
8
+ export declare function normalizeEmail(email: string): string;
9
+ export declare function normalizeGroupIds(groupIds: readonly string[] | undefined): readonly string[];
10
+ export declare function dateOrNow(value: Date | undefined): Date;
11
+ export declare function hasEmptyFilter(values: readonly unknown[] | undefined): boolean;
12
+ export declare function appendPagination(query: string, params: PgValue[], nextIndex: number, input: {
13
+ readonly limit?: number;
14
+ readonly offset?: number;
15
+ }): string;
16
+ export declare function placeholders(startIndex: number, count: number): readonly string[];
17
+ export declare function getUserRowById(sql: SQLClient, params: {
18
+ readonly projectId: string;
19
+ readonly id: string;
20
+ }, options?: {
21
+ readonly forUpdate?: boolean;
22
+ }): Promise<PgAuthUserRow | null>;
23
+ export declare function getUserById(sql: SQLClient, params: {
24
+ readonly projectId: string;
25
+ readonly id: string;
26
+ }): Promise<UserRecord | null>;
27
+ export declare function getUserRowByEmail(sql: SQLClient, params: {
28
+ readonly projectId: string;
29
+ readonly email: string;
30
+ }, options?: {
31
+ readonly forUpdate?: boolean;
32
+ }): Promise<PgAuthUserRow | null>;
33
+ export declare function getUserByEmail(sql: SQLClient, params: {
34
+ readonly projectId: string;
35
+ readonly email: string;
36
+ }): Promise<UserRecord | null>;
37
+ export declare function requireUserById(sql: SQLClient, params: {
38
+ readonly projectId: string;
39
+ readonly id: string;
40
+ }): Promise<UserRecord>;
41
+ export declare function getIdentityRowBySubject(sql: SQLClient, params: {
42
+ readonly projectId: string;
43
+ readonly strategyId: string;
44
+ readonly subject: string;
45
+ }, options?: {
46
+ readonly forUpdate?: boolean;
47
+ }): Promise<PgAuthUserIdentityRow | null>;
48
+ export declare function getSessionRowById(sql: SQLClient, params: {
49
+ readonly projectId: string;
50
+ readonly id: string;
51
+ }, options?: {
52
+ readonly forUpdate?: boolean;
53
+ }): Promise<PgAuthSessionRow | null>;
54
+ export declare function getSessionById(sql: SQLClient, params: {
55
+ readonly projectId: string;
56
+ readonly id: string;
57
+ }): Promise<ReturnType<typeof rowToSessionRecord> | null>;
58
+ export declare function requireSessionById(sql: SQLClient, params: {
59
+ readonly projectId: string;
60
+ readonly id: string;
61
+ }): Promise<ReturnType<typeof rowToSessionRecord>>;
62
+ export declare function getInvitationGroupIds(sql: SQLClient, params: {
63
+ readonly projectId: string;
64
+ readonly invitationId: string;
65
+ }): Promise<readonly string[]>;
66
+ export declare function getInvitationById(sql: SQLClient, params: {
67
+ readonly projectId: string;
68
+ readonly id: string;
69
+ }, options?: {
70
+ readonly forUpdate?: boolean;
71
+ }): Promise<InvitationRecord | null>;
72
+ export declare function requireInvitationById(sql: SQLClient, params: {
73
+ readonly projectId: string;
74
+ readonly id: string;
75
+ }, options?: {
76
+ readonly forUpdate?: boolean;
77
+ }): Promise<InvitationRecord>;
78
+ export declare function getActiveInvitationByEmail(sql: SQLClient, params: {
79
+ readonly projectId: string;
80
+ readonly email: string;
81
+ readonly now: Date;
82
+ }, options?: {
83
+ readonly forUpdate?: boolean;
84
+ }): Promise<InvitationRecord | null>;
85
+ export declare function replaceInvitationGroups(sql: SQLClient, params: {
86
+ readonly projectId: string;
87
+ readonly invitationId: string;
88
+ readonly groupIds: readonly string[];
89
+ }): Promise<void>;
90
+ export declare function getMagicLinkRowById(sql: SQLClient, params: {
91
+ readonly projectId: string;
92
+ readonly id: string;
93
+ }, options?: {
94
+ readonly forUpdate?: boolean;
95
+ }): Promise<PgAuthMagicLinkRow | null>;
96
+ export declare function getMagicLinkById(sql: SQLClient, params: {
97
+ readonly projectId: string;
98
+ readonly id: string;
99
+ }): Promise<MagicLinkRecord | null>;
100
+ export declare function consumeMagicLink(sql: SQLClient, params: {
101
+ readonly projectId: string;
102
+ readonly id: string;
103
+ readonly tokenHash: string;
104
+ readonly consumedAt: Date;
105
+ }): Promise<MagicLinkRecord>;
106
+ export declare function getOidcAttemptRowById(sql: SQLClient, params: {
107
+ readonly projectId: string;
108
+ readonly id: string;
109
+ }, options?: {
110
+ readonly forUpdate?: boolean;
111
+ }): Promise<PgAuthOidcAttemptRow | null>;
112
+ export declare function getOidcAttemptById(sql: SQLClient, params: {
113
+ readonly projectId: string;
114
+ readonly id: string;
115
+ }): Promise<OidcAuthorizationAttemptRecord | null>;
116
+ export declare function consumeOidcAttempt(sql: SQLClient, params: {
117
+ readonly projectId: string;
118
+ readonly id: string;
119
+ readonly stateHash: string;
120
+ readonly consumedAt: Date;
121
+ }): Promise<OidcAuthorizationAttemptRecord>;
122
+ export declare function validateCompleteSessionInput(sql: SQLClient, projectId: string, session: CompleteAuthSessionInput): Promise<void>;
123
+ export declare function assertSessionIdAvailable(sql: SQLClient, projectId: string, sessionId: string): Promise<void>;
124
+ export declare function createSession(sql: SQLClient, input: CreateAuthSessionInput): Promise<SessionRecord>;
125
+ export declare function revokeActiveSessionsForUser(sql: SQLClient, params: {
126
+ readonly projectId: string;
127
+ readonly userId: string;
128
+ readonly audience?: AuthSessionAudience;
129
+ readonly revokedAt: Date;
130
+ }): Promise<readonly SessionRecord[]>;
131
+ export declare function upsertGroupMembership(sql: SQLClient, input: UpsertAuthGroupMembershipInput): Promise<GroupMembershipRecord>;
132
+ export declare function removeGroupMembership(sql: SQLClient, params: {
133
+ readonly projectId: string;
134
+ readonly userId: string;
135
+ readonly groupId: string;
136
+ }): Promise<GroupMembershipRecord | null>;
137
+ export declare function getGroupMembership(sql: SQLClient, params: {
138
+ readonly projectId: string;
139
+ readonly userId: string;
140
+ readonly groupId: string;
141
+ }): Promise<GroupMembershipRecord | null>;
142
+ export declare function listMembershipsForUser(sql: SQLClient, params: {
143
+ readonly projectId: string;
144
+ readonly userId: string;
145
+ }): Promise<readonly GroupMembershipRecord[]>;
146
+ export declare function revokeActiveMagicLinksForEmail(sql: SQLClient, params: {
147
+ readonly projectId: string;
148
+ readonly email: string;
149
+ readonly revokedAt: Date;
150
+ }): Promise<readonly MagicLinkRecord[]>;
151
+ export declare function invitationCreatorColumns(principal: Principal | undefined): {
152
+ readonly createdByUserId: string | null;
153
+ readonly createdByServiceAccountId: string | null;
154
+ readonly createdBySystemId: string | null;
155
+ };
156
+ export declare function assertMagicLinkUsable(projectId: string, id: string, tokenHash: string, at: Date, row: PgAuthMagicLinkRow): void;
157
+ export declare function assertOidcAttemptUsable(projectId: string, id: string, stateHash: string, at: Date, row: PgAuthOidcAttemptRow): void;
158
+ export declare function mapUniqueConstraintError(error: unknown, code: "duplicate_access_token" | "duplicate_identity" | "duplicate_invitation" | "duplicate_magic_link" | "duplicate_oidc_attempt" | "duplicate_service_account" | "duplicate_session" | "duplicate_user", message: string): never;
159
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/auth-storage/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,8BAA8B,EAC9B,aAAa,EACb,8BAA8B,EAC9B,UAAU,EACX,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAGV,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACd,MAAM,QAAQ,CAAA;AACf,OAAO,EAKL,kBAAkB,EAEnB,MAAM,QAAQ,CAAA;AAEf,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;AAEnD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMnE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,CAE5F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI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QAAQ,CAAC,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAA;IACjD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1C,CAMA;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,IAAI,EACR,GAAG,EAAE,kBAAkB,GACtB,IAAI,CAcN;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,IAAI,EACR,GAAG,EAAE,oBAAoB,GACxB,IAAI,CAcN;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,IAAI,EACA,wBAAwB,GACxB,oBAAoB,GACpB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,2BAA2B,GAC3B,mBAAmB,GACnB,gBAAgB,EACpB,OAAO,EAAE,MAAM,GACd,KAAK,CAMP"}
@@ -0,0 +1,19 @@
1
+ import type { AuthUserStore, CreateAuthUserInput, ListAuthUsersInput, ListAuthUsersResult, UpdateAuthUserProfileInput, UpdateAuthUserStatusInput, UserRecord } from "@sixb/core/storage";
2
+ import type { PgStoreClient } from "../transactions";
3
+ export declare class PgAuthUserStore implements AuthUserStore {
4
+ private readonly sql;
5
+ constructor(sql: PgStoreClient);
6
+ create(input: CreateAuthUserInput): Promise<UserRecord>;
7
+ getById(params: {
8
+ readonly projectId: string;
9
+ readonly id: string;
10
+ }): Promise<UserRecord | null>;
11
+ getByEmail(params: {
12
+ readonly projectId: string;
13
+ readonly email: string;
14
+ }): Promise<UserRecord | null>;
15
+ updateProfile(input: UpdateAuthUserProfileInput): Promise<UserRecord>;
16
+ updateStatus(input: UpdateAuthUserStatusInput): Promise<UserRecord>;
17
+ list(input: ListAuthUsersInput): Promise<ListAuthUsersResult>;
18
+ }
19
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/auth-storage/users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,yBAAyB,EACzB,UAAU,EACX,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAepD,qBAAa,eAAgB,YAAW,aAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAwDvD,OAAO,CAAC,MAAM,EAAE;QACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KACpB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAKxB,UAAU,CAAC,MAAM,EAAE;QACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KACvB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAKxB,aAAa,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,UAAU,CAAC;IA2BrE,YAAY,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC;IA0BnE,IAAI,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA0CpE"}
@@ -0,0 +1,127 @@
1
+ import type { MigrationCapableStorage, Storage, StorageMigrator, StorageTransactionOptions } from "@sixb/core";
2
+ import { type ObjectStorage } from "@sixb/core/storage";
3
+ import { PgAgentStorage } from "./agents";
4
+ import { PgAuthStorage } from "./auth-storage";
5
+ import { PgOntologyStorage } from "./ontology-storage";
6
+ import { PgActionRunStorage } from "./pg-action-run-storage";
7
+ import { PgPipelineRunStorage } from "./pg-pipeline-run-storage";
8
+ import { PgProjectionRunStorage } from "./pg-projection-run-storage";
9
+ import { PgRulesStorage } from "./pg-rules-storage";
10
+ import { PgSyncRunStorage } from "./pg-sync-run-storage";
11
+ import { PgWebhookDeliveryStorage } from "./pg-webhook-delivery-storage";
12
+ import { PgWebhookRunStorage } from "./pg-webhook-run-storage";
13
+ import { PgWorkflowInterventionStorage } from "./pg-workflow-intervention-storage";
14
+ import { PgWorkflowRunStorage } from "./pg-workflow-run-storage";
15
+ export interface PostgresStorageOptions {
16
+ /** Full connection string (e.g. DATABASE_URL). Takes precedence over individual fields. */
17
+ connectionString?: string;
18
+ /** PostgreSQL host. Defaults to 'localhost'. */
19
+ host?: string;
20
+ /** PostgreSQL port. Defaults to 5432. */
21
+ port?: number;
22
+ /** Database name. */
23
+ database?: string;
24
+ /** Database user. */
25
+ user?: string;
26
+ /** Database password. */
27
+ password?: string;
28
+ /** Maximum number of connections in the pool. Defaults to 10. */
29
+ max?: number;
30
+ /** Idle connection timeout in milliseconds. Defaults to 30000. */
31
+ idleTimeoutMillis?: number;
32
+ /**
33
+ * Server-side `statement_timeout` (ms) applied to every connection in the pool. A query
34
+ * exceeding it is cancelled by PostgreSQL, which frees its pooled connection instead of
35
+ * pinning it indefinitely. Without this, a single stalled query can starve a small pool
36
+ * until the process is restarted. Unset by default (no timeout). Set per role — keep it
37
+ * generous or unset for workers that run long migrations/bulk writes.
38
+ */
39
+ statementTimeoutMillis?: number;
40
+ /**
41
+ * Server-side `idle_in_transaction_session_timeout` (ms) applied to every connection. A
42
+ * transaction left open and idle beyond it is aborted by PostgreSQL, releasing the
43
+ * connection. Unset by default (no timeout).
44
+ */
45
+ idleInTransactionSessionTimeoutMillis?: number;
46
+ /**
47
+ * Grace period (ms) for {@link PostgresStorage.close}. On shutdown the pool stops
48
+ * accepting new queries and waits up to this long for in-flight queries to finish before
49
+ * destroying the connections, so a restart drains cleanly instead of severing live work.
50
+ * Defaults to 5000.
51
+ */
52
+ shutdownTimeoutMillis?: number;
53
+ /** Seconds to wait when establishing a connection. Defaults to 10000. */
54
+ connectTimeoutMillis?: number;
55
+ /**
56
+ * Whether to use server-side prepared statements (porsager's default, faster against a
57
+ * direct Postgres connection). Behind PgBouncer transaction mode they require PgBouncer
58
+ * >= 1.21 with `max_prepared_statements > 0`; set `false` for an older PgBouncer or when
59
+ * that setting is 0. Defaults to `true`.
60
+ */
61
+ prepare?: boolean;
62
+ /** PostgreSQL schema name for all Sixb tables. Defaults to 'sixb'. */
63
+ schemaName?: string;
64
+ /** SSL configuration. */
65
+ ssl?: boolean | "require" | "prefer";
66
+ }
67
+ /**
68
+ * PostgreSQL storage provider for Sixb.
69
+ *
70
+ * Bundles Sixb storage adapters backed by a shared PostgreSQL connection pool (porsager
71
+ * `postgres`), which reliably reclaims connections under load.
72
+ *
73
+ * The storage exposes a core `StorageMigrator`. Sixb CLI startup and
74
+ * `sixb db migrate` run it automatically through `migrateStorage(storage)`.
75
+ *
76
+ * Usage:
77
+ * ```ts
78
+ * const pg = new PostgresStorage({
79
+ * connectionString: process.env.DATABASE_URL!,
80
+ * })
81
+ *
82
+ * export const sixb = createSixb({
83
+ * broker: myBroker,
84
+ * storage: pg,
85
+ * })
86
+ * ```
87
+ */
88
+ export declare class PostgresStorage implements MigrationCapableStorage {
89
+ readonly objects: ObjectStorage;
90
+ readonly ontology: PgOntologyStorage;
91
+ readonly auth: PgAuthStorage;
92
+ readonly agents: PgAgentStorage;
93
+ readonly actionRuns: PgActionRunStorage;
94
+ readonly pipelineRuns: PgPipelineRunStorage;
95
+ readonly workflowRuns: PgWorkflowRunStorage;
96
+ readonly workflowInterventions: PgWorkflowInterventionStorage;
97
+ readonly syncRuns: PgSyncRunStorage;
98
+ readonly projectionRuns: PgProjectionRunStorage;
99
+ readonly timeseries: Storage["timeseries"];
100
+ readonly webhookDeliveries: PgWebhookDeliveryStorage;
101
+ readonly webhookRuns: PgWebhookRunStorage;
102
+ readonly rules: PgRulesStorage;
103
+ readonly migrators: readonly StorageMigrator[];
104
+ private readonly sql;
105
+ private readonly schemaName;
106
+ private readonly shutdownTimeoutSeconds;
107
+ private readonly transactionScope;
108
+ constructor(options: PostgresStorageOptions);
109
+ ping(): Promise<void>;
110
+ transaction<T>(run: (tx: Storage) => Promise<T> | T, options?: StorageTransactionOptions): Promise<T>;
111
+ private assertRootOperationAvailable;
112
+ /**
113
+ * Close the connection pool. Should be called on shutdown.
114
+ *
115
+ * Stops accepting new queries and waits up to `shutdownTimeoutMillis` for in-flight
116
+ * queries to finish before destroying connections.
117
+ */
118
+ close(): Promise<void>;
119
+ /**
120
+ * Drop all Sixb tables and schema. Useful for test cleanup.
121
+ * WARNING: This permanently deletes all data.
122
+ */
123
+ dropSchema(): Promise<void>;
124
+ private createTransactionStorage;
125
+ }
126
+ export { migratePostgresStorage } from "./migrations";
127
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,uBAAuB,EACvB,OAAO,EACP,eAAe,EACf,yBAAyB,EAC1B,MAAM,YAAY,CAAA;AAUnB,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,EAAE,iBAAiB,EAAqC,MAAM,oBAAoB,CAAA;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EA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