@superblocksteam/shared 0.9620.0 → 0.9620.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.
- package/dist/bindings/utils.d.ts.map +1 -1
- package/dist/constants.d.ts +7 -9
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +11 -13
- package/dist/constants.js.map +1 -1
- package/dist/database-lifecycle/appDatabaseCompatibility.d.ts +2 -2
- package/dist/database-lifecycle/appDatabaseCompatibility.d.ts.map +1 -1
- package/dist/database-lifecycle/appDatabaseImport.d.ts +2 -2
- package/dist/database-lifecycle/appDatabaseImport.d.ts.map +1 -1
- package/dist/database-lifecycle/appDatabaseStatus.d.ts +1 -1
- package/dist/database-lifecycle/appDatabaseStatus.d.ts.map +1 -1
- package/dist/database-lifecycle/appDatabaseStatus.test.js.map +1 -1
- package/dist/database-lifecycle/capacityPolicy.d.ts +2 -2
- package/dist/database-lifecycle/capacityPolicy.d.ts.map +1 -1
- package/dist/database-lifecycle/capacityPolicy.js.map +1 -1
- package/dist/database-lifecycle/dataImport.d.ts +4 -4
- package/dist/database-lifecycle/dataImport.d.ts.map +1 -1
- package/dist/database-lifecycle/destructiveMigrations.d.ts +3 -3
- package/dist/database-lifecycle/destructiveMigrations.js.map +1 -1
- package/dist/database-lifecycle/importCompatibility.d.ts +4 -4
- package/dist/database-lifecycle/importCompatibility.d.ts.map +1 -1
- package/dist/database-lifecycle/importCompatibility.test.js.map +1 -1
- package/dist/database-lifecycle/index.d.ts +13 -13
- package/dist/database-lifecycle/index.d.ts.map +1 -1
- package/dist/database-lifecycle/physicalPoolIdentity.d.ts.map +1 -1
- package/dist/database-lifecycle/physicalPoolIdentity.js.map +1 -1
- package/dist/errors/git.d.ts.map +1 -1
- package/dist/errors/http.d.ts.map +1 -1
- package/dist/errors/integration.d.ts.map +1 -1
- package/dist/jwt/verifier.d.ts.map +1 -1
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/org-features/index.d.ts +2 -2
- package/dist/org-features/index.d.ts.map +1 -1
- package/dist/pageMigrations/migrations/v4to5.d.ts.map +1 -1
- package/dist/pageMigrations/migrations/v5to6.d.ts.map +1 -1
- package/dist/pageMigrations/migrations/v5to6.test.js +1 -1
- package/dist/pageMigrations/migrations/v6to7/adjustModalCanvases.d.ts.map +1 -1
- package/dist/pageMigrations/migrations/v6to7/adjustModalCanvases.test.js +1 -1
- package/dist/pageMigrations/migrations/v6to7/migrateToDimensions.d.ts.map +1 -1
- package/dist/pageMigrations/migrations/v6to7/migrateToDimensions.test.js +2 -2
- package/dist/pageMigrations/migrations/v6to7/migrateToSections.d.ts.map +1 -1
- package/dist/pageMigrations/migrations/v6to7/v6to7.d.ts.map +1 -1
- package/dist/pageMigrations/migrations/v7to8.d.ts.map +1 -1
- package/dist/pageMigrations/migrations/v7to8.test.js +1 -1
- package/dist/pages/pageV6.d.ts.map +1 -1
- package/dist/pages/pageV7.d.ts.map +1 -1
- package/dist/pages/pageV8.d.ts.map +1 -1
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/templates/constants.d.ts +1 -1
- package/dist/plugins/templates/constants.d.ts.map +1 -1
- package/dist/plugins/templates/graphql.d.ts.map +1 -1
- package/dist/plugins/templates/gsheets.d.ts.map +1 -1
- package/dist/plugins/templates/lakebase.d.ts.map +1 -1
- package/dist/plugins/templates/mcp.d.ts.map +1 -1
- package/dist/plugins/templates/mcp.test.js +13 -0
- package/dist/plugins/templates/mcp.test.js.map +1 -1
- package/dist/plugins/templates/salesforce.d.ts.map +1 -1
- package/dist/plugins/templates/shared/auth.d.ts.map +1 -1
- package/dist/plugins/templates/shared/auth.js +16 -0
- package/dist/plugins/templates/shared/auth.js.map +1 -1
- package/dist/plugins/templates/shared/aws.d.ts.map +1 -1
- package/dist/plugins/templates/shared/db.d.ts.map +1 -1
- package/dist/plugins/templates/shared/openapi.d.ts.map +1 -1
- package/dist/plugins/templates/shared/restapiintegration.d.ts.map +1 -1
- package/dist/plugins/templates/shared/sql.d.ts.map +1 -1
- package/dist/plugins/templates/shared/sshtunnel.d.ts.map +1 -1
- package/dist/plugins/templates/snowflakepostgres.d.ts.map +1 -1
- package/dist/refactoring/refactor.test.js +274 -260
- package/dist/refactoring/refactor.test.js.map +1 -1
- package/dist/refactoring/rename.js.map +1 -1
- package/dist/relay/builder.d.ts.map +1 -1
- package/dist/signing/JSON/portable.js +2 -2
- package/dist/signing/index.js.map +1 -1
- package/dist/socket/heartbeat.d.ts.map +1 -1
- package/dist/socket/heartbeat.js.map +1 -1
- package/dist/socket/heartbeat.test.js.map +1 -1
- package/dist/socket/protocol.d.ts +6 -1
- package/dist/socket/protocol.d.ts.map +1 -1
- package/dist/socket/socket.d.ts +1 -1
- package/dist/socket/socket.d.ts.map +1 -1
- package/dist/socket/socket.js +2 -2
- package/dist/socket/socketWithClientAuth.d.ts.map +1 -1
- package/dist/socket/tracedSocket.d.ts.map +1 -1
- package/dist/socket/types.d.ts.map +1 -1
- package/dist/socket/util.js.map +1 -1
- package/dist/tracing/methodTracing.js +1 -1
- package/dist/types/ai/builder-caller.d.ts.map +1 -1
- package/dist/types/ai/builder-caller.js.map +1 -1
- package/dist/types/ai/index.d.ts +16 -4
- package/dist/types/ai/index.d.ts.map +1 -1
- package/dist/types/ai/index.js +1 -0
- package/dist/types/ai/index.js.map +1 -1
- package/dist/types/ai/native-builder-model.d.ts +21 -0
- package/dist/types/ai/native-builder-model.d.ts.map +1 -0
- package/dist/types/ai/native-builder-model.js +26 -0
- package/dist/types/ai/native-builder-model.js.map +1 -0
- package/dist/types/ai/native-builder-model.test.d.ts +2 -0
- package/dist/types/ai/native-builder-model.test.d.ts.map +1 -0
- package/dist/types/ai/native-builder-model.test.js +30 -0
- package/dist/types/ai/native-builder-model.test.js.map +1 -0
- package/dist/types/ai/provider-credential.d.ts +1 -1
- package/dist/types/ai/provider-credential.d.ts.map +1 -1
- package/dist/types/ai/quota-paywall.d.ts.map +1 -1
- package/dist/types/ai/safety-classification.d.ts +1 -1
- package/dist/types/ai/safety-classification.d.ts.map +1 -1
- package/dist/types/api/control-flow.d.ts +12 -12
- package/dist/types/api/control-flow.d.ts.map +1 -1
- package/dist/types/api/control-flow.js.map +1 -1
- package/dist/types/api/execution.d.ts.map +1 -1
- package/dist/types/api/global.d.ts.map +1 -1
- package/dist/types/api/global.js +1 -2
- package/dist/types/api/global.js.map +1 -1
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/schedule.d.ts.map +1 -1
- package/dist/types/application/index.d.ts +2 -1
- package/dist/types/application/index.d.ts.map +1 -1
- package/dist/types/application/index.js.map +1 -1
- package/dist/types/application/index.test.js.map +1 -1
- package/dist/types/audit/ocsf.d.ts.map +1 -1
- package/dist/types/audit/ocsf.js +1 -0
- package/dist/types/audit/ocsf.js.map +1 -1
- package/dist/types/branch/index.d.ts +40 -9
- package/dist/types/branch/index.d.ts.map +1 -1
- package/dist/types/codeSecurity/index.d.ts +3 -3
- package/dist/types/codeSecurity/index.d.ts.map +1 -1
- package/dist/types/common/env.d.ts.map +1 -1
- package/dist/types/common/response.d.ts.map +1 -1
- package/dist/types/credentials/index.d.ts +3 -3
- package/dist/types/credentials/index.d.ts.map +1 -1
- package/dist/types/customAgents.d.ts +2 -3
- package/dist/types/customAgents.d.ts.map +1 -1
- package/dist/types/datasource/auth.d.ts.map +1 -1
- package/dist/types/datasource/auth.js.map +1 -1
- package/dist/types/datasource/index.d.ts.map +1 -1
- package/dist/types/datasource/metadata/database.d.ts.map +1 -1
- package/dist/types/event/index.d.ts +3 -3
- package/dist/types/group/index.d.ts.map +1 -1
- package/dist/types/integration/index.d.ts.map +1 -1
- package/dist/types/integration/index.js +2 -2
- package/dist/types/metadata/index.d.ts.map +1 -1
- package/dist/types/organization/agent.d.ts.map +1 -1
- package/dist/types/organization/token.d.ts.map +1 -1
- package/dist/types/page/Dimension.d.ts +7 -7
- package/dist/types/page/Dimension.d.ts.map +1 -1
- package/dist/types/page/Dimension.js +1 -1
- package/dist/types/page/Dimension.js.map +1 -1
- package/dist/types/page/Dimension.test.js +1 -1
- package/dist/types/page/Padding.d.ts +2 -2
- package/dist/types/page/Padding.d.ts.map +1 -1
- package/dist/types/page/Padding.js +1 -1
- package/dist/types/plugin/evaluation.d.ts +12 -5
- package/dist/types/plugin/evaluation.d.ts.map +1 -1
- package/dist/types/plugin/evaluation.js +5 -5
- package/dist/types/plugin/evaluation.js.map +1 -1
- package/dist/types/plugin/form.d.ts +1 -1
- package/dist/types/plugin/form.d.ts.map +1 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/integration.d.ts.map +1 -1
- package/dist/types/plugin/js-tokenizer.d.ts +14 -0
- package/dist/types/plugin/js-tokenizer.d.ts.map +1 -0
- package/dist/types/plugin/js-tokenizer.js +97 -0
- package/dist/types/plugin/js-tokenizer.js.map +1 -0
- package/dist/types/plugin/js-tokenizer.test.d.ts +2 -0
- package/dist/types/plugin/js-tokenizer.test.d.ts.map +1 -0
- package/dist/types/plugin/js-tokenizer.test.js +126 -0
- package/dist/types/plugin/js-tokenizer.test.js.map +1 -0
- package/dist/types/policyGate/errors.d.ts +23 -23
- package/dist/types/policyGate/errors.d.ts.map +1 -1
- package/dist/types/profile/index.d.ts.map +1 -1
- package/dist/types/publishPipeline/index.d.ts +6 -6
- package/dist/types/publishPipeline/index.d.ts.map +1 -1
- package/dist/types/publishPipeline/policyStatus.js.map +1 -1
- package/dist/types/rbac/index.d.ts +4 -0
- package/dist/types/rbac/index.d.ts.map +1 -1
- package/dist/types/rbac/index.js +4 -0
- package/dist/types/rbac/index.js.map +1 -1
- package/dist/types/repository/index.d.ts.map +1 -1
- package/dist/types/repository/index.js.map +1 -1
- package/dist/types/response/IssueSuperblocksResponseBody.d.ts +6 -0
- package/dist/types/response/IssueSuperblocksResponseBody.d.ts.map +1 -1
- package/dist/types/reviewPolicy/index.d.ts +24 -24
- package/dist/types/reviewPolicy/index.d.ts.map +1 -1
- package/dist/types/user/analytics.d.ts +1 -1
- package/dist/types/user/analytics.d.ts.map +1 -1
- package/dist/utils/apiv2.d.ts.map +1 -1
- package/dist/utils/apiv2.js +1 -1
- package/dist/utils/apiv2.test.js +10 -10
- package/dist/utils/appDSL.d.ts.map +1 -1
- package/dist/utils/attachment-upload.d.ts +1 -1
- package/dist/utils/attachment-upload.d.ts.map +1 -1
- package/dist/utils/attachment-upload.js +3 -1
- package/dist/utils/attachment-upload.js.map +1 -1
- package/dist/utils/attachment-validation.d.ts +6 -6
- package/dist/utils/attachment-validation.d.ts.map +1 -1
- package/dist/utils/attachment-validation.js.map +1 -1
- package/dist/utils/azure-devops-workflow.js.map +1 -1
- package/dist/utils/bitbucket-workflow.js.map +1 -1
- package/dist/utils/bytestring.js +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +4 -4
- package/dist/utils/github-workflow.js.map +1 -1
- package/dist/utils/gitlab-workflow.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/localNativeBuilderFlags.d.ts +9 -0
- package/dist/utils/localNativeBuilderFlags.d.ts.map +1 -0
- package/dist/utils/localNativeBuilderFlags.js +26 -0
- package/dist/utils/localNativeBuilderFlags.js.map +1 -0
- package/dist/utils/localNativeBuilderFlags.test.d.ts +2 -0
- package/dist/utils/localNativeBuilderFlags.test.d.ts.map +1 -0
- package/dist/utils/localNativeBuilderFlags.test.js +35 -0
- package/dist/utils/localNativeBuilderFlags.test.js.map +1 -0
- package/dist/utils/maskCredential.d.ts.map +1 -1
- package/dist/utils/openApiSpecRef.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v4/container.d.ts +346 -346
- package/dist/utils/pageFixtures/v4/container.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v4/empty.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v4/form.d.ts +11 -11
- package/dist/utils/pageFixtures/v4/form.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v4/grid.d.ts +9 -9
- package/dist/utils/pageFixtures/v4/grid.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v4/slideout.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v4/tabs.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v5/codeTrigger.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v5/complexTriggers.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v5/duplicateTriggers.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v5/missingTriggers.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v6/initial_app.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v6/nested_modal.d.ts +32 -32
- package/dist/utils/pageFixtures/v6/nested_modal.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v6/slideout_without_child.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v6/with_2_modals.d.ts +30 -30
- package/dist/utils/pageFixtures/v6/with_2_modals.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v6/with_main_canvas_children.d.ts +97 -97
- package/dist/utils/pageFixtures/v6/with_main_canvas_children.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v6/with_slideouts.d.ts +42 -42
- package/dist/utils/pageFixtures/v6/with_slideouts.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v6/with_widgets_named_page.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v7/canvases.d.ts +29 -29
- package/dist/utils/pageFixtures/v7/canvases.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v7/grids_and_forms.d.ts +56 -56
- package/dist/utils/pageFixtures/v7/grids_and_forms.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v7/images.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v7/initial_app.d.ts.map +1 -1
- package/dist/utils/pageFixtures/v7/nested_containers.d.ts +2 -2
- package/dist/utils/pageFixtures/v7/nested_containers.d.ts.map +1 -1
- package/dist/utils/platform-mcp-server-routes.d.ts +23 -0
- package/dist/utils/platform-mcp-server-routes.d.ts.map +1 -0
- package/dist/utils/platform-mcp-server-routes.js +59 -0
- package/dist/utils/platform-mcp-server-routes.js.map +1 -0
- package/dist/utils/platform-mcp-server-routes.test.d.ts +2 -0
- package/dist/utils/platform-mcp-server-routes.test.d.ts.map +1 -0
- package/dist/utils/platform-mcp-server-routes.test.js +21 -0
- package/dist/utils/platform-mcp-server-routes.test.js.map +1 -0
- package/dist/utils/string.d.ts.map +1 -1
- package/dist/utils/string.js +1 -1
- package/dist/utils/tracedEventEmitter.d.ts.map +1 -1
- package/dist/utils/tracedEventEmitter.js +3 -3
- package/dist/utils/truncate.d.ts.map +1 -1
- package/dist/utils/truncate.test.js +1 -1
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js.map +1 -1
- package/package.json +11 -5
- package/src/constants.ts +11 -14
- package/src/pageMigrations/migrations/v4to5.ts +1 -1
- package/src/pageMigrations/migrations/v5to6.test.ts +1 -1
- package/src/pageMigrations/migrations/v6to7/adjustModalCanvases.test.ts +1 -1
- package/src/pageMigrations/migrations/v6to7/migrateToDimensions.test.ts +2 -2
- package/src/pageMigrations/migrations/v7to8.test.ts +1 -1
- package/src/plugins/templates/mcp.test.ts +17 -0
- package/src/plugins/templates/shared/auth.ts +16 -0
- package/src/refactoring/refactor.test.ts +306 -287
- package/src/signing/JSON/portable.ts +2 -2
- package/src/socket/protocol.ts +6 -1
- package/src/socket/socket.ts +2 -2
- package/src/socket/types.ts +1 -1
- package/src/tracing/methodTracing.ts +1 -1
- package/src/types/ai/index.ts +14 -1
- package/src/types/ai/native-builder-model.test.ts +33 -0
- package/src/types/ai/native-builder-model.ts +28 -0
- package/src/types/api/global.ts +1 -3
- package/src/types/application/index.ts +2 -1
- package/src/types/audit/ocsf.ts +1 -0
- package/src/types/branch/index.ts +33 -6
- package/src/types/customAgents.ts +2 -3
- package/src/types/datasource/metadata/index.ts +4 -4
- package/src/types/event/index.ts +1 -1
- package/src/types/integration/index.ts +3 -3
- package/src/types/page/Dimension.test.ts +1 -1
- package/src/types/page/Dimension.ts +1 -1
- package/src/types/page/Padding.ts +1 -1
- package/src/types/plugin/evaluation.ts +17 -12
- package/src/types/plugin/form.ts +1 -1
- package/src/types/plugin/js-tokenizer.test.ts +139 -0
- package/src/types/plugin/js-tokenizer.ts +98 -0
- package/src/types/rbac/index.ts +4 -0
- package/src/types/response/IssueSuperblocksResponseBody.ts +6 -0
- package/src/utils/apiv2.test.ts +10 -10
- package/src/utils/apiv2.ts +1 -1
- package/src/utils/attachment-upload.ts +4 -1
- package/src/utils/bytestring.ts +1 -1
- package/src/utils/env.ts +5 -5
- package/src/utils/index.ts +2 -0
- package/src/utils/localNativeBuilderFlags.test.ts +39 -0
- package/src/utils/localNativeBuilderFlags.ts +27 -0
- package/src/utils/page.ts +1 -1
- package/src/utils/platform-mcp-server-routes.test.ts +27 -0
- package/src/utils/platform-mcp-server-routes.ts +65 -0
- package/src/utils/string.ts +1 -1
- package/src/utils/tracedEventEmitter.ts +5 -5
- package/src/utils/truncate.test.ts +1 -1
package/src/types/ai/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './native-builder-model.js';
|
|
1
2
|
export * from './builder-caller.js';
|
|
2
3
|
import type { DeploymentTypeEnum, RegionEnum } from '../common/index.js';
|
|
3
4
|
|
|
@@ -182,11 +183,23 @@ export * from './provider-credential.js';
|
|
|
182
183
|
export * from './quota-paywall.js';
|
|
183
184
|
export * from './safety-classification.js';
|
|
184
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Where an app branch's working tree and dev-server run. `sessionKey` is set only for `agentcore`
|
|
188
|
+
* and is an opaque AgentCore session id shared by every chat on the branch; never parse it.
|
|
189
|
+
*/
|
|
190
|
+
export interface WorkspaceBinding {
|
|
191
|
+
placement: 'live-edit' | 'agentcore';
|
|
192
|
+
sessionKey?: string;
|
|
193
|
+
harness?: AiBuilderBinding['harness'];
|
|
194
|
+
}
|
|
195
|
+
|
|
185
196
|
export interface AiBuilderBinding {
|
|
186
197
|
actorId: string;
|
|
187
198
|
chatSessionId: string;
|
|
188
|
-
harness: 'clark' | 'codex';
|
|
199
|
+
harness: 'clark' | 'codex' | 'claude_code';
|
|
189
200
|
model?: string;
|
|
201
|
+
/** Per-chat conversation id. */
|
|
190
202
|
runtimeSessionId: string;
|
|
191
203
|
nativeSessionId?: string;
|
|
204
|
+
workspace: WorkspaceBinding;
|
|
192
205
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { NativeBuilderModel, NATIVE_BUILDER_MODELS } from './native-builder-model.js';
|
|
4
|
+
|
|
5
|
+
describe('NativeBuilderModel', () => {
|
|
6
|
+
it.each([
|
|
7
|
+
['codex', 'gpt-5.5'],
|
|
8
|
+
['claude_code', 'claude-opus-5-5'],
|
|
9
|
+
['clark', undefined]
|
|
10
|
+
] as const)('keeps the default for %s', (harness, expected) => {
|
|
11
|
+
expect(NativeBuilderModel.resolve(harness)).toBe(expected);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('accepts every advertised model only for its harness', () => {
|
|
15
|
+
for (const [harness, models] of Object.entries(NATIVE_BUILDER_MODELS)) {
|
|
16
|
+
for (const { id } of models) {
|
|
17
|
+
expect(NativeBuilderModel.resolve(harness as 'codex' | 'claude_code', id)).toBe(id);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it.each([
|
|
23
|
+
['codex', 'claude-sonnet-4-6'],
|
|
24
|
+
['claude_code', 'gpt-5.5'],
|
|
25
|
+
['claude_code', 'sonnet'],
|
|
26
|
+
['claude_code', ''],
|
|
27
|
+
['claude_code', null],
|
|
28
|
+
['claude_code', {}],
|
|
29
|
+
['clark', 'claude-opus-4-6']
|
|
30
|
+
] as const)('rejects %s model selection %j', (harness, model) => {
|
|
31
|
+
expect(() => NativeBuilderModel.resolve(harness, model)).toThrow('Unsupported builder model');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BadRequestError } from '../../errors/http.js';
|
|
2
|
+
|
|
3
|
+
export const NATIVE_BUILDER_MODELS = {
|
|
4
|
+
codex: [{ id: 'gpt-5.5', label: 'GPT-5.5' }],
|
|
5
|
+
claude_code: [
|
|
6
|
+
{ id: 'claude-opus-5-5', label: 'Opus 5.5' },
|
|
7
|
+
{ id: 'claude-opus-4-6', label: 'Opus 4.6' },
|
|
8
|
+
{ id: 'claude-sonnet-4-6', label: 'Sonnet 4.6' }
|
|
9
|
+
]
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export type NativeBuilderModelId =
|
|
13
|
+
| (typeof NATIVE_BUILDER_MODELS.codex)[number]['id']
|
|
14
|
+
| (typeof NATIVE_BUILDER_MODELS.claude_code)[number]['id'];
|
|
15
|
+
|
|
16
|
+
export class NativeBuilderModel {
|
|
17
|
+
static resolve(harness: keyof typeof NATIVE_BUILDER_MODELS | 'clark', preferredModel?: unknown): NativeBuilderModelId | undefined {
|
|
18
|
+
if (harness === 'clark') {
|
|
19
|
+
if (preferredModel !== undefined) throw new BadRequestError('Unsupported builder model for Clark');
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const models = NATIVE_BUILDER_MODELS[harness];
|
|
23
|
+
if (preferredModel === undefined) return models[0].id;
|
|
24
|
+
const selected = models.find(({ id }) => id === preferredModel);
|
|
25
|
+
if (!selected) throw new BadRequestError('Unsupported builder model for this harness');
|
|
26
|
+
return selected.id;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/types/api/global.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApplicationSignatureTreeSigned, Signature } from '../../signing/index.js';
|
|
2
|
-
import type { AiBuilderBinding } from '../ai/index.js';
|
|
2
|
+
import type { AiBuilderBinding, NativeBuilderModelId } from '../ai/index.js';
|
|
3
3
|
import type {
|
|
4
4
|
ApplicationUserDto,
|
|
5
5
|
BaseBlock,
|
|
@@ -537,6 +537,7 @@ export type PostApplicationCreateRequestBody = {
|
|
|
537
537
|
/** When provided, server generates an AI app name from this prompt */
|
|
538
538
|
initialPrompt?: string;
|
|
539
539
|
builderHarness?: AiBuilderBinding['harness'];
|
|
540
|
+
builderModel?: NativeBuilderModelId;
|
|
540
541
|
};
|
|
541
542
|
export interface ApplicationPageClonePayload {
|
|
542
543
|
applicationId: string;
|
package/src/types/audit/ocsf.ts
CHANGED
|
@@ -258,6 +258,7 @@ export const AUDIT_EVENT_TYPE_CATALOG: AuditEventTypeEntry[] = [
|
|
|
258
258
|
category_name: 'APPLICATION_ACTIVITY',
|
|
259
259
|
resource_type: 'Organization',
|
|
260
260
|
operations: [
|
|
261
|
+
'organization.mcp_allowed_clients.update',
|
|
261
262
|
'organization.npm_allow_install_scripts_changed',
|
|
262
263
|
'organization.npm_registry.create',
|
|
263
264
|
'organization.npm_registry.delete',
|
|
@@ -8,17 +8,32 @@ export interface BranchDto {
|
|
|
8
8
|
baseBranchName?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export type BranchStatusCommit = { id: string; message: string | null; authorId: string | null; authorName: string | null };
|
|
12
|
+
|
|
11
13
|
export type BranchStatus = {
|
|
12
14
|
branch: string;
|
|
13
15
|
branchHead: string | null;
|
|
14
16
|
mainHead: string | null;
|
|
15
|
-
/**
|
|
17
|
+
/** Until an editor turns branching on, everyone edits main directly. */
|
|
18
|
+
branchingEnabled: boolean;
|
|
19
|
+
/** The default target of Pull and Merge. Null on main. */
|
|
20
|
+
upstream: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Counted against the upstream, only commits since the merge base that changed the tree. Merge commits do not count.
|
|
23
|
+
*/
|
|
16
24
|
ahead: number;
|
|
25
|
+
/** The commits counted in ahead, newest first, at most 10. */
|
|
26
|
+
aheadCommits: BranchStatusCommit[];
|
|
17
27
|
behind: number;
|
|
18
|
-
|
|
28
|
+
/** The commits counted in behind, newest first, at most 10. */
|
|
29
|
+
behindCommits: BranchStatusCommit[];
|
|
19
30
|
/** A merge with conflicts waits for the checkpoint that resolves it. */
|
|
20
31
|
pendingMerge: boolean;
|
|
21
|
-
/** The
|
|
32
|
+
/** The number of conflict paths in the open merge. 0 when none is open. */
|
|
33
|
+
conflictCount: number;
|
|
34
|
+
/** The conflict paths in the open merge, for the conflict handoff to Clark. */
|
|
35
|
+
conflictPaths: string[];
|
|
36
|
+
/** The branch lands on its merge target by itself when that checkpoint is saved. */
|
|
22
37
|
landPending: boolean;
|
|
23
38
|
hasUncommittedChanges: boolean;
|
|
24
39
|
/** Another user's publish going out for this app. Publishing waits until it finishes. */
|
|
@@ -29,14 +44,25 @@ export type BranchStatus = {
|
|
|
29
44
|
|
|
30
45
|
export type UserBranchSummary = {
|
|
31
46
|
name: string;
|
|
32
|
-
/** The title of a named branch; null for the owner's default branch. */
|
|
33
|
-
title: string | null;
|
|
34
47
|
ownerId: string | null;
|
|
35
48
|
ownerName: string | null;
|
|
36
49
|
holderId: string | null;
|
|
37
50
|
holderName: string | null;
|
|
51
|
+
upstream: string | null;
|
|
52
|
+
/** Commits not yet in the upstream. */
|
|
53
|
+
ahead: number;
|
|
54
|
+
/** Upstream commits not yet on the branch. */
|
|
55
|
+
behind: number;
|
|
56
|
+
/** Everything on the branch is already in its upstream. */
|
|
57
|
+
merged: boolean;
|
|
38
58
|
};
|
|
39
59
|
|
|
60
|
+
/** Returned by a Clark branch tool when the editor must move. null opens main in view-only mode. */
|
|
61
|
+
export type BranchNavigation = { branch: string | null };
|
|
62
|
+
|
|
63
|
+
/** Set on connect when the user's last branch is held by someone else and the editor opened main instead. */
|
|
64
|
+
export type BranchLanding = { branch: string; holderName: string | null };
|
|
65
|
+
|
|
40
66
|
export type BranchIncomingCommit = {
|
|
41
67
|
commitId: string;
|
|
42
68
|
committerId: string | null;
|
|
@@ -65,6 +91,7 @@ export type BranchLandResult = {
|
|
|
65
91
|
outcome: 'landed' | 'up-to-date' | 'conflict' | 'contended' | 'migrating' | 'migration-failed';
|
|
66
92
|
/** The worker's error, for 'migration-failed'. */
|
|
67
93
|
migrationError?: string;
|
|
94
|
+
/** The head of the merge target, which is main unless the land named another target. */
|
|
68
95
|
mainHead: string;
|
|
69
96
|
update?: BranchUpdateResult;
|
|
70
97
|
contextNote: string;
|
|
@@ -74,7 +101,7 @@ export type BranchLandResult = {
|
|
|
74
101
|
// above every migration main or the database has. 'migrating' means main takes the files once every data tag's
|
|
75
102
|
// database reports them ready.
|
|
76
103
|
export type BranchMigrationLandResult = {
|
|
77
|
-
outcome: 'landed' | 'migrating' | 'migration-failed' | '
|
|
104
|
+
outcome: 'landed' | 'migrating' | 'migration-failed' | 'collision' | 'busy' | 'nothing-to-land';
|
|
78
105
|
mainHead: string;
|
|
79
106
|
/** The main commit that carries the files, once one exists. */
|
|
80
107
|
commitId?: string;
|
|
@@ -19,13 +19,12 @@ export interface CustomAgentConfiguration {
|
|
|
19
19
|
retentionDays: number;
|
|
20
20
|
};
|
|
21
21
|
filesystem: {
|
|
22
|
-
type: 'session'
|
|
22
|
+
type: 'session';
|
|
23
23
|
mountPath: string;
|
|
24
|
-
accessPointArn?: string;
|
|
25
24
|
}[];
|
|
26
25
|
environment: {
|
|
27
26
|
containerUri?: string;
|
|
28
|
-
networkMode: 'public'
|
|
27
|
+
networkMode: 'public';
|
|
29
28
|
subnetIds: string[];
|
|
30
29
|
securityGroupIds: string[];
|
|
31
30
|
idleTimeoutSeconds: number;
|
|
@@ -17,13 +17,13 @@ export interface DatasourceMetadataDto {
|
|
|
17
17
|
// NOTE(joey): each integration type should have their own field here for metadata
|
|
18
18
|
dbSchema?: DatabaseSchemaMetadata;
|
|
19
19
|
buckets?: BucketMetadata[];
|
|
20
|
-
//
|
|
20
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
21
|
graphql?: any;
|
|
22
22
|
couchbase?: CouchbasePluginV1.Metadata;
|
|
23
23
|
kafka?: KafkaV1.Metadata; // NOTE(frank): Why do we use a much different pattern here than we do for action and datasource configurations?
|
|
24
24
|
kinesis?: KinesisPluginV1.Metadata;
|
|
25
25
|
integrationId?: string;
|
|
26
|
-
//
|
|
26
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
27
|
openApiSpec?: any;
|
|
28
28
|
dynamodb?: DynamoDbV1.Metadata;
|
|
29
29
|
connectedUserTokens?: Record<string, ConnectedUserTokenDto[]>;
|
|
@@ -44,7 +44,7 @@ export interface DatasourceMetadataV2Dto {
|
|
|
44
44
|
bucketsMetadata?: {
|
|
45
45
|
buckets: BucketMetadata[];
|
|
46
46
|
};
|
|
47
|
-
//
|
|
47
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
48
|
graphql?: any;
|
|
49
49
|
couchbase?: CouchbasePluginV1.Metadata;
|
|
50
50
|
kafka?: KafkaV1.Metadata;
|
|
@@ -52,7 +52,7 @@ export interface DatasourceMetadataV2Dto {
|
|
|
52
52
|
cosmosdb?: CosmosDbPluginV1.Plugin_Metadata;
|
|
53
53
|
adls?: AdlsPluginV1.Plugin_Metadata;
|
|
54
54
|
integrationId?: string;
|
|
55
|
-
//
|
|
55
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
56
|
openApiSpec?: any;
|
|
57
57
|
gSheetsNextPageToken?: string | undefined | null;
|
|
58
58
|
}
|
package/src/types/event/index.ts
CHANGED
|
@@ -145,7 +145,7 @@ export interface UserEvent {
|
|
|
145
145
|
entityType?: EventEntityType;
|
|
146
146
|
entityName?: string;
|
|
147
147
|
// properties is a field for event specific fields
|
|
148
|
-
//
|
|
148
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
149
|
properties?: Record<string, any>;
|
|
150
150
|
createdAt: Date;
|
|
151
151
|
region?: RegionEnum;
|
|
@@ -8,7 +8,7 @@ export class IntegrationConfigurationDto {
|
|
|
8
8
|
// Created date could be used for sorting
|
|
9
9
|
created: Date;
|
|
10
10
|
integrationId: string;
|
|
11
|
-
//
|
|
11
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
12
|
configuration: Record<string, any>; // DatasourceConfiguration;
|
|
13
13
|
isDefault: boolean;
|
|
14
14
|
|
|
@@ -51,7 +51,7 @@ export class IntegrationConfigurationDtoProtobuf {
|
|
|
51
51
|
// Created date could be used for sorting
|
|
52
52
|
created: Date;
|
|
53
53
|
integrationId: string;
|
|
54
|
-
//
|
|
54
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
55
|
configuration: Record<string, any>;
|
|
56
56
|
isDefault: boolean;
|
|
57
57
|
|
|
@@ -70,7 +70,7 @@ export class IntegrationConfigurationDtoProtobuf {
|
|
|
70
70
|
id: string;
|
|
71
71
|
created: Date;
|
|
72
72
|
integrationId: string;
|
|
73
|
-
//
|
|
73
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
74
|
configuration: Record<string, any>;
|
|
75
75
|
isDefault: boolean;
|
|
76
76
|
profileIds?: string[];
|
|
@@ -309,7 +309,7 @@ describe('Dimension math functions', () => {
|
|
|
309
309
|
});
|
|
310
310
|
});
|
|
311
311
|
|
|
312
|
-
//
|
|
312
|
+
// oxlint-disable-next-line
|
|
313
313
|
const typeTest = () => {
|
|
314
314
|
// This should cause typescript error because if we're mixing px with non px then parentColumnSpace should be required
|
|
315
315
|
// @ts-expect-error
|
|
@@ -13,7 +13,7 @@ interface DimensionCache<Type extends object> {
|
|
|
13
13
|
clear(): void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
//
|
|
16
|
+
// oxlint-disable-next-line @typescript-eslint/no-namespace
|
|
17
17
|
export namespace Dimension {
|
|
18
18
|
let enableCaching = false;
|
|
19
19
|
let cache: DimensionCache<Dimension<DimensionModes>>;
|
|
@@ -7,7 +7,7 @@ export type Padding = {
|
|
|
7
7
|
bottom?: Dimension<'px'>; // Default: { value: 0, mode: 'px' }
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// oxlint-disable-next-line @typescript-eslint/no-namespace
|
|
11
11
|
export namespace Padding {
|
|
12
12
|
export const y = (padding?: Padding): Dimension<'px'> => {
|
|
13
13
|
if (padding === undefined) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { TreeCursor } from '@lezer/common';
|
|
2
2
|
import type { LRParser } from '@lezer/lr';
|
|
3
|
-
import type { Token, TokenizeOptions } from 'esprima';
|
|
4
3
|
import type { SourceLocation } from 'estree';
|
|
5
4
|
import get from 'lodash-es/get.js';
|
|
6
5
|
import isFunction from 'lodash-es/isFunction.js';
|
|
@@ -8,7 +7,7 @@ import isPlainObject from 'lodash-es/isPlainObject.js';
|
|
|
8
7
|
|
|
9
8
|
export type EvaluationPair = {
|
|
10
9
|
binding: string;
|
|
11
|
-
//
|
|
10
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
11
|
value: any;
|
|
13
12
|
range: {
|
|
14
13
|
start: number;
|
|
@@ -20,7 +19,13 @@ export type EvaluationPair = {
|
|
|
20
19
|
|
|
21
20
|
export type PythonParser = LRParser;
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* A JavaScript token in the shape esprima's `tokenize` returns: `type` is a name like
|
|
24
|
+
* 'Identifier', 'Punctuator', 'Numeric', 'String' or 'Template', and `value` is the exact source text.
|
|
25
|
+
*/
|
|
26
|
+
export type JsToken = {
|
|
27
|
+
type: string;
|
|
28
|
+
value: string;
|
|
24
29
|
range?: [number, number];
|
|
25
30
|
loc?: SourceLocation;
|
|
26
31
|
};
|
|
@@ -28,12 +33,12 @@ type TokenWithRangeAndLoc = Token & {
|
|
|
28
33
|
export const extractJsEvaluationPairsWithTokenizer = (
|
|
29
34
|
jsSnippet: string,
|
|
30
35
|
entitiesToExtract: Set<string>,
|
|
31
|
-
//
|
|
36
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
37
|
dataTree: Record<string, any>,
|
|
33
|
-
tokenize: (input: string, config
|
|
38
|
+
tokenize: (input: string, config: { range: true; loc: true }) => JsToken[],
|
|
34
39
|
namespacedEntitiesToExtract: Record<string, Set<string>> = {}
|
|
35
40
|
): EvaluationPair[] => {
|
|
36
|
-
let tokens:
|
|
41
|
+
let tokens: JsToken[] = [];
|
|
37
42
|
const ret: EvaluationPair[] = [];
|
|
38
43
|
try {
|
|
39
44
|
tokens = tokenize(jsSnippet, { range: true, loc: true });
|
|
@@ -106,14 +111,14 @@ export const extractJsEvaluationPairsWithTokenizer = (
|
|
|
106
111
|
// TODO: Move test for this into shared.
|
|
107
112
|
export const extractEntity = (
|
|
108
113
|
indexToStart: number,
|
|
109
|
-
tokens: Array<
|
|
110
|
-
//
|
|
114
|
+
tokens: Array<JsToken>,
|
|
115
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
116
|
dataTree: Record<string, any>
|
|
112
117
|
): EvaluationPair => {
|
|
113
118
|
const currentPropertyPath: string[] = [];
|
|
114
|
-
let previousToken:
|
|
119
|
+
let previousToken: JsToken | null = null;
|
|
115
120
|
let done = false; // cant do break out of switch without state variable
|
|
116
|
-
//
|
|
121
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
122
|
let entity: any;
|
|
118
123
|
const removeTrailingPunctuation = () => {
|
|
119
124
|
if (currentPropertyPath[currentPropertyPath.length - 1] === '.' || currentPropertyPath[currentPropertyPath.length - 1] === '[') {
|
|
@@ -238,7 +243,7 @@ export const extractEntity = (
|
|
|
238
243
|
export const extractPythonEvaluationPairsWithParser = (
|
|
239
244
|
code: string,
|
|
240
245
|
entities: Set<string>,
|
|
241
|
-
//
|
|
246
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
247
|
dataTree: Record<string, any>,
|
|
243
248
|
parser: PythonParser,
|
|
244
249
|
namespacedEntitiesToExtract: Record<string, Set<string>> = {}
|
|
@@ -250,7 +255,7 @@ export const extractPythonEvaluationPairsWithParser = (
|
|
|
250
255
|
let isCapturing = false;
|
|
251
256
|
const bindingPairs: EvaluationPair[] = [];
|
|
252
257
|
let currentEntityPath: string[] = [];
|
|
253
|
-
//
|
|
258
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
254
259
|
let entity: any;
|
|
255
260
|
let bindingStart = 0;
|
|
256
261
|
let bindingEnd = 0;
|
package/src/types/plugin/form.ts
CHANGED
|
@@ -144,7 +144,7 @@ export interface BaseFormItem {
|
|
|
144
144
|
doNotClearOnDependenciesChange?: boolean;
|
|
145
145
|
initialValue?: InitialValue;
|
|
146
146
|
secondaryInitialValue?: InitialValue;
|
|
147
|
-
//
|
|
147
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
148
148
|
rules?: any[];
|
|
149
149
|
style?: FormItemStyle;
|
|
150
150
|
disabled?: boolean;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { tokenizeJs } from './js-tokenizer.js';
|
|
4
|
+
|
|
5
|
+
// Each token is written as `Type:value` to keep the tables readable.
|
|
6
|
+
function tokenStream(code: string): string[] {
|
|
7
|
+
return tokenizeJs(code).map((token) => `${token.type}:${token.value}`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const templateCases: [string, string, string[]][] = [
|
|
11
|
+
['a template with no substitutions is one token', '`a`', ['Template:`a`']],
|
|
12
|
+
['a template with a substitution is split into head, expression and tail', '`a${x}b`', ['Template:`a${', 'Identifier:x', 'Template:}b`']],
|
|
13
|
+
[
|
|
14
|
+
'a nested template is joined chunk by chunk',
|
|
15
|
+
'`a${`b${c}`}d`',
|
|
16
|
+
['Template:`a${', 'Template:`b${', 'Identifier:c', 'Template:}`', 'Template:}d`']
|
|
17
|
+
],
|
|
18
|
+
['back-to-back templates stay separate', '`a``b`', ['Template:`a`', 'Template:`b`']],
|
|
19
|
+
['a tagged template keeps the tag as an identifier', 'tag`a${x}`', ['Identifier:tag', 'Template:`a${', 'Identifier:x', 'Template:}`']],
|
|
20
|
+
[
|
|
21
|
+
'two substitutions in a row share the middle chunk',
|
|
22
|
+
'`${a}${b}`',
|
|
23
|
+
['Template:`${', 'Identifier:a', 'Template:}${', 'Identifier:b', 'Template:}`']
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
'braces inside a substitution are not mistaken for the template tail',
|
|
27
|
+
'`a${ {b:1}.b }c`',
|
|
28
|
+
[
|
|
29
|
+
'Template:`a${',
|
|
30
|
+
'Punctuator:{',
|
|
31
|
+
'Identifier:b',
|
|
32
|
+
'Punctuator::',
|
|
33
|
+
'Numeric:1',
|
|
34
|
+
'Punctuator:}',
|
|
35
|
+
'Punctuator:.',
|
|
36
|
+
'Identifier:b',
|
|
37
|
+
'Template:}c`'
|
|
38
|
+
]
|
|
39
|
+
]
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
it.each(templateCases)('%s', (_name, code, expected) => {
|
|
43
|
+
expect(tokenStream(code)).toEqual(expected);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Esprima 4 does not know these operators, so it reads each as smaller ones. The extractors rely on
|
|
47
|
+
// the `.` in `a?.b` to avoid treating `b` as a top-level name.
|
|
48
|
+
const operatorCases: [string, string[]][] = [
|
|
49
|
+
['a?.b', ['Identifier:a', 'Punctuator:?', 'Punctuator:.', 'Identifier:b']],
|
|
50
|
+
['a?.[0]', ['Identifier:a', 'Punctuator:?', 'Punctuator:.', 'Punctuator:[', 'Numeric:0', 'Punctuator:]']],
|
|
51
|
+
['f?.()', ['Identifier:f', 'Punctuator:?', 'Punctuator:.', 'Punctuator:(', 'Punctuator:)']],
|
|
52
|
+
['a ?? b', ['Identifier:a', 'Punctuator:?', 'Punctuator:?', 'Identifier:b']],
|
|
53
|
+
['a ??= b', ['Identifier:a', 'Punctuator:?', 'Punctuator:?', 'Punctuator:=', 'Identifier:b']],
|
|
54
|
+
['a ||= b', ['Identifier:a', 'Punctuator:||', 'Punctuator:=', 'Identifier:b']],
|
|
55
|
+
['a &&= b', ['Identifier:a', 'Punctuator:&&', 'Punctuator:=', 'Identifier:b']]
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
it.each(operatorCases)('splits the operators in %j the way esprima did', (code, expected) => {
|
|
59
|
+
expect(tokenStream(code)).toEqual(expected);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('reports let, yield and enum as keywords, like esprima', () => {
|
|
63
|
+
expect(tokenStream('let yield enum')).toEqual(['Keyword:let', 'Keyword:yield', 'Keyword:enum']);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const newSyntaxCases: [string, string, string[]][] = [
|
|
67
|
+
[
|
|
68
|
+
'a private field declaration',
|
|
69
|
+
'class A { #x = 1 }',
|
|
70
|
+
['Keyword:class', 'Identifier:A', 'Punctuator:{', 'PrivateIdentifier:#x', 'Punctuator:=', 'Numeric:1', 'Punctuator:}']
|
|
71
|
+
],
|
|
72
|
+
['a private field brand check', '#x in o', ['PrivateIdentifier:#x', 'Keyword:in', 'Identifier:o']],
|
|
73
|
+
['a numeric separator', '1_000', ['Numeric:1_000']],
|
|
74
|
+
['a BigInt', '10n', ['Numeric:10n']],
|
|
75
|
+
['a BigInt with separators', '0x1_0n', ['Numeric:0x1_0n']]
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
it.each(newSyntaxCases)('reads %s, which esprima 4 throws on', (_name, code, expected) => {
|
|
79
|
+
expect(tokenStream(code)).toEqual(expected);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Acorn decides between a regex and a division from the syntax around the `/`. Esprima guessed from
|
|
83
|
+
// the previous token and got these wrong, so the streams differ from esprima 4 on purpose.
|
|
84
|
+
const regexCases: [string, string, string[]][] = [
|
|
85
|
+
[
|
|
86
|
+
'a regex on the line after a block is one token (esprima read /, foo, /)',
|
|
87
|
+
'{}\n/foo/.test(x)',
|
|
88
|
+
[
|
|
89
|
+
'Punctuator:{',
|
|
90
|
+
'Punctuator:}',
|
|
91
|
+
'RegularExpression:/foo/',
|
|
92
|
+
'Punctuator:.',
|
|
93
|
+
'Identifier:test',
|
|
94
|
+
'Punctuator:(',
|
|
95
|
+
'Identifier:x',
|
|
96
|
+
'Punctuator:)'
|
|
97
|
+
]
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
'a regex on the line after an arrow function body is one token (esprima read /, re, /, g)',
|
|
101
|
+
'a=>{}\n/re/g',
|
|
102
|
+
['Identifier:a', 'Punctuator:=>', 'Punctuator:{', 'Punctuator:}', 'RegularExpression:/re/g']
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
'slashes after a property named return are divisions (esprima read a regex)',
|
|
106
|
+
'x.return /2/ y',
|
|
107
|
+
['Identifier:x', 'Punctuator:.', 'Keyword:return', 'Punctuator:/', 'Numeric:2', 'Punctuator:/', 'Identifier:y']
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
'a division between names stays a division',
|
|
111
|
+
'a / b / c',
|
|
112
|
+
['Identifier:a', 'Punctuator:/', 'Identifier:b', 'Punctuator:/', 'Identifier:c']
|
|
113
|
+
],
|
|
114
|
+
['a regex after an assignment is one token', 'x = /a+/gi', ['Identifier:x', 'Punctuator:=', 'RegularExpression:/a+/gi']]
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
it.each(regexCases)('%s', (_name, code, expected) => {
|
|
118
|
+
expect(tokenStream(code)).toEqual(expected);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('gives range and loc for every token on multi-line input, including split operators and joined templates', () => {
|
|
122
|
+
const code = 'a ??= 1;\n`x${\n y}`';
|
|
123
|
+
|
|
124
|
+
expect(tokenizeJs(code)).toEqual([
|
|
125
|
+
{ type: 'Identifier', value: 'a', range: [0, 1], loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 1 } } },
|
|
126
|
+
{ type: 'Punctuator', value: '?', range: [2, 3], loc: { start: { line: 1, column: 2 }, end: { line: 1, column: 3 } } },
|
|
127
|
+
{ type: 'Punctuator', value: '?', range: [3, 4], loc: { start: { line: 1, column: 3 }, end: { line: 1, column: 4 } } },
|
|
128
|
+
{ type: 'Punctuator', value: '=', range: [4, 5], loc: { start: { line: 1, column: 4 }, end: { line: 1, column: 5 } } },
|
|
129
|
+
{ type: 'Numeric', value: '1', range: [6, 7], loc: { start: { line: 1, column: 6 }, end: { line: 1, column: 7 } } },
|
|
130
|
+
{ type: 'Punctuator', value: ';', range: [7, 8], loc: { start: { line: 1, column: 7 }, end: { line: 1, column: 8 } } },
|
|
131
|
+
{ type: 'Template', value: '`x${', range: [9, 13], loc: { start: { line: 2, column: 0 }, end: { line: 2, column: 4 } } },
|
|
132
|
+
{ type: 'Identifier', value: 'y', range: [16, 17], loc: { start: { line: 3, column: 2 }, end: { line: 3, column: 3 } } },
|
|
133
|
+
{ type: 'Template', value: '}`', range: [17, 19], loc: { start: { line: 3, column: 3 }, end: { line: 3, column: 5 } } }
|
|
134
|
+
]);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('throws on code that is not JavaScript', () => {
|
|
138
|
+
expect(() => tokenizeJs('const = ;;"')).toThrow();
|
|
139
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type Token as AcornToken, tokenizer, tokTypes } from 'acorn';
|
|
2
|
+
|
|
3
|
+
import type { JsToken } from './evaluation.js';
|
|
4
|
+
|
|
5
|
+
// Published as `@superblocksteam/shared/js-tokenizer` and left out of the package index on purpose.
|
|
6
|
+
// The browser apps import the index and bundle every module it reaches, so exporting this from
|
|
7
|
+
// there would ship acorn to every browser.
|
|
8
|
+
|
|
9
|
+
// Words esprima reports as keywords but acorn reports as plain names.
|
|
10
|
+
const ESPRIMA_ONLY_KEYWORDS = new Set(['let', 'yield', 'enum']);
|
|
11
|
+
|
|
12
|
+
function jsTokenType(token: AcornToken, value: string): string {
|
|
13
|
+
const { type } = token;
|
|
14
|
+
if (type === tokTypes.name) return ESPRIMA_ONLY_KEYWORDS.has(value) ? 'Keyword' : 'Identifier';
|
|
15
|
+
if (type === tokTypes._null) return 'Null';
|
|
16
|
+
if (type === tokTypes._true || type === tokTypes._false) return 'Boolean';
|
|
17
|
+
if (type.keyword) return 'Keyword';
|
|
18
|
+
if (type === tokTypes.num) return 'Numeric';
|
|
19
|
+
if (type === tokTypes.string) return 'String';
|
|
20
|
+
if (type === tokTypes.regexp) return 'RegularExpression';
|
|
21
|
+
if (type === tokTypes.privateId) return 'PrivateIdentifier';
|
|
22
|
+
return 'Punctuator';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isTemplateChunk(token: AcornToken | undefined): boolean {
|
|
26
|
+
return token?.type === tokTypes.template || token?.type === tokTypes.invalidTemplate;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Operators added after esprima 4. Esprima reads each as smaller operators, for example `a?.b` as
|
|
30
|
+
// `a`, `?`, `.`, `b`. The extractors rely on that: the `.` stops `b` from being read as a top-level name.
|
|
31
|
+
const ESPRIMA_OPERATOR_PARTS = new Map([
|
|
32
|
+
['?.', ['?', '.']],
|
|
33
|
+
['??', ['?', '?']],
|
|
34
|
+
['??=', ['?', '?', '=']],
|
|
35
|
+
['||=', ['||', '=']],
|
|
36
|
+
['&&=', ['&&', '=']]
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Tokenizes JavaScript with acorn, which also reads syntax esprima 4 rejects, such as numeric
|
|
41
|
+
* separators, BigInt and private class fields. For code esprima could read, the tokens match
|
|
42
|
+
* esprima's `tokenize(code, { range: true, loc: true })`, so the extractors in evaluation.ts
|
|
43
|
+
* behave as before. The exception is where esprima guessed wrong between a regex and a division:
|
|
44
|
+
* after a block or arrow body followed by a newline (`{}\n/foo/.test(x)`) acorn returns one regex
|
|
45
|
+
* token where esprima returned `/`, `foo`, `/`, and for `x.return /2/ y` it is the other way round.
|
|
46
|
+
* Acorn is right in both. So the extractors no longer see a name written inside the first kind of
|
|
47
|
+
* regex, and they now see the text between the slashes in the second.
|
|
48
|
+
* Throws on code acorn cannot read.
|
|
49
|
+
*/
|
|
50
|
+
export function tokenizeJs(code: string): JsToken[] {
|
|
51
|
+
const acornTokens = [...tokenizer(code, { ecmaVersion: 'latest', locations: true })];
|
|
52
|
+
const tokens: JsToken[] = [];
|
|
53
|
+
const push = (type: string, first: AcornToken, last: AcornToken) => {
|
|
54
|
+
tokens.push({
|
|
55
|
+
type,
|
|
56
|
+
value: code.slice(first.start, last.end),
|
|
57
|
+
range: [first.start, last.end],
|
|
58
|
+
loc:
|
|
59
|
+
first.loc && last.loc
|
|
60
|
+
? {
|
|
61
|
+
start: { line: first.loc.start.line, column: first.loc.start.column },
|
|
62
|
+
end: { line: last.loc.end.line, column: last.loc.end.column }
|
|
63
|
+
}
|
|
64
|
+
: undefined
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
for (let i = 0; i < acornTokens.length; i++) {
|
|
69
|
+
const token = acornTokens[i];
|
|
70
|
+
const value = code.slice(token.start, token.end);
|
|
71
|
+
// Acorn splits a template literal into backquote, text and `${` tokens, where esprima returns
|
|
72
|
+
// one 'Template' token per run of text, such as "`a${" or "}b`". Join them the same way.
|
|
73
|
+
if (token.type === tokTypes.backQuote || (token.type === tokTypes.braceR && isTemplateChunk(acornTokens[i + 1]))) {
|
|
74
|
+
i += 2;
|
|
75
|
+
push('Template', token, acornTokens[i]);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const parts = ESPRIMA_OPERATOR_PARTS.get(value);
|
|
79
|
+
if (!parts) {
|
|
80
|
+
push(jsTokenType(token, value), token, token);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
let start = token.start;
|
|
84
|
+
for (const part of parts) {
|
|
85
|
+
const end = start + part.length;
|
|
86
|
+
const line = token.loc?.start.line ?? 0;
|
|
87
|
+
const column = (token.loc?.start.column ?? 0) + (start - token.start);
|
|
88
|
+
tokens.push({
|
|
89
|
+
type: 'Punctuator',
|
|
90
|
+
value: part,
|
|
91
|
+
range: [start, end],
|
|
92
|
+
loc: token.loc ? { start: { line, column }, end: { line, column: column + part.length } } : undefined
|
|
93
|
+
});
|
|
94
|
+
start = end;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return tokens;
|
|
98
|
+
}
|