@superblocksteam/sdk 2.0.102 → 2.0.103-next.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 (150) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/application-build.d.mts.map +1 -1
  3. package/dist/application-build.mjs +1 -1
  4. package/dist/application-build.mjs.map +1 -1
  5. package/dist/cli-replacement/auth-hot-reload.d.mts.map +1 -1
  6. package/dist/cli-replacement/auth-hot-reload.mjs.map +1 -1
  7. package/dist/cli-replacement/automatic-upgrades.d.ts +1 -1
  8. package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
  9. package/dist/cli-replacement/automatic-upgrades.js +1 -1
  10. package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
  11. package/dist/cli-replacement/dev.d.mts.map +1 -1
  12. package/dist/cli-replacement/dev.mjs +5 -7
  13. package/dist/cli-replacement/dev.mjs.map +1 -1
  14. package/dist/cli-replacement/git-repo-setup.d.mts.map +1 -1
  15. package/dist/cli-replacement/git-repo-setup.mjs +30 -0
  16. package/dist/cli-replacement/git-repo-setup.mjs.map +1 -1
  17. package/dist/cli-replacement/git-repo-setup.test.mjs.map +1 -1
  18. package/dist/cli-replacement/init.d.ts +2 -2
  19. package/dist/cli-replacement/init.d.ts.map +1 -1
  20. package/dist/cli-replacement/init.js.map +1 -1
  21. package/dist/cli-replacement/version-detection.d.ts.map +1 -1
  22. package/dist/cli-replacement/version-detection.js.map +1 -1
  23. package/dist/cli-replacement/version-detection.test.js.map +1 -1
  24. package/dist/client-sync.test.mjs.map +1 -1
  25. package/dist/client.d.ts +252 -3
  26. package/dist/client.d.ts.map +1 -1
  27. package/dist/client.fetch-audit-events.test.d.ts +2 -0
  28. package/dist/client.fetch-audit-events.test.d.ts.map +1 -0
  29. package/dist/client.fetch-audit-events.test.js +69 -0
  30. package/dist/client.fetch-audit-events.test.js.map +1 -0
  31. package/dist/client.js +762 -5
  32. package/dist/client.js.map +1 -1
  33. package/dist/collect-sdk-apis.d.mts.map +1 -1
  34. package/dist/collect-sdk-apis.mjs.map +1 -1
  35. package/dist/collect-sdk-apis.test.mjs.map +1 -1
  36. package/dist/dbfs/client.d.ts.map +1 -1
  37. package/dist/dbfs/client.js.map +1 -1
  38. package/dist/dbfs/client.test.js +1 -1
  39. package/dist/dbfs/client.test.js.map +1 -1
  40. package/dist/dbfs/local.d.ts.map +1 -1
  41. package/dist/dbfs/local.js.map +1 -1
  42. package/dist/dev-utils/custom-build.d.mts.map +1 -1
  43. package/dist/dev-utils/custom-build.mjs.map +1 -1
  44. package/dist/dev-utils/custom-config.d.mts.map +1 -1
  45. package/dist/dev-utils/custom-config.mjs.map +1 -1
  46. package/dist/dev-utils/dev-server.d.mts +2 -2
  47. package/dist/dev-utils/dev-server.d.mts.map +1 -1
  48. package/dist/dev-utils/dev-server.mjs +5 -4
  49. package/dist/dev-utils/dev-server.mjs.map +1 -1
  50. package/dist/dev-utils/token-manager.d.ts.map +1 -1
  51. package/dist/dev-utils/token-manager.js.map +1 -1
  52. package/dist/extract-api-integrations.d.mts +1 -16
  53. package/dist/extract-api-integrations.d.mts.map +1 -1
  54. package/dist/extract-api-integrations.mjs +1 -232
  55. package/dist/extract-api-integrations.mjs.map +1 -1
  56. package/dist/extract-api-integrations.test.mjs.map +1 -1
  57. package/dist/flag.d.ts.map +1 -1
  58. package/dist/flag.js.map +1 -1
  59. package/dist/index.d.ts +1 -1
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js.map +1 -1
  62. package/dist/parse-sdk-registry.d.mts.map +1 -1
  63. package/dist/parse-sdk-registry.mjs.map +1 -1
  64. package/dist/parse-sdk-registry.test.mjs.map +1 -1
  65. package/dist/sdk.d.ts +59 -4
  66. package/dist/sdk.d.ts.map +1 -1
  67. package/dist/sdk.js +184 -1
  68. package/dist/sdk.js.map +1 -1
  69. package/dist/sdk.test.js +72 -2
  70. package/dist/sdk.test.js.map +1 -1
  71. package/dist/socket/handlers.d.ts +1 -1
  72. package/dist/socket/handlers.d.ts.map +1 -1
  73. package/dist/socket/handlers.js.map +1 -1
  74. package/dist/socket/index.d.ts +1 -1
  75. package/dist/socket/index.d.ts.map +1 -1
  76. package/dist/socket/index.js.map +1 -1
  77. package/dist/socket/signing.d.ts +1 -1
  78. package/dist/socket/signing.d.ts.map +1 -1
  79. package/dist/socket/signing.js.map +1 -1
  80. package/dist/telemetry/index.d.ts.map +1 -1
  81. package/dist/telemetry/index.js.map +1 -1
  82. package/dist/telemetry/logging.d.ts.map +1 -1
  83. package/dist/telemetry/logging.js +1 -1
  84. package/dist/telemetry/logging.js.map +1 -1
  85. package/dist/types/common.d.ts +1 -1
  86. package/dist/types/common.d.ts.map +1 -1
  87. package/dist/types/common.js.map +1 -1
  88. package/dist/utils.d.ts +1 -1
  89. package/dist/utils.d.ts.map +1 -1
  90. package/dist/utils.js.map +1 -1
  91. package/dist/version-control.d.mts +1 -1
  92. package/dist/version-control.d.mts.map +1 -1
  93. package/dist/version-control.mjs +2 -2
  94. package/dist/version-control.mjs.map +1 -1
  95. package/dist/vite-plugin-generate-api-build-manifest.d.mts.map +1 -1
  96. package/dist/vite-plugin-generate-api-build-manifest.mjs +3 -3
  97. package/dist/vite-plugin-generate-api-build-manifest.mjs.map +1 -1
  98. package/dist/vite-plugin-inject-sb-ids-transform.d.mts.map +1 -1
  99. package/dist/vite-plugin-inject-sb-ids-transform.mjs +1 -1
  100. package/dist/vite-plugin-inject-sb-ids-transform.mjs.map +1 -1
  101. package/dist/vite-plugin-sdk-api-entry-point.d.mts.map +1 -1
  102. package/dist/vite-plugin-sdk-api-entry-point.mjs.map +1 -1
  103. package/dist/vite-plugin-sdk-api-entry-point.test.mjs.map +1 -1
  104. package/eslint.config.js +2 -17
  105. package/package.json +6 -6
  106. package/src/application-build.mts +4 -1
  107. package/src/cli-replacement/auth-hot-reload.mts +2 -2
  108. package/src/cli-replacement/automatic-upgrades.ts +10 -7
  109. package/src/cli-replacement/dev.mts +17 -17
  110. package/src/cli-replacement/git-repo-setup.mts +34 -1
  111. package/src/cli-replacement/git-repo-setup.test.mts +4 -1
  112. package/src/cli-replacement/init.ts +5 -4
  113. package/src/cli-replacement/version-detection.test.ts +2 -0
  114. package/src/cli-replacement/version-detection.ts +1 -0
  115. package/src/client-sync.test.mts +1 -0
  116. package/src/client.fetch-audit-events.test.ts +82 -0
  117. package/src/client.ts +1204 -21
  118. package/src/collect-sdk-apis.mts +1 -0
  119. package/src/collect-sdk-apis.test.mts +2 -0
  120. package/src/dbfs/client.test.ts +2 -1
  121. package/src/dbfs/client.ts +1 -0
  122. package/src/dbfs/local.ts +2 -0
  123. package/src/dev-utils/custom-build.mts +3 -1
  124. package/src/dev-utils/custom-config.mts +1 -0
  125. package/src/dev-utils/dev-server.mts +22 -19
  126. package/src/dev-utils/token-manager.ts +1 -0
  127. package/src/extract-api-integrations.mts +5 -345
  128. package/src/extract-api-integrations.test.mts +1 -0
  129. package/src/flag.ts +1 -0
  130. package/src/index.ts +7 -0
  131. package/src/parse-sdk-registry.mts +1 -0
  132. package/src/parse-sdk-registry.test.mts +2 -0
  133. package/src/sdk.test.ts +85 -5
  134. package/src/sdk.ts +324 -14
  135. package/src/socket/handlers.ts +3 -2
  136. package/src/socket/index.ts +4 -3
  137. package/src/socket/signing.ts +5 -3
  138. package/src/telemetry/index.ts +5 -2
  139. package/src/telemetry/logging.ts +4 -3
  140. package/src/types/common.ts +2 -1
  141. package/src/utils.ts +4 -2
  142. package/src/version-control.mts +21 -18
  143. package/src/vite-plugin-generate-api-build-manifest.mts +10 -7
  144. package/src/vite-plugin-inject-sb-ids-transform.mts +5 -2
  145. package/src/vite-plugin-sdk-api-entry-point.mts +1 -0
  146. package/src/vite-plugin-sdk-api-entry-point.test.mts +2 -0
  147. package/test/clients.test.mts +4 -1
  148. package/test/safe-stringify.test.mts +1 -0
  149. package/test/version-control.test.mts +17 -14
  150. package/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+
