@superblocksteam/shared 0.9619.8 → 0.9620.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.
Files changed (197) hide show
  1. package/dist/bindings/utils.js +1 -1
  2. package/dist/bindings/utils.js.map +1 -1
  3. package/dist/constants.d.ts +12 -8
  4. package/dist/constants.d.ts.map +1 -1
  5. package/dist/constants.js +10 -8
  6. package/dist/constants.js.map +1 -1
  7. package/dist/database-lifecycle/appDatabaseImport.d.ts +16 -0
  8. package/dist/database-lifecycle/appDatabaseImport.d.ts.map +1 -1
  9. package/dist/database-lifecycle/appDatabaseImport.js.map +1 -1
  10. package/dist/database-lifecycle/appDatabaseStatus.d.ts +12 -2
  11. package/dist/database-lifecycle/appDatabaseStatus.d.ts.map +1 -1
  12. package/dist/database-lifecycle/appDatabaseStatus.js +8 -2
  13. package/dist/database-lifecycle/appDatabaseStatus.js.map +1 -1
  14. package/dist/database-lifecycle/appDatabaseStatus.test.js +2 -0
  15. package/dist/database-lifecycle/appDatabaseStatus.test.js.map +1 -1
  16. package/dist/database-lifecycle/dataImport.d.ts +3 -0
  17. package/dist/database-lifecycle/dataImport.d.ts.map +1 -1
  18. package/dist/database-lifecycle/dataImport.js.map +1 -1
  19. package/dist/database-lifecycle/importCompatibility.d.ts +13 -0
  20. package/dist/database-lifecycle/importCompatibility.d.ts.map +1 -1
  21. package/dist/database-lifecycle/importCompatibility.js +33 -0
  22. package/dist/database-lifecycle/importCompatibility.js.map +1 -1
  23. package/dist/database-lifecycle/importCompatibility.test.js +47 -1
  24. package/dist/database-lifecycle/importCompatibility.test.js.map +1 -1
  25. package/dist/database-lifecycle/index.d.ts +5 -1
  26. package/dist/database-lifecycle/index.d.ts.map +1 -1
  27. package/dist/database-lifecycle/index.js +4 -0
  28. package/dist/database-lifecycle/index.js.map +1 -1
  29. package/dist/errors/integration.js +1 -1
  30. package/dist/errors/integration.js.map +1 -1
  31. package/dist/headers.d.ts +9 -0
  32. package/dist/headers.d.ts.map +1 -0
  33. package/dist/headers.js +12 -0
  34. package/dist/headers.js.map +1 -0
  35. package/dist/jwt/verifier.js +1 -1
  36. package/dist/jwt/verifier.js.map +1 -1
  37. package/dist/observability/index.d.ts +1 -0
  38. package/dist/observability/index.d.ts.map +1 -1
  39. package/dist/observability/index.js +1 -0
  40. package/dist/observability/index.js.map +1 -1
  41. package/dist/package.json +1 -1
  42. package/dist/pageMigrations/migrations/v5to6.d.ts.map +1 -1
  43. package/dist/pageMigrations/migrations/v5to6.js +6 -1
  44. package/dist/pageMigrations/migrations/v5to6.js.map +1 -1
  45. package/dist/pageMigrations/migrations/v6to7/adjustModalCanvases.js +1 -1
  46. package/dist/pageMigrations/migrations/v6to7/adjustModalCanvases.js.map +1 -1
  47. package/dist/pageMigrations/migrations/v6to7/migrateToDimensions.js +1 -1
  48. package/dist/pageMigrations/migrations/v6to7/migrateToDimensions.js.map +1 -1
  49. package/dist/pageMigrations/migrations/v7to8.d.ts.map +1 -1
  50. package/dist/pageMigrations/migrations/v7to8.js +2 -1
  51. package/dist/pageMigrations/migrations/v7to8.js.map +1 -1
  52. package/dist/pages/pageV8.js +1 -1
  53. package/dist/pages/pageV8.js.map +1 -1
  54. package/dist/plugins/index.d.ts +1 -0
  55. package/dist/plugins/index.d.ts.map +1 -1
  56. package/dist/plugins/index.js +1 -0
  57. package/dist/plugins/index.js.map +1 -1
  58. package/dist/plugins/templates/shared/openapi.js +1 -1
  59. package/dist/plugins/templates/shared/openapi.js.map +1 -1
  60. package/dist/plugins/unsupported-integration-types.d.ts +10 -0
  61. package/dist/plugins/unsupported-integration-types.d.ts.map +1 -0
  62. package/dist/plugins/unsupported-integration-types.js +29 -0
  63. package/dist/plugins/unsupported-integration-types.js.map +1 -0
  64. package/dist/refactoring/application.d.ts.map +1 -1
  65. package/dist/refactoring/application.js +2 -1
  66. package/dist/refactoring/application.js.map +1 -1
  67. package/dist/refactoring/refactor.d.ts.map +1 -1
  68. package/dist/refactoring/refactor.js +4 -1
  69. package/dist/refactoring/refactor.js.map +1 -1
  70. package/dist/refactoring/rename.js +1 -1
  71. package/dist/refactoring/rename.js.map +1 -1
  72. package/dist/refactoring/updates.d.ts.map +1 -1
  73. package/dist/refactoring/updates.js +3 -1
  74. package/dist/refactoring/updates.js.map +1 -1
  75. package/dist/signing/index.js +1 -1
  76. package/dist/signing/index.js.map +1 -1
  77. package/dist/socket/dist-entry.test.js +10 -2
  78. package/dist/socket/dist-entry.test.js.map +1 -1
  79. package/dist/socket/protocol.d.ts +21 -0
  80. package/dist/socket/protocol.d.ts.map +1 -1
  81. package/dist/types/ai/builder-caller.d.ts +16 -0
  82. package/dist/types/ai/builder-caller.d.ts.map +1 -0
  83. package/dist/types/ai/builder-caller.js +64 -0
  84. package/dist/types/ai/builder-caller.js.map +1 -0
  85. package/dist/types/ai/builder-caller.test.d.ts +2 -0
  86. package/dist/types/ai/builder-caller.test.d.ts.map +1 -0
  87. package/dist/types/ai/builder-caller.test.js +40 -0
  88. package/dist/types/ai/builder-caller.test.js.map +1 -0
  89. package/dist/types/ai/index.d.ts +10 -0
  90. package/dist/types/ai/index.d.ts.map +1 -1
  91. package/dist/types/ai/index.js +2 -0
  92. package/dist/types/ai/index.js.map +1 -1
  93. package/dist/types/api/execution.d.ts.map +1 -1
  94. package/dist/types/api/execution.js +4 -1
  95. package/dist/types/api/execution.js.map +1 -1
  96. package/dist/types/api/global.js +1 -1
  97. package/dist/types/api/global.js.map +1 -1
  98. package/dist/types/application/index.d.ts +2 -0
  99. package/dist/types/application/index.d.ts.map +1 -1
  100. package/dist/types/application/index.js.map +1 -1
  101. package/dist/types/branch/index.d.ts +76 -0
  102. package/dist/types/branch/index.d.ts.map +1 -1
  103. package/dist/types/common/response.d.ts +3 -0
  104. package/dist/types/common/response.d.ts.map +1 -1
  105. package/dist/types/common/response.js +2 -0
  106. package/dist/types/common/response.js.map +1 -1
  107. package/dist/types/datasource/auth.js +1 -1
  108. package/dist/types/datasource/auth.js.map +1 -1
  109. package/dist/types/event/index.d.ts +1 -0
  110. package/dist/types/event/index.d.ts.map +1 -1
  111. package/dist/types/event/index.js +1 -0
  112. package/dist/types/event/index.js.map +1 -1
  113. package/dist/types/page/event.d.ts.map +1 -1
  114. package/dist/types/page/event.js +2 -1
  115. package/dist/types/page/event.js.map +1 -1
  116. package/dist/types/plugin/evaluation.d.ts.map +1 -1
  117. package/dist/types/plugin/evaluation.js +3 -1
  118. package/dist/types/plugin/evaluation.js.map +1 -1
  119. package/dist/utils/attachment-validation.d.ts.map +1 -1
  120. package/dist/utils/attachment-validation.js +5 -4
  121. package/dist/utils/attachment-validation.js.map +1 -1
  122. package/dist/utils/bytestring.d.ts.map +1 -1
  123. package/dist/utils/bytestring.js +4 -3
  124. package/dist/utils/bytestring.js.map +1 -1
  125. package/dist/utils/bytestring.test.d.ts +2 -0
  126. package/dist/utils/bytestring.test.d.ts.map +1 -0
  127. package/dist/utils/bytestring.test.js +23 -0
  128. package/dist/utils/bytestring.test.js.map +1 -0
  129. package/dist/utils/configuration.d.ts.map +1 -1
  130. package/dist/utils/configuration.js +3 -1
  131. package/dist/utils/configuration.js.map +1 -1
  132. package/dist/utils/index.d.ts +1 -0
  133. package/dist/utils/index.d.ts.map +1 -1
  134. package/dist/utils/index.js +1 -0
  135. package/dist/utils/index.js.map +1 -1
  136. package/dist/utils/openApiSpecRef.d.ts +3 -0
  137. package/dist/utils/openApiSpecRef.d.ts.map +1 -0
  138. package/dist/utils/openApiSpecRef.js +27 -0
  139. package/dist/utils/openApiSpecRef.js.map +1 -0
  140. package/dist/utils/openApiSpecRef.test.d.ts +2 -0
  141. package/dist/utils/openApiSpecRef.test.d.ts.map +1 -0
  142. package/dist/utils/openApiSpecRef.test.js +16 -0
  143. package/dist/utils/openApiSpecRef.test.js.map +1 -0
  144. package/dist/utils/page.js +1 -1
  145. package/dist/utils/page.js.map +1 -1
  146. package/dist/utils/url.js +1 -1
  147. package/dist/utils/url.js.map +1 -1
  148. package/package.json +16 -16
  149. package/src/bindings/utils.ts +1 -1
  150. package/src/constants.ts +14 -8
  151. package/src/database-lifecycle/appDatabaseImport.ts +34 -0
  152. package/src/database-lifecycle/appDatabaseStatus.test.ts +2 -0
  153. package/src/database-lifecycle/appDatabaseStatus.ts +19 -3
  154. package/src/database-lifecycle/dataImport.ts +6 -0
  155. package/src/database-lifecycle/importCompatibility.test.ts +60 -1
  156. package/src/database-lifecycle/importCompatibility.ts +52 -0
  157. package/src/database-lifecycle/index.ts +6 -0
  158. package/src/errors/integration.ts +1 -1
  159. package/src/headers.ts +11 -0
  160. package/src/jwt/verifier.ts +1 -1
  161. package/src/observability/index.ts +1 -0
  162. package/src/pageMigrations/migrations/v5to6.ts +6 -1
  163. package/src/pageMigrations/migrations/v6to7/adjustModalCanvases.ts +1 -1
  164. package/src/pageMigrations/migrations/v6to7/migrateToDimensions.ts +1 -1
  165. package/src/pageMigrations/migrations/v7to8.ts +2 -1
  166. package/src/pages/pageV8.ts +1 -1
  167. package/src/plugins/index.ts +1 -0
  168. package/src/plugins/templates/shared/openapi.ts +1 -1
  169. package/src/plugins/unsupported-integration-types.ts +30 -0
  170. package/src/refactoring/application.ts +2 -1
  171. package/src/refactoring/refactor.ts +4 -1
  172. package/src/refactoring/rename.ts +1 -1
  173. package/src/refactoring/updates.ts +3 -1
  174. package/src/signing/index.ts +1 -1
  175. package/src/socket/dist-entry.test.ts +14 -2
  176. package/src/socket/protocol.ts +12 -0
  177. package/src/types/ai/builder-caller.test.ts +45 -0
  178. package/src/types/ai/builder-caller.ts +63 -0
  179. package/src/types/ai/index.ts +11 -0
  180. package/src/types/api/execution.ts +4 -1
  181. package/src/types/api/global.ts +1 -1
  182. package/src/types/application/index.ts +2 -0
  183. package/src/types/branch/index.ts +74 -0
  184. package/src/types/common/response.ts +3 -0
  185. package/src/types/datasource/auth.ts +1 -1
  186. package/src/types/event/index.ts +1 -0
  187. package/src/types/page/event.ts +2 -1
  188. package/src/types/plugin/evaluation.ts +3 -1
  189. package/src/utils/attachment-validation.ts +8 -4
  190. package/src/utils/bytestring.test.ts +31 -0
  191. package/src/utils/bytestring.ts +6 -3
  192. package/src/utils/configuration.ts +3 -1
  193. package/src/utils/index.ts +1 -0
  194. package/src/utils/openApiSpecRef.test.ts +20 -0
  195. package/src/utils/openApiSpecRef.ts +30 -0
  196. package/src/utils/page.ts +1 -1
  197. package/src/utils/url.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  import { ViewMode } from '../types/event/index.js';
