@synopackageland/cli 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/build-spk/delete-app-data.d.ts +27 -7
- package/dist/build-spk/delete-app-data.js +35 -34
- package/dist/build-spk/dsm-arch.d.ts +6 -1
- package/dist/build-spk/dsm-arch.js +25 -1
- package/dist/build-spk/dsm-version.d.ts +14 -0
- package/dist/build-spk/dsm-version.js +47 -0
- package/dist/build-spk/gateway.d.ts +31 -0
- package/dist/build-spk/gateway.js +55 -0
- package/dist/build-spk/generator.d.ts +5 -0
- package/dist/build-spk/generator.js +103 -107
- package/dist/build-spk/install-wizard.d.ts +20 -0
- package/dist/build-spk/install-wizard.js +76 -0
- package/dist/build-spk/native-lifecycle.d.ts +5 -0
- package/dist/build-spk/native-lifecycle.js +12 -2
- package/dist/build-spk/resource-worker.d.ts +9 -4
- package/dist/build-spk/resource-worker.js +15 -6
- package/dist/build-spk/share-combobox.d.ts +3 -0
- package/dist/build-spk/share-combobox.js +27 -0
- package/dist/build-spk/uninstall-wizard.d.ts +14 -0
- package/dist/build-spk/uninstall-wizard.js +33 -0
- package/dist/build-spk/wizard-i18n.d.ts +18 -0
- package/dist/build-spk/wizard-i18n.js +38 -0
- package/dist/build-spk/wizard-messages.d.ts +388 -0
- package/dist/build-spk/wizard-messages.js +387 -0
- package/dist/cli.js +130 -30
- package/dist/compose/analyze.d.ts +20 -0
- package/dist/compose/analyze.js +75 -11
- package/dist/contract/validate.js +33 -1
- package/dist/contract/web-launch.d.ts +22 -0
- package/dist/contract/web-launch.js +37 -0
- package/dist/deploy/deploy.d.ts +3 -0
- package/dist/deploy/deploy.js +11 -2
- package/dist/error-registry.js +60 -1
- package/dist/host/open-url.d.ts +2 -0
- package/dist/host/open-url.js +4 -1
- package/dist/images/pin.d.ts +52 -0
- package/dist/images/pin.js +249 -0
- package/dist/init.d.ts +27 -3
- package/dist/init.js +104 -15
- package/dist/inspect.d.ts +3 -0
- package/dist/inspect.js +15 -3
- package/dist/standalone/background.d.ts +21 -0
- package/dist/standalone/background.js +52 -0
- package/dist/standalone/binary.d.ts +1 -0
- package/dist/standalone/binary.js +1 -1
- package/dist/standalone/build.d.ts +2 -0
- package/dist/standalone/build.js +38 -6
- package/dist/standalone/dsm-window.js +2 -2
- package/dist/standalone/helper-inventory.d.ts +15 -0
- package/dist/standalone/helper-inventory.js +9 -0
- package/dist/standalone/helper.d.ts +1 -0
- package/dist/standalone/helper.js +28 -10
- package/dist/standalone/host-adapter.d.ts +1 -1
- package/dist/standalone/host-adapter.js +33 -15
- package/dist/standalone/host-file-navigation.d.ts +7 -0
- package/dist/standalone/host-file-navigation.js +172 -0
- package/dist/standalone/inspect-helper.js +9 -4
- package/dist/standalone/inspect-spk.d.ts +1 -1
- package/dist/standalone/inspect-spk.js +200 -7
- package/dist/standalone/job-diagnostics.d.ts +1 -0
- package/dist/standalone/job-diagnostics.js +49 -0
- package/dist/standalone/lifecycle.js +12 -2
- package/dist/standalone/manifest.d.ts +15 -2
- package/dist/standalone/manifest.js +37 -6
- package/dist/standalone/native-layout.d.ts +74 -0
- package/dist/standalone/native-layout.js +318 -0
- package/dist/standalone/resource.d.ts +11 -0
- package/dist/standalone/resource.js +13 -0
- package/dist/standalone/root-window.d.ts +3 -1
- package/dist/standalone/root-window.js +156 -38
- package/dist/standalone/shared-folder.d.ts +39 -0
- package/dist/standalone/shared-folder.js +141 -0
- package/dist/standalone/spk.d.ts +2 -0
- package/dist/standalone/spk.js +33 -3
- package/dist/standalone/worker-contract-json.d.ts +8 -0
- package/dist/standalone/worker-contract-json.js +141 -0
- package/dist/standalone/worker-contract.d.ts +189 -0
- package/dist/standalone/worker-contract.js +175 -0
- package/dist/standalone/worker-registry.d.ts +40 -0
- package/dist/standalone/worker-registry.js +167 -0
- package/dist/templates/_daemon/go.mod +2 -0
- package/dist/templates/_gateway/auth.go +101 -0
- package/dist/templates/_gateway/auth_test.go +216 -0
- package/dist/templates/_gateway/cgi.go +133 -0
- package/dist/templates/_gateway/cgi_test.go +156 -0
- package/dist/templates/_gateway/csrf.go +73 -0
- package/dist/templates/_gateway/csrf_test.go +155 -0
- package/dist/templates/_gateway/directory.go +108 -0
- package/dist/templates/_gateway/directory_test.go +202 -0
- package/dist/templates/_gateway/gateway.go +412 -0
- package/dist/templates/_gateway/gateway_test.go +676 -0
- package/dist/templates/_gateway/go.mod +3 -0
- package/dist/templates/_gateway/groups.go +66 -0
- package/dist/templates/_gateway/main.go +45 -0
- package/dist/templates/binary/synology-app.yaml +1 -1
- package/dist/templates/compose-import/compose.yaml +1 -1
- package/dist/templates/compose-import/synology-app.yaml +1 -1
- package/dist/templates/hello-files/compose.yaml +1 -1
- package/dist/templates/hello-files/synology-app.yaml +1 -1
- package/dist/templates/hello-web/compose.yaml +5 -2
- package/dist/templates/hello-web/synology-app.yaml +4 -1
- package/dist/templates/hello-web-page/compose.yaml +5 -2
- package/dist/templates/hello-web-page/synology-app.yaml +4 -1
- package/dist/templates/native-go/README.md +93 -4
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +3 -1
- package/dist/templates/native-go/backend/cmd/app/main.go +17 -0
- package/dist/templates/native-go/backend/cmd/app/sdk_main.go +60 -0
- package/dist/templates/native-go/backend/cmd/background-worker/main.go +38 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +10 -1
- package/dist/templates/native-go/backend/cmd/helper/sdk_registry.go +19 -0
- package/dist/templates/native-go/backend/go.mod +5 -3
- package/dist/templates/native-go/backend/go.sum +4 -4
- package/dist/templates/native-go/backend/internal/api/registry.go +17 -6
- package/dist/templates/native-go/backend/internal/api/server.go +7 -1
- package/dist/templates/native-go/backend/internal/app/background.go +270 -0
- package/dist/templates/native-go/backend/internal/app/background_none.go +8 -0
- package/dist/templates/native-go/backend/internal/app/background_owner.go +59 -0
- package/dist/templates/native-go/backend/internal/app/background_owner_test.go +145 -0
- package/dist/templates/native-go/backend/internal/app/background_schedule.go +74 -0
- package/dist/templates/native-go/backend/internal/app/background_schedule_test.go +62 -0
- package/dist/templates/native-go/backend/internal/app/background_test.go +346 -0
- package/dist/templates/native-go/backend/internal/app/integration_state.go +16 -0
- package/dist/templates/native-go/backend/internal/app/migrations.go +41 -0
- package/dist/templates/native-go/backend/internal/app/migrations_test.go +41 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +8 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +17 -3
- package/dist/templates/native-go/backend/internal/app/routes_test.go +20 -3
- package/dist/templates/native-go/backend/internal/app/sdk_jobs.go +70 -0
- package/dist/templates/native-go/backend/internal/app/sdk_jobs_test.go +116 -0
- package/dist/templates/native-go/backend/internal/app/sdk_routes.go +174 -0
- package/dist/templates/native-go/backend/internal/app/session_files.go +15 -0
- package/dist/templates/native-go/backend/internal/app/session_files_test.go +26 -0
- package/dist/templates/native-go/backend/internal/app/shared_folder.go +144 -0
- package/dist/templates/native-go/backend/internal/app/shared_folder_test.go +158 -0
- package/dist/templates/native-go/backend/internal/background/access.go +57 -0
- package/dist/templates/native-go/backend/internal/background/owner_test.go +126 -0
- package/dist/templates/native-go/backend/internal/background/runner.go +185 -0
- package/dist/templates/native-go/backend/internal/background/runner_test.go +209 -0
- package/dist/templates/native-go/backend/internal/background/schedule.go +300 -0
- package/dist/templates/native-go/backend/internal/background/schedule_test.go +335 -0
- package/dist/templates/native-go/backend/internal/background/store.go +807 -0
- package/dist/templates/native-go/backend/internal/background/store_test.go +407 -0
- package/dist/templates/native-go/backend/internal/datamigrate/migrate.go +191 -0
- package/dist/templates/native-go/backend/internal/datamigrate/migrate_test.go +177 -0
- package/dist/templates/native-go/backend/internal/filestation/browse_test.go +67 -0
- package/dist/templates/native-go/backend/internal/filestation/client.go +251 -0
- package/dist/templates/native-go/backend/internal/filestation/client_test.go +155 -0
- package/dist/templates/native-go/backend/internal/filestation/doc.go +4 -0
- package/dist/templates/native-go/backend/internal/filestation/read_file_test.go +90 -0
- package/dist/templates/native-go/backend/internal/filestation/repository.go +207 -0
- package/dist/templates/native-go/backend/internal/filestation/repository_test.go +104 -0
- package/dist/templates/native-go/backend/internal/filestation/sdk_session.go +241 -0
- package/dist/templates/native-go/backend/internal/filestation/sdk_session_test.go +183 -0
- package/dist/templates/native-go/backend/internal/filestation/service.go +254 -0
- package/dist/templates/native-go/backend/internal/filestation/service_test.go +94 -0
- package/dist/templates/native-go/backend/internal/filestation/session_semantics_test.go +383 -0
- package/dist/templates/native-go/backend/internal/filestation/write.go +72 -0
- package/dist/templates/native-go/backend/internal/filestation/write_test.go +123 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof.go +163 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof_contract.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof_test.go +161 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +2 -1
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +4 -3
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/bindings.go +48 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/contract_test.go +436 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/decode.go +185 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/digest.go +55 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/registry.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/registry_test.go +73 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/result.go +53 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/stub.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/testdata/input-digests.json +127 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/types.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/types_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/validate.go +462 -0
- package/dist/templates/native-go/backend/internal/helper/legacy_authority_schema_linux_test.go +34 -0
- package/dist/templates/native-go/backend/internal/helper/legacy_authority_schema_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/management.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +42 -2
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +13 -1
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +56 -10
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_writer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/query_deadline_linux_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/query_pending_diagnostic_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +23 -4
- package/dist/templates/native-go/backend/internal/helper/sdk_assembly_linux.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach_contract.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_authority_schema_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_authority.go +832 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_authority_test.go +714 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_invalidation.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_lease.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_snapshot.go +110 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_store_linux_test.go +261 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_store_test.go +58 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_bindings.go +60 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_data_contract.go +251 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_data_protocol.go +424 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_dispatch_absence_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display.go +488 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display_contract.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display_test.go +459 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_authority.go +559 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_repository_linux.go +417 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_snapshot.go +94 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_history.go +80 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_history_test.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job.go +697 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_child_linux.go +309 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_contract.go +122 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_linux_test.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_process_linux.go +327 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_test.go +501 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_vm_linux_test.go +343 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_linux.go +244 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_linux_test.go +295 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_test.go +71 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_picker_test.go +50 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_process_linux.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_public_vm_linux_test.go +129 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_relaxed_invalidation.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc.go +299 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc_contract.go +70 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_server_linux.go +152 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session.go +677 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_contract.go +72 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_fence_test.go +215 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_test.go +475 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_supervisor_frame.go +78 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_supervisor_linux.go +414 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport_linux.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport_test.go +64 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/stale_management_linux_test.go +126 -0
- package/dist/templates/native-go/backend/internal/helper/stale_management_test.go +122 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic.go +68 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic_linux_test.go +126 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/status.go +22 -13
- package/dist/templates/native-go/backend/internal/helper/status_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +6 -2
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +22 -4
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +7 -3
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +5 -1
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +7 -4
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +26 -0
- package/dist/templates/native-go/dsm-package.yaml +1 -1
- package/dist/templates/native-go-background/BACKGROUND.md +111 -0
- package/dist/templates/native-go-background/backend/internal/app/background_on.go +7 -0
- package/dist/templates/native-go-background/backend/internal/app/background_routes_test.go +32 -0
- package/dist/templates/native-go-background/frontend/src/background/BackgroundPanel.vue +178 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/de.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/en.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/es.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/fr.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/it.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/ja.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/ko.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/zh-CN.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/zh-TW.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n.ts +19 -0
- package/dist/templates/native-go-background/frontend/src/background/picker-provider.ts +13 -0
- package/dist/templates/native-go-background/frontend/test/background.test.ts +179 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal.go +2 -2
- package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +37 -0
- package/dist/templates/native-go-vue/README.md +38 -7
- package/dist/templates/native-go-vue/frontend/DESIGN.md +15 -3
- package/dist/templates/native-go-vue/frontend/README-JOBS.md +75 -0
- package/dist/templates/native-go-vue/frontend/README-M2.md +64 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +5 -4
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +39 -11
- package/dist/templates/native-go-vue/frontend/src/M2App.vue +57 -0
- package/dist/templates/native-go-vue/frontend/src/SDKApp.vue +203 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/InteractiveJobForm.vue +70 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/JobsAdminPanel.vue +33 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/JobsPanel.vue +135 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/connected-provider.ts +179 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/de.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/en.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/es.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/fr.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/it.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/ja.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/ko.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/zh-CN.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/zh-TW.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n.ts +15 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/mock-provider.ts +67 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/provider.ts +60 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/validate.ts +44 -0
- package/dist/templates/native-go-vue/frontend/src/m2-main.ts +21 -0
- package/dist/templates/native-go-vue/frontend/src/m2-style.css +7 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2Files.vue +94 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2PathPicker.vue +70 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2Settings.vue +69 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/de.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/en.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/es.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/fr.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/it.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/ja.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/ko.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-CN.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-TW.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-contract.ts +33 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-i18n.ts +24 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-provider.ts +104 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-m2-request.ts +18 -0
- package/dist/templates/native-go-vue/frontend/src/sdk-main.ts +39 -0
- package/dist/templates/native-go-vue/frontend/src/shell/AppShell.vue +48 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/de.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/en.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/es.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/fr.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/it.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/ja.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/ko.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/zh-CN.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/zh-TW.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n.ts +17 -0
- package/dist/templates/native-go-vue/frontend/src/shell/pages.ts +34 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +2 -6
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/jobs-connected.test.ts +163 -0
- package/dist/templates/native-go-vue/frontend/test/jobs-preview.html +22 -0
- package/dist/templates/native-go-vue/frontend/test/jobs.test.ts +176 -0
- package/dist/templates/native-go-vue/frontend/test/m2-preview.html +27 -0
- package/dist/templates/native-go-vue/frontend/test/m2-provider.test.ts +87 -0
- package/dist/templates/native-go-vue/frontend/test/m2-ui.test.ts +209 -0
- package/dist/templates/native-go-vue/frontend/test/native-controls.test.ts +27 -0
- package/dist/templates/native-go-vue/frontend/test/picker-wire.test.ts +110 -0
- package/dist/templates/native-go-vue/frontend/test/shell-preview.html +19 -0
- package/dist/templates/native-go-vue/frontend/test/shell-sdk.test.ts +73 -0
- package/dist/templates/native-go-vue/frontend/test/shell-ui.test.ts +114 -0
- package/dist/templates/native-go-vue/frontend/test/shell.test.ts +45 -0
- package/dist/templates/native-go-vue/frontend/vite.config.ts +2 -2
- package/dist/validate.js +6 -3
- package/package.json +1 -1
- package/schema/synology-app.schema.json +19 -0
- package/skills/reference/create.md +4 -0
- package/templates/_daemon/go.mod +2 -0
- package/templates/_gateway/auth.go +101 -0
- package/templates/_gateway/auth_test.go +216 -0
- package/templates/_gateway/cgi.go +133 -0
- package/templates/_gateway/cgi_test.go +156 -0
- package/templates/_gateway/csrf.go +73 -0
- package/templates/_gateway/csrf_test.go +155 -0
- package/templates/_gateway/directory.go +108 -0
- package/templates/_gateway/directory_test.go +202 -0
- package/templates/_gateway/gateway.go +412 -0
- package/templates/_gateway/gateway_test.go +676 -0
- package/templates/_gateway/go.mod +3 -0
- package/templates/_gateway/groups.go +66 -0
- package/templates/_gateway/main.go +45 -0
- package/templates/binary/synology-app.yaml +1 -1
- package/templates/compose-import/compose.yaml +1 -1
- package/templates/compose-import/synology-app.yaml +1 -1
- package/templates/hello-files/compose.yaml +1 -1
- package/templates/hello-files/synology-app.yaml +1 -1
- package/templates/hello-web/compose.yaml +5 -2
- package/templates/hello-web/synology-app.yaml +4 -1
- package/templates/hello-web-page/compose.yaml +5 -2
- package/templates/hello-web-page/synology-app.yaml +4 -1
- package/templates/native-go/README.md +93 -4
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +3 -1
- package/templates/native-go/backend/cmd/app/main.go +17 -0
- package/templates/native-go/backend/cmd/app/sdk_main.go +60 -0
- package/templates/native-go/backend/cmd/background-worker/main.go +38 -0
- package/templates/native-go/backend/cmd/helper/main.go +10 -1
- package/templates/native-go/backend/cmd/helper/sdk_registry.go +19 -0
- package/templates/native-go/backend/go.mod +5 -3
- package/templates/native-go/backend/go.sum +4 -4
- package/templates/native-go/backend/internal/api/registry.go +17 -6
- package/templates/native-go/backend/internal/api/server.go +7 -1
- package/templates/native-go/backend/internal/app/background.go +270 -0
- package/templates/native-go/backend/internal/app/background_none.go +8 -0
- package/templates/native-go/backend/internal/app/background_owner.go +59 -0
- package/templates/native-go/backend/internal/app/background_owner_test.go +145 -0
- package/templates/native-go/backend/internal/app/background_schedule.go +74 -0
- package/templates/native-go/backend/internal/app/background_schedule_test.go +62 -0
- package/templates/native-go/backend/internal/app/background_test.go +346 -0
- package/templates/native-go/backend/internal/app/integration_state.go +16 -0
- package/templates/native-go/backend/internal/app/migrations.go +41 -0
- package/templates/native-go/backend/internal/app/migrations_test.go +41 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +8 -0
- package/templates/native-go/backend/internal/app/routes.go +17 -3
- package/templates/native-go/backend/internal/app/routes_test.go +20 -3
- package/templates/native-go/backend/internal/app/sdk_jobs.go +70 -0
- package/templates/native-go/backend/internal/app/sdk_jobs_test.go +116 -0
- package/templates/native-go/backend/internal/app/sdk_routes.go +174 -0
- package/templates/native-go/backend/internal/app/session_files.go +15 -0
- package/templates/native-go/backend/internal/app/session_files_test.go +26 -0
- package/templates/native-go/backend/internal/app/shared_folder.go +144 -0
- package/templates/native-go/backend/internal/app/shared_folder_test.go +158 -0
- package/templates/native-go/backend/internal/background/access.go +57 -0
- package/templates/native-go/backend/internal/background/owner_test.go +126 -0
- package/templates/native-go/backend/internal/background/runner.go +185 -0
- package/templates/native-go/backend/internal/background/runner_test.go +209 -0
- package/templates/native-go/backend/internal/background/schedule.go +300 -0
- package/templates/native-go/backend/internal/background/schedule_test.go +335 -0
- package/templates/native-go/backend/internal/background/store.go +807 -0
- package/templates/native-go/backend/internal/background/store_test.go +407 -0
- package/templates/native-go/backend/internal/datamigrate/migrate.go +191 -0
- package/templates/native-go/backend/internal/datamigrate/migrate_test.go +177 -0
- package/templates/native-go/backend/internal/filestation/browse_test.go +67 -0
- package/templates/native-go/backend/internal/filestation/client.go +251 -0
- package/templates/native-go/backend/internal/filestation/client_test.go +155 -0
- package/templates/native-go/backend/internal/filestation/doc.go +4 -0
- package/templates/native-go/backend/internal/filestation/read_file_test.go +90 -0
- package/templates/native-go/backend/internal/filestation/repository.go +207 -0
- package/templates/native-go/backend/internal/filestation/repository_test.go +104 -0
- package/templates/native-go/backend/internal/filestation/sdk_session.go +241 -0
- package/templates/native-go/backend/internal/filestation/sdk_session_test.go +183 -0
- package/templates/native-go/backend/internal/filestation/service.go +254 -0
- package/templates/native-go/backend/internal/filestation/service_test.go +94 -0
- package/templates/native-go/backend/internal/filestation/session_semantics_test.go +383 -0
- package/templates/native-go/backend/internal/filestation/write.go +72 -0
- package/templates/native-go/backend/internal/filestation/write_test.go +123 -0
- package/templates/native-go/backend/internal/helper/background_proof.go +163 -0
- package/templates/native-go/backend/internal/helper/background_proof_contract.go +46 -0
- package/templates/native-go/backend/internal/helper/background_proof_test.go +161 -0
- package/templates/native-go/backend/internal/helper/data_contract.go +3 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +3 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +1 -1
- package/templates/native-go/backend/internal/helper/grant_authority.go +3 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +1 -1
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +2 -1
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +4 -3
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +3 -0
- package/templates/native-go/backend/internal/helper/jobcontract/bindings.go +48 -0
- package/templates/native-go/backend/internal/helper/jobcontract/contract_test.go +436 -0
- package/templates/native-go/backend/internal/helper/jobcontract/decode.go +185 -0
- package/templates/native-go/backend/internal/helper/jobcontract/digest.go +55 -0
- package/templates/native-go/backend/internal/helper/jobcontract/registry.go +85 -0
- package/templates/native-go/backend/internal/helper/jobcontract/registry_test.go +73 -0
- package/templates/native-go/backend/internal/helper/jobcontract/result.go +53 -0
- package/templates/native-go/backend/internal/helper/jobcontract/stub.go +8 -0
- package/templates/native-go/backend/internal/helper/jobcontract/testdata/input-digests.json +127 -0
- package/templates/native-go/backend/internal/helper/jobcontract/types.go +234 -0
- package/templates/native-go/backend/internal/helper/jobcontract/types_test.go +29 -0
- package/templates/native-go/backend/internal/helper/jobcontract/validate.go +462 -0
- package/templates/native-go/backend/internal/helper/legacy_authority_schema_linux_test.go +34 -0
- package/templates/native-go/backend/internal/helper/legacy_authority_schema_test.go +6 -0
- package/templates/native-go/backend/internal/helper/management.go +79 -0
- package/templates/native-go/backend/internal/helper/observation.go +42 -2
- package/templates/native-go/backend/internal/helper/observation_health_test.go +13 -1
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +56 -10
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +6 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_writer.go +40 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +3 -0
- package/templates/native-go/backend/internal/helper/query_deadline_linux_test.go +115 -0
- package/templates/native-go/backend/internal/helper/query_pending_diagnostic_test.go +254 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +3 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +23 -4
- package/templates/native-go/backend/internal/helper/sdk_assembly_linux.go +51 -0
- package/templates/native-go/backend/internal/helper/sdk_attach.go +83 -0
- package/templates/native-go/backend/internal/helper/sdk_attach_contract.go +32 -0
- package/templates/native-go/backend/internal/helper/sdk_attach_test.go +184 -0
- package/templates/native-go/backend/internal/helper/sdk_authority_schema_test.go +6 -0
- package/templates/native-go/backend/internal/helper/sdk_background_authority.go +832 -0
- package/templates/native-go/backend/internal/helper/sdk_background_authority_test.go +714 -0
- package/templates/native-go/backend/internal/helper/sdk_background_invalidation.go +218 -0
- package/templates/native-go/backend/internal/helper/sdk_background_lease.go +218 -0
- package/templates/native-go/backend/internal/helper/sdk_background_snapshot.go +110 -0
- package/templates/native-go/backend/internal/helper/sdk_background_store_linux_test.go +261 -0
- package/templates/native-go/backend/internal/helper/sdk_background_store_test.go +58 -0
- package/templates/native-go/backend/internal/helper/sdk_bindings.go +60 -0
- package/templates/native-go/backend/internal/helper/sdk_data_contract.go +251 -0
- package/templates/native-go/backend/internal/helper/sdk_data_protocol.go +424 -0
- package/templates/native-go/backend/internal/helper/sdk_dispatch_absence_test.go +51 -0
- package/templates/native-go/backend/internal/helper/sdk_display.go +488 -0
- package/templates/native-go/backend/internal/helper/sdk_display_contract.go +121 -0
- package/templates/native-go/backend/internal/helper/sdk_display_test.go +459 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_authority.go +559 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_repository_linux.go +417 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_snapshot.go +94 -0
- package/templates/native-go/backend/internal/helper/sdk_history.go +80 -0
- package/templates/native-go/backend/internal/helper/sdk_history_test.go +76 -0
- package/templates/native-go/backend/internal/helper/sdk_job.go +697 -0
- package/templates/native-go/backend/internal/helper/sdk_job_child_linux.go +309 -0
- package/templates/native-go/backend/internal/helper/sdk_job_contract.go +122 -0
- package/templates/native-go/backend/internal/helper/sdk_job_linux_test.go +159 -0
- package/templates/native-go/backend/internal/helper/sdk_job_process_linux.go +327 -0
- package/templates/native-go/backend/internal/helper/sdk_job_test.go +501 -0
- package/templates/native-go/backend/internal/helper/sdk_job_vm_linux_test.go +343 -0
- package/templates/native-go/backend/internal/helper/sdk_journal.go +77 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_linux.go +244 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_linux_test.go +295 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_test.go +71 -0
- package/templates/native-go/backend/internal/helper/sdk_picker_test.go +50 -0
- package/templates/native-go/backend/internal/helper/sdk_process_linux.go +184 -0
- package/templates/native-go/backend/internal/helper/sdk_public_vm_linux_test.go +129 -0
- package/templates/native-go/backend/internal/helper/sdk_relaxed_invalidation.go +242 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc.go +299 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc_contract.go +70 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc_test.go +135 -0
- package/templates/native-go/backend/internal/helper/sdk_server_linux.go +152 -0
- package/templates/native-go/backend/internal/helper/sdk_session.go +677 -0
- package/templates/native-go/backend/internal/helper/sdk_session_contract.go +72 -0
- package/templates/native-go/backend/internal/helper/sdk_session_fence_test.go +215 -0
- package/templates/native-go/backend/internal/helper/sdk_session_test.go +475 -0
- package/templates/native-go/backend/internal/helper/sdk_supervisor_frame.go +78 -0
- package/templates/native-go/backend/internal/helper/sdk_supervisor_linux.go +414 -0
- package/templates/native-go/backend/internal/helper/sdk_transport.go +79 -0
- package/templates/native-go/backend/internal/helper/sdk_transport_linux.go +82 -0
- package/templates/native-go/backend/internal/helper/sdk_transport_test.go +64 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +3 -0
- package/templates/native-go/backend/internal/helper/stale_management_linux_test.go +126 -0
- package/templates/native-go/backend/internal/helper/stale_management_test.go +122 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic.go +68 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic_linux_test.go +126 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic_test.go +117 -0
- package/templates/native-go/backend/internal/helper/status.go +22 -13
- package/templates/native-go/backend/internal/helper/status_test.go +45 -0
- package/templates/native-go/backend/internal/helper/supervision.go +1 -1
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +3 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +6 -2
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +22 -4
- package/templates/native-go/backend/internal/helper/unit_linux.go +7 -3
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +5 -1
- package/templates/native-go/backend/internal/helper/write_files_linux.go +7 -4
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +26 -0
- package/templates/native-go/dsm-package.yaml +1 -1
- package/templates/native-go-background/BACKGROUND.md +111 -0
- package/templates/native-go-background/backend/internal/app/background_on.go +7 -0
- package/templates/native-go-background/backend/internal/app/background_routes_test.go +32 -0
- package/templates/native-go-background/frontend/src/background/BackgroundPanel.vue +178 -0
- package/templates/native-go-background/frontend/src/background/i18n/de.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/en.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/es.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/fr.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/it.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/ja.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/ko.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/zh-CN.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/zh-TW.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n.ts +19 -0
- package/templates/native-go-background/frontend/src/background/picker-provider.ts +13 -0
- package/templates/native-go-background/frontend/test/background.test.ts +179 -0
- package/templates/native-go-integration/backend/internal/app/personal.go +2 -2
- package/templates/native-go-integration/backend/internal/app/personal_test.go +37 -0
- package/templates/native-go-vue/README.md +38 -7
- package/templates/native-go-vue/frontend/DESIGN.md +15 -3
- package/templates/native-go-vue/frontend/README-JOBS.md +75 -0
- package/templates/native-go-vue/frontend/README-M2.md +64 -0
- package/templates/native-go-vue/frontend/package-lock.json +5 -4
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +39 -11
- package/templates/native-go-vue/frontend/src/M2App.vue +57 -0
- package/templates/native-go-vue/frontend/src/SDKApp.vue +203 -0
- package/templates/native-go-vue/frontend/src/jobs/InteractiveJobForm.vue +70 -0
- package/templates/native-go-vue/frontend/src/jobs/JobsAdminPanel.vue +33 -0
- package/templates/native-go-vue/frontend/src/jobs/JobsPanel.vue +135 -0
- package/templates/native-go-vue/frontend/src/jobs/connected-provider.ts +179 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/de.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/en.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/es.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/fr.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/it.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/ja.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/ko.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/zh-CN.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/zh-TW.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n.ts +15 -0
- package/templates/native-go-vue/frontend/src/jobs/mock-provider.ts +67 -0
- package/templates/native-go-vue/frontend/src/jobs/provider.ts +60 -0
- package/templates/native-go-vue/frontend/src/jobs/validate.ts +44 -0
- package/templates/native-go-vue/frontend/src/m2-main.ts +21 -0
- package/templates/native-go-vue/frontend/src/m2-style.css +7 -0
- package/templates/native-go-vue/frontend/src/nas/M2Files.vue +94 -0
- package/templates/native-go-vue/frontend/src/nas/M2PathPicker.vue +70 -0
- package/templates/native-go-vue/frontend/src/nas/M2Settings.vue +69 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/de.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/en.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/es.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/fr.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/it.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/ja.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/ko.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-CN.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-TW.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/m2-contract.ts +33 -0
- package/templates/native-go-vue/frontend/src/nas/m2-i18n.ts +24 -0
- package/templates/native-go-vue/frontend/src/nas/m2-provider.ts +104 -0
- package/templates/native-go-vue/frontend/src/nas/use-m2-request.ts +18 -0
- package/templates/native-go-vue/frontend/src/sdk-main.ts +39 -0
- package/templates/native-go-vue/frontend/src/shell/AppShell.vue +48 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/de.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/en.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/es.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/fr.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/it.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/ja.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/ko.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/zh-CN.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/zh-TW.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n.ts +17 -0
- package/templates/native-go-vue/frontend/src/shell/pages.ts +34 -0
- package/templates/native-go-vue/frontend/src/style.css +2 -6
- package/templates/native-go-vue/frontend/test/apps.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/jobs-connected.test.ts +163 -0
- package/templates/native-go-vue/frontend/test/jobs-preview.html +22 -0
- package/templates/native-go-vue/frontend/test/jobs.test.ts +176 -0
- package/templates/native-go-vue/frontend/test/m2-preview.html +27 -0
- package/templates/native-go-vue/frontend/test/m2-provider.test.ts +87 -0
- package/templates/native-go-vue/frontend/test/m2-ui.test.ts +209 -0
- package/templates/native-go-vue/frontend/test/native-controls.test.ts +27 -0
- package/templates/native-go-vue/frontend/test/picker-wire.test.ts +110 -0
- package/templates/native-go-vue/frontend/test/shell-preview.html +19 -0
- package/templates/native-go-vue/frontend/test/shell-sdk.test.ts +73 -0
- package/templates/native-go-vue/frontend/test/shell-ui.test.ts +114 -0
- package/templates/native-go-vue/frontend/test/shell.test.ts +45 -0
- package/templates/native-go-vue/frontend/vite.config.ts +2 -2
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
package datamigrate
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"errors"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"reflect"
|
|
8
|
+
"testing"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func readState(t *testing.T, dir string) State {
|
|
12
|
+
t.Helper()
|
|
13
|
+
got, err := Load(dir)
|
|
14
|
+
if err != nil {
|
|
15
|
+
t.Fatalf("Load: %v", err)
|
|
16
|
+
}
|
|
17
|
+
return got
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
func TestMissingStateIsZero(t *testing.T) {
|
|
21
|
+
got, err := Load(t.TempDir())
|
|
22
|
+
if err != nil {
|
|
23
|
+
t.Fatalf("Load: %v", err)
|
|
24
|
+
}
|
|
25
|
+
if got != (State{}) {
|
|
26
|
+
t.Fatalf("missing state = %+v, want zero", got)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func TestRunAppliesEveryMigrationInVersionOrderAndRecordsSchema(t *testing.T) {
|
|
31
|
+
dir := t.TempDir()
|
|
32
|
+
var order []int
|
|
33
|
+
migrations := []Migration{
|
|
34
|
+
{Version: 2, Name: "second", Apply: func(Context) error { order = append(order, 2); return nil }},
|
|
35
|
+
{Version: 1, Name: "first", Apply: func(Context) error { order = append(order, 1); return nil }},
|
|
36
|
+
}
|
|
37
|
+
got, err := Run(dir, Info{NewPkgVer: "1.1.0-0002"}, migrations)
|
|
38
|
+
if err != nil {
|
|
39
|
+
t.Fatalf("Run: %v", err)
|
|
40
|
+
}
|
|
41
|
+
if want := []int{1, 2}; !reflect.DeepEqual(order, want) {
|
|
42
|
+
t.Fatalf("migration order = %v, want %v", order, want)
|
|
43
|
+
}
|
|
44
|
+
if got.Schema != 2 {
|
|
45
|
+
t.Fatalf("returned schema = %d, want 2", got.Schema)
|
|
46
|
+
}
|
|
47
|
+
if reread := readState(t, dir); reread.Schema != 2 || reread.PackageVersion != "1.1.0-0002" {
|
|
48
|
+
t.Fatalf("recorded state = %+v", reread)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func TestRunSkipsMigrationsAlreadyRecorded(t *testing.T) {
|
|
53
|
+
dir := t.TempDir()
|
|
54
|
+
runs := 0
|
|
55
|
+
migration := Migration{Version: 1, Name: "once", Apply: func(Context) error { runs++; return nil }}
|
|
56
|
+
for range 2 {
|
|
57
|
+
if _, err := Run(dir, Info{}, []Migration{migration}); err != nil {
|
|
58
|
+
t.Fatalf("Run: %v", err)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if runs != 1 {
|
|
62
|
+
t.Fatalf("migration applied %d times, want 1", runs)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func TestRunStopsAtFailureAndKeepsEarlierVersion(t *testing.T) {
|
|
67
|
+
dir := t.TempDir()
|
|
68
|
+
sentinel := errors.New("boom")
|
|
69
|
+
applied := 0
|
|
70
|
+
migrations := []Migration{
|
|
71
|
+
{Version: 1, Name: "ok", Apply: func(Context) error { applied++; return nil }},
|
|
72
|
+
{Version: 2, Name: "bad", Apply: func(Context) error { applied++; return sentinel }},
|
|
73
|
+
{Version: 3, Name: "later", Apply: func(Context) error { applied++; return nil }},
|
|
74
|
+
}
|
|
75
|
+
_, err := Run(dir, Info{}, migrations)
|
|
76
|
+
if !errors.Is(err, sentinel) {
|
|
77
|
+
t.Fatalf("Run error = %v, want the migration error", err)
|
|
78
|
+
}
|
|
79
|
+
if applied != 2 {
|
|
80
|
+
t.Fatalf("applied %d migrations, want 2", applied)
|
|
81
|
+
}
|
|
82
|
+
if got := readState(t, dir); got.Schema != 1 {
|
|
83
|
+
t.Fatalf("recorded schema = %d, want 1 (last success)", got.Schema)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
func TestRunLeavesOldDataWhenAMigrationFails(t *testing.T) {
|
|
88
|
+
dir := t.TempDir()
|
|
89
|
+
keep := filepath.Join(dir, "old.db")
|
|
90
|
+
if err := os.WriteFile(keep, []byte("old"), 0o600); err != nil {
|
|
91
|
+
t.Fatal(err)
|
|
92
|
+
}
|
|
93
|
+
if _, err := Run(dir, Info{}, []Migration{{Version: 1, Name: "bad", Apply: func(Context) error { return errors.New("nope") }}}); err == nil {
|
|
94
|
+
t.Fatal("want error")
|
|
95
|
+
}
|
|
96
|
+
if data, err := os.ReadFile(keep); err != nil || string(data) != "old" {
|
|
97
|
+
t.Fatalf("old data = %q, %v", data, err)
|
|
98
|
+
}
|
|
99
|
+
if _, err := os.Stat(filepath.Join(dir, StateFile)); !os.IsNotExist(err) {
|
|
100
|
+
t.Fatalf("a failed first migration must not record a version: %v", err)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
func TestRunGivesMigrationsTheOldAndNewPackageVersion(t *testing.T) {
|
|
105
|
+
dir := t.TempDir()
|
|
106
|
+
var first Context
|
|
107
|
+
if _, err := Run(dir, Info{OldPkgVer: "1.0.0-0001", NewPkgVer: "1.1.0-0002"}, []Migration{
|
|
108
|
+
{Version: 1, Name: "m1", Apply: func(ctx Context) error { first = ctx; return nil }},
|
|
109
|
+
}); err != nil {
|
|
110
|
+
t.Fatal(err)
|
|
111
|
+
}
|
|
112
|
+
if first.OldPkgVer != "1.0.0-0001" || first.NewPkgVer != "1.1.0-0002" || first.DataDir != dir {
|
|
113
|
+
t.Fatalf("context = %+v", first)
|
|
114
|
+
}
|
|
115
|
+
var second Context
|
|
116
|
+
if _, err := Run(dir, Info{NewPkgVer: "1.2.0-0003"}, []Migration{
|
|
117
|
+
{Version: 2, Name: "m2", Apply: func(ctx Context) error { second = ctx; return nil }},
|
|
118
|
+
}); err != nil {
|
|
119
|
+
t.Fatal(err)
|
|
120
|
+
}
|
|
121
|
+
if second.OldPkgVer != "1.1.0-0002" {
|
|
122
|
+
t.Fatalf("old package version without SYNOPKG_OLD_PKGVER = %q, want the recorded one", second.OldPkgVer)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
func TestRunRecordsThePackageVersionWithoutMigrations(t *testing.T) {
|
|
127
|
+
dir := t.TempDir()
|
|
128
|
+
if _, err := Run(dir, Info{NewPkgVer: "1.0.0-0001"}, nil); err != nil {
|
|
129
|
+
t.Fatal(err)
|
|
130
|
+
}
|
|
131
|
+
if got := readState(t, dir); got.Schema != 0 || got.PackageVersion != "1.0.0-0001" {
|
|
132
|
+
t.Fatalf("state = %+v", got)
|
|
133
|
+
}
|
|
134
|
+
if _, err := Run(dir, Info{NewPkgVer: "1.1.0-0002"}, nil); err != nil {
|
|
135
|
+
t.Fatal(err)
|
|
136
|
+
}
|
|
137
|
+
if got := readState(t, dir); got.PackageVersion != "1.1.0-0002" {
|
|
138
|
+
t.Fatalf("state = %+v", got)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
func TestRunRejectsInvalidMigrationLists(t *testing.T) {
|
|
143
|
+
dir := t.TempDir()
|
|
144
|
+
ok := func(Context) error { return nil }
|
|
145
|
+
for name, migrations := range map[string][]Migration{
|
|
146
|
+
"zero version": {{Version: 0, Name: "z", Apply: ok}},
|
|
147
|
+
"negative": {{Version: -1, Name: "n", Apply: ok}},
|
|
148
|
+
"duplicate": {{Version: 1, Name: "a", Apply: ok}, {Version: 1, Name: "b", Apply: ok}},
|
|
149
|
+
"nil apply": {{Version: 1, Name: "a"}},
|
|
150
|
+
} {
|
|
151
|
+
if _, err := Run(dir, Info{}, migrations); err == nil {
|
|
152
|
+
t.Errorf("%s: want an error before anything runs", name)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
func TestRunRejectsAnEmptyDataDirectory(t *testing.T) {
|
|
158
|
+
if _, err := Run("", Info{}, nil); err == nil {
|
|
159
|
+
t.Fatal("want an error")
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
func TestLoadRejectsCorruptState(t *testing.T) {
|
|
164
|
+
for name, body := range map[string]string{
|
|
165
|
+
"not json": "{",
|
|
166
|
+
"negative": `{"schema":-1}`,
|
|
167
|
+
"not a number": `{"schema":"one"}`,
|
|
168
|
+
} {
|
|
169
|
+
dir := t.TempDir()
|
|
170
|
+
if err := os.WriteFile(filepath.Join(dir, StateFile), []byte(body), 0o600); err != nil {
|
|
171
|
+
t.Fatal(err)
|
|
172
|
+
}
|
|
173
|
+
if _, err := Load(dir); err == nil {
|
|
174
|
+
t.Errorf("%s: want an error", name)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package filestation
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"fmt"
|
|
6
|
+
"net/http"
|
|
7
|
+
"testing"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// browseServer answers the session check and both List methods, and records
|
|
11
|
+
// the folder_path DSM was asked to list ("" for the share roots).
|
|
12
|
+
func browseServer(t *testing.T, user string, listed *[]string) *Client {
|
|
13
|
+
return fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
14
|
+
r.ParseForm()
|
|
15
|
+
switch r.Form.Get("method") {
|
|
16
|
+
case "get":
|
|
17
|
+
fmt.Fprintf(w, `{"success":true,"data":{"username":%q}}`, user)
|
|
18
|
+
case "list_share":
|
|
19
|
+
*listed = append(*listed, "")
|
|
20
|
+
fmt.Fprint(w, `{"success":true,"data":{"shares":[{"path":"/share","name":"share","isdir":true}],"total":1,"offset":0}}`)
|
|
21
|
+
case "list":
|
|
22
|
+
*listed = append(*listed, r.Form.Get("folder_path"))
|
|
23
|
+
fmt.Fprint(w, `{"success":true,"data":{"files":[{"path":"/share/a.txt","name":"a.txt","isdir":false,"additional":{"size":3}}],"total":1,"offset":0}}`)
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
func TestBrowseListsShareRootsAndFoldersThroughCurrentSession(t *testing.T) {
|
|
29
|
+
var listed []string
|
|
30
|
+
s, _ := fileService(t, browseServer(t, "alice", &listed))
|
|
31
|
+
roots, err := s.Browse(context.Background(), alice(t), sessionRequest(), "", 0)
|
|
32
|
+
if err != nil || len(roots.Shares) != 1 || roots.Shares[0].Path != "/share" {
|
|
33
|
+
t.Fatalf("%+v %v", roots, err)
|
|
34
|
+
}
|
|
35
|
+
page, err := s.Browse(context.Background(), alice(t), sessionRequest(), "/share", 0)
|
|
36
|
+
if err != nil || len(page.Files) != 1 || page.Files[0].Name != "a.txt" {
|
|
37
|
+
t.Fatalf("%+v %v", page, err)
|
|
38
|
+
}
|
|
39
|
+
if len(listed) != 2 || listed[0] != "" || listed[1] != "/share" {
|
|
40
|
+
t.Fatalf("listed %q", listed)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func TestBrowseRefusesAnotherUsersSessionBeforeListing(t *testing.T) {
|
|
45
|
+
var listed []string
|
|
46
|
+
s, _ := fileService(t, browseServer(t, "mallory", &listed))
|
|
47
|
+
if _, err := s.Browse(context.Background(), alice(t), sessionRequest(), "/share", 0); err == nil {
|
|
48
|
+
t.Fatal("a session that resolves to another user must be refused")
|
|
49
|
+
}
|
|
50
|
+
if len(listed) != 0 {
|
|
51
|
+
t.Fatalf("listed %q", listed)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
func TestBrowseRefusesBadPathsAndOnNilService(t *testing.T) {
|
|
56
|
+
var listed []string
|
|
57
|
+
s, _ := fileService(t, browseServer(t, "alice", &listed))
|
|
58
|
+
for _, folder := range []string{"share", "/share/../etc"} {
|
|
59
|
+
if _, err := s.Browse(context.Background(), alice(t), sessionRequest(), folder, 0); err == nil {
|
|
60
|
+
t.Errorf("%q must be refused", folder)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
var nilService *Service
|
|
64
|
+
if _, err := nilService.Browse(context.Background(), alice(t), sessionRequest(), "", 0); err == nil {
|
|
65
|
+
t.Fatal("nil service must refuse")
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
package filestation
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"io"
|
|
8
|
+
"mime"
|
|
9
|
+
"net"
|
|
10
|
+
"net/http"
|
|
11
|
+
"net/url"
|
|
12
|
+
"path"
|
|
13
|
+
"strconv"
|
|
14
|
+
"strings"
|
|
15
|
+
"time"
|
|
16
|
+
|
|
17
|
+
"dsmapp/internal/api"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const MaxBytes = 512 * 1024
|
|
21
|
+
const maxMetadata = 1024 * 1024
|
|
22
|
+
const PageSize = 100
|
|
23
|
+
|
|
24
|
+
// Client has no cookie jar or credentials. The destination is startup-owned,
|
|
25
|
+
// literal loopback only; proxies, redirects and automatic retries are disabled.
|
|
26
|
+
type Client struct {
|
|
27
|
+
endpoint string
|
|
28
|
+
http *http.Client
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func NewClient(base string) (*Client, error) {
|
|
32
|
+
u, e := url.Parse(base)
|
|
33
|
+
if e != nil || u.Scheme != "http" || u.User != nil || u.RawQuery != "" || u.Fragment != "" || (u.Path != "" && u.Path != "/") || net.ParseIP(u.Hostname()) == nil || !net.ParseIP(u.Hostname()).IsLoopback() {
|
|
34
|
+
return nil, fail("unavailable")
|
|
35
|
+
}
|
|
36
|
+
tr := &http.Transport{Proxy: nil, DialContext: (&net.Dialer{Timeout: 3 * time.Second}).DialContext, DisableKeepAlives: true, ResponseHeaderTimeout: 10 * time.Second, MaxResponseHeaderBytes: 32 * 1024, DisableCompression: true}
|
|
37
|
+
return &Client{endpoint: strings.TrimRight(base, "/") + "/webapi/entry.cgi", http: &http.Client{Transport: tr, Timeout: 15 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}}, nil
|
|
38
|
+
}
|
|
39
|
+
func fail(code string) error {
|
|
40
|
+
return &api.Error{Code: code, Message: "File Station operation refused"}
|
|
41
|
+
}
|
|
42
|
+
func wireError(code int) error {
|
|
43
|
+
switch code {
|
|
44
|
+
case 106, 107, 119:
|
|
45
|
+
return fail("session_required")
|
|
46
|
+
case 105, 403, 407:
|
|
47
|
+
return fail("denied")
|
|
48
|
+
case 408:
|
|
49
|
+
return fail("not_found")
|
|
50
|
+
case 414, 1805:
|
|
51
|
+
return fail("conflict")
|
|
52
|
+
case 400:
|
|
53
|
+
return fail("invalid-request")
|
|
54
|
+
default:
|
|
55
|
+
return fail("unavailable")
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
func fields(family, method, version string) url.Values {
|
|
59
|
+
return url.Values{"api": {family}, "method": {method}, "version": {version}}
|
|
60
|
+
}
|
|
61
|
+
func array(s string) string { b, _ := json.Marshal([]string{s}); return string(b) }
|
|
62
|
+
func validPath(p string) bool {
|
|
63
|
+
return len(p) > 1 && len(p) <= 4096 && strings.HasPrefix(p, "/") && path.Clean(p) == p && !strings.ContainsAny(p, "\x00\r\n\\,\"")
|
|
64
|
+
}
|
|
65
|
+
func (c *Client) send(ctx context.Context, original *http.Request, body io.Reader, contentType string) (*http.Response, error) {
|
|
66
|
+
if c == nil || original == nil {
|
|
67
|
+
return nil, fail("unavailable")
|
|
68
|
+
}
|
|
69
|
+
cookies := original.CookiesNamed("id")
|
|
70
|
+
token := original.Header.Get("X-SYNO-TOKEN")
|
|
71
|
+
if len(cookies) != 1 || cookies[0].Value == "" || len(cookies[0].Value) > 4096 || len(token) > 4096 || strings.ContainsAny(token, "\r\n\x00") {
|
|
72
|
+
return nil, fail("session_required")
|
|
73
|
+
}
|
|
74
|
+
method, endpoint := http.MethodPost, c.endpoint
|
|
75
|
+
if contentType == "" {
|
|
76
|
+
method = http.MethodGet
|
|
77
|
+
encoded, err := io.ReadAll(body)
|
|
78
|
+
if err != nil {
|
|
79
|
+
return nil, fail("unavailable")
|
|
80
|
+
}
|
|
81
|
+
endpoint += "?" + string(encoded)
|
|
82
|
+
body = nil
|
|
83
|
+
}
|
|
84
|
+
req, e := http.NewRequestWithContext(ctx, method, endpoint, body)
|
|
85
|
+
if e != nil {
|
|
86
|
+
return nil, fail("unavailable")
|
|
87
|
+
}
|
|
88
|
+
req.Header.Set("Content-Type", contentType)
|
|
89
|
+
req.AddCookie(cookies[0])
|
|
90
|
+
req.Header.Set("X-SYNO-TOKEN", token)
|
|
91
|
+
// Never forward caller Host, Authorization, forwarding headers or URLs.
|
|
92
|
+
resp, e := c.http.Do(req)
|
|
93
|
+
if e != nil {
|
|
94
|
+
if ctx.Err() != nil {
|
|
95
|
+
return nil, fail("canceled")
|
|
96
|
+
}
|
|
97
|
+
return nil, fail("unavailable")
|
|
98
|
+
}
|
|
99
|
+
if resp.StatusCode != http.StatusOK {
|
|
100
|
+
resp.Body.Close()
|
|
101
|
+
return nil, fail("unavailable")
|
|
102
|
+
}
|
|
103
|
+
return resp, nil
|
|
104
|
+
}
|
|
105
|
+
func (c *Client) form(ctx context.Context, r *http.Request, v url.Values) (*http.Response, error) {
|
|
106
|
+
if r == nil {
|
|
107
|
+
return nil, fail("unavailable")
|
|
108
|
+
}
|
|
109
|
+
v.Set("SynoToken", r.Header.Get("X-SYNO-TOKEN"))
|
|
110
|
+
return c.send(ctx, r, strings.NewReader(v.Encode()), "application/x-www-form-urlencoded")
|
|
111
|
+
}
|
|
112
|
+
func decode(resp *http.Response, into any) error {
|
|
113
|
+
defer resp.Body.Close()
|
|
114
|
+
b, e := io.ReadAll(io.LimitReader(resp.Body, maxMetadata+1))
|
|
115
|
+
if e != nil || len(b) > maxMetadata {
|
|
116
|
+
return fail("unavailable")
|
|
117
|
+
}
|
|
118
|
+
var envelope struct {
|
|
119
|
+
Success *bool `json:"success"`
|
|
120
|
+
Data json.RawMessage `json:"data"`
|
|
121
|
+
Error struct {
|
|
122
|
+
Code int `json:"code"`
|
|
123
|
+
} `json:"error"`
|
|
124
|
+
}
|
|
125
|
+
if json.Unmarshal(b, &envelope) != nil || envelope.Success == nil {
|
|
126
|
+
return fail("unavailable")
|
|
127
|
+
}
|
|
128
|
+
if !*envelope.Success {
|
|
129
|
+
return wireError(envelope.Error.Code)
|
|
130
|
+
}
|
|
131
|
+
if into != nil && json.Unmarshal(envelope.Data, into) != nil {
|
|
132
|
+
return fail("unavailable")
|
|
133
|
+
}
|
|
134
|
+
return nil
|
|
135
|
+
}
|
|
136
|
+
func (c *Client) call(ctx context.Context, r *http.Request, v url.Values, into any) error {
|
|
137
|
+
resp, e := c.form(ctx, r, v)
|
|
138
|
+
if e != nil {
|
|
139
|
+
return e
|
|
140
|
+
}
|
|
141
|
+
return decode(resp, into)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Verify checks that loopback WebAPI resolves the same user as authenticate.cgi.
|
|
145
|
+
// Failure (including DSM IP-bound sessions) never falls back to admin credentials.
|
|
146
|
+
func (c *Client) Verify(ctx context.Context, r *http.Request, user string) error {
|
|
147
|
+
var d struct {
|
|
148
|
+
Username string `json:"username"`
|
|
149
|
+
}
|
|
150
|
+
if e := c.call(ctx, r, fields("SYNO.Core.NormalUser", "get", "1"), &d); e != nil {
|
|
151
|
+
return e
|
|
152
|
+
}
|
|
153
|
+
if user == "" || d.Username != user {
|
|
154
|
+
return fail("session_required")
|
|
155
|
+
}
|
|
156
|
+
return nil
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
type Entry struct {
|
|
160
|
+
Path string `json:"path"`
|
|
161
|
+
Name string `json:"name"`
|
|
162
|
+
IsDir bool `json:"isdir"`
|
|
163
|
+
Additional struct {
|
|
164
|
+
Size int64 `json:"size"`
|
|
165
|
+
} `json:"additional"`
|
|
166
|
+
}
|
|
167
|
+
type Page struct {
|
|
168
|
+
Files []Entry `json:"files"`
|
|
169
|
+
Shares []Entry `json:"shares,omitempty"`
|
|
170
|
+
Total int `json:"total"`
|
|
171
|
+
Offset int `json:"offset"`
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
func (c *Client) page(ctx context.Context, r *http.Request, p string, offset int) (Page, error) {
|
|
175
|
+
var d Page
|
|
176
|
+
if offset < 0 || offset > 1000000 || (p != "" && !validPath(p)) {
|
|
177
|
+
return d, fail("invalid-request")
|
|
178
|
+
}
|
|
179
|
+
method := "list"
|
|
180
|
+
if p == "" {
|
|
181
|
+
method = "list_share"
|
|
182
|
+
}
|
|
183
|
+
v := fields("SYNO.FileStation.List", method, "2")
|
|
184
|
+
v.Set("offset", strconv.Itoa(offset))
|
|
185
|
+
v.Set("limit", strconv.Itoa(PageSize))
|
|
186
|
+
v.Set("additional", `["size"]`)
|
|
187
|
+
if p != "" {
|
|
188
|
+
v.Set("folder_path", p)
|
|
189
|
+
}
|
|
190
|
+
e := c.call(ctx, r, v, &d)
|
|
191
|
+
if len(d.Files) > PageSize || len(d.Shares) > PageSize {
|
|
192
|
+
return Page{}, fail("unavailable")
|
|
193
|
+
}
|
|
194
|
+
return d, e
|
|
195
|
+
}
|
|
196
|
+
func (c *Client) Discover(ctx context.Context, r *http.Request, offset int) (Page, error) {
|
|
197
|
+
return c.page(ctx, r, "", offset)
|
|
198
|
+
}
|
|
199
|
+
func (c *Client) List(ctx context.Context, r *http.Request, p string, offset int) (Page, error) {
|
|
200
|
+
return c.page(ctx, r, p, offset)
|
|
201
|
+
}
|
|
202
|
+
func (c *Client) Stat(ctx context.Context, r *http.Request, p string) (Entry, error) {
|
|
203
|
+
var d Page
|
|
204
|
+
if !validPath(p) {
|
|
205
|
+
return Entry{}, fail("invalid-request")
|
|
206
|
+
}
|
|
207
|
+
v := fields("SYNO.FileStation.List", "getinfo", "2")
|
|
208
|
+
v.Set("path", array(p))
|
|
209
|
+
v.Set("additional", `["size"]`)
|
|
210
|
+
if e := c.call(ctx, r, v, &d); e != nil {
|
|
211
|
+
return Entry{}, e
|
|
212
|
+
}
|
|
213
|
+
if len(d.Files) != 1 || d.Files[0].Path != p || d.Files[0].Name == "" {
|
|
214
|
+
return Entry{}, fail("not_found")
|
|
215
|
+
}
|
|
216
|
+
return d.Files[0], nil
|
|
217
|
+
}
|
|
218
|
+
func (c *Client) Read(ctx context.Context, r *http.Request, p string) ([]byte, error) {
|
|
219
|
+
if !validPath(p) {
|
|
220
|
+
return nil, fail("invalid-request")
|
|
221
|
+
}
|
|
222
|
+
v := fields("SYNO.FileStation.Download", "download", "2")
|
|
223
|
+
v.Set("path", array(p))
|
|
224
|
+
v.Set("mode", "download")
|
|
225
|
+
resp, e := c.send(ctx, r, strings.NewReader(v.Encode()), "")
|
|
226
|
+
if e != nil {
|
|
227
|
+
return nil, e
|
|
228
|
+
}
|
|
229
|
+
// DSM error envelopes must never be returned as successful file content.
|
|
230
|
+
// A real JSON file remains downloadable when attachment disposition is set.
|
|
231
|
+
disposition, _, _ := mime.ParseMediaType(resp.Header.Get("Content-Disposition"))
|
|
232
|
+
if disposition != "attachment" {
|
|
233
|
+
e = decode(resp, nil)
|
|
234
|
+
if e == nil {
|
|
235
|
+
e = fail("unavailable")
|
|
236
|
+
}
|
|
237
|
+
return nil, e
|
|
238
|
+
}
|
|
239
|
+
defer resp.Body.Close()
|
|
240
|
+
b, e := io.ReadAll(io.LimitReader(resp.Body, MaxBytes+1))
|
|
241
|
+
if e != nil {
|
|
242
|
+
return nil, fail("read_failed")
|
|
243
|
+
}
|
|
244
|
+
if len(b) > MaxBytes {
|
|
245
|
+
return nil, fail("limit-exceeded")
|
|
246
|
+
}
|
|
247
|
+
if resp.ContentLength >= 0 && resp.ContentLength != int64(len(b)) {
|
|
248
|
+
return nil, fail("read_failed")
|
|
249
|
+
}
|
|
250
|
+
return bytes.Clone(b), nil
|
|
251
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
package filestation
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"fmt"
|
|
7
|
+
"net/http"
|
|
8
|
+
"net/http/httptest"
|
|
9
|
+
"strings"
|
|
10
|
+
"testing"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
func fakeClient(t *testing.T, h http.HandlerFunc) *Client {
|
|
14
|
+
t.Helper()
|
|
15
|
+
s := httptest.NewServer(h)
|
|
16
|
+
t.Cleanup(s.Close)
|
|
17
|
+
c, err := NewClient(s.URL)
|
|
18
|
+
if err != nil {
|
|
19
|
+
t.Fatal(err)
|
|
20
|
+
}
|
|
21
|
+
return c
|
|
22
|
+
}
|
|
23
|
+
func sessionRequest() *http.Request {
|
|
24
|
+
r := httptest.NewRequest("POST", "http://package/api", nil)
|
|
25
|
+
r.AddCookie(&http.Cookie{Name: "id", Value: "test-session"})
|
|
26
|
+
r.Header.Set("X-SYNO-TOKEN", "test-token")
|
|
27
|
+
return r
|
|
28
|
+
}
|
|
29
|
+
func TestReadOperationsUseOnlyCurrentSession(t *testing.T) {
|
|
30
|
+
calls := 0
|
|
31
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
32
|
+
calls++
|
|
33
|
+
if (r.Method != "GET" && r.URL.RawQuery != "") || r.Header.Get("X-SYNO-TOKEN") != "test-token" || r.Header.Get("Cookie") != "id=test-session" {
|
|
34
|
+
t.Error("incorrect session transport")
|
|
35
|
+
}
|
|
36
|
+
r.ParseForm()
|
|
37
|
+
if r.Form.Get("_sid") != "" || (r.Method != "GET" && r.Form.Get("SynoToken") != "test-token") {
|
|
38
|
+
t.Error("incorrect form carriers")
|
|
39
|
+
}
|
|
40
|
+
switch r.Form.Get("method") {
|
|
41
|
+
case "get":
|
|
42
|
+
fmt.Fprint(w, `{"success":true,"data":{"username":"alice"}}`)
|
|
43
|
+
case "list_share":
|
|
44
|
+
fmt.Fprint(w, `{"success":true,"data":{"shares":[{"path":"/home","name":"home","isdir":true}],"total":1}}`)
|
|
45
|
+
case "list":
|
|
46
|
+
if r.Form.Get("folder_path") != "/home" || r.Form.Get("limit") != "100" {
|
|
47
|
+
t.Error("list fields")
|
|
48
|
+
}
|
|
49
|
+
fmt.Fprint(w, `{"success":true,"data":{"files":[{"path":"/home/a","name":"a","isdir":false}],"total":1}}`)
|
|
50
|
+
case "getinfo":
|
|
51
|
+
fmt.Fprint(w, `{"success":true,"data":{"files":[{"path":"/home/a","name":"a","isdir":false,"additional":{"size":3}}]}}`)
|
|
52
|
+
case "download":
|
|
53
|
+
if r.Form.Get("path") != `["/home/a"]` {
|
|
54
|
+
t.Error("download path")
|
|
55
|
+
}
|
|
56
|
+
w.Header().Set("Content-Type", "application/octet-stream")
|
|
57
|
+
w.Header().Set("Content-Disposition", `attachment; filename="a"`)
|
|
58
|
+
fmt.Fprint(w, "abc")
|
|
59
|
+
default:
|
|
60
|
+
t.Error("unexpected method")
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
r := sessionRequest()
|
|
64
|
+
if err := c.Verify(context.Background(), r, "alice"); err != nil {
|
|
65
|
+
t.Fatal(err)
|
|
66
|
+
}
|
|
67
|
+
if _, err := c.Discover(context.Background(), r, 0); err != nil {
|
|
68
|
+
t.Fatal(err)
|
|
69
|
+
}
|
|
70
|
+
if _, err := c.List(context.Background(), r, "/home", 0); err != nil {
|
|
71
|
+
t.Fatal(err)
|
|
72
|
+
}
|
|
73
|
+
if _, err := c.Stat(context.Background(), r, "/home/a"); err != nil {
|
|
74
|
+
t.Fatal(err)
|
|
75
|
+
}
|
|
76
|
+
b, err := c.Read(context.Background(), r, "/home/a")
|
|
77
|
+
if err != nil || string(b) != "abc" {
|
|
78
|
+
t.Fatal(err)
|
|
79
|
+
}
|
|
80
|
+
if calls != 5 {
|
|
81
|
+
t.Fatal(calls)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
func TestRefusalAndBoundedErrors(t *testing.T) {
|
|
85
|
+
for _, tt := range []struct{ body, want string }{
|
|
86
|
+
{`{"success":false,"error":{"code":119,"secret":"test-session"}}`, "session_required"},
|
|
87
|
+
{`{"success":false,"error":{"code":407}}`, "denied"},
|
|
88
|
+
{`{"success":false,"error":{"code":408}}`, "not_found"},
|
|
89
|
+
{`{"success":false,"error":{"code":1805}}`, "conflict"},
|
|
90
|
+
{`{"success":false,"error":{"code":9999}}`, "unavailable"},
|
|
91
|
+
{`{"data":{}}`, "unavailable"}, {`not json`, "unavailable"},
|
|
92
|
+
} {
|
|
93
|
+
t.Run(tt.want+tt.body, func(t *testing.T) {
|
|
94
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, tt.body) })
|
|
95
|
+
_, err := c.List(context.Background(), sessionRequest(), "/home", 0)
|
|
96
|
+
if err == nil || !strings.Contains(err.Error(), tt.want) || strings.Contains(err.Error(), "test-session") {
|
|
97
|
+
t.Fatal(err)
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
func TestNoSessionRedirectOrRemoteDestination(t *testing.T) {
|
|
103
|
+
for _, url := range []string{"https://example.com", "http://localhost:5000", "http://127.0.0.1:5000/evil", "http://user@127.0.0.1:5000", "http://127.0.0.1:5000?x=y"} {
|
|
104
|
+
if _, err := NewClient(url); err == nil {
|
|
105
|
+
t.Fatal("accepted", url)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
calls := 0
|
|
109
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
110
|
+
calls++
|
|
111
|
+
http.Redirect(w, r, "http://127.0.0.1:1/leak", 302)
|
|
112
|
+
})
|
|
113
|
+
if _, err := c.List(context.Background(), httptest.NewRequest("POST", "/", nil), "/home", 0); err == nil || calls != 0 {
|
|
114
|
+
t.Fatal("missing session sent")
|
|
115
|
+
}
|
|
116
|
+
if _, err := c.List(context.Background(), sessionRequest(), "/home", 0); err == nil || calls != 1 {
|
|
117
|
+
t.Fatal("redirect accepted")
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
func TestDownloadDoesNotTurnErrorsIntoFileBytes(t *testing.T) {
|
|
121
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
122
|
+
w.Header().Set("Content-Type", "application/json")
|
|
123
|
+
json.NewEncoder(w).Encode(map[string]any{"success": false, "error": map[string]int{"code": 407}})
|
|
124
|
+
})
|
|
125
|
+
if b, err := c.Read(context.Background(), sessionRequest(), "/home/a"); err == nil || len(b) != 0 {
|
|
126
|
+
t.Fatal("error bytes escaped")
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
func TestBoundariesCancellationAndIdentityMismatch(t *testing.T) {
|
|
131
|
+
c := fakeClient(t, func(w http.ResponseWriter, r *http.Request) {
|
|
132
|
+
if r.URL.Query().Get("method") == "download" {
|
|
133
|
+
w.Header().Set("Content-Disposition", `attachment; filename="large"`)
|
|
134
|
+
fmt.Fprint(w, strings.Repeat("x", MaxBytes+1))
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
fmt.Fprint(w, `{"success":true,"data":{"username":"someone-else"}}`)
|
|
138
|
+
})
|
|
139
|
+
if e := c.Verify(context.Background(), sessionRequest(), "alice"); e == nil {
|
|
140
|
+
t.Fatal("identity mismatch admitted")
|
|
141
|
+
}
|
|
142
|
+
if b, e := c.Read(context.Background(), sessionRequest(), "/home/large"); e == nil || len(b) != 0 {
|
|
143
|
+
t.Fatal("oversized read escaped")
|
|
144
|
+
}
|
|
145
|
+
ctx, cancel := context.WithCancel(context.Background())
|
|
146
|
+
cancel()
|
|
147
|
+
if _, e := c.List(ctx, sessionRequest(), "/home", 0); e == nil {
|
|
148
|
+
t.Fatal("canceled request succeeded")
|
|
149
|
+
}
|
|
150
|
+
r := sessionRequest()
|
|
151
|
+
r.AddCookie(&http.Cookie{Name: "id", Value: "other"})
|
|
152
|
+
if _, e := c.List(context.Background(), r, "/home", 0); e == nil {
|
|
153
|
+
t.Fatal("ambiguous session accepted")
|
|
154
|
+
}
|
|
155
|
+
}
|