wizards 0.7.3 → 0.7.5
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/README.md +4 -4
- package/bin/wizards.mjs +95 -26
- package/{apps/web/dist/install.sh → install.sh} +23 -5
- package/package.json +2 -58
- package/apps/runtime/dist/agents/architect.js +0 -444
- package/apps/runtime/dist/agents/studio-assistant.js +0 -883
- package/apps/runtime/dist/agents/subscription.js +0 -207
- package/apps/runtime/dist/agents/thought.js +0 -21
- package/apps/runtime/dist/agents/website.js +0 -480
- package/apps/runtime/dist/app.js +0 -359
- package/apps/runtime/dist/apple/wizards-apple +0 -0
- package/apps/runtime/dist/assistant/browser.js +0 -26
- package/apps/runtime/dist/assistant/docs.js +0 -158
- package/apps/runtime/dist/assistant/knows.js +0 -353
- package/apps/runtime/dist/assistant/primer.js +0 -26
- package/apps/runtime/dist/assistant/runs.js +0 -24
- package/apps/runtime/dist/auth/account.js +0 -175
- package/apps/runtime/dist/auth/device.js +0 -112
- package/apps/runtime/dist/auth/index.js +0 -358
- package/apps/runtime/dist/auth/keys.js +0 -55
- package/apps/runtime/dist/auth/local-ticket.js +0 -26
- package/apps/runtime/dist/authoring/example.js +0 -74
- package/apps/runtime/dist/authoring/guide.js +0 -433
- package/apps/runtime/dist/authoring/ops.js +0 -117
- package/apps/runtime/dist/browser/fast/action-space.js +0 -160
- package/apps/runtime/dist/browser/fast/classifier.js +0 -91
- package/apps/runtime/dist/browser/fast/decide.js +0 -171
- package/apps/runtime/dist/browser/fast/driver.js +0 -141
- package/apps/runtime/dist/browser/fast/instructions.js +0 -33
- package/apps/runtime/dist/browser/fast/run.js +0 -249
- package/apps/runtime/dist/browser/fast/span-picker.js +0 -153
- package/apps/runtime/dist/browser/fast/text-helper.js +0 -178
- package/apps/runtime/dist/browser/snapshot.js +0 -335
- package/apps/runtime/dist/cli/account.js +0 -385
- package/apps/runtime/dist/cli/autostart.js +0 -182
- package/apps/runtime/dist/cli/autoupdate.js +0 -221
- package/apps/runtime/dist/cli/clients.js +0 -44
- package/apps/runtime/dist/cli/connect.js +0 -539
- package/apps/runtime/dist/cli/environment.js +0 -93
- package/apps/runtime/dist/cli/exec.js +0 -45
- package/apps/runtime/dist/cli/features.js +0 -50
- package/apps/runtime/dist/cli/home.js +0 -88
- package/apps/runtime/dist/cli/install-env.js +0 -33
- package/apps/runtime/dist/cli/machine.js +0 -106
- package/apps/runtime/dist/cli/main.js +0 -222
- package/apps/runtime/dist/cli/mcp.js +0 -136
- package/apps/runtime/dist/cli/menu.js +0 -202
- package/apps/runtime/dist/cli/processes.js +0 -72
- package/apps/runtime/dist/cli/report.js +0 -66
- package/apps/runtime/dist/cli/setup.js +0 -335
- package/apps/runtime/dist/cli/start.js +0 -276
- package/apps/runtime/dist/cli/status.js +0 -203
- package/apps/runtime/dist/cli/ui.js +0 -59
- package/apps/runtime/dist/cli/uninstall-main.js +0 -20
- package/apps/runtime/dist/cli/uninstall.js +0 -231
- package/apps/runtime/dist/cli/update.js +0 -86
- package/apps/runtime/dist/cli/validate.js +0 -75
- package/apps/runtime/dist/cli/versions.js +0 -106
- package/apps/runtime/dist/connectors/builtin.js +0 -86
- package/apps/runtime/dist/connectors/external.js +0 -409
- package/apps/runtime/dist/connectors/gmail.js +0 -107
- package/apps/runtime/dist/connectors/imap.js +0 -261
- package/apps/runtime/dist/connectors/index.js +0 -325
- package/apps/runtime/dist/connectors/mail.js +0 -72
- package/apps/runtime/dist/connectors/outlook.js +0 -90
- package/apps/runtime/dist/connectors/plugin-connections.js +0 -343
- package/apps/runtime/dist/connectors/via-account.js +0 -65
- package/apps/runtime/dist/credits/credits.js +0 -100
- package/apps/runtime/dist/credits/estimate.js +0 -152
- package/apps/runtime/dist/db/adopt.js +0 -149
- package/apps/runtime/dist/db/client.js +0 -173
- package/apps/runtime/dist/db/control-schema.js +0 -133
- package/apps/runtime/dist/db/migrations/control/0000_last_absorbing_man.sql +0 -47
- package/apps/runtime/dist/db/migrations/control/0001_gorgeous_nicolaos.sql +0 -41
- package/apps/runtime/dist/db/migrations/control/0002_secret_penance.sql +0 -1
- package/apps/runtime/dist/db/migrations/control/0003_nasty_mordo.sql +0 -3
- package/apps/runtime/dist/db/migrations/control/0004_breezy_eddie_brock.sql +0 -6
- package/apps/runtime/dist/db/migrations/control/0005_chilly_oracle.sql +0 -1
- package/apps/runtime/dist/db/migrations/control/0006_sleepy_mojo.sql +0 -1
- package/apps/runtime/dist/db/migrations/control/0007_common_the_hand.sql +0 -15
- package/apps/runtime/dist/db/migrations/control/0008_runner.sql +0 -8
- package/apps/runtime/dist/db/migrations/control/0009_plugin_claim.sql +0 -9
- package/apps/runtime/dist/db/migrations/control/0010_tan_snowbird.sql +0 -6
- package/apps/runtime/dist/db/migrations/control/meta/0000_snapshot.json +0 -311
- package/apps/runtime/dist/db/migrations/control/meta/0001_snapshot.json +0 -599
- package/apps/runtime/dist/db/migrations/control/meta/0002_snapshot.json +0 -607
- package/apps/runtime/dist/db/migrations/control/meta/0003_snapshot.json +0 -311
- package/apps/runtime/dist/db/migrations/control/meta/0004_snapshot.json +0 -350
- package/apps/runtime/dist/db/migrations/control/meta/0005_snapshot.json +0 -358
- package/apps/runtime/dist/db/migrations/control/meta/0006_snapshot.json +0 -365
- package/apps/runtime/dist/db/migrations/control/meta/0007_snapshot.json +0 -460
- package/apps/runtime/dist/db/migrations/control/meta/0008_snapshot.json +0 -505
- package/apps/runtime/dist/db/migrations/control/meta/0009_snapshot.json +0 -561
- package/apps/runtime/dist/db/migrations/control/meta/0010_snapshot.json +0 -600
- package/apps/runtime/dist/db/migrations/control/meta/_journal.json +0 -83
- package/apps/runtime/dist/db/migrations/tenant/0000_eminent_freak.sql +0 -188
- package/apps/runtime/dist/db/migrations/tenant/0001_salty_master_chief.sql +0 -1
- package/apps/runtime/dist/db/migrations/tenant/0002_cloudy_firebird.sql +0 -1
- package/apps/runtime/dist/db/migrations/tenant/0003_brown_warbound.sql +0 -52
- package/apps/runtime/dist/db/migrations/tenant/0004_romantic_nocturne.sql +0 -6
- package/apps/runtime/dist/db/migrations/tenant/0005_reflective_forgotten_one.sql +0 -2
- package/apps/runtime/dist/db/migrations/tenant/0006_hard_war_machine.sql +0 -30
- package/apps/runtime/dist/db/migrations/tenant/0007_space_data.sql +0 -43
- package/apps/runtime/dist/db/migrations/tenant/0008_run_event_note.sql +0 -1
- package/apps/runtime/dist/db/migrations/tenant/0009_knowledge.sql +0 -104
- package/apps/runtime/dist/db/migrations/tenant/0010_plugin_connection.sql +0 -15
- package/apps/runtime/dist/db/migrations/tenant/0011_runners.sql +0 -2
- package/apps/runtime/dist/db/migrations/tenant/0012_assistant_chat.sql +0 -40
- package/apps/runtime/dist/db/migrations/tenant/0013_run_origin.sql +0 -1
- package/apps/runtime/dist/db/migrations/tenant/0014_run_answer.sql +0 -2
- package/apps/runtime/dist/db/migrations/tenant/0015_device_calls.sql +0 -13
- package/apps/runtime/dist/db/migrations/tenant/0016_even_trish_tilby.sql +0 -12
- package/apps/runtime/dist/db/migrations/tenant/meta/0000_snapshot.json +0 -1323
- package/apps/runtime/dist/db/migrations/tenant/meta/0001_snapshot.json +0 -1330
- package/apps/runtime/dist/db/migrations/tenant/meta/0002_snapshot.json +0 -1337
- package/apps/runtime/dist/db/migrations/tenant/meta/0003_snapshot.json +0 -1605
- package/apps/runtime/dist/db/migrations/tenant/meta/0004_snapshot.json +0 -1645
- package/apps/runtime/dist/db/migrations/tenant/meta/0005_snapshot.json +0 -1659
- package/apps/runtime/dist/db/migrations/tenant/meta/0006_snapshot.json +0 -1696
- package/apps/runtime/dist/db/migrations/tenant/meta/0007_snapshot.json +0 -2012
- package/apps/runtime/dist/db/migrations/tenant/meta/0008_snapshot.json +0 -2019
- package/apps/runtime/dist/db/migrations/tenant/meta/0009_snapshot.json +0 -2837
- package/apps/runtime/dist/db/migrations/tenant/meta/0010_snapshot.json +0 -2942
- package/apps/runtime/dist/db/migrations/tenant/meta/0011_snapshot.json +0 -2956
- package/apps/runtime/dist/db/migrations/tenant/meta/0012_snapshot.json +0 -3132
- package/apps/runtime/dist/db/migrations/tenant/meta/0013_snapshot.json +0 -3139
- package/apps/runtime/dist/db/migrations/tenant/meta/0014_snapshot.json +0 -3154
- package/apps/runtime/dist/db/migrations/tenant/meta/0015_snapshot.json +0 -3243
- package/apps/runtime/dist/db/migrations/tenant/meta/0016_snapshot.json +0 -3326
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +0 -125
- package/apps/runtime/dist/db/schema.js +0 -602
- package/apps/runtime/dist/debug.js +0 -196
- package/apps/runtime/dist/docs/dev/index.md +0 -41
- package/apps/runtime/dist/docs/dev/meta.json +0 -7
- package/apps/runtime/dist/docs/dev/plugins/connections.md +0 -74
- package/apps/runtime/dist/docs/dev/plugins/events.md +0 -89
- package/apps/runtime/dist/docs/dev/plugins/examples.md +0 -101
- package/apps/runtime/dist/docs/dev/plugins/index.md +0 -78
- package/apps/runtime/dist/docs/dev/plugins/layout.md +0 -90
- package/apps/runtime/dist/docs/dev/plugins/meta.json +0 -28
- package/apps/runtime/dist/docs/dev/plugins/quick-start.md +0 -94
- package/apps/runtime/dist/docs/dev/plugins/reference.md +0 -348
- package/apps/runtime/dist/docs/dev/plugins/reloading.md +0 -76
- package/apps/runtime/dist/docs/dev/plugins/routes.md +0 -185
- package/apps/runtime/dist/docs/dev/plugins/runners.md +0 -230
- package/apps/runtime/dist/docs/dev/plugins/server.md +0 -281
- package/apps/runtime/dist/docs/dev/plugins/shipping.md +0 -79
- package/apps/runtime/dist/docs/dev/plugins/space.md +0 -297
- package/apps/runtime/dist/docs/dev/plugins/starters.md +0 -70
- package/apps/runtime/dist/docs/dev/plugins/studio.md +0 -363
- package/apps/runtime/dist/docs/dev/plugins/styling.md +0 -129
- package/apps/runtime/dist/docs/dev/plugins/tables.md +0 -104
- package/apps/runtime/dist/docs/dev/plugins/tools.md +0 -139
- package/apps/runtime/dist/docs/dev/wizard-format.md +0 -121
- package/apps/runtime/dist/docs/meta.json +0 -3
- package/apps/runtime/dist/docs/user/ai-apps.md +0 -112
- package/apps/runtime/dist/docs/user/assistant.md +0 -77
- package/apps/runtime/dist/docs/user/build-a-wizard.md +0 -116
- package/apps/runtime/dist/docs/user/command-line.md +0 -83
- package/apps/runtime/dist/docs/user/connectors.md +0 -90
- package/apps/runtime/dist/docs/user/create-account.md +0 -52
- package/apps/runtime/dist/docs/user/data.md +0 -66
- package/apps/runtime/dist/docs/user/first-start.md +0 -55
- package/apps/runtime/dist/docs/user/index.md +0 -49
- package/apps/runtime/dist/docs/user/install.md +0 -121
- package/apps/runtime/dist/docs/user/local-only.md +0 -42
- package/apps/runtime/dist/docs/user/meta.json +0 -32
- package/apps/runtime/dist/docs/user/models.md +0 -156
- package/apps/runtime/dist/docs/user/plugins.md +0 -71
- package/apps/runtime/dist/docs/user/run.md +0 -98
- package/apps/runtime/dist/docs/user/server.md +0 -52
- package/apps/runtime/dist/docs/user/space.md +0 -126
- package/apps/runtime/dist/docs/user/steps.md +0 -220
- package/apps/runtime/dist/docs/user/test-and-share.md +0 -224
- package/apps/runtime/dist/docs/user/troubleshooting.md +0 -67
- package/apps/runtime/dist/docs/user/wordpress.md +0 -121
- package/apps/runtime/dist/documents/parse.js +0 -246
- package/apps/runtime/dist/engenty/connections-external/build-connector.js +0 -193
- package/apps/runtime/dist/engenty/connections-external/errors.js +0 -11
- package/apps/runtime/dist/engenty/connections-external/import-service.js +0 -270
- package/apps/runtime/dist/engenty/connections-external/importer/classify.js +0 -34
- package/apps/runtime/dist/engenty/connections-external/importer/map-auth.js +0 -185
- package/apps/runtime/dist/engenty/connections-external/importer/normalize-mcp.js +0 -63
- package/apps/runtime/dist/engenty/connections-external/importer/normalize-openapi.js +0 -130
- package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +0 -143
- package/apps/runtime/dist/engenty/connections-external/invoke/mcp-client.js +0 -143
- package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +0 -119
- package/apps/runtime/dist/engenty/connections-external/oauth-dcr.js +0 -88
- package/apps/runtime/dist/engenty/connections-external/registry-client.js +0 -336
- package/apps/runtime/dist/engenty/connections-external/registry-source.js +0 -82
- package/apps/runtime/dist/engenty/connections-external/types.js +0 -7
- package/apps/runtime/dist/engenty/connections-github/connector.js +0 -209
- package/apps/runtime/dist/engenty/connections-google/connectors/calendar.js +0 -381
- package/apps/runtime/dist/engenty/connections-google/connectors/contacts.js +0 -94
- package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +0 -290
- package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +0 -567
- package/apps/runtime/dist/engenty/connections-google/definitions.js +0 -11
- package/apps/runtime/dist/engenty/connections-google/shared.js +0 -73
- package/apps/runtime/dist/engenty/connections-hubspot/connector.js +0 -140
- package/apps/runtime/dist/engenty/connections-microsoft/action.js +0 -17
- package/apps/runtime/dist/engenty/connections-microsoft/graph.js +0 -114
- package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +0 -286
- package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +0 -492
- package/apps/runtime/dist/engenty/connections-s3/s3.js +0 -328
- package/apps/runtime/dist/engenty/connections-sdk/files-capability.js +0 -86
- package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +0 -150
- package/apps/runtime/dist/engenty/connections-sdk/registry.js +0 -89
- package/apps/runtime/dist/engenty/connections-sdk/storage-capability.js +0 -84
- package/apps/runtime/dist/engenty/connections-sdk/types.js +0 -30
- package/apps/runtime/dist/engenty/connections-slack/connector.js +0 -360
- package/apps/runtime/dist/engenty/csv-import/csv-matrix.js +0 -178
- package/apps/runtime/dist/engenty/csv-import/import-sources.js +0 -87
- package/apps/runtime/dist/engenty/csv-import/parse-csv.js +0 -129
- package/apps/runtime/dist/engenty/csv-import/serialize-csv.js +0 -20
- package/apps/runtime/dist/engenty/csv-import/types.js +0 -1
- package/apps/runtime/dist/engenty/csv-import/xlsx-workbook.js +0 -159
- package/apps/runtime/dist/engenty/doc-converter/interface.js +0 -9
- package/apps/runtime/dist/engenty/doc-converter/page-break.js +0 -92
- package/apps/runtime/dist/engenty/doc-converter/providers/local/index.js +0 -72
- package/apps/runtime/dist/engenty/document-scanner/schemas/classifier.js +0 -30
- package/apps/runtime/dist/engenty/document-scanner/schemas/index.js +0 -4
- package/apps/runtime/dist/engenty/document-scanner/schemas/invoice.js +0 -73
- package/apps/runtime/dist/engenty/document-scanner/schemas/receipt.js +0 -63
- package/apps/runtime/dist/engenty/document-scanner/schemas/shared.js +0 -40
- package/apps/runtime/dist/engenty/search-index/chunks.js +0 -164
- package/apps/runtime/dist/engenty/search-index/contracts.js +0 -9
- package/apps/runtime/dist/engenty/shims/connections-sdk.js +0 -39
- package/apps/runtime/dist/engenty/shims/plugin-sdk.js +0 -1
- package/apps/runtime/dist/engenty/shims/web-ingest.js +0 -19
- package/apps/runtime/dist/engenty/web-ingest/ssrf.js +0 -277
- package/apps/runtime/dist/engine/asks.js +0 -82
- package/apps/runtime/dist/engine/decide.js +0 -82
- package/apps/runtime/dist/engine/device.js +0 -194
- package/apps/runtime/dist/engine/events.js +0 -128
- package/apps/runtime/dist/engine/input.js +0 -208
- package/apps/runtime/dist/engine/owner.js +0 -32
- package/apps/runtime/dist/engine/prepare.js +0 -90
- package/apps/runtime/dist/engine/push.js +0 -58
- package/apps/runtime/dist/engine/requirements.js +0 -355
- package/apps/runtime/dist/engine/resources.js +0 -198
- package/apps/runtime/dist/engine/runner.js +0 -970
- package/apps/runtime/dist/engine/steps.js +0 -1000
- package/apps/runtime/dist/engine/surface.js +0 -91
- package/apps/runtime/dist/engine/template.js +0 -240
- package/apps/runtime/dist/engine/types.js +0 -4
- package/apps/runtime/dist/env.js +0 -295
- package/apps/runtime/dist/features.js +0 -123
- package/apps/runtime/dist/files/blobs.js +0 -22
- package/apps/runtime/dist/files/objects.js +0 -86
- package/apps/runtime/dist/files/storage.js +0 -120
- package/apps/runtime/dist/files/web-images.js +0 -101
- package/apps/runtime/dist/film/project.js +0 -257
- package/apps/runtime/dist/film/skills.js +0 -91
- package/apps/runtime/dist/film/sounds.js +0 -122
- package/apps/runtime/dist/film/step.js +0 -289
- package/apps/runtime/dist/film/tools.js +0 -99
- package/apps/runtime/dist/geocode.js +0 -58
- package/apps/runtime/dist/harness/apple.js +0 -269
- package/apps/runtime/dist/harness/claude.js +0 -147
- package/apps/runtime/dist/harness/codex.js +0 -229
- package/apps/runtime/dist/harness/cursor.js +0 -93
- package/apps/runtime/dist/harness/env.js +0 -124
- package/apps/runtime/dist/harness/gemini.js +0 -126
- package/apps/runtime/dist/harness/index.js +0 -95
- package/apps/runtime/dist/harness/model.js +0 -271
- package/apps/runtime/dist/harness/prompt.js +0 -121
- package/apps/runtime/dist/harness/terminal.js +0 -194
- package/apps/runtime/dist/harness/types.js +0 -7
- package/apps/runtime/dist/index.js +0 -113
- package/apps/runtime/dist/limits.js +0 -81
- package/apps/runtime/dist/link-preview.js +0 -60
- package/apps/runtime/dist/log.js +0 -106
- package/apps/runtime/dist/manage.js +0 -249
- package/apps/runtime/dist/mcp/auth.js +0 -161
- package/apps/runtime/dist/mcp/bridge.js +0 -59
- package/apps/runtime/dist/mcp/flow-app.js +0 -97
- package/apps/runtime/dist/mcp/handler.js +0 -54
- package/apps/runtime/dist/mcp/scopes.js +0 -14
- package/apps/runtime/dist/mcp/seen.js +0 -65
- package/apps/runtime/dist/mcp/tools.js +0 -572
- package/apps/runtime/dist/media/conversation.js +0 -167
- package/apps/runtime/dist/media/ffmpeg.js +0 -121
- package/apps/runtime/dist/media/generate.js +0 -120
- package/apps/runtime/dist/media/marking.js +0 -121
- package/apps/runtime/dist/media/transcribe.js +0 -198
- package/apps/runtime/dist/model-errors.js +0 -42
- package/apps/runtime/dist/models.js +0 -1106
- package/apps/runtime/dist/plugin.js +0 -61
- package/apps/runtime/dist/plugins/channels.js +0 -78
- package/apps/runtime/dist/plugins/claims.js +0 -56
- package/apps/runtime/dist/plugins/discovery.js +0 -155
- package/apps/runtime/dist/plugins/events.js +0 -63
- package/apps/runtime/dist/plugins/jobs.js +0 -64
- package/apps/runtime/dist/plugins/loader.js +0 -501
- package/apps/runtime/dist/plugins/migrations.js +0 -69
- package/apps/runtime/dist/plugins/pro-keys.js +0 -34
- package/apps/runtime/dist/plugins/pro-state.js +0 -83
- package/apps/runtime/dist/plugins/pro.js +0 -310
- package/apps/runtime/dist/plugins/public.js +0 -44
- package/apps/runtime/dist/plugins/registry.js +0 -122
- package/apps/runtime/dist/plugins/runs.js +0 -210
- package/apps/runtime/dist/render/browser-path.js +0 -54
- package/apps/runtime/dist/render/chromium.js +0 -98
- package/apps/runtime/dist/render/convert.js +0 -158
- package/apps/runtime/dist/render/downloads.js +0 -299
- package/apps/runtime/dist/render/guard.js +0 -25
- package/apps/runtime/dist/render/shaped.js +0 -137
- package/apps/runtime/dist/routes/api.js +0 -440
- package/apps/runtime/dist/routes/debug.js +0 -42
- package/apps/runtime/dist/routes/delivery.js +0 -90
- package/apps/runtime/dist/routes/internal.js +0 -81
- package/apps/runtime/dist/routes/lang.js +0 -25
- package/apps/runtime/dist/routes/marketplace.js +0 -43
- package/apps/runtime/dist/routes/plugin-public.js +0 -113
- package/apps/runtime/dist/routes/plugins.js +0 -212
- package/apps/runtime/dist/routes/runs.js +0 -1422
- package/apps/runtime/dist/routes/studio.js +0 -1600
- package/apps/runtime/dist/routes/wizard-stream.js +0 -30
- package/apps/runtime/dist/running.js +0 -39
- package/apps/runtime/dist/sandbox/docker.js +0 -75
- package/apps/runtime/dist/sandbox/index.js +0 -23
- package/apps/runtime/dist/sandbox/types.js +0 -1
- package/apps/runtime/dist/secrets/crypto.js +0 -28
- package/apps/runtime/dist/secrets/signing.js +0 -52
- package/apps/runtime/dist/secrets/vault.js +0 -59
- package/apps/runtime/dist/services/access.js +0 -88
- package/apps/runtime/dist/services/api.js +0 -248
- package/apps/runtime/dist/services/architect.js +0 -95
- package/apps/runtime/dist/services/assistant-chats.js +0 -311
- package/apps/runtime/dist/services/brand.js +0 -85
- package/apps/runtime/dist/services/cloud.js +0 -456
- package/apps/runtime/dist/services/draft-events.js +0 -27
- package/apps/runtime/dist/services/engenty-shapes.js +0 -71
- package/apps/runtime/dist/services/errors.js +0 -29
- package/apps/runtime/dist/services/files.js +0 -178
- package/apps/runtime/dist/services/knowledge-model.js +0 -559
- package/apps/runtime/dist/services/knowledge.js +0 -721
- package/apps/runtime/dist/services/links.js +0 -16
- package/apps/runtime/dist/services/marketplace.js +0 -492
- package/apps/runtime/dist/services/onboarding.js +0 -152
- package/apps/runtime/dist/services/package-file.js +0 -82
- package/apps/runtime/dist/services/package.js +0 -170
- package/apps/runtime/dist/services/profile.js +0 -51
- package/apps/runtime/dist/services/project-files.js +0 -439
- package/apps/runtime/dist/services/project-index.js +0 -707
- package/apps/runtime/dist/services/projects.js +0 -387
- package/apps/runtime/dist/services/relevance.js +0 -58
- package/apps/runtime/dist/services/runners.js +0 -178
- package/apps/runtime/dist/services/runs.js +0 -524
- package/apps/runtime/dist/services/shares.js +0 -130
- package/apps/runtime/dist/services/site.js +0 -270
- package/apps/runtime/dist/services/space-categories.js +0 -861
- package/apps/runtime/dist/services/space-data.js +0 -792
- package/apps/runtime/dist/services/space-origin.js +0 -207
- package/apps/runtime/dist/services/spaces.js +0 -656
- package/apps/runtime/dist/services/translations.js +0 -306
- package/apps/runtime/dist/services/widgets.js +0 -34
- package/apps/runtime/dist/services/wizard-icon.js +0 -157
- package/apps/runtime/dist/services/wizards.js +0 -420
- package/apps/runtime/dist/settings.js +0 -16
- package/apps/runtime/dist/store/errors.js +0 -4
- package/apps/runtime/dist/store/index.js +0 -299
- package/apps/runtime/dist/store/shared-lists.js +0 -123
- package/apps/runtime/dist/tenants/control.js +0 -238
- package/apps/runtime/dist/tenants/tenant.js +0 -26
- package/apps/runtime/dist/texts.js +0 -203
- package/apps/runtime/dist/tools/browser.js +0 -703
- package/apps/runtime/dist/tools/connector.js +0 -204
- package/apps/runtime/dist/tools/index.js +0 -291
- package/apps/runtime/dist/tools/mail.js +0 -104
- package/apps/runtime/dist/tools/net-guard.js +0 -170
- package/apps/runtime/dist/tools/pages.js +0 -81
- package/apps/runtime/dist/tools/plugin.js +0 -180
- package/apps/runtime/dist/tools/project.js +0 -154
- package/apps/runtime/dist/tools/shared.js +0 -69
- package/apps/runtime/dist/tools/store.js +0 -238
- package/apps/runtime/dist/update.js +0 -113
- package/apps/runtime/dist/widgets/bundle.js +0 -99
- package/apps/runtime/dist/widgets/render.js +0 -329
- package/apps/runtime/dist/widgets/runtime.js +0 -108
- package/apps/runtime/dist/widgets/script.js +0 -30
- package/apps/runtime/dist/widgets/step.js +0 -223
- package/apps/web/dist/ai-labels/ai-black.svg +0 -20
- package/apps/web/dist/ai-labels/ai-generated-black.svg +0 -31
- package/apps/web/dist/ai-labels/ai-generated-white.svg +0 -32
- package/apps/web/dist/ai-labels/ai-modified-black.svg +0 -30
- package/apps/web/dist/ai-labels/ai-modified-white.svg +0 -31
- package/apps/web/dist/ai-labels/ai-white.svg +0 -21
- package/apps/web/dist/assets/AboutDialog--aZOfowz.js +0 -1
- package/apps/web/dist/assets/ChangelogDialog-CcMXT8l9.js +0 -1
- package/apps/web/dist/assets/ChatView-BqK5nH84.js +0 -10
- package/apps/web/dist/assets/EditorPage-BRZmuMsK.js +0 -3
- package/apps/web/dist/assets/FlowPreview-CpA_aX8t.js +0 -1
- package/apps/web/dist/assets/Harness-BrP-ENHg.css +0 -1
- package/apps/web/dist/assets/Harness-C8demwfW.js +0 -16
- package/apps/web/dist/assets/NewWizardChannels-vph1mN1m.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-u1BIy4q9.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-BR3FmORm.js +0 -1
- package/apps/web/dist/assets/ProjectPage-BWN0iO0X.js +0 -1
- package/apps/web/dist/assets/PublicRunner-CohatW8Y.js +0 -1
- package/apps/web/dist/assets/ReadOnly-rQGZBuzb.js +0 -1
- package/apps/web/dist/assets/RunDrawer-Cs8XqQUo.js +0 -4
- package/apps/web/dist/assets/RunnerView-B85O0i1h.js +0 -1
- package/apps/web/dist/assets/SettingsPage-CM6HfO-O.js +0 -1
- package/apps/web/dist/assets/SetupPage-BpAobBc4.js +0 -1
- package/apps/web/dist/assets/SharePage-CbmAN4M4.js +0 -1
- package/apps/web/dist/assets/changelog-BBR59khF.js +0 -1
- package/apps/web/dist/assets/engenty-eXZ-EAwd.js +0 -1
- package/apps/web/dist/assets/esm-CY-A_13f.js +0 -7
- package/apps/web/dist/assets/fluffy-engenty-ClRou7yu.js +0 -456
- package/apps/web/dist/assets/index-C7HL_Fjz.js +0 -14
- package/apps/web/dist/assets/index-Co9Yr23e.css +0 -1
- package/apps/web/dist/assets/jsx-runtime-BNakU3Ej.js +0 -1
- package/apps/web/dist/assets/lock--JFmtLDU.js +0 -1
- package/apps/web/dist/assets/oss-credits-BJrR7BR1.js +0 -1
- package/apps/web/dist/assets/pdfmake-Cx9scTbD.js +0 -228
- package/apps/web/dist/assets/phone-DMtADQ4-.js +0 -1
- package/apps/web/dist/assets/preload-helper-CNEI7N0N.js +0 -1
- package/apps/web/dist/assets/qr-scanner-worker.min-CJaXo3yu.js +0 -98
- package/apps/web/dist/assets/qr-scanner.min-C_UI0gH-.js +0 -1
- package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
- package/apps/web/dist/assets/settings-menu-Dac4JUiM.js +0 -1
- package/apps/web/dist/assets/ui-CTXSFCzc.js +0 -137
- package/apps/web/dist/assets/upload-Bcpc3mDn.js +0 -1
- package/apps/web/dist/assets/vfs_fonts-DllDSYt1.js +0 -1
- package/apps/web/dist/embed.js +0 -266
- package/apps/web/dist/favicon.svg +0 -1
- package/apps/web/dist/icons/apple-touch-icon.png +0 -0
- package/apps/web/dist/icons/icon-192.png +0 -0
- package/apps/web/dist/icons/icon-512.png +0 -0
- package/apps/web/dist/icons/icon-maskable-512.png +0 -0
- package/apps/web/dist/index.html +0 -48
- package/apps/web/dist/manifest.webmanifest +0 -21
- package/apps/web/dist/mcp/flow.html +0 -980
- package/apps/web/dist/sw.js +0 -15
- package/modules/README.md +0 -15
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +0 -1150
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.js +0 -4
- package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.d.ts +0 -322
- package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.js +0 -4
- package/node_modules/@engenty-wizards/plugin-sdk/dist/thread.d.ts +0 -174
- package/node_modules/@engenty-wizards/plugin-sdk/dist/thread.js +0 -821
- package/node_modules/@engenty-wizards/plugin-sdk/package.json +0 -11
- package/node_modules/@engenty-wizards/shared/dist/assistant.d.ts +0 -174
- package/node_modules/@engenty-wizards/shared/dist/assistant.js +0 -65
- package/node_modules/@engenty-wizards/shared/dist/changes.d.ts +0 -22
- package/node_modules/@engenty-wizards/shared/dist/changes.js +0 -61
- package/node_modules/@engenty-wizards/shared/dist/connectors.d.ts +0 -77
- package/node_modules/@engenty-wizards/shared/dist/connectors.js +0 -2
- package/node_modules/@engenty-wizards/shared/dist/decision.d.ts +0 -76
- package/node_modules/@engenty-wizards/shared/dist/decision.js +0 -147
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +0 -2922
- package/node_modules/@engenty-wizards/shared/dist/definition.js +0 -1920
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.d.ts +0 -5
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.js +0 -132
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.d.ts +0 -11
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.js +0 -209
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.d.ts +0 -532
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.js +0 -217
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.d.ts +0 -3
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.js +0 -3
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.d.ts +0 -14
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.js +0 -166
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.d.ts +0 -33
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.js +0 -99
- package/node_modules/@engenty-wizards/shared/dist/feature-flags.d.ts +0 -78
- package/node_modules/@engenty-wizards/shared/dist/feature-flags.js +0 -70
- package/node_modules/@engenty-wizards/shared/dist/features.d.ts +0 -41
- package/node_modules/@engenty-wizards/shared/dist/features.js +0 -89
- package/node_modules/@engenty-wizards/shared/dist/fit.d.ts +0 -71
- package/node_modules/@engenty-wizards/shared/dist/fit.js +0 -382
- package/node_modules/@engenty-wizards/shared/dist/json-schema.d.ts +0 -14
- package/node_modules/@engenty-wizards/shared/dist/json-schema.js +0 -66
- package/node_modules/@engenty-wizards/shared/dist/knowledge.d.ts +0 -199
- package/node_modules/@engenty-wizards/shared/dist/knowledge.js +0 -68
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.d.ts +0 -35
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.js +0 -107
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.d.ts +0 -20
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.js +0 -136
- package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +0 -227
- package/node_modules/@engenty-wizards/shared/dist/marketplace.js +0 -354
- package/node_modules/@engenty-wizards/shared/dist/merge.d.ts +0 -7
- package/node_modules/@engenty-wizards/shared/dist/merge.js +0 -40
- package/node_modules/@engenty-wizards/shared/dist/numbers.d.ts +0 -24
- package/node_modules/@engenty-wizards/shared/dist/numbers.js +0 -54
- package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +0 -224
- package/node_modules/@engenty-wizards/shared/dist/projects.js +0 -319
- package/node_modules/@engenty-wizards/shared/dist/providers.d.ts +0 -101
- package/node_modules/@engenty-wizards/shared/dist/providers.js +0 -390
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +0 -679
- package/node_modules/@engenty-wizards/shared/dist/run.js +0 -618
- package/node_modules/@engenty-wizards/shared/dist/runner-texts.d.ts +0 -546
- package/node_modules/@engenty-wizards/shared/dist/runner-texts.js +0 -523
- package/node_modules/@engenty-wizards/shared/dist/runners.d.ts +0 -93
- package/node_modules/@engenty-wizards/shared/dist/runners.js +0 -146
- package/node_modules/@engenty-wizards/shared/dist/shape.d.ts +0 -102
- package/node_modules/@engenty-wizards/shared/dist/shape.js +0 -318
- package/node_modules/@engenty-wizards/shared/dist/space-data.d.ts +0 -89
- package/node_modules/@engenty-wizards/shared/dist/space-data.js +0 -47
- package/node_modules/@engenty-wizards/shared/dist/store.d.ts +0 -117
- package/node_modules/@engenty-wizards/shared/dist/store.js +0 -81
- package/node_modules/@engenty-wizards/shared/dist/surface.d.ts +0 -115
- package/node_modules/@engenty-wizards/shared/dist/surface.js +0 -442
- package/node_modules/@engenty-wizards/shared/dist/texts.d.ts +0 -45
- package/node_modules/@engenty-wizards/shared/dist/texts.js +0 -54
- package/node_modules/@engenty-wizards/shared/dist/translation.d.ts +0 -23
- package/node_modules/@engenty-wizards/shared/dist/translation.js +0 -154
- package/node_modules/@engenty-wizards/shared/dist/wizard-package.d.ts +0 -48
- package/node_modules/@engenty-wizards/shared/dist/wizard-package.js +0 -49
- package/node_modules/@engenty-wizards/shared/dist/workspace.d.ts +0 -16
- package/node_modules/@engenty-wizards/shared/dist/workspace.js +0 -51
- package/node_modules/@engenty-wizards/shared/package.json +0 -10
- package/plugin/.claude-plugin/plugin.json +0 -9
- package/plugin/.mcp.json +0 -8
- package/plugin/commands/wizard.md +0 -8
- package/plugin/skills/build-wizard/SKILL.md +0 -27
- package/plugin/skills/use-wizard/SKILL.md +0 -18
|
@@ -1,721 +0,0 @@
|
|
|
1
|
-
import { formatTableCell } from "@engenty-wizards/shared/engenty/data-tables";
|
|
2
|
-
import { slugOf, } from "@engenty-wizards/shared/knowledge";
|
|
3
|
-
import { and, asc, count, eq, inArray, isNotNull, isNull } from "drizzle-orm";
|
|
4
|
-
import { db, schema } from "../db/client.js";
|
|
5
|
-
import { embeddingModel, systemOneAccess } from "../models.js";
|
|
6
|
-
import { notFound, ServiceError } from "./errors.js";
|
|
7
|
-
import { ownedProject } from "./projects.js";
|
|
8
|
-
import { categoryLines, categoryRows, dateOf, filterItems, itemCategoriesOf, listCategories, numberOf, } from "./space-categories.js";
|
|
9
|
-
/** Gives each item without a slug one, unique among its siblings, and keeps it. */
|
|
10
|
-
async function slugsFor(rows, siblingsOf, save) {
|
|
11
|
-
const taken = new Map();
|
|
12
|
-
const out = new Map();
|
|
13
|
-
for (const row of rows) {
|
|
14
|
-
if (row.slug) {
|
|
15
|
-
const set = taken.get(siblingsOf(row)) ?? new Set();
|
|
16
|
-
set.add(row.slug);
|
|
17
|
-
taken.set(siblingsOf(row), set);
|
|
18
|
-
out.set(row.id, row.slug);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
for (const row of rows) {
|
|
22
|
-
if (row.slug) {
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
const set = taken.get(siblingsOf(row)) ?? new Set();
|
|
26
|
-
const base = slugOf(row.title);
|
|
27
|
-
let slug = base;
|
|
28
|
-
for (let i = 2; set.has(slug); i++) {
|
|
29
|
-
slug = `${base}-${i}`;
|
|
30
|
-
}
|
|
31
|
-
set.add(slug);
|
|
32
|
-
taken.set(siblingsOf(row), set);
|
|
33
|
-
out.set(row.id, slug);
|
|
34
|
-
await save(row.id, slug);
|
|
35
|
-
}
|
|
36
|
-
return out;
|
|
37
|
-
}
|
|
38
|
-
/** A slug for a new page among its siblings, or a new table among the space's tables. */
|
|
39
|
-
export async function freeSlug(projectId, title, of, except) {
|
|
40
|
-
const rows = of === "table"
|
|
41
|
-
? await db.query.spaceTable.findMany({
|
|
42
|
-
where: and(eq(schema.spaceTable.projectId, projectId), isNull(schema.spaceTable.wizardId)),
|
|
43
|
-
columns: { id: true, slug: true },
|
|
44
|
-
})
|
|
45
|
-
: await db.query.spacePage.findMany({
|
|
46
|
-
where: and(eq(schema.spacePage.projectId, projectId), isNull(schema.spacePage.wizardId), of.parentId
|
|
47
|
-
? eq(schema.spacePage.parentId, of.parentId)
|
|
48
|
-
: isNull(schema.spacePage.parentId)),
|
|
49
|
-
columns: { id: true, slug: true },
|
|
50
|
-
});
|
|
51
|
-
const taken = new Set(rows.filter((r) => r.id !== except).map((r) => r.slug));
|
|
52
|
-
const base = slugOf(title);
|
|
53
|
-
let slug = base;
|
|
54
|
-
for (let i = 2; taken.has(slug); i++) {
|
|
55
|
-
slug = `${base}-${i}`;
|
|
56
|
-
}
|
|
57
|
-
return slug;
|
|
58
|
-
}
|
|
59
|
-
/** The space's own pages with their paths, by id. */
|
|
60
|
-
export async function pageTree(projectId) {
|
|
61
|
-
const rows = await db.query.spacePage.findMany({
|
|
62
|
-
where: and(eq(schema.spacePage.projectId, projectId), isNull(schema.spacePage.wizardId)),
|
|
63
|
-
columns: { id: true, parentId: true, title: true, slug: true, position: true },
|
|
64
|
-
orderBy: [asc(schema.spacePage.position), asc(schema.spacePage.title)],
|
|
65
|
-
});
|
|
66
|
-
const slugs = await slugsFor(rows, (r) => r.parentId ?? "", (id, slug) => db.update(schema.spacePage).set({ slug }).where(eq(schema.spacePage.id, id)));
|
|
67
|
-
const byId = new Map(rows.map((r) => [r.id, r]));
|
|
68
|
-
const out = new Map();
|
|
69
|
-
const walk = (id, seen) => {
|
|
70
|
-
const known = out.get(id);
|
|
71
|
-
if (known) {
|
|
72
|
-
return known;
|
|
73
|
-
}
|
|
74
|
-
const row = byId.get(id);
|
|
75
|
-
if (!row || seen.has(id)) {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
seen.add(id);
|
|
79
|
-
const parent = row.parentId ? walk(row.parentId, seen) : undefined;
|
|
80
|
-
const slug = slugs.get(id);
|
|
81
|
-
const node = {
|
|
82
|
-
id,
|
|
83
|
-
parentId: parent ? row.parentId : null,
|
|
84
|
-
title: row.title,
|
|
85
|
-
slug,
|
|
86
|
-
position: row.position,
|
|
87
|
-
path: parent ? `${parent.path}/${slug}` : `pages/${slug}`,
|
|
88
|
-
titles: [...(parent?.titles ?? []), row.title],
|
|
89
|
-
};
|
|
90
|
-
out.set(id, node);
|
|
91
|
-
return node;
|
|
92
|
-
};
|
|
93
|
-
for (const row of rows) {
|
|
94
|
-
walk(row.id, new Set());
|
|
95
|
-
}
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
|
-
/** The space's own tables with their paths, by id. */
|
|
99
|
-
export async function tablePaths(projectId) {
|
|
100
|
-
const rows = await db.query.spaceTable.findMany({
|
|
101
|
-
where: and(eq(schema.spaceTable.projectId, projectId), isNull(schema.spaceTable.wizardId)),
|
|
102
|
-
columns: { id: true, slug: true, title: true },
|
|
103
|
-
orderBy: [asc(schema.spaceTable.createdAt)],
|
|
104
|
-
});
|
|
105
|
-
const slugs = await slugsFor(rows, () => "", (id, slug) => db.update(schema.spaceTable).set({ slug }).where(eq(schema.spaceTable.id, id)));
|
|
106
|
-
return new Map(rows.map((r) => [r.id, `tables/${slugs.get(r.id)}`]));
|
|
107
|
-
}
|
|
108
|
-
/** The space's documents with their paths, by id: their names, made unique. */
|
|
109
|
-
export async function filePaths(projectId) {
|
|
110
|
-
const rows = await db.query.projectFile.findMany({
|
|
111
|
-
where: and(eq(schema.projectFile.projectId, projectId), eq(schema.projectFile.kind, "document")),
|
|
112
|
-
columns: { id: true, name: true },
|
|
113
|
-
orderBy: [asc(schema.projectFile.createdAt)],
|
|
114
|
-
});
|
|
115
|
-
const taken = new Set();
|
|
116
|
-
const out = new Map();
|
|
117
|
-
for (const row of rows) {
|
|
118
|
-
const base = row.name.replace(/[/\\]/g, "-");
|
|
119
|
-
let name = base;
|
|
120
|
-
for (let i = 2; taken.has(name.toLowerCase()); i++) {
|
|
121
|
-
const dot = base.lastIndexOf(".");
|
|
122
|
-
name = dot > 0 ? `${base.slice(0, dot)}-${i}${base.slice(dot)}` : `${base}-${i}`;
|
|
123
|
-
}
|
|
124
|
-
taken.add(name.toLowerCase());
|
|
125
|
-
out.set(row.id, `files/${name}`);
|
|
126
|
-
}
|
|
127
|
-
return out;
|
|
128
|
-
}
|
|
129
|
-
const cleanPath = (path) => path
|
|
130
|
-
.trim()
|
|
131
|
-
.replace(/^\/+|\/+$/g, "")
|
|
132
|
-
.replace(/\.(md|csv)$/i, "")
|
|
133
|
-
.toLowerCase();
|
|
134
|
-
/** What a path names; null when nothing in the space has it. */
|
|
135
|
-
export async function resolvePath(projectId, path) {
|
|
136
|
-
const want = cleanPath(path);
|
|
137
|
-
if (want.startsWith("pages/")) {
|
|
138
|
-
for (const node of (await pageTree(projectId)).values()) {
|
|
139
|
-
if (node.path === want) {
|
|
140
|
-
return { kind: "page", id: node.id, path: node.path };
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else if (want.startsWith("tables/")) {
|
|
145
|
-
for (const [id, p] of await tablePaths(projectId)) {
|
|
146
|
-
if (p === want) {
|
|
147
|
-
return { kind: "table", id, path: p };
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else if (want.startsWith("files/")) {
|
|
152
|
-
for (const [id, p] of await filePaths(projectId)) {
|
|
153
|
-
if (p.toLowerCase() === want) {
|
|
154
|
-
return { kind: "file", id, path: p };
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
// --- what the studio lists ---------------------------------------------------------
|
|
161
|
-
/** Files a page or a table was read from: they stand behind it, not on their own. */
|
|
162
|
-
async function convertedFiles(projectId) {
|
|
163
|
-
const [pages, tables] = await Promise.all([
|
|
164
|
-
db
|
|
165
|
-
.selectDistinct({ id: schema.spacePage.fileId })
|
|
166
|
-
.from(schema.spacePage)
|
|
167
|
-
.where(and(eq(schema.spacePage.projectId, projectId), isNotNull(schema.spacePage.fileId))),
|
|
168
|
-
db
|
|
169
|
-
.selectDistinct({ id: schema.spaceTable.fileId })
|
|
170
|
-
.from(schema.spaceTable)
|
|
171
|
-
.where(and(eq(schema.spaceTable.projectId, projectId), isNotNull(schema.spaceTable.fileId))),
|
|
172
|
-
]);
|
|
173
|
-
return new Set([...pages, ...tables].map((r) => r.id));
|
|
174
|
-
}
|
|
175
|
-
/** Everything Knowledge holds: pages (sub-pages counted under them), tables, files, categories. */
|
|
176
|
-
export async function listKnowledge(userId, projectId) {
|
|
177
|
-
const project = await ownedProject(userId, projectId);
|
|
178
|
-
const [tree, tables, rowCounts, files, converted, categories, embeddings, checker] = await Promise.all([
|
|
179
|
-
pageTree(project.id),
|
|
180
|
-
db.query.spaceTable.findMany({
|
|
181
|
-
where: and(eq(schema.spaceTable.projectId, project.id), isNull(schema.spaceTable.wizardId)),
|
|
182
|
-
}),
|
|
183
|
-
db
|
|
184
|
-
.select({ tableId: schema.spaceTableRow.tableId, n: count() })
|
|
185
|
-
.from(schema.spaceTableRow)
|
|
186
|
-
.innerJoin(schema.spaceTable, eq(schema.spaceTable.id, schema.spaceTableRow.tableId))
|
|
187
|
-
.where(and(eq(schema.spaceTable.projectId, project.id), isNull(schema.spaceTable.wizardId)))
|
|
188
|
-
.groupBy(schema.spaceTableRow.tableId),
|
|
189
|
-
db.query.projectFile.findMany({
|
|
190
|
-
where: and(eq(schema.projectFile.projectId, project.id), eq(schema.projectFile.kind, "document")),
|
|
191
|
-
}),
|
|
192
|
-
convertedFiles(project.id),
|
|
193
|
-
listCategories(project.id),
|
|
194
|
-
embeddingModel()
|
|
195
|
-
.then(Boolean)
|
|
196
|
-
.catch(() => false),
|
|
197
|
-
systemOneAccess()
|
|
198
|
-
.then(Boolean)
|
|
199
|
-
.catch(() => false),
|
|
200
|
-
]);
|
|
201
|
-
const tPaths = await tablePaths(project.id);
|
|
202
|
-
const fPaths = await filePaths(project.id);
|
|
203
|
-
const pages = await db.query.spacePage.findMany({
|
|
204
|
-
where: and(eq(schema.spacePage.projectId, project.id), isNull(schema.spacePage.wizardId), isNull(schema.spacePage.parentId)),
|
|
205
|
-
columns: { markdown: false },
|
|
206
|
-
});
|
|
207
|
-
const children = new Map();
|
|
208
|
-
for (const node of tree.values()) {
|
|
209
|
-
if (node.parentId) {
|
|
210
|
-
children.set(node.parentId, (children.get(node.parentId) ?? 0) + 1);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const loose = files.filter((f) => !converted.has(f.id));
|
|
214
|
-
const cats = await itemCategoriesOf([
|
|
215
|
-
...pages.map((p) => ({ pageId: p.id })),
|
|
216
|
-
...tables.map((t) => ({ tableId: t.id })),
|
|
217
|
-
...loose.map((f) => ({ fileId: f.id })),
|
|
218
|
-
]);
|
|
219
|
-
const items = [
|
|
220
|
-
...pages.map((p) => ({
|
|
221
|
-
key: `p:${p.id}`,
|
|
222
|
-
kind: "page",
|
|
223
|
-
id: p.id,
|
|
224
|
-
title: p.title,
|
|
225
|
-
path: tree.get(p.id)?.path ?? "",
|
|
226
|
-
children: children.get(p.id) ?? 0,
|
|
227
|
-
rows: null,
|
|
228
|
-
format: null,
|
|
229
|
-
origin: p.origin,
|
|
230
|
-
originLabel: p.originLabel,
|
|
231
|
-
kept: p.kept,
|
|
232
|
-
review: p.review,
|
|
233
|
-
fileId: p.fileId,
|
|
234
|
-
status: "ready",
|
|
235
|
-
categories: cats.get(`p:${p.id}`) ?? [],
|
|
236
|
-
updatedAt: p.updatedAt.toISOString(),
|
|
237
|
-
})),
|
|
238
|
-
...tables.map((t) => ({
|
|
239
|
-
key: `t:${t.id}`,
|
|
240
|
-
kind: "table",
|
|
241
|
-
id: t.id,
|
|
242
|
-
title: t.title,
|
|
243
|
-
path: tPaths.get(t.id) ?? "",
|
|
244
|
-
children: 0,
|
|
245
|
-
rows: rowCounts.find((r) => r.tableId === t.id)?.n ?? 0,
|
|
246
|
-
format: t.format,
|
|
247
|
-
origin: t.origin,
|
|
248
|
-
originLabel: t.originLabel,
|
|
249
|
-
kept: t.kept,
|
|
250
|
-
review: t.review,
|
|
251
|
-
fileId: t.fileId,
|
|
252
|
-
status: "ready",
|
|
253
|
-
categories: cats.get(`t:${t.id}`) ?? [],
|
|
254
|
-
updatedAt: t.updatedAt.toISOString(),
|
|
255
|
-
})),
|
|
256
|
-
...loose.map((f) => ({
|
|
257
|
-
key: `f:${f.id}`,
|
|
258
|
-
kind: "file",
|
|
259
|
-
id: f.id,
|
|
260
|
-
title: f.name,
|
|
261
|
-
path: fPaths.get(f.id) ?? "",
|
|
262
|
-
children: 0,
|
|
263
|
-
rows: null,
|
|
264
|
-
format: null,
|
|
265
|
-
origin: f.origin,
|
|
266
|
-
originLabel: f.originLabel,
|
|
267
|
-
kept: false,
|
|
268
|
-
review: null,
|
|
269
|
-
fileId: f.id,
|
|
270
|
-
status: f.status === "pending" && Date.now() - f.updatedAt.getTime() > 15 * 60_000
|
|
271
|
-
? "failed"
|
|
272
|
-
: f.status,
|
|
273
|
-
categories: cats.get(`f:${f.id}`) ?? [],
|
|
274
|
-
updatedAt: f.updatedAt.toISOString(),
|
|
275
|
-
})),
|
|
276
|
-
];
|
|
277
|
-
items.sort((a, b) => a.title.localeCompare(b.title, "de"));
|
|
278
|
-
return { items, categories, embeddings, checked: checker };
|
|
279
|
-
}
|
|
280
|
-
/** A value opened in the studio: its summary, and the items and rows that have it. */
|
|
281
|
-
export async function valueContents(userId, valueId) {
|
|
282
|
-
const value = await db.query.spaceCategoryValue.findFirst({
|
|
283
|
-
where: eq(schema.spaceCategoryValue.id, valueId),
|
|
284
|
-
});
|
|
285
|
-
const category = value
|
|
286
|
-
? await db.query.spaceCategory.findFirst({
|
|
287
|
-
where: eq(schema.spaceCategory.id, value.categoryId),
|
|
288
|
-
})
|
|
289
|
-
: undefined;
|
|
290
|
-
if (!(value && category)) {
|
|
291
|
-
throw notFound();
|
|
292
|
-
}
|
|
293
|
-
const project = await ownedProject(userId, category.projectId);
|
|
294
|
-
const having = await db.query.spaceItemCategory.findMany({
|
|
295
|
-
where: eq(schema.spaceItemCategory.valueId, value.id),
|
|
296
|
-
});
|
|
297
|
-
return {
|
|
298
|
-
id: value.id,
|
|
299
|
-
value: value.value,
|
|
300
|
-
category: { id: category.id, name: category.name },
|
|
301
|
-
summary: value.summary,
|
|
302
|
-
summaryAt: value.summaryAt?.toISOString() ?? null,
|
|
303
|
-
...(await itemsHaving(userId, project.id, having)),
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
/** Everything that has a category, whatever its value: what the category's page lists. */
|
|
307
|
-
export async function categoryContents(userId, categoryId) {
|
|
308
|
-
const category = await db.query.spaceCategory.findFirst({
|
|
309
|
-
where: eq(schema.spaceCategory.id, categoryId),
|
|
310
|
-
});
|
|
311
|
-
if (!category) {
|
|
312
|
-
throw notFound();
|
|
313
|
-
}
|
|
314
|
-
const project = await ownedProject(userId, category.projectId);
|
|
315
|
-
const having = await db.query.spaceItemCategory.findMany({
|
|
316
|
-
where: eq(schema.spaceItemCategory.categoryId, category.id),
|
|
317
|
-
});
|
|
318
|
-
return itemsHaving(userId, project.id, having);
|
|
319
|
-
}
|
|
320
|
-
/** The items rows of `space_item_category` name, as the studio lists them, and rows by table. */
|
|
321
|
-
async function itemsHaving(userId, projectId, having) {
|
|
322
|
-
const project = { id: projectId };
|
|
323
|
-
const pageIds = having.flatMap((h) => (h.pageId ? [h.pageId] : []));
|
|
324
|
-
const tableIds = having.flatMap((h) => (h.tableId ? [h.tableId] : []));
|
|
325
|
-
const fileIds = having.flatMap((h) => (h.fileId ? [h.fileId] : []));
|
|
326
|
-
const rowIds = having.flatMap((h) => (h.rowId ? [h.rowId] : []));
|
|
327
|
-
const all = await listKnowledge(userId, project.id);
|
|
328
|
-
const tree = await pageTree(project.id);
|
|
329
|
-
const subPages = pageIds.filter((id) => !all.items.some((i) => i.key === `p:${id}`));
|
|
330
|
-
const subItems = [];
|
|
331
|
-
if (subPages.length) {
|
|
332
|
-
const cats = await itemCategoriesOf(subPages.map((pageId) => ({ pageId })));
|
|
333
|
-
for (const page of await db.query.spacePage.findMany({
|
|
334
|
-
where: inArray(schema.spacePage.id, subPages),
|
|
335
|
-
columns: { markdown: false },
|
|
336
|
-
})) {
|
|
337
|
-
subItems.push({
|
|
338
|
-
key: `p:${page.id}`,
|
|
339
|
-
kind: "page",
|
|
340
|
-
id: page.id,
|
|
341
|
-
title: tree.get(page.id)?.titles.join(" › ") ?? page.title,
|
|
342
|
-
path: tree.get(page.id)?.path ?? "",
|
|
343
|
-
children: [...tree.values()].filter((n) => n.parentId === page.id).length,
|
|
344
|
-
rows: null,
|
|
345
|
-
format: null,
|
|
346
|
-
origin: page.origin,
|
|
347
|
-
originLabel: page.originLabel,
|
|
348
|
-
kept: page.kept,
|
|
349
|
-
review: page.review,
|
|
350
|
-
fileId: page.fileId,
|
|
351
|
-
status: "ready",
|
|
352
|
-
categories: cats.get(`p:${page.id}`) ?? [],
|
|
353
|
-
updatedAt: page.updatedAt.toISOString(),
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
const rowTables = new Map();
|
|
358
|
-
for (let i = 0; i < rowIds.length; i += 500) {
|
|
359
|
-
for (const r of await db.query.spaceTableRow.findMany({
|
|
360
|
-
where: inArray(schema.spaceTableRow.id, rowIds.slice(i, i + 500)),
|
|
361
|
-
columns: { tableId: true },
|
|
362
|
-
})) {
|
|
363
|
-
rowTables.set(r.tableId, (rowTables.get(r.tableId) ?? 0) + 1);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
return {
|
|
367
|
-
items: [
|
|
368
|
-
...all.items.filter((i) => (i.kind === "page" && pageIds.includes(i.id)) ||
|
|
369
|
-
(i.kind === "table" && tableIds.includes(i.id)) ||
|
|
370
|
-
(i.kind === "file" && fileIds.includes(i.id))),
|
|
371
|
-
...subItems,
|
|
372
|
-
],
|
|
373
|
-
rows: [...rowTables].map(([tableId, n]) => ({
|
|
374
|
-
tableId,
|
|
375
|
-
title: all.items.find((i) => i.key === `t:${tableId}`)?.title ?? "",
|
|
376
|
-
count: n,
|
|
377
|
-
})),
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
/** What the studio shows around a page of Knowledge: where it stands, its sub-pages, its origin. */
|
|
381
|
-
export async function knowledgePage(page) {
|
|
382
|
-
const tree = await pageTree(page.projectId);
|
|
383
|
-
const node = tree.get(page.id);
|
|
384
|
-
const parents = [];
|
|
385
|
-
for (let at = node?.parentId ? tree.get(node.parentId) : undefined; at;) {
|
|
386
|
-
parents.unshift({ id: at.id, title: at.title });
|
|
387
|
-
at = at.parentId ? tree.get(at.parentId) : undefined;
|
|
388
|
-
}
|
|
389
|
-
const children = [...tree.values()]
|
|
390
|
-
.filter((n) => n.parentId === page.id)
|
|
391
|
-
.sort((a, b) => a.position - b.position || a.title.localeCompare(b.title, "de"))
|
|
392
|
-
.map((n) => ({ id: n.id, title: n.title, path: n.path }));
|
|
393
|
-
const file = page.fileId
|
|
394
|
-
? await db.query.projectFile.findFirst({
|
|
395
|
-
where: eq(schema.projectFile.id, page.fileId),
|
|
396
|
-
columns: { id: true, name: true, mime: true },
|
|
397
|
-
})
|
|
398
|
-
: undefined;
|
|
399
|
-
return {
|
|
400
|
-
id: page.id,
|
|
401
|
-
path: node?.path ?? "",
|
|
402
|
-
parents,
|
|
403
|
-
children,
|
|
404
|
-
categories: (await itemCategoriesOf([{ pageId: page.id }])).get(`p:${page.id}`) ?? [],
|
|
405
|
-
origin: page.origin,
|
|
406
|
-
originLabel: page.originLabel,
|
|
407
|
-
kept: page.kept,
|
|
408
|
-
review: page.review,
|
|
409
|
-
file: file ?? null,
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
// --- what a step reads ---------------------------------------------------------------
|
|
413
|
-
const PART = 20_000;
|
|
414
|
-
function yamlValue(v) {
|
|
415
|
-
return typeof v === "string" && /[:#\n"']|^\s|\s$/.test(v) ? JSON.stringify(v) : String(v);
|
|
416
|
-
}
|
|
417
|
-
/** The headings of a page, outermost first, for a step that wants one section. */
|
|
418
|
-
function sectionOf(markdown, wanted) {
|
|
419
|
-
const lines = markdown.split("\n");
|
|
420
|
-
const want = wanted
|
|
421
|
-
.replace(/^#+\s*/, "")
|
|
422
|
-
.trim()
|
|
423
|
-
.toLowerCase();
|
|
424
|
-
let start = -1;
|
|
425
|
-
let level = 0;
|
|
426
|
-
let fence = false;
|
|
427
|
-
for (let i = 0; i < lines.length; i++) {
|
|
428
|
-
if (/^\s*(```|~~~)/.test(lines[i])) {
|
|
429
|
-
fence = !fence;
|
|
430
|
-
}
|
|
431
|
-
const h = fence ? null : /^(#{1,6})\s+(.*)$/.exec(lines[i]);
|
|
432
|
-
if (!h) {
|
|
433
|
-
continue;
|
|
434
|
-
}
|
|
435
|
-
if (start >= 0 && h[1].length <= level) {
|
|
436
|
-
return lines.slice(start, i).join("\n").trim();
|
|
437
|
-
}
|
|
438
|
-
if (start < 0 && h[2].trim().toLowerCase().includes(want)) {
|
|
439
|
-
start = i;
|
|
440
|
-
level = h[1].length;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
return start >= 0 ? lines.slice(start).join("\n").trim() : null;
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* A page as a step reads it: front matter (title, path, categories, where it came from, its
|
|
447
|
-
* original, its parent and sub-pages) and its Markdown, or one section of it. Long pages come in
|
|
448
|
-
* parts: `from` continues where the last part ended.
|
|
449
|
-
*/
|
|
450
|
-
export async function readPage(projectId, path, opts = {}) {
|
|
451
|
-
const found = await resolvePath(projectId, path);
|
|
452
|
-
if (found?.kind !== "page") {
|
|
453
|
-
throw new ServiceError("not_found", `No page "${path}". project_list or project_search name the pages there are.`);
|
|
454
|
-
}
|
|
455
|
-
const page = await db.query.spacePage.findFirst({ where: eq(schema.spacePage.id, found.id) });
|
|
456
|
-
if (!page) {
|
|
457
|
-
throw notFound();
|
|
458
|
-
}
|
|
459
|
-
const tree = await pageTree(projectId);
|
|
460
|
-
const node = tree.get(page.id);
|
|
461
|
-
const categories = await categoryRows(projectId);
|
|
462
|
-
const lines = categoryLines(categories, (await itemCategoriesOf([{ pageId: page.id }])).get(`p:${page.id}`));
|
|
463
|
-
const children = [...tree.values()]
|
|
464
|
-
.filter((n) => n.parentId === page.id)
|
|
465
|
-
.sort((a, b) => a.position - b.position)
|
|
466
|
-
.map((n) => n.path);
|
|
467
|
-
const original = page.fileId ? (await filePaths(projectId)).get(page.fileId) : undefined;
|
|
468
|
-
const front = [
|
|
469
|
-
"---",
|
|
470
|
-
`title: ${yamlValue(page.title)}`,
|
|
471
|
-
`path: ${found.path}`,
|
|
472
|
-
...(node?.parentId ? [`parent: ${tree.get(node.parentId)?.path}`] : []),
|
|
473
|
-
...(lines.length
|
|
474
|
-
? [
|
|
475
|
-
"categories:",
|
|
476
|
-
...lines.map((l) => ` ${l.replace(/^([^:]+): (.*)$/, (_m, k, v) => `${yamlValue(k)}: ${yamlValue(v)}`)}`),
|
|
477
|
-
]
|
|
478
|
-
: []),
|
|
479
|
-
...(page.originLabel ? [`source: ${yamlValue(page.originLabel)}`] : []),
|
|
480
|
-
...(original ? [`original: ${original}`] : []),
|
|
481
|
-
...(children.length ? ["sub-pages:", ...children.slice(0, 200).map((c) => ` - ${c}`)] : []),
|
|
482
|
-
...(children.length > 200 ? [` # … ${children.length - 200} more, see project_list`] : []),
|
|
483
|
-
"---",
|
|
484
|
-
].join("\n");
|
|
485
|
-
let text = page.markdown;
|
|
486
|
-
if (opts.section) {
|
|
487
|
-
const section = sectionOf(text, opts.section);
|
|
488
|
-
if (section === null) {
|
|
489
|
-
throw new ServiceError("not_found", `No section "${opts.section}" on ${found.path}.`);
|
|
490
|
-
}
|
|
491
|
-
text = section;
|
|
492
|
-
}
|
|
493
|
-
const start = Math.min(Math.max(0, opts.from ?? 0), text.length);
|
|
494
|
-
const part = text.slice(start, start + PART);
|
|
495
|
-
return {
|
|
496
|
-
path: found.path,
|
|
497
|
-
page: `${front}\n\n${part}`,
|
|
498
|
-
next: start + part.length < text.length ? start + part.length : null,
|
|
499
|
-
length: text.length,
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
/** A cell as a table's filter compares it. */
|
|
503
|
-
function matchesCell(column, cell, w) {
|
|
504
|
-
const shown = formatTableCell(column, cell, "de").toLowerCase();
|
|
505
|
-
if (Array.isArray(w)) {
|
|
506
|
-
return w.some((v) => matchesCell(column, cell, v));
|
|
507
|
-
}
|
|
508
|
-
if (typeof w === "object" && w !== null) {
|
|
509
|
-
if (w.contains !== undefined) {
|
|
510
|
-
return shown.includes(w.contains.toLowerCase());
|
|
511
|
-
}
|
|
512
|
-
if (w.gte !== undefined || w.lte !== undefined) {
|
|
513
|
-
const n = typeof cell === "number" ? cell : numberOf(String(cell ?? ""));
|
|
514
|
-
return (n !== null && (w.gte === undefined || n >= w.gte) && (w.lte === undefined || n <= w.lte));
|
|
515
|
-
}
|
|
516
|
-
if (w.after !== undefined || w.before !== undefined) {
|
|
517
|
-
const at = dateOf(cell);
|
|
518
|
-
const after = w.after ? dateOf(w.after) : null;
|
|
519
|
-
const before = w.before ? dateOf(w.before) : null;
|
|
520
|
-
return (at !== null &&
|
|
521
|
-
(after === null || at >= after) &&
|
|
522
|
-
(before === null || at < before + 86_400_000));
|
|
523
|
-
}
|
|
524
|
-
return false;
|
|
525
|
-
}
|
|
526
|
-
if (typeof w === "number") {
|
|
527
|
-
return (typeof cell === "number" ? cell : numberOf(String(cell ?? ""))) === w;
|
|
528
|
-
}
|
|
529
|
-
if (typeof w === "boolean") {
|
|
530
|
-
return cell === w;
|
|
531
|
-
}
|
|
532
|
-
return (shown === String(w).toLowerCase() ||
|
|
533
|
-
String(cell ?? "").toLowerCase() === String(w).toLowerCase());
|
|
534
|
-
}
|
|
535
|
-
const csvCell = (value) => /[",\n;]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value;
|
|
536
|
-
/**
|
|
537
|
-
* A table as a step reads it: its rows as CSV, filtered by its columns (by their names), a few
|
|
538
|
-
* hundred at a time.
|
|
539
|
-
*/
|
|
540
|
-
export async function readTable(projectId, path, opts = {}) {
|
|
541
|
-
const found = await resolvePath(projectId, path);
|
|
542
|
-
if (found?.kind !== "table") {
|
|
543
|
-
throw new ServiceError("not_found", `No table "${path}". project_list or project_search name the tables there are.`);
|
|
544
|
-
}
|
|
545
|
-
const table = await db.query.spaceTable.findFirst({ where: eq(schema.spaceTable.id, found.id) });
|
|
546
|
-
if (!table) {
|
|
547
|
-
throw notFound();
|
|
548
|
-
}
|
|
549
|
-
const byName = (name) => table.columns.find((c) => c.name.toLowerCase() === name.trim().toLowerCase() || c.id === name.trim());
|
|
550
|
-
const filters = Object.entries(opts.where ?? {}).map(([name, w]) => {
|
|
551
|
-
const column = byName(name);
|
|
552
|
-
if (!column) {
|
|
553
|
-
throw new ServiceError("invalid", `No column "${name}" in ${found.path}. It has: ${table.columns.map((c) => c.name).join(", ")}.`);
|
|
554
|
-
}
|
|
555
|
-
return { column, w };
|
|
556
|
-
});
|
|
557
|
-
const shown = opts.columns?.length
|
|
558
|
-
? opts.columns.map((name) => {
|
|
559
|
-
const column = byName(name);
|
|
560
|
-
if (!column) {
|
|
561
|
-
throw new ServiceError("invalid", `No column "${name}" in ${found.path}.`);
|
|
562
|
-
}
|
|
563
|
-
return column;
|
|
564
|
-
})
|
|
565
|
-
: table.columns;
|
|
566
|
-
const rows = (await db.query.spaceTableRow.findMany({
|
|
567
|
-
where: eq(schema.spaceTableRow.tableId, table.id),
|
|
568
|
-
orderBy: [asc(schema.spaceTableRow.createdAt), asc(schema.spaceTableRow.id)],
|
|
569
|
-
})).filter((row) => filters.every((f) => matchesCell(f.column, row.cells[f.column.id], f.w)));
|
|
570
|
-
const limit = Math.min(Math.max(1, opts.limit ?? 200), 1000);
|
|
571
|
-
const offset = Math.max(0, opts.offset ?? 0);
|
|
572
|
-
const part = rows.slice(offset, offset + limit);
|
|
573
|
-
const csv = [
|
|
574
|
-
shown.map((c) => csvCell(c.name)).join(","),
|
|
575
|
-
...part.map((row) => shown.map((c) => csvCell(formatTableCell(c, row.cells[c.id], "de"))).join(",")),
|
|
576
|
-
].join("\n");
|
|
577
|
-
return {
|
|
578
|
-
path: found.path,
|
|
579
|
-
title: table.title,
|
|
580
|
-
format: table.format,
|
|
581
|
-
columns: table.columns.map((c) => `${c.name} (${c.type})`),
|
|
582
|
-
rows: rows.length,
|
|
583
|
-
shown: part.length,
|
|
584
|
-
next: offset + part.length < rows.length ? offset + part.length : null,
|
|
585
|
-
csv,
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* For project_list: without a filter, the categories with their values and how many items each
|
|
590
|
-
* has; with one, the items it leaves, with their paths and categories.
|
|
591
|
-
*/
|
|
592
|
-
export async function listForStep(projectId, where) {
|
|
593
|
-
const categories = await listCategories(projectId);
|
|
594
|
-
const taken = categories.filter((c) => !c.proposed);
|
|
595
|
-
if (!Object.keys(where ?? {}).length) {
|
|
596
|
-
return {
|
|
597
|
-
categories: taken.map((c) => ({
|
|
598
|
-
name: c.name,
|
|
599
|
-
type: c.type,
|
|
600
|
-
...(c.unit ? { unit: c.unit } : {}),
|
|
601
|
-
items: c.count,
|
|
602
|
-
...(c.type === "choice"
|
|
603
|
-
? { values: c.values.slice(0, 60).map((v) => `${v.value} (${v.count})`) }
|
|
604
|
-
: {}),
|
|
605
|
-
...(c.range ? { range: `${c.range.min} … ${c.range.max}` } : {}),
|
|
606
|
-
})),
|
|
607
|
-
hint: 'Pass `where` to list the items of values, e.g. { "Baustelle": "Graz Süd" }.',
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
const filtered = await filterItems(projectId, where);
|
|
611
|
-
const [tree, tPaths, fPaths] = await Promise.all([
|
|
612
|
-
pageTree(projectId),
|
|
613
|
-
tablePaths(projectId),
|
|
614
|
-
filePaths(projectId),
|
|
615
|
-
]);
|
|
616
|
-
const refs = [
|
|
617
|
-
...[...(filtered?.pages ?? [])].map((pageId) => ({ pageId })),
|
|
618
|
-
...[...(filtered?.tables ?? [])].map((tableId) => ({ tableId })),
|
|
619
|
-
...[...(filtered?.files ?? [])].map((fileId) => ({ fileId })),
|
|
620
|
-
];
|
|
621
|
-
const cats = await itemCategoriesOf(refs);
|
|
622
|
-
// Rows whose table is not left as a whole: by their table, with how many.
|
|
623
|
-
const rowTables = new Map();
|
|
624
|
-
const looseRows = [...(filtered?.rows ?? [])];
|
|
625
|
-
for (let i = 0; i < looseRows.length; i += 500) {
|
|
626
|
-
for (const r of await db.query.spaceTableRow.findMany({
|
|
627
|
-
where: inArray(schema.spaceTableRow.id, looseRows.slice(i, i + 500)),
|
|
628
|
-
columns: { tableId: true },
|
|
629
|
-
})) {
|
|
630
|
-
if (!filtered?.tables.has(r.tableId)) {
|
|
631
|
-
rowTables.set(r.tableId, (rowTables.get(r.tableId) ?? 0) + 1);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
const items = [
|
|
636
|
-
...[...(filtered?.pages ?? [])]
|
|
637
|
-
.map((id) => tree.get(id))
|
|
638
|
-
.filter((n) => Boolean(n))
|
|
639
|
-
.sort((a, b) => a.path.localeCompare(b.path))
|
|
640
|
-
.map((n) => ({
|
|
641
|
-
path: n.path,
|
|
642
|
-
title: n.title,
|
|
643
|
-
categories: categoryLines(taken, cats.get(`p:${n.id}`)),
|
|
644
|
-
})),
|
|
645
|
-
...[...(filtered?.tables ?? [])].map((id) => ({
|
|
646
|
-
path: tPaths.get(id) ?? "",
|
|
647
|
-
title: "",
|
|
648
|
-
categories: categoryLines(taken, cats.get(`t:${id}`)),
|
|
649
|
-
})),
|
|
650
|
-
...[...rowTables].map(([id, n]) => ({
|
|
651
|
-
path: tPaths.get(id) ?? "",
|
|
652
|
-
title: `${n} rows match: read them with table_read and the same values as its columns`,
|
|
653
|
-
categories: [],
|
|
654
|
-
})),
|
|
655
|
-
...[...(filtered?.files ?? [])].map((id) => ({
|
|
656
|
-
path: fPaths.get(id) ?? "",
|
|
657
|
-
title: "",
|
|
658
|
-
categories: categoryLines(taken, cats.get(`f:${id}`)),
|
|
659
|
-
})),
|
|
660
|
-
];
|
|
661
|
-
return { items: items.slice(0, 200), total: items.length };
|
|
662
|
-
}
|
|
663
|
-
/** How much Knowledge a space holds: what the block of the steps' instructions says. */
|
|
664
|
-
export async function knowledgeCounts(projectId) {
|
|
665
|
-
const [pages, tables, files] = await Promise.all([
|
|
666
|
-
db
|
|
667
|
-
.select({ n: count() })
|
|
668
|
-
.from(schema.spacePage)
|
|
669
|
-
.where(and(eq(schema.spacePage.projectId, projectId), isNull(schema.spacePage.wizardId))),
|
|
670
|
-
db
|
|
671
|
-
.select({ n: count() })
|
|
672
|
-
.from(schema.spaceTable)
|
|
673
|
-
.where(and(eq(schema.spaceTable.projectId, projectId), isNull(schema.spaceTable.wizardId))),
|
|
674
|
-
db
|
|
675
|
-
.select({ n: count() })
|
|
676
|
-
.from(schema.projectFile)
|
|
677
|
-
.where(and(eq(schema.projectFile.projectId, projectId), eq(schema.projectFile.kind, "document"))),
|
|
678
|
-
]);
|
|
679
|
-
return { pages: pages[0].n, tables: tables[0].n, files: files[0].n };
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* What every step of the space is told about Knowledge: how much there is, the categories to filter
|
|
683
|
-
* by, the tools to find and read. Empty when Knowledge is.
|
|
684
|
-
*/
|
|
685
|
-
export async function knowledgeBlock(projectId) {
|
|
686
|
-
const counts = await knowledgeCounts(projectId);
|
|
687
|
-
if (!(counts.pages || counts.tables || counts.files)) {
|
|
688
|
-
return "";
|
|
689
|
-
}
|
|
690
|
-
const categories = (await listCategories(projectId)).filter((c) => !c.proposed && c.count);
|
|
691
|
-
const what = [
|
|
692
|
-
counts.pages ? `${counts.pages} pages` : "",
|
|
693
|
-
counts.tables ? `${counts.tables} tables` : "",
|
|
694
|
-
counts.files ? `${counts.files} files` : "",
|
|
695
|
-
]
|
|
696
|
-
.filter(Boolean)
|
|
697
|
-
.join(", ");
|
|
698
|
-
const lines = categories.slice(0, 30).map((c) => {
|
|
699
|
-
const type = `${c.type}${c.unit ? `, ${c.unit}` : ""}`;
|
|
700
|
-
const values = c.type === "choice"
|
|
701
|
-
? `: ${c.values
|
|
702
|
-
.slice(0, 12)
|
|
703
|
-
.map((v) => v.value)
|
|
704
|
-
.join(", ")}${c.values.length > 12 ? ` … (${c.values.length} values)` : ""}`
|
|
705
|
-
: c.range
|
|
706
|
-
? `: ${c.range.min} … ${c.range.max}`
|
|
707
|
-
: "";
|
|
708
|
-
return `- ${c.name} (${type})${values}`;
|
|
709
|
-
});
|
|
710
|
-
return [
|
|
711
|
-
"# KNOWLEDGE — WHAT THE SPACE KNOWS",
|
|
712
|
-
`Ground truth the space's owner keeps for all wizards: ${what}. Use it when the task touches what it covers, and prefer it to what you remember.`,
|
|
713
|
-
...(lines.length
|
|
714
|
-
? [
|
|
715
|
-
"Categories, to filter with `where` in project_search and project_list before searching:",
|
|
716
|
-
...lines,
|
|
717
|
-
]
|
|
718
|
-
: []),
|
|
719
|
-
"Find with project_search (a question; `where` on categories). List with project_list. Read whole with page_read and table_read by path. A page marks the pages of its original as <!-- S. n -->: quote them when the source matters.",
|
|
720
|
-
].join("\n");
|
|
721
|
-
}
|