2
2
  import type { AppDatabaseTagRef } from './appDatabaseCompatibility.js';
3
- import type { AppDatabaseImportTagSupport } from './importCompatibility.js';
3
+ import type { AppDatabaseDumpSupport, AppDatabaseImportTagSupport } from './importCompatibility.js';
4
4
  import type { DatabaseEngine, LifecycleMigrationState, LifecycleState } from './index.js';
5
5
 
6
6
  /**
@@ -23,7 +23,12 @@ export type AppDatabaseStatusIntegration = {
23
23
 
24
24
  // These rewrite or remove the whole database. A CSV import into any table on
25
25
  // that binding has to wait until the lifecycle request leaves these states.
26
- export const DATABASE_WIDE_LIFECYCLE_OPERATIONS = ['migrate_schema', 'restore_import_data', 'retire_database'] as const;
26
+ export const DATABASE_WIDE_LIFECYCLE_OPERATIONS = [
27
+ 'migrate_schema',
28
+ 'restore_import_data',
29
+ 'restore_integration_pg_dump',
30
+ 'retire_database'
31
+ ] as const;
27
32
  export type DatabaseWideLifecycleOperation = (typeof DATABASE_WIDE_LIFECYCLE_OPERATIONS)[number];
28
33
 
29
34
  export const TABLE_IMPORT_IN_PROGRESS_REASON = 'A table import is running on this database.';
@@ -33,13 +38,14 @@ export function databaseWideOperationBlockReason(operation: DatabaseWideLifecycl
33
38
  case 'migrate_schema':
34
39
  return 'A schema migration is running on this database.';
35
40
  case 'restore_import_data':
41
+ case 'restore_integration_pg_dump':
36
42
  return 'A database restore is running on this data tag.';
37
43
  case 'retire_database':
38
44
  return 'This database is being removed.';
39
45
  }
40
46
  }
41
47
 
42
- const BLOCKING_OPERATION_PRIORITY = ['retire_database', 'migrate_schema', 'restore_import_data'] as const;
48
+ const BLOCKING_OPERATION_PRIORITY = ['retire_database', 'migrate_schema', 'restore_import_data', 'restore_integration_pg_dump'] as const;
43
49
 
44
50
  export function preferredBlockingDatabaseOperation(operations: readonly string[]): DatabaseWideLifecycleOperation | undefined {
45
51
  return BLOCKING_OPERATION_PRIORITY.find((operation) => operations.includes(operation));
@@ -74,6 +80,7 @@ export type AppDatabaseStatusTag = AppDatabaseTagRef & {
74
80
  * the server from connected-agent registrations, not from a browser probe.
75
81
  */