2
3
  import {
3
4
  extractIntegrationsFromSource,
4
5
  type IntegrationInfo,
@@ -1,5 +1,7 @@
1
1
  import path from "node:path";
2
+
2
3
  import { describe, it, expect, vi } from "vitest";
4
+
3
5
  import { collectSdkApisFromRegistry } from "./collect-sdk-apis.mjs";
4
6
 
5
7
  describe("collectSdkApisFromRegistry", () => {
@@ -1,6 +1,7 @@
1
- import { ExportViewMode, NotFoundError } from "@superblocksteam/shared";
2
1
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
2
 
3
+ import { ExportViewMode, NotFoundError } from "@superblocksteam/shared";
4
+
4
5
  const { connectToISocketRPCServer, unwrapResponseDto, warn } = vi.hoisted(
5
6
  () => ({
6
7
  connectToISocketRPCServer: vi.fn(),
@@ -4,6 +4,7 @@ import {
4
4
  NotFoundError,
5
5
  } from "@superblocksteam/shared";
6
6
  import { unreachable } from "@superblocksteam/util";
7
+
7
8
  import { connectToISocketRPCServer } from "../socket/index.js";
8
9
  import { getLogger } from "../telemetry/logging.js";
9
10
  import { doDownloadDirectoryToLocal, doUploadLocalDirectory } from "./local.js";
package/src/dbfs/local.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as fsp from "node:fs/promises";
2
+
2
3
  import {
3
4
  hashDirectoryContents,
4
5
  hashFileContents,
@@ -6,6 +7,7 @@ import {
6
7
  } from "@superblocksteam/shared";
7
8
  import { unreachable } from "@superblocksteam/util";
8
9
  import { listLocalDirectory } from "@superblocksteam/vite-plugin-file-sync/list-dir";
10
+
9
11
  import type { StdISocketRPCClient } from "../socket/index.js";
10
12
 
11
13
  export async function doDownloadDirectoryToLocal(
@@ -1,12 +1,14 @@
1
1
  import path from "node:path";
2
+
2
3
  import watcher, { type FSWatcher } from "chokidar";
3
4
  import { red } from "colorette";
4
5
  import fs from "fs-extra";
5
6
  import semver from "semver";
6
7
  import { build } from "vite";
7
- import { getLegacyComponentsConfig } from "./custom-config.mjs";
8
8
  import type { Plugin, UserConfig, ViteDevServer } from "vite";
9
9
 
10
+ import { getLegacyComponentsConfig } from "./custom-config.mjs";
11
+
10
12
  // we only need to build if not on React 18
11
13
  export async function isCustomComponentsEnabled() {
12
14
  try {
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+
2
3
  import react from "@vitejs/plugin-react";
3
4
  import glob from "fast-glob";
4
5
  import { defineConfig } from "vite";
@@ -1,6 +1,17 @@
1
+ import type http from "node:http";
1
2
  import net from "node:net";
2
3
  import os from "node:os";
3
4
  import path from "node:path";
5
+
6
+ import react from "@vitejs/plugin-react";
7
+ import cors from "cors";
8
+ import express from "express";
9
+ import type { IRouter, RequestHandler } from "express";
10
+ import { createLogger, createServer, loadEnv } from "vite";
11
+ import type { HmrOptions } from "vite";
12
+ import type { ViteDevServer } from "vite";
13
+ import tsconfigPaths from "vite-tsconfig-paths";
14
+
4
15
  import {
5
16
  JwtVerifier,
6
17
  SUPERBLOCKS_LIVE_GIT_BRANCH,
@@ -11,12 +22,17 @@ import {
11
22
  type FileSyncPluginParams,
12
23
  fileSyncVitePlugin,
13
24
  } from "@superblocksteam/vite-plugin-file-sync";
14
- import react from "@vitejs/plugin-react";
15
- import cors from "cors";
16
- import express from "express";
17
- import { createLogger, createServer, loadEnv } from "vite";
18
- import tsconfigPaths from "vite-tsconfig-paths";
25
+ import type {
26
+ AiService,
27
+ SnapshotManager,
28
+ } from "@superblocksteam/vite-plugin-file-sync/ai-service";
29
+ import type { GitService } from "@superblocksteam/vite-plugin-file-sync/git-service";
30
+ import type { LockService } from "@superblocksteam/vite-plugin-file-sync/lock-service";
31
+ import type { OperationQueue } from "@superblocksteam/vite-plugin-file-sync/operation-queue";
32
+ import type { SyncService } from "@superblocksteam/vite-plugin-file-sync/sync-service";
33
+
19
34
  import pkg from "../../package.json" with { type: "json" };
35
+ import type { SuperblocksSdk } from "../sdk.js";
20
36
  import { getTracer } from "../telemetry/index.js";
21
37
  import { getErrorMeta, getLogger } from "../telemetry/logging.js";
22
38
  import {
@@ -24,7 +40,6 @@ import {
24
40
  type SuperblocksScopedJwtPayload,
25
41
  } from "../types/scoped-jwt-token-payload.js";
26
42
  import { getCurrentGitBranchIfGit } from "../version-control.mjs";
27
-
28
43
  import createLucideReactImportOptimizer from "../vite-plugin-optimize-lucide-imports.js";
29
44
  import { sdkApiEntryPointPlugin } from "../vite-plugin-sdk-api-entry-point.mjs";
30
45
  import {
@@ -33,19 +48,6 @@ import {
33
48
  } from "./custom-build.mjs";
34
49
  import { buildManifestStubPlugin } from "./vite-plugin-build-manifest-stub.mjs";
35
50
  import { ddRumPlugin } from "./vite-plugin-dd-rum.mjs";
36
- import type { SuperblocksSdk } from "../sdk.js";
37
- import type {
38
- AiService,
39
- SnapshotManager,
40
- } from "@superblocksteam/vite-plugin-file-sync/ai-service";
41
- import type { GitService } from "@superblocksteam/vite-plugin-file-sync/git-service";
42
- import type { LockService } from "@superblocksteam/vite-plugin-file-sync/lock-service";
43
- import type { OperationQueue } from "@superblocksteam/vite-plugin-file-sync/operation-queue";
44
- import type { SyncService } from "@superblocksteam/vite-plugin-file-sync/sync-service";
45
- import type { IRouter, RequestHandler } from "express";
46
- import type http from "node:http";
47
- import type { HmrOptions } from "vite";
48
- import type { ViteDevServer } from "vite";
49
51
 
50
52
  const tracer = getTracer();
51
53
 
@@ -635,6 +637,7 @@ async function startVite({
635
637
  tracer,
636
638
  logger,
637
639
  superblocksBaseUrl,
640
+ appRootDir: root,
638
641
  features,
639
642
  },
640
643
  { isCustomBuildEnabled },
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter } from "node:events";
2
+
2
3
  import type { ITokenManager, TokenUpdateEvent } from "@superblocksteam/util";
3
4
 
4
5
  export class TokenManager extends EventEmitter implements ITokenManager {
@@ -1,345 +1,5 @@
1
- import { parse } from "@babel/parser";
2
-
3
- export type IntegrationInfo = {
4
- key: string;
5
- pluginId: string;
6
- id: string;
7
- };
8
-
9
- type AstNode = {
10
- type?: string;
11
- [key: string]: unknown;
12
- };
13
-
14
- function isNode(value: unknown): value is AstNode {
15
- return !!value && typeof value === "object";
16
- }
17
-
18
- function getPropertyName(node: unknown): string | undefined {
19
- if (!isNode(node)) {
20
- return undefined;
21
- }
22
-
23
- if (node.type === "Identifier" && typeof node.name === "string") {
24
- return node.name;
25
- }
26
-
27
- if (node.type === "StringLiteral" && typeof node.value === "string") {
28
- return node.value;
29
- }
30
-
31
- return undefined;
32
- }
33
-
34
- function getLiteralString(node: unknown): string | undefined {
35
- if (!isNode(node)) {
36
- return undefined;
37
- }
38
-
39
- if (node.type === "StringLiteral" && typeof node.value === "string") {
40
- return node.value;
41
- }
42
-
43
- if (
44
- node.type === "TemplateLiteral" &&
45
- Array.isArray(node.expressions) &&
46
- node.expressions.length === 0 &&
47
- Array.isArray(node.quasis) &&
48
- node.quasis.length === 1
49
- ) {
50
- const quasi = node.quasis[0];
51
- if (
52
- isNode(quasi) &&
53
- isNode(quasi.value) &&
54
- typeof quasi.value.cooked === "string"
55
- ) {
56
- return quasi.value.cooked;
57
- }
58
- }
59
-
60
- return undefined;
61
- }
62
-
63
- function getCalleeName(node: unknown): string | undefined {
64
- if (!isNode(node)) {
65
- return undefined;
66
- }
67
-
68
- if (node.type === "Identifier" && typeof node.name === "string") {
69
- return node.name;
70
- }
71
-
72
- if (node.type === "MemberExpression") {
73
- return getPropertyName(node.property);
74
- }
75
-
76
- return undefined;
77
- }
78
-
79
- function unwrapExpression(node: unknown): AstNode | undefined {
80
- if (!isNode(node)) {
81
- return undefined;
82
- }
83
-
84
- if (
85
- node.type === "TSAsExpression" ||
86
- node.type === "TSTypeAssertion" ||
87
- node.type === "ParenthesizedExpression"
88
- ) {
89
- return unwrapExpression(node.expression);
90
- }
91
-
92
- return node;
93
- }
94
-
95
- function buildVariableInitializerMap(
96
- programBody: unknown[],
97
- ): Map<string, unknown> {
98
- const initializers = new Map<string, unknown>();
99
-
100
- for (const statement of programBody) {
101
- if (
102
- !isNode(statement) ||
103
- statement.type !== "VariableDeclaration" ||
104
- !Array.isArray(statement.declarations)
105
- ) {
106
- continue;
107
- }
108
-
109
- for (const declaration of statement.declarations) {
110
- if (!isNode(declaration)) {
111
- continue;
112
- }
113
-
114
- const identifier = declaration.id;
115
- if (
116
- !isNode(identifier) ||
117
- identifier.type !== "Identifier" ||
118
- typeof identifier.name !== "string"
119
- ) {
120
- continue;
121
- }
122
-
123
- initializers.set(identifier.name, declaration.init);
124
- }
125
- }
126
-
127
- return initializers;
128
- }
129
-
130
- function resolveApiConfigObject(
131
- expression: unknown,
132
- variableInitializers: Map<string, unknown>,
133
- ): AstNode | undefined {
134
- const resolvedExpression = unwrapExpression(expression);
135
- if (!resolvedExpression) {
136
- return undefined;
137
- }
138
-
139
- if (
140
- resolvedExpression.type === "Identifier" &&
141
- typeof resolvedExpression.name === "string"
142
- ) {
143
- return resolveApiConfigObject(
144
- variableInitializers.get(resolvedExpression.name),
145
- variableInitializers,
146
- );
147
- }
148
-
149
- if (
150
- resolvedExpression.type !== "CallExpression" ||
151
- getCalleeName(resolvedExpression.callee) !== "api" ||
152
- !Array.isArray(resolvedExpression.arguments)
153
- ) {
154
- return undefined;
155
- }
156
-
157
- const config = unwrapExpression(resolvedExpression.arguments[0]);
158
- if (!config || config.type !== "ObjectExpression") {
159
- return undefined;
160
- }
161
-
162
- return config;
163
- }
164
-
165
- function findExportedApiConfigObject(
166
- programBody: unknown[],
167
- ): AstNode | undefined {
168
- const variableInitializers = buildVariableInitializerMap(programBody);
169
-
170
- for (const statement of programBody) {
171
- if (!isNode(statement)) {
172
- continue;
173
- }
174
-
175
- if (statement.type === "ExportDefaultDeclaration") {
176
- return resolveApiConfigObject(
177
- statement.declaration,
178
- variableInitializers,
179
- );
180
- }
181
-
182
- if (
183
- statement.type === "ExportNamedDeclaration" &&
184
- Array.isArray(statement.specifiers)
185
- ) {
186
- for (const specifier of statement.specifiers) {
187
- if (
188
- !isNode(specifier) ||
189
- specifier.type !== "ExportSpecifier" ||
190
- getPropertyName(specifier.exported) !== "default"
191
- ) {
192
- continue;
193
- }
194
-
195
- return resolveApiConfigObject(specifier.local, variableInitializers);
196
- }
197
- }
198
- }
199
-
200
- return undefined;
201
- }
202
-
203
- function buildVariableReferenceMap(
204
- programBody: unknown[],
205
- ): Map<string, Omit<IntegrationInfo, "key">> {
206
- const refs = new Map<string, Omit<IntegrationInfo, "key">>();
207
-
208
- for (const statement of programBody) {
209
- if (
210
- !isNode(statement) ||
211
- statement.type !== "VariableDeclaration" ||
212
- !Array.isArray(statement.declarations)
213
- ) {
214
- continue;
215
- }
216
-
217
- for (const declaration of statement.declarations) {
218
- if (!isNode(declaration)) {
219
- continue;
220
- }
221
-
222
- const identifier = declaration.id;
223
- const init = declaration.init;
224
- if (
225
- !isNode(identifier) ||
226
- identifier.type !== "Identifier" ||
227
- typeof identifier.name !== "string"
228
- ) {
229
- continue;
230
- }
231
-
232
- if (
233
- !isNode(init) ||
234
- init.type !== "CallExpression" ||
235
- !Array.isArray(init.arguments)
236
- ) {
237
- continue;
238
- }
239
-
240
- const pluginId = getCalleeName(init.callee);
241
- const id = getLiteralString(init.arguments[0]);
242
- if (!pluginId || !id) {
243
- continue;
244
- }
245
-
246
- refs.set(identifier.name, { pluginId, id });
247
- }
248
- }
249
-
250
- return refs;
251
- }
252
-
253
- /**
254
- * Extract integration declarations from an SDK API source file.
255
- *
256
- * Supports both inline declarations:
257
- * `integrations: { db: postgres("uuid") }`
258
- *
259
- * and top-level variable references:
260
- * `const DB = postgres("uuid"); integrations: { db: DB }`
261
- */
262
- export function extractIntegrationsFromSource(
263
- source: string,
264
- ): IntegrationInfo[] {
265
- let ast: ReturnType<typeof parse>;
266
- try {
267
- ast = parse(source, {
268
- sourceType: "module",
269
- plugins: ["typescript"],
270
- });
271
- } catch {
272
- return [];
273
- }
274
-
275
- const variableRefs = buildVariableReferenceMap(ast.program.body);
276
- const apiConfig = findExportedApiConfigObject(ast.program.body);
277
- if (!apiConfig) {
278
- return [];
279
- }
280
- const results: IntegrationInfo[] = [];
281
-
282
- const apiConfigProperties = Array.isArray(apiConfig.properties)
283
- ? apiConfig.properties
284
- : [];
285
- const integrationsProperty = apiConfigProperties.find(
286
- (property: AstNode) =>
287
- isNode(property) &&
288
- property.type === "ObjectProperty" &&
289
- getPropertyName(property.key) === "integrations",
290
- );
291
-
292
- if (
293
- !isNode(integrationsProperty) ||
294
- !isNode(integrationsProperty.value) ||
295
- integrationsProperty.value.type !== "ObjectExpression"
296
- ) {
297
- return [];
298
- }
299
-
300
- const properties = Array.isArray(integrationsProperty.value.properties)
301
- ? integrationsProperty.value.properties
302
- : [];
303
- for (const property of properties) {
304
- if (!isNode(property) || property.type !== "ObjectProperty") {
305
- continue;
306
- }
307
-
308
- const key = getPropertyName(property.key);
309
- if (!key) {
310
- continue;
311
- }
312
-
313
- if (
314
- isNode(property.value) &&
315
- property.value.type === "CallExpression" &&
316
- Array.isArray(property.value.arguments)
317
- ) {
318
- const pluginId = getCalleeName(property.value.callee);
319
- const id = getLiteralString(property.value.arguments[0]);
320
- if (pluginId && id) {
321
- results.push({ key, pluginId, id });
322
- }
323
- continue;
324
- }
325
-
326
- if (
327
- isNode(property.value) &&
328
- property.value.type === "Identifier" &&
329
- typeof property.value.name === "string"
330
- ) {
331
- const resolved = variableRefs.get(property.value.name);
332
- if (resolved) {
333
- results.push({ key, ...resolved });
334
- }
335
- }
336
- }
337
-
338
- return results;
339
- }
340
-
341
- export function extractIntegrationIdsFromSource(source: string): string[] {
342
- return extractIntegrationsFromSource(source).map(
343
- (integration) => integration.id,
344
- );
345
- }
1
+ export {
2
+ extractIntegrationIdsFromSource,
3
+ extractIntegrationsFromSource,
4
+ type IntegrationInfo,
5
+ } from "@superblocksteam/vite-plugin-file-sync/extract-api-integrations";
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
+
2
3
  import {
3
4
  extractIntegrationIdsFromSource,
4
5
  extractIntegrationsFromSource,
package/src/flag.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DEFAULT_LINES_FOR_LARGE_STEPS } from "@superblocksteam/util";
2
+
2
3
  import type { FlagBootstrap } from "./types/index.js";
3
4
 
4
5
  export const signingEnabled = (flags: FlagBootstrap): boolean => {
package/src/index.ts CHANGED
@@ -3,11 +3,18 @@ export { buildApplication } from "./application-build.mjs";
3
3
  export {
4
4
  getCurrentBranchInfo,
5
5
  uploadApplication,
6
+ type AuditLogFilters,
6
7
  type CodeModeApplicationWrapper,
8
+ type CreateApplicationResult,
7
9
  type CurrentBranch,
10
+ type DailyUsageRow,
8
11
  type GetCommitsResponseBody,
12
+ type IntegrationFilters,
13
+ type IntegrationSummary,
9
14
  type MultiPageApplicationWrapper,
10
15
  type MultiPageApplicationWrapperWithComponents,
16
+ type PlanSummary,
17
+ type UsageRecordRow,
11
18
  } from "./client.js";
12
19
 
13
20
  export { FeatureFlags } from "./flag.js";
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+
2
3
  import { parseSdkRegistryFromContent } from "@superblocksteam/vite-plugin-file-sync/parsing";
3
4
 
4
5
  export type RegistryKeyToPath = Map<string, string>;
@@ -1,5 +1,7 @@
1
1
  import path from "node:path";
2
+
2
3
  import { describe, it, expect } from "vitest";
4
+
3
5
  import { parseSdkRegistry } from "./parse-sdk-registry.mjs";
4
6
 
5
7
  describe("parseSdkRegistry", () => {
package/src/sdk.test.ts CHANGED
@@ -1,17 +1,18 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
1
3
  import {
2
4
  CommitType,
3
5
  BillingPlan,
4
6
  type GetApplicationCommitsResponseBody,
5
7
  type GetPublicOrganizationSummaryResponseBody,
6
8
  } from "@superblocksteam/shared";
7
- import { beforeEach, describe, expect, it, vi } from "vitest";
8
9
 
9
- const { fetchApplicationCommits, fetchOrganizationSummary } = vi.hoisted(
10
- () => ({
10
+ const { fetchApplicationCommits, fetchAuditEvents, fetchOrganizationSummary } =
11
+ vi.hoisted(() => ({
11
12
  fetchApplicationCommits: vi.fn(),
13
+ fetchAuditEvents: vi.fn(),
12
14
  fetchOrganizationSummary: vi.fn(),
13
- }),
14
- );
15
+ }));
15
16
 
16
17
  vi.mock("./client.js", async () => {
17
18
  const actual = await vi.importActual("./client.js");
@@ -19,6 +20,7 @@ vi.mock("./client.js", async () => {
19
20
  return {
20
21
  ...actual,
21
22
  fetchApplicationCommits,
23
+ fetchAuditEvents,
22
24
  fetchOrganizationSummary,
23
25
  };
24
26
  });
@@ -104,3 +106,81 @@ describe("SuperblocksSdk.fetchApplicationCommits", () => {
104
106
  });
105
107
  });
106
108
  });
109
+
110
+ describe("SuperblocksSdk.fetchAuditEvents", () => {
111
+ beforeEach(() => {
112
+ fetchAuditEvents.mockReset();
113
+ });
114
+
115
+ it("delegates audit event requests with OCSF filters", async () => {
116
+ const expectedResponse = {
117
+ events: [
118
+ {
119
+ activity_id: 5,
120
+ category_uid: 6,
121
+ class_uid: 6003,
122
+ status_id: 1,
123
+ severity_id: 1,
124
+ type_uid: 600305,
125
+ time: 1742428800000,
126
+ actor: {
127
+ user: {
128
+ uid: "user-1",
129
+ },
130
+ },
131
+ resource: {
132
+ uid: "api-1",
133
+ type: "API",
134
+ },
135
+ metadata: {
136
+ log_name: "audit_event",
137
+ version: "1.3.0",
138
+ product: { name: "Superblocks", vendor_name: "Superblocks" },
139
+ },
140
+ },
141
+ ],
142
+ next_cursor: "cursor-2",
143
+ };
144
+ fetchAuditEvents.mockResolvedValue(expectedResponse);
145
+
146
+ const sdk = new SuperblocksSdk(
147
+ "test-token",
148
+ "https://staging.superblocks.com",
149
+ "1.2.3",
150
+ );
151
+
152
+ await expect(
153
+ sdk.fetchAuditEvents({
154
+ timeStart: "2025-03-20T00:00:00Z",
155
+ timeEnd: "2025-03-21T00:00:00Z",
156
+ classUid: 6003,
157
+ status: 2,
158
+ severity: 4,
159
+ actor: "user-1",
160
+ resourceType: "API",
161
+ resourceId: "api-1",
162
+ search: "deploy",
163
+ cursor: "cursor-1",
164
+ limit: 50,
165
+ }),
166
+ ).resolves.toEqual(expectedResponse);
167
+ expect(fetchAuditEvents).toHaveBeenCalledWith({
168
+ cliVersion: "1.2.3",
169
+ token: "test-token",
170
+ superblocksBaseUrl: "https://staging.superblocks.com",
171
+ filters: {
172
+ timeStart: "2025-03-20T00:00:00Z",
173
+ timeEnd: "2025-03-21T00:00:00Z",
174
+ classUid: 6003,
175
+ status: 2,
176
+ severity: 4,
177
+ actor: "user-1",
178
+ resourceType: "API",
179
+ resourceId: "api-1",
180
+ search: "deploy",
181
+ cursor: "cursor-1",
182
+ limit: 50,
183
+ },
184
+ });
185
+ });
186
+ });