76
82
  csvImport?: AppDatabaseImportTagSupport;
83
+ dumpImport?: AppDatabaseDumpSupport;
77
84
  /**
78
85
  * True when this data tag had a database that was retired. The live
79
86
  * binding is omitted so the tag can be provisioned again, but Status
@@ -104,8 +111,17 @@ export type AppDatabaseStatus = {
104
111
  * requirement. Working-state (Edit) rows are not this signal: a leftover
105
112
  * production database stays undeletable until a version without databases
106
113
  * is live.
114
+ *
115
+ * Also true when the deployed commit id is not a UUID (a git SHA from a CLI
116
+ * push): deploy cannot stamp a requirement for those commits, so whether the
117
+ * live version needs a database cannot be determined, and this reports true
118
+ * to keep production database retirement blocked. This is a stopgap, not a
119
+ * fact about the app; remove it once requirements are recorded for git SHA
120
+ * commits.
107
121
  */
108
122
  liveVersionHasAppDatabase: boolean;
123
+ /** False when the caller edits a user branch: every branch shares one database, so only the default branch migrates or retires it. */
124
+ onDefaultBranch?: boolean;
109
125
  tags: AppDatabaseStatusTag[];
110
126
  };
111
127
 
@@ -1,3 +1,5 @@
1
+ import type { AppDatabaseImportSchemaDifferences } from './appDatabaseImport.js';
2
+
1
3
  export const DATA_IMPORT_KINDS = ['csv', 'pg_dump_custom'] as const;
2
4
  // CHECK union for every kind. Prefix/schema success is `schema_validated`.
3
5
  // `ready` stays available for CSV/JSON "validated, waiting to apply".
@@ -48,6 +50,9 @@ export type DataImportTarget = AppDatabaseDataImportTarget;
48
50
  export type DataImportUploadMetadata = {
49
51
  completedPartNumbers?: number[];
50
52
  filename: string;
53
+ // When the current multipart part URLs stop working (ms since epoch).
54
+ // The expiry only, never the signed URLs themselves.
55
+ partUrlsExpireAt?: number;
51
56
  prefixExpiresAt?: number;
52
57
  // Browser handoff for the current prefix. Cleared when that step ends.
53
58
  prefixUploadHeaders?: Record<string, string>;
@@ -74,6 +79,7 @@ export type PgDumpDataImportMetadata = {
74
79
  prefixChecksumSha256?: string;
75
80
  prefixObjectKey?: string;
76
81
  requestedPrefixSizeBytes?: number;
82
+ schemaDifferences?: AppDatabaseImportSchemaDifferences;
77
83
  source?: {
78
84
  integrationConfigurationId: string;
79
85
  integrationId: string;
@@ -1,7 +1,13 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
3
  import { AgentStatus } from '../types/organization/agent.js';
4
- import { DATABASE_LIFECYCLE_TAG_IMPORT_TRANSFORMS, evaluateAppDatabaseImportTag } from './importCompatibility.js';
4
+ import {
5
+ APP_DATABASE_DUMP_FILE_OPERATIONS,
6
+ APP_DATABASE_DUMP_INTEGRATION_OPERATIONS,
7
+ evaluateAppDatabaseDumpTag,
8
+ DATABASE_LIFECYCLE_TAG_IMPORT_TRANSFORMS,
9
+ evaluateAppDatabaseImportTag
10
+ } from './importCompatibility.js';
5
11
 
6
12
  const IMPORT_OPERATIONS = ['complete_import_upload', 'describe_schema', 'import_table_data', 'prepare_import_upload'];
7
13
 
@@ -144,3 +150,56 @@ describe('evaluateAppDatabaseImportTag', () => {
144
150
  ).toBe('temporarily_unavailable');
145
151
  });
146
152
  });
153
+
154
+ describe('pg_dump capability preflight', () => {
155
+ const worker = (operations: readonly string[]) => ({
156
+ status: AgentStatus.ACTIVE,
157
+ tags: {
158
+ 'databaseLifecycle:agentName': ['owner'],
159
+ 'databaseLifecycle:engines': ['postgres'],
160
+ 'databaseLifecycle:capabilities': ['managed-IAM-v1'],
161
+ 'databaseLifecycle:operations': [...operations],
162
+ profile: ['production']
163
+ }
164
+ });
165
+ const check = (agents: ReturnType<typeof worker>[], source: 'file' | 'integration' = 'file') =>
166
+ evaluateAppDatabaseDumpTag({ agents, agentName: 'owner', profileKey: 'production', source });
167
+ it.each(APP_DATABASE_DUMP_FILE_OPERATIONS)('rejects a file import missing %s', (operation) => {
168
+ expect(check([worker(APP_DATABASE_DUMP_FILE_OPERATIONS.filter((value) => value !== operation))])).toMatchObject({
169
+ supportState: 'unsupported',
170
+ missingOperations: [operation]
171
+ });
172
+ });
173
+ it('accepts file restore without CSV transforms or integration capture', () => {
174
+ expect(check([worker(APP_DATABASE_DUMP_FILE_OPERATIONS)])).toMatchObject({ supportState: 'supported', reason: '' });
175
+ });
176
+ it('checks integration capture separately', () => {
177
+ expect(check([worker(APP_DATABASE_DUMP_INTEGRATION_OPERATIONS)], 'integration').supportState).toBe('supported');
178
+ expect(check([worker(APP_DATABASE_DUMP_FILE_OPERATIONS)], 'integration').supportState).toBe('unsupported');
179
+ });
180
+ it('does not borrow capabilities from another owner or profile', () => {
181
+ const other = worker(APP_DATABASE_DUMP_FILE_OPERATIONS);
182
+ other.tags['databaseLifecycle:agentName'] = ['other'];
183
+ expect(check([other]).supportState).toBe('temporarily_unavailable');
184
+ other.tags['databaseLifecycle:agentName'] = ['owner'];
185
+ other.tags.profile = ['staging'];
186
+ expect(check([other]).supportState).toBe('temporarily_unavailable');
187
+ });
188
+ it('does not combine incomplete replicas into a capable worker', () => {
189
+ expect(
190
+ check([worker(APP_DATABASE_DUMP_FILE_OPERATIONS.slice(0, 2)), worker(APP_DATABASE_DUMP_FILE_OPERATIONS.slice(2))]).supportState
191
+ ).toBe('unsupported');
192
+ });
193
+ it.each(['databaseLifecycle:engines', 'databaseLifecycle:capabilities'] as const)(
194
+ 'rejects a fully advertised worker missing %s',
195
+ (tag) => {
196
+ const agent = worker(APP_DATABASE_DUMP_FILE_OPERATIONS);
197
+ agent.tags[tag] = [];
198
+ expect(check([agent])).toMatchObject({
199
+ missingOperations: [],
200
+ reason: 'pg_dump import requires a PostgreSQL worker with managed IAM support.',
201
+ supportState: 'unsupported'
202
+ });
203
+ }
204
+ );
205
+ });
@@ -146,3 +146,55 @@ function transformsInCommon(agents: readonly AgentLifecycleTagSource[]): AppData
146
146
  }
147
147
  return APP_DATABASE_IMPORT_TRANSFORMS.filter((transform) => counts.get(transform) === agents.length);
148
148
  }
149
+
150
+ export const APP_DATABASE_DUMP_FILE_OPERATIONS = [
151
+ 'prepare_import_prefix_upload',
152
+ 'inspect_import_prefix',
153
+ 'prepare_import_upload',
154
+ 'complete_import_upload',
155
+ 'restore_import_data'
156
+ ] as const;
157
+ export const APP_DATABASE_DUMP_INTEGRATION_OPERATIONS = ['capture_integration_pg_dump', 'restore_integration_pg_dump'] as const;
158
+ export type AppDatabaseDumpTagSupport = Pick<AppDatabaseImportTagSupport, 'missingOperations' | 'reason' | 'supportState'>;
159
+ export type AppDatabaseDumpSupport = { file: AppDatabaseDumpTagSupport; integration: AppDatabaseDumpTagSupport };
160
+
161
+ export function evaluateAppDatabaseDumpTag({
162
+ agents,
163
+ agentName,
164
+ profileKey,
165
+ source
166
+ }: {
167
+ agents: readonly AgentLifecycleTagSource[] | undefined;
168
+ agentName?: string | null;
169
+ profileKey: string;
170
+ source: 'file' | 'integration';
171
+ }): AppDatabaseDumpTagSupport {
172
+ const operations = source === 'file' ? APP_DATABASE_DUMP_FILE_OPERATIONS : APP_DATABASE_DUMP_INTEGRATION_OPERATIONS;
173
+ const eligible = (agents ?? []).filter(
174
+ (agent) => isActiveAgent(agent) && !!agentName && publishesAgentName(agent, agentName) && coversProfile(agent, profileKey)
175
+ );
176
+ if (eligible.length === 0) {
177
+ return {
178
+ missingOperations: [...operations],
179
+ supportState: 'temporarily_unavailable',
180
+ reason: 'pg_dump import is unavailable: the worker for this data tag is not connected or its capabilities could not be checked.'
181
+ };
182
+ }
183
+ const missing = eligible.map((agent) => operations.filter((operation) => !publishedOperations(agent).includes(operation)));
184
+ const supported = eligible.some(
185
+ (agent, index) =>
186
+ missing[index].length === 0 &&
187
+ agent.tags?.['databaseLifecycle:engines']?.includes('postgres') &&
188
+ agent.tags?.['databaseLifecycle:capabilities']?.includes('managed-IAM-v1')
189
+ );
190
+ if (supported) return { missingOperations: [], supportState: 'supported', reason: '' };
191
+ const missingOperations = missing.sort((a, b) => a.length - b.length)[0];
192
+ return {
193
+ missingOperations,
194
+ supportState: 'unsupported',
195
+ reason:
196
+ missingOperations.length > 0
197
+ ? `pg_dump import is unavailable: the worker does not advertise ${missingOperations.join(', ')}. Configure import storage and update the worker.`
198
+ : 'pg_dump import requires a PostgreSQL worker with managed IAM support.'
199
+ };
200
+ }
@@ -69,6 +69,7 @@ export const APP_DB_CONNECTOR_ROLE_NAME_PREFIX = 'superblocks-app-db-connector';
69
69
  export const NATIVE_DB_IAM_AUTH_MODE = 'aws_iam_role' as const;
70
70
  export const NATIVE_DB_IDENTIFIER_HASH_DOMAIN = 'superblocks-native-db:v1';
71
71
  export const DATABASE_LIFECYCLE_CAPABILITY_MANAGED_IAM_V1 = 'managed-IAM-v1';
72
+ export const DATABASE_LIFECYCLE_CAPABILITY_DATA_QUERY = 'data-query';
72
73
 
73
74
  export function isLifecycleManagedIntegrationAllowedForApiTrigger(
74
75
  triggerType: ApiTriggerType,
@@ -90,6 +91,10 @@ export function isLifecycleManagedIntegrationAllowedForApiTrigger(
90
91
  export const DATABASE_LIFECYCLE_TAG_OPERATIONS = 'databaseLifecycle:operations';
91
92
  export const DATABASE_LIFECYCLE_TAG_ENGINES = 'databaseLifecycle:engines';
92
93
  export const DATABASE_LIFECYCLE_TAG_CAPABILITIES = 'databaseLifecycle:capabilities';
94
+
95
+ export function agentTagsAdvertiseDataQuery(tags: { [key: string]: readonly string[] | undefined } | undefined): boolean {
96
+ return (tags?.[DATABASE_LIFECYCLE_TAG_CAPABILITIES] ?? []).includes(DATABASE_LIFECYCLE_CAPABILITY_DATA_QUERY);
97
+ }
93
98
  export const DATABASE_LIFECYCLE_TAG_PHYSICAL_CONFIG_FINGERPRINT = 'databaseLifecycle:physicalConfigFingerprint';
94
99
  export {
95
100
  APP_DATABASE_IMPORT_ERROR_CODES,
@@ -108,6 +113,7 @@ export {
108
113
  type AppDatabaseImportLifecycleOperation,
109
114
  type AppDatabaseImportSource,
110
115
  type AppDatabaseImportState,
116
+ type AppDatabaseImportSchemaDifferences,
111
117
  type AppDatabaseImportValidationMetadata,
112
118
  type CaptureIntegrationPgDumpCallbackResult,
113
119
  type CaptureIntegrationPgDumpDispatchPayloadEnvelope,
@@ -1,5 +1,5 @@
1
1
  // Integration errors are external errors to Superblocks and thrown from API execution
2
- import { isEmpty } from 'lodash-es';
2
+ import isEmpty from 'lodash-es/isEmpty.js';
3
3
 
4
4
  import { Code as CommonErrorCode } from '@superblocksteam/types';
5
5
 
package/src/headers.ts ADDED
@@ -0,0 +1,11 @@
1
+ // Kept apart from constants.ts, which loads generated protobuf code. Code shipped
2
+ // to user apps imports these headers, and importing constants.ts would bundle that
3
+ // protobuf code too.
4
+ export const SUPERBLOCKS_REQUEST_ID_HEADER = 'x-superblocks-request-id';
5
+ export const SUPERBLOCKS_CLI_VERSION_HEADER = 'x-superblocks-cli-version';
6
+ export const SUPERBLOCKS_COMPONENT_EVENT_HEADER = 'x-superblocks-component-event';
7
+ export const SUPERBLOCKS_URL_HEADER = 'x-superblocks-url';
8
+ export const SUPERBLOCKS_AUTHORIZATION_HEADER = 'x-superblocks-authorization';
9
+ export const SUPERBLOCKS_EMBED_HEADER = 'x-superblocks-embed';
10
+ export const SUPERBLOCKS_RESOLVED_PROFILE_KEY_HEADER = 'x-superblocks-resolved-profile-key';
11
+ export const SUPERBLOCKS_SESSION_ID_HEADER = 'x-superblocks-session-id';
@@ -1,6 +1,6 @@
1
1
  import { createLocalJWKSet, createRemoteJWKSet, decodeProtectedHeader, jwtVerify } from 'jose';
2
2
  import type { JWTPayload, JWTVerifyOptions, RemoteJWKSetOptions } from 'jose';
3
- import { isEmpty } from 'lodash-es';
3
+ import isEmpty from 'lodash-es/isEmpty.js';
4
4
 
5
5
  import { UnauthorizedError } from '../errors/index.js';
6
6
 
@@ -18,6 +18,7 @@ export const OBS_TAG_FEATURE_GROUP = 'feature-group';
18
18
  // SUPERBLOCKS ORGANZIATION
19
19
  export const OBS_TAG_ORG_ID = 'organization-id';
20
20
  export const OBS_TAG_ORG_NAME = 'organization-name';
21
+ export const OBS_TAG_USER_ID = 'user-id';
21
22
  export const OBS_TAG_USER_EMAIL = 'user-email';
22
23
  export const OBS_TAG_USER_TYPE = 'user-type';
23
24
  export const OBS_TAG_BILLING_PLAN = 'billing-plan';
@@ -1,4 +1,9 @@
1
- import { get, isArray, isEmpty, isString, set, uniq } from 'lodash-es';
1
+ import get from 'lodash-es/get.js';
2
+ import isArray from 'lodash-es/isArray.js';
3
+ import isEmpty from 'lodash-es/isEmpty.js';
4
+ import isString from 'lodash-es/isString.js';
5
+ import set from 'lodash-es/set.js';
6
+ import uniq from 'lodash-es/uniq.js';
2
7
 
3
8
  import type { PageDSL4and5, PageDSL6 } from '../../types/index.js';
4
9
 
@@ -3,7 +3,7 @@
3
3
  // So we are using `!` to assert that `widget.children` is never undefined.
4
4
  // Note that `!` does not change the runtime behavior of the code so the code will work the same way as before.
5
5
 
6
- import { cloneDeep } from 'lodash-es';
6
+ import cloneDeep from 'lodash-es/cloneDeep.js';
7
7
 
8
8
  import type { PageDSL6, WidgetProps6 } from '../../../types/index.js';
9
9
 
@@ -1,4 +1,4 @@
1
- import { cloneDeep } from 'lodash-es';
1
+ import cloneDeep from 'lodash-es/cloneDeep.js';
2
2
 
3
3
  import { Dimension, type PageDSL6, type PageDSL7, type WidgetProps6, type WidgetProps7 } from '../../../types/index.js';
4
4
 
@@ -1,4 +1,5 @@
1
- import { cloneDeep, isEqual } from 'lodash-es';
1
+ import cloneDeep from 'lodash-es/cloneDeep.js';
2
+ import isEqual from 'lodash-es/isEqual.js';
2
3
 
3
4
  import type { PageDSL7, PageDSL8, WidgetProps7, WidgetProps8 } from '../../types/index.js';
4
5
 
@@ -1,4 +1,4 @@
1
- import { cloneDeep } from 'lodash-es';
1
+ import cloneDeep from 'lodash-es/cloneDeep.js';
2
2
 
3
3
  import type { PageDSL8 } from '../types/index.js';
4
4
  import page7 from './pageV7.js';
@@ -79,6 +79,7 @@ import {
79
79
  export * from './clientCredentialsAuthConfig.js';
80
80
  export * from './registry.js';
81
81
  export * from './templates/index.js';
82
+ export * from './unsupported-integration-types.js';
82
83
 
83
84
  // WHEN A NEW INTEGRATION IS ADDED, WE WILL NEED TO ADD IT HERE IN ORDER FOR IT TO BE REGISTERED WITH CLOUD
84
85
  // we use a really big version so we don't have to manually bump this each time a plugin has a version increment
@@ -1,4 +1,4 @@
1
- import { isEmpty } from 'lodash-es';
1
+ import isEmpty from 'lodash-es/isEmpty.js';
2
2
 
3
3
  import {
4
4
  ActionResponseType,
@@ -0,0 +1,30 @@
1
+ import { EmailPlugin } from './templates/email.js';
2
+ import { GOOGLE_SHEETS_PLUGIN_ID } from './templates/gsheets.js';
3
+ import { ConfluentPlugin, KafkaPlugin, RedpandaPlugin } from './templates/kafka.js';
4
+ import { KinesisPlugin } from './templates/kinesis.js';
5
+ import { OpenAiPlugin } from './templates/openai.js';
6
+ import { RedisPlugin } from './templates/redis.js';
7
+ import { SuperblocksOcrPlugin } from './templates/superblocks-ocr.js';
8
+ import { WorkflowPlugin } from './templates/workflow.js';
9
+
10
+ /**
11
+ * Plugin ids current apps cannot set up. Older apps still create them through the server API.
12
+ */
13
+ export const UNSUPPORTED_INTEGRATION_TYPES: Set<string> = new Set([
14
+ ConfluentPlugin.id,
15
+ EmailPlugin.id,
16
+ GOOGLE_SHEETS_PLUGIN_ID,
17
+ KafkaPlugin.id,
18
+ KinesisPlugin.id,
19
+ OpenAiPlugin.id,
20
+ RedisPlugin.id,
21
+ RedpandaPlugin.id,
22
+ SuperblocksOcrPlugin.id,
23
+ WorkflowPlugin.id
24
+ ]);
25
+
26
+ /**
27
+ * Unsupported plugins whose service is an HTTP API, so a REST integration is a real substitute.
28
+ * Protocol plugins such as Redis and Kafka are absent: a REST connection cannot speak those protocols.
29
+ */
30
+ export const HTTP_API_UNSUPPORTED_PLUGIN_IDS: Set<string> = new Set([GOOGLE_SHEETS_PLUGIN_ID, OpenAiPlugin.id]);
@@ -1,4 +1,5 @@
1
- import { cloneDeep, set } from 'lodash-es';
1
+ import cloneDeep from 'lodash-es/cloneDeep.js';
2
+ import set from 'lodash-es/set.js';
2
3
 
3
4
  import type { ApplicationConfiguration } from '../types/index.js';
4
5
  import type { ScopedDataTree } from './refactor.js';
@@ -1,4 +1,7 @@
1
- import { isArray, isEqual, isObject, isString } from 'lodash-es';
1
+ import isArray from 'lodash-es/isArray.js';
2
+ import isEqual from 'lodash-es/isEqual.js';
3
+ import isObject from 'lodash-es/isObject.js';
4
+ import isString from 'lodash-es/isString.js';
2
5
 
3
6
  import { type StringSegment, getDynamicStringSegments, isExactBinding, joinStringWithBindings } from '../bindings/index.js';
4
7
  import { LanguagePluginID } from '../types/plugin/language.js';
@@ -1,4 +1,4 @@
1
- import { isEqual } from 'lodash-es';
1
+ import isEqual from 'lodash-es/isEqual.js';
2
2
  import { v4 as uuidv4 } from 'uuid';
3
3
 
4
4
  import { isValidMultiStepDef, isValidStepDef, TriggerStepType, type ValidStepDef } from '../types/page/event.js';
@@ -1,4 +1,6 @@
1
- import { get, isEqual, isArray } from 'lodash-es';
1
+ import get from 'lodash-es/get.js';
2
+ import isArray from 'lodash-es/isArray.js';
3
+ import isEqual from 'lodash-es/isEqual.js';
2
4
 
3
5
  import { type PageDSL, isValidStepDef, type ValidMultiStepDef, type StepDef } from '../types/index.js';
4
6
  import type { FlattenedWidgetProps } from '../utils/normalize.js';
@@ -1,4 +1,4 @@
1
- import { isEqual } from 'lodash-es';
1
+ import isEqual from 'lodash-es/isEqual.js';
2
2
 
3
3
  import { UtilsV1 as UtilsV1Pb } from '@superblocksteam/types';
4
4
 
@@ -1,6 +1,9 @@
1
+ import { execFile } from 'node:child_process';
1
2
  import { existsSync } from 'node:fs';
2
3
  import { createRequire } from 'node:module';
3
4
  import path from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+ import { promisify } from 'node:util';
4
7
 
5
8
  import { describe, expect, it } from 'vitest';
6
9
 
@@ -23,7 +26,16 @@ describe('Node package entry', () => {
23
26
  if (!existsSync(entry)) {
24
27
  return;
25
28
  }
26
- const shared = await import(entry);
27
- expect(typeof shared.SocketHeartbeat).toBe('function');
29
+ const { stdout } = await promisify(execFile)(
30
+ process.execPath,
31
+ [
32
+ '--input-type=module',
33
+ '-e',
34
+ 'const shared = await import(process.argv[1]); console.log(typeof shared.SocketHeartbeat);',
35
+ pathToFileURL(entry).href
36
+ ],
37
+ { timeout: 4_000, killSignal: 'SIGKILL' }
38
+ );
39
+ expect(stdout.trim()).toBe('function');
28
40
  });
29
41
  });
@@ -153,8 +153,18 @@ export interface ServerMethods {
153
153
  { chatSessionId: string; messages: AiChatMessageDto[] }
154
154
  >;
155
155
  /** Id of the active chat session, created if the app has none yet. Reads no messages. */
156
+ resolveBuilderBinding: ServerMethodSchema<
157
+ { applicationId: string; branchName: string; preferredHarness: 'clark' | 'codex' },
158
+ import('../types/ai/index.js').AiBuilderBinding
159
+ >;
160
+ saveBuilderSession: ServerMethodSchema<
161
+ { applicationId: string; branchName: string; chatSessionId: string; runtimeSessionId: string; nativeSessionId: string },
162
+ void
163
+ >;
156
164
  getActiveSessionId: ServerMethodSchema<{ applicationId: string }, { chatSessionId: string }>;
157
165
  new: ServerMethodSchema<{ applicationId: string; branchName?: string | null }, { chatSessionId: string }>;
166
+ /** Makes an existing chat of the caller's branch the active one. */
167
+ switch: ServerMethodSchema<{ applicationId: string; chatSessionId: string }, { chatSessionId: string }>;
158
168
  truncateAfterTimestamp: ServerMethodSchema<{ applicationId: string; sinceTimestamp: number }, void>;
159
169
  };
160
170
  billing: {
@@ -275,6 +285,7 @@ export interface ServerMethods {
275
285
  applicationId: string;
276
286
  branchName?: string;
277
287
  hash: string;
288
+ baseHash?: string;
278
289
  source?: string;
279
290
  targetTemplateName?: string;
280
291
  migrationGeneration?: number;
@@ -285,6 +296,7 @@ export interface ServerMethods {
285
296
  commitId?: string;
286
297
  commitMessage?: string;
287
298
  checkpointSkipped?: CheckpointSkipReason;
299
+ conflicts?: string[];
288
300
  }
289
301
  >;
290
302
  };
@@ -0,0 +1,45 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { BuilderCaller } from './builder-caller.js';
4
+
5
+ describe('BuilderCaller', () => {
6
+ it('attributes a gateway prompt to its MCP host', () => {
7
+ const caller = BuilderCaller.fromPeer('gateway', 'claude-ai');
8
+
9
+ expect(caller.metadata).toEqual({ callerChannel: 'mcp', mcpClient: 'claude' });
10
+ expect(caller.spanTags).toEqual({ 'builder.caller_channel': 'mcp', 'builder.mcp_client': 'claude' });
11
+ });
12
+
13
+ it.each([
14
+ ['claude-code', 'claude_code'],
15
+ ['local-agent-mode-plugin:superblocks', 'cowork'],
16
+ ['local-agent-mode-superblocks', 'cowork'],
17
+ ['Cursor', 'cursor'],
18
+ ['codex', 'codex'],
19
+ ['my-private-host@example.com', 'other'],
20
+ [undefined, 'unknown'],
21
+ [{ name: 'claude-ai' }, 'unknown']
22
+ ])('bounds the reported host %j to %s', (name, expected) => {
23
+ expect(BuilderCaller.fromPeer('gateway', name).metadata.mcpClient).toBe(expected);
24
+ });
25
+
26
+ it('uses the current peer instead of client-supplied host claims on editor and library turns', () => {
27
+ expect(BuilderCaller.fromPeer('editor', 'claude-ai').metadata).toEqual({ callerChannel: 'editor' });
28
+ expect(BuilderCaller.fromPeer('library', 'claude-ai').metadata).toEqual({ callerChannel: 'library' });
29
+ expect(BuilderCaller.fromPeer(undefined).metadata).toEqual({ callerChannel: 'unknown' });
30
+ });
31
+
32
+ it('reads only bounded caller fields from inference metadata', () => {
33
+ expect(BuilderCaller.fromMetadata({ callerChannel: 'mcp', mcpClient: 'cowork' })?.spanTags).toEqual({
34
+ 'builder.caller_channel': 'mcp',
35
+ 'builder.mcp_client': 'cowork'
36
+ });
37
+ expect(BuilderCaller.fromMetadata({ callerChannel: 'editor', mcpClient: 'cowork' })?.metadata).toEqual({ callerChannel: 'editor' });
38
+ expect(BuilderCaller.fromMetadata({ callerChannel: 'mcp', mcpClient: 'private@example.com' })?.metadata).toEqual({
39
+ callerChannel: 'mcp',
40
+ mcpClient: 'unknown'
41
+ });
42
+ expect(BuilderCaller.fromMetadata({ callerChannel: 'private@example.com' })).toBeUndefined();
43
+ expect(BuilderCaller.fromMetadata(undefined)).toBeUndefined();
44
+ });
45
+ });
@@ -0,0 +1,63 @@
1
+ export type BuilderCallerChannel = 'editor' | 'mcp' | 'library' | 'unknown';
2
+ export type BuilderMcpClient = 'claude' | 'claude_code' | 'cowork' | 'cursor' | 'codex' | 'other' | 'unknown';
3
+
4
+ export class BuilderCaller {
5
+ private constructor(
6
+ readonly channel: BuilderCallerChannel,
7
+ readonly client?: BuilderMcpClient
8
+ ) {}
9
+
10
+ static fromPeer(kind: string | undefined, clientName?: unknown): BuilderCaller {
11
+ if (kind === 'gateway') return new BuilderCaller('mcp', BuilderCaller.clientName(clientName));
12
+ return new BuilderCaller(kind === 'editor' || kind === 'library' ? kind : 'unknown');
13
+ }
14
+
15
+ // Metadata arrives after normalization, so an MCP client value outside the bounded set is
16
+ // reported as 'unknown' (cannot be trusted) rather than 'other' (a recognized but unlisted host
17
+ // name from clientName below). Both values are members of BuilderMcpClient.
18
+ static fromMetadata(value: unknown): BuilderCaller | undefined {
19
+ if (!value || typeof value !== 'object' || !('callerChannel' in value)) return undefined;
20
+ const channel = value.callerChannel;
21
+ if (channel !== 'editor' && channel !== 'mcp' && channel !== 'library' && channel !== 'unknown') return undefined;
22
+ if (channel !== 'mcp') return new BuilderCaller(channel);
23
+ const client = 'mcpClient' in value ? value.mcpClient : undefined;
24
+ switch (client) {
25
+ case 'claude':
26
+ case 'claude_code':
27
+ case 'cowork':
28
+ case 'cursor':
29
+ case 'codex':
30
+ case 'other':
31
+ return new BuilderCaller(channel, client);
32
+ default:
33
+ return new BuilderCaller(channel, 'unknown');
34
+ }
35
+ }
36
+
37
+ private static clientName(value: unknown): BuilderMcpClient {
38
+ if (typeof value !== 'string' || !value.trim()) return 'unknown';
39
+ const name = value.trim().toLowerCase();
40
+ if (name === 'local-agent-mode-superblocks' || name.startsWith('local-agent-mode-plugin:')) return 'cowork';
41
+ switch (name) {
42
+ case 'claude':
43
+ case 'claude-ai':
44
+ return 'claude';
45
+ case 'claude-code':
46
+ return 'claude_code';
47
+ case 'cursor':
48
+ return 'cursor';
49
+ case 'codex':
50
+ return 'codex';
51
+ default:
52
+ return 'other';
53
+ }
54
+ }
55
+
56
+ get metadata(): { callerChannel: BuilderCallerChannel; mcpClient?: BuilderMcpClient } {
57
+ return { callerChannel: this.channel, ...(this.client ? { mcpClient: this.client } : {}) };
58
+ }
59
+
60
+ get spanTags(): Record<string, string> {
61
+ return { 'builder.caller_channel': this.channel, ...(this.client ? { 'builder.mcp_client': this.client } : {}) };
62
+ }
63
+ }
@@ -1,3 +1,4 @@
1
+ export * from './builder-caller.js';
1
2
  import type { DeploymentTypeEnum, RegionEnum } from '../common/index.js';
2
3
 
3
4
  export type AiChatMessagePayload = Record<string, unknown>;
@@ -70,6 +71,7 @@ export enum AiSystemTriggerType {
70
71
  API_USAGE_SUMMARY = 'api_usage_summary',
71
72
  APP_NAME = 'app_name',
72
73
  ATTACHMENT_LABEL = 'attachment_label',
74
+ CHAT_TITLE = 'chat_title',
73
75
  COMMIT_MESSAGE = 'commit_message',
74
76
  DASHBOARD_CHAT = 'dashboard_chat',
75
77
  DESTRUCTIVE_MIGRATION_SUMMARY = 'destructive_migration_summary',
@@ -179,3 +181,12 @@ export interface AiPromptCostResponse {
179
181
  export * from './provider-credential.js';
180
182
  export * from './quota-paywall.js';
181
183
  export * from './safety-classification.js';
184
+
185
+ export interface AiBuilderBinding {
186
+ actorId: string;
187
+ chatSessionId: string;
188
+ harness: 'clark' | 'codex';
189
+ model?: string;
190
+ runtimeSessionId: string;
191
+ nativeSessionId?: string;
192
+ }
@@ -1,4 +1,7 @@
1
- import { cloneDeep, isArray, isEmpty, mergeWith } from 'lodash-es';
1
+ import cloneDeep from 'lodash-es/cloneDeep.js';
2
+ import isArray from 'lodash-es/isArray.js';
3
+ import isEmpty from 'lodash-es/isEmpty.js';
4
+ import mergeWith from 'lodash-es/mergeWith.js';
2
5
 
3
6
  import type { Code } from '@superblocksteam/types';
4
7
 
@@ -6,7 +6,7 @@
6
6
  * Global variables which can be reference during runtime.
7
7
  */
8
8
 
9
- import { merge } from 'lodash-es';
9
+ import merge from 'lodash-es/merge.js';
10
10
 
11
11
  export class Global {
12
12
  private payloads: Record<string, any> = {};