@synopackageland/cli 0.4.1 → 0.5.3
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/authorization-sdk.d.ts +5 -0
- package/dist/authorization-sdk.js +5 -0
- 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 +132 -32
- 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 +62 -3
- package/dist/host/dsm-port-profile.d.ts +1 -1
- package/dist/host/dsm-port-profile.js +1 -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 +126 -16
- package/dist/inspect.d.ts +3 -0
- package/dist/inspect.js +15 -3
- package/dist/standalone/authorization-window.d.ts +2 -0
- package/dist/standalone/authorization-window.js +28 -0
- package/dist/standalone/authorization.d.ts +48 -0
- package/dist/standalone/authorization.js +116 -0
- 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 +54 -10
- package/dist/standalone/dsm-window.js +10 -3
- 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 +29 -11
- 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 +21 -6
- package/dist/standalone/inspect-spk.d.ts +1 -1
- package/dist/standalone/inspect-spk.js +211 -7
- package/dist/standalone/job-diagnostics.d.ts +1 -0
- package/dist/standalone/job-diagnostics.js +49 -0
- package/dist/standalone/lifecycle-helper.d.ts +1 -1
- package/dist/standalone/lifecycle-helper.js +2 -2
- package/dist/standalone/lifecycle.d.ts +1 -1
- package/dist/standalone/lifecycle.js +14 -4
- 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-ops.d.ts +2 -0
- package/dist/standalone/root-ops.js +10 -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 +4 -0
- package/dist/standalone/spk.js +47 -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/_authorization/main.go +104 -0
- package/dist/templates/_authorization/main_test.go +35 -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/native-go/README.md +118 -5
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +3 -1
- package/dist/templates/native-go/backend/cmd/app/main.go +25 -6
- package/dist/templates/native-go/backend/cmd/app/sdk_main.go +62 -0
- package/dist/templates/native-go/backend/cmd/background-worker/main.go +38 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +27 -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/authorization_none.go +5 -0
- 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 +22 -5
- 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 +177 -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 +86 -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/purge.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/purge_test.go +59 -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/revoke.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/revoke_test.go +121 -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 +161 -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 +14 -2
- 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 +2 -2
- package/dist/templates/native-go-authorization/backend/internal/app/authorization.go +298 -0
- package/dist/templates/native-go-authorization/backend/internal/app/authorization_test.go +96 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/AuthorizationGate.vue +89 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/de.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/en.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/es.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/fr.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/index.ts +15 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/it.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/ja.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/ko.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/zh-CN.json +36 -0
- package/dist/templates/native-go-authorization/frontend/src/authorization/i18n/zh-TW.json +36 -0
- package/dist/templates/native-go-authorization/frontend/test/authorization-preview.html +14 -0
- package/dist/templates/native-go-authorization/frontend/test/authorization.test.ts +59 -0
- 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/context.ts +3 -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/types.d.ts +1 -1
- package/dist/validate.js +6 -3
- package/package.json +5 -2
- package/schema/synology-app.schema.json +19 -0
- package/skills/reference/create.md +6 -2
- package/templates/_authorization/main.go +104 -0
- package/templates/_authorization/main_test.go +35 -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/native-go/README.md +118 -5
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +3 -1
- package/templates/native-go/backend/cmd/app/main.go +25 -6
- package/templates/native-go/backend/cmd/app/sdk_main.go +62 -0
- package/templates/native-go/backend/cmd/background-worker/main.go +38 -0
- package/templates/native-go/backend/cmd/helper/main.go +27 -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/authorization_none.go +5 -0
- 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 +22 -5
- 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 +177 -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 +86 -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/purge.go +115 -0
- package/templates/native-go/backend/internal/helper/purge_test.go +59 -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/revoke.go +109 -0
- package/templates/native-go/backend/internal/helper/revoke_test.go +121 -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 +161 -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 +14 -2
- 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 +2 -2
- package/templates/native-go-authorization/backend/internal/app/authorization.go +298 -0
- package/templates/native-go-authorization/backend/internal/app/authorization_test.go +96 -0
- package/templates/native-go-authorization/frontend/src/authorization/AuthorizationGate.vue +89 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/de.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/en.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/es.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/fr.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/index.ts +15 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/it.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/ja.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/ko.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/zh-CN.json +36 -0
- package/templates/native-go-authorization/frontend/src/authorization/i18n/zh-TW.json +36 -0
- package/templates/native-go-authorization/frontend/test/authorization-preview.html +14 -0
- package/templates/native-go-authorization/frontend/test/authorization.test.ts +59 -0
- 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/context.ts +3 -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
- package/dist/templates/hello-web/compose.yaml +0 -21
- package/dist/templates/hello-web/html/app.js +0 -1
- package/dist/templates/hello-web/html/index.html +0 -13
- package/dist/templates/hello-web/synology-app.yaml +0 -13
- package/dist/templates/hello-web-page/compose.yaml +0 -21
- package/dist/templates/hello-web-page/html/app.js +0 -1
- package/dist/templates/hello-web-page/html/index.html +0 -13
- package/dist/templates/hello-web-page/synology-app.yaml +0 -13
- package/templates/hello-web/compose.yaml +0 -21
- package/templates/hello-web/html/app.js +0 -1
- package/templates/hello-web/html/index.html +0 -13
- package/templates/hello-web/synology-app.yaml +0 -13
- package/templates/hello-web-page/compose.yaml +0 -21
- package/templates/hello-web-page/html/app.js +0 -1
- package/templates/hello-web-page/html/index.html +0 -13
- package/templates/hello-web-page/synology-app.yaml +0 -13
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
package app
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"fmt"
|
|
7
|
+
"net/http"
|
|
8
|
+
"net/http/httptest"
|
|
9
|
+
"path/filepath"
|
|
10
|
+
"strings"
|
|
11
|
+
"testing"
|
|
12
|
+
"time"
|
|
13
|
+
|
|
14
|
+
"dsmapp/internal/api"
|
|
15
|
+
"dsmapp/internal/background"
|
|
16
|
+
"dsmapp/internal/filestation"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
type fakeFiles struct {
|
|
20
|
+
data []byte
|
|
21
|
+
err error
|
|
22
|
+
calls int
|
|
23
|
+
folder string
|
|
24
|
+
rel string
|
|
25
|
+
offset int
|
|
26
|
+
page filestation.Page
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
func (f *fakeFiles) Browse(_ context.Context, _ api.Caller, _ *http.Request, folder string, offset int) (filestation.Page, error) {
|
|
30
|
+
f.calls++
|
|
31
|
+
f.folder, f.offset = folder, offset
|
|
32
|
+
return f.page, f.err
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func (f *fakeFiles) ReadFile(_ context.Context, _ api.Caller, _ *http.Request, folder, rel string) ([]byte, error) {
|
|
36
|
+
f.calls++
|
|
37
|
+
f.folder, f.rel = folder, rel
|
|
38
|
+
return f.data, f.err
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type bgEnv struct {
|
|
42
|
+
t *testing.T
|
|
43
|
+
store *background.Store
|
|
44
|
+
files *fakeFiles
|
|
45
|
+
srv map[string]*api.Server
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
func newBgEnv(t *testing.T) *bgEnv {
|
|
49
|
+
lookupSubmitterUID = func(string) string { return "1024" }
|
|
50
|
+
t.Cleanup(func() { lookupSubmitterUID = osLookupUID })
|
|
51
|
+
store := background.NewStore(filepath.Join(t.TempDir(), "background"))
|
|
52
|
+
files := &fakeFiles{data: []byte("hello")}
|
|
53
|
+
return &bgEnv{t: t, store: store, files: files, srv: map[string]*api.Server{}}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
func (e *bgEnv) call(auth api.Authenticator, method, params string) (string, map[string]any) {
|
|
57
|
+
e.t.Helper()
|
|
58
|
+
srv, err := api.NewServer(auth, newBackgroundRoutes(e.store, e.files)...)
|
|
59
|
+
if err != nil {
|
|
60
|
+
e.t.Fatal(err)
|
|
61
|
+
}
|
|
62
|
+
req := httptest.NewRequest(http.MethodPost, "/api.cgi", strings.NewReader(`{"method":"`+method+`","params":`+params+`}`))
|
|
63
|
+
req.Header.Set("Content-Type", "application/json")
|
|
64
|
+
rec := httptest.NewRecorder()
|
|
65
|
+
srv.ServeHTTP(rec, req)
|
|
66
|
+
var out map[string]any
|
|
67
|
+
if err := json.Unmarshal(rec.Body.Bytes(), &out); err != nil {
|
|
68
|
+
e.t.Fatalf("not JSON: %s", rec.Body.String())
|
|
69
|
+
}
|
|
70
|
+
code := ""
|
|
71
|
+
if er, ok := out["error"].(map[string]any); ok {
|
|
72
|
+
code, _ = er["code"].(string)
|
|
73
|
+
}
|
|
74
|
+
return code, out
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
func (e *bgEnv) enable() {
|
|
78
|
+
e.t.Helper()
|
|
79
|
+
if code, out := e.call(alice, "bg.mode.set", `{"enabled":true}`); code != "" {
|
|
80
|
+
e.t.Fatalf("%s %v", code, out)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
func data(out map[string]any) map[string]any { return out["data"].(map[string]any) }
|
|
85
|
+
|
|
86
|
+
var bgSample = map[string]string{
|
|
87
|
+
"bg.schedules.list": `{}`,
|
|
88
|
+
"bg.schedules.create": `{"key":"schedule","jobId":"missing","intervalSeconds":3600,"consent":true}`,
|
|
89
|
+
"bg.schedules.disable": `{"id":"missing"}`,
|
|
90
|
+
"bg.schedules.delete": `{"id":"missing"}`,
|
|
91
|
+
"bg.schedules.enable": `{"id":"missing","consent":true}`,
|
|
92
|
+
"bg.status": `{}`,
|
|
93
|
+
"bg.users.set": `{"allowOrdinaryUsers":true}`,
|
|
94
|
+
"bg.jobs.purge": `{"owner":{"user":"bob","uid":"1025"}}`,
|
|
95
|
+
"bg.mode.set": `{"enabled":true}`,
|
|
96
|
+
"bg.browse": `{"folder":"/share","offset":0}`,
|
|
97
|
+
"bg.jobs.submit": `{"key":"k1","folder":"/share","relative":"a.txt"}`,
|
|
98
|
+
"bg.jobs.list": `{}`,
|
|
99
|
+
"bg.jobs.get": `{"id":"` + strings.Repeat("a", 32) + `"}`,
|
|
100
|
+
"bg.jobs.cancel": `{"id":"` + strings.Repeat("a", 32) + `"}`,
|
|
101
|
+
"bg.jobs.result": `{"id":"` + strings.Repeat("a", 32) + `"}`,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
func TestBackgroundRoutesAreAdminOnlyByUnsupportedForOrdinaryUsers(t *testing.T) {
|
|
105
|
+
e := newBgEnv(t)
|
|
106
|
+
routes := newBackgroundRoutes(e.store, e.files)
|
|
107
|
+
if len(routes) != len(bgSample) {
|
|
108
|
+
t.Fatalf("%d routes, %d samples", len(routes), len(bgSample))
|
|
109
|
+
}
|
|
110
|
+
for _, r := range routes {
|
|
111
|
+
if r.Public() {
|
|
112
|
+
t.Errorf("%s must not be public", r.Method())
|
|
113
|
+
}
|
|
114
|
+
params, ok := bgSample[r.Method()]
|
|
115
|
+
if !ok {
|
|
116
|
+
t.Fatalf("no sample for %s", r.Method())
|
|
117
|
+
}
|
|
118
|
+
if code, _ := e.call(bob, r.Method(), params); code != "unsupported" {
|
|
119
|
+
t.Errorf("%s as an ordinary user: %q", r.Method(), code)
|
|
120
|
+
}
|
|
121
|
+
if code, _ := e.call(nobody, r.Method(), params); code != "session_required" {
|
|
122
|
+
t.Errorf("%s without a session: %q", r.Method(), code)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if e.files.calls != 0 {
|
|
126
|
+
t.Fatal("an ordinary user must not trigger a NAS read")
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
func TestBackgroundStatusReportsModeLimitsAndWorker(t *testing.T) {
|
|
131
|
+
e := newBgEnv(t)
|
|
132
|
+
code, out := e.call(alice, "bg.status", `{}`)
|
|
133
|
+
d := data(out)
|
|
134
|
+
if code != "" || d["enabled"] != false || d["algorithm"] != "sha256-v1" || d["worker"] != nil {
|
|
135
|
+
t.Fatalf("%s %v", code, out)
|
|
136
|
+
}
|
|
137
|
+
limits := d["limits"].(map[string]any)
|
|
138
|
+
if limits["maxInputBytes"].(float64) != 512*1024 || limits["maxQueued"].(float64) != 16 || limits["maxTotalBytes"].(float64) != 16<<20 || limits["jobTimeoutSeconds"].(float64) != 60 {
|
|
139
|
+
t.Fatalf("limits: %v", limits)
|
|
140
|
+
}
|
|
141
|
+
if err := e.store.Heartbeat(context.Background(), background.WorkerInfo{PID: 9, UID: 255853, Username: "pkg"}); err != nil {
|
|
142
|
+
t.Fatal(err)
|
|
143
|
+
}
|
|
144
|
+
_, out = e.call(alice, "bg.status", `{}`)
|
|
145
|
+
w := data(out)["worker"].(map[string]any)
|
|
146
|
+
if w["alive"] != true || w["uid"].(float64) != 255853 {
|
|
147
|
+
t.Fatalf("worker: %v", w)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
func TestBackgroundSubmitRefusedWhileOffAndDoesNotReadNAS(t *testing.T) {
|
|
152
|
+
e := newBgEnv(t)
|
|
153
|
+
code, _ := e.call(alice, "bg.jobs.submit", bgSample["bg.jobs.submit"])
|
|
154
|
+
if code != "disabled" || e.files.calls != 0 {
|
|
155
|
+
t.Fatalf("%q, NAS reads %d", code, e.files.calls)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
func TestBackgroundSubmitImportsSelectedFileAndIsIdempotent(t *testing.T) {
|
|
160
|
+
e := newBgEnv(t)
|
|
161
|
+
e.enable()
|
|
162
|
+
params := `{"key":"k1","folder":"/share","relative":"docs/a.txt"}`
|
|
163
|
+
code, out := e.call(alice, "bg.jobs.submit", params)
|
|
164
|
+
job := data(out)["job"].(map[string]any)
|
|
165
|
+
if code != "" || job["state"] != "queued" || job["name"] != "a.txt" || data(out)["duplicate"] != false {
|
|
166
|
+
t.Fatalf("%s %v", code, out)
|
|
167
|
+
}
|
|
168
|
+
if e.files.folder != "/share" || e.files.rel != "docs/a.txt" {
|
|
169
|
+
t.Fatalf("adapter saw %q %q", e.files.folder, e.files.rel)
|
|
170
|
+
}
|
|
171
|
+
submitter := job["submitter"].(map[string]any)
|
|
172
|
+
if submitter["user"] != "alice" || submitter["uid"] != "1024" {
|
|
173
|
+
t.Fatalf("submitter: %v", submitter)
|
|
174
|
+
}
|
|
175
|
+
_, again := e.call(alice, "bg.jobs.submit", params)
|
|
176
|
+
if data(again)["duplicate"] != true || data(again)["job"].(map[string]any)["id"] != job["id"] {
|
|
177
|
+
t.Fatalf("duplicate: %v", again)
|
|
178
|
+
}
|
|
179
|
+
e.files.data = []byte("other")
|
|
180
|
+
if code, _ := e.call(alice, "bg.jobs.submit", params); code != "conflict" {
|
|
181
|
+
t.Fatalf("same key with different bytes: %q", code)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
func TestBackgroundSubmitPassesAdapterRefusalsThrough(t *testing.T) {
|
|
186
|
+
e := newBgEnv(t)
|
|
187
|
+
e.enable()
|
|
188
|
+
e.files.err = &api.Error{Code: "limit-exceeded", Message: "x"}
|
|
189
|
+
if code, _ := e.call(alice, "bg.jobs.submit", bgSample["bg.jobs.submit"]); code != "limit-exceeded" {
|
|
190
|
+
t.Fatalf("%q", code)
|
|
191
|
+
}
|
|
192
|
+
if jobs, _ := e.store.List(context.Background()); len(jobs) != 0 {
|
|
193
|
+
t.Fatal("a failed import must never enter the queue")
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
func TestBackgroundSubmitValidatesParams(t *testing.T) {
|
|
198
|
+
e := newBgEnv(t)
|
|
199
|
+
e.enable()
|
|
200
|
+
for _, p := range []string{
|
|
201
|
+
`{}`, `{"key":"k","folder":"/share","relative":"a","extra":1}`, `{"key":"bad key","folder":"/share","relative":"a"}`,
|
|
202
|
+
`{"key":"k","folder":"/share","relative":""}`,
|
|
203
|
+
} {
|
|
204
|
+
if code, _ := e.call(alice, "bg.jobs.submit", p); code != "bad_request" {
|
|
205
|
+
t.Errorf("%s: %q", p, code)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
func TestBackgroundQueueFullAndQuotaErrorsHaveStableCodes(t *testing.T) {
|
|
211
|
+
e := newBgEnv(t)
|
|
212
|
+
e.enable()
|
|
213
|
+
for i := 0; i < background.MaxQueued; i++ {
|
|
214
|
+
lookupSubmitterUID = func(string) string { return fmt.Sprint(1024 + i/2) }
|
|
215
|
+
key := "k" + string(rune('a'+i))
|
|
216
|
+
if code, _ := e.call(alice, "bg.jobs.submit", `{"key":"`+key+`","folder":"/share","relative":"a.txt"}`); code != "" {
|
|
217
|
+
t.Fatalf("%d: %q", i, code)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
lookupSubmitterUID = func(string) string { return "9999" }
|
|
221
|
+
if code, _ := e.call(alice, "bg.jobs.submit", `{"key":"more","folder":"/share","relative":"a.txt"}`); code != "queue-full" {
|
|
222
|
+
t.Fatalf("%q", code)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
func TestBackgroundListGetCancelAndResult(t *testing.T) {
|
|
227
|
+
e := newBgEnv(t)
|
|
228
|
+
e.enable()
|
|
229
|
+
_, out := e.call(alice, "bg.jobs.submit", `{"key":"k1","folder":"/share","relative":"a.txt"}`)
|
|
230
|
+
id := data(out)["job"].(map[string]any)["id"].(string)
|
|
231
|
+
idp := `{"id":"` + id + `"}`
|
|
232
|
+
|
|
233
|
+
if _, out = e.call(alice, "bg.jobs.list", `{}`); len(data(out)["jobs"].([]any)) != 1 {
|
|
234
|
+
t.Fatalf("%v", out)
|
|
235
|
+
}
|
|
236
|
+
if code, out := e.call(alice, "bg.jobs.get", idp); code != "" || data(out)["job"].(map[string]any)["id"] != id {
|
|
237
|
+
t.Fatalf("%s %v", code, out)
|
|
238
|
+
}
|
|
239
|
+
if code, _ := e.call(alice, "bg.jobs.result", idp); code != "not_ready" {
|
|
240
|
+
t.Fatalf("result of a queued job: %q", code)
|
|
241
|
+
}
|
|
242
|
+
ctx := context.Background()
|
|
243
|
+
if _, err := e.store.Claim(ctx); err != nil {
|
|
244
|
+
t.Fatal(err)
|
|
245
|
+
}
|
|
246
|
+
sum := "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
|
|
247
|
+
if err := e.store.Finish(ctx, id, background.Outcome{State: background.StateSucceeded, Result: &background.Result{SHA256: sum, Bytes: 5}}); err != nil {
|
|
248
|
+
t.Fatal(err)
|
|
249
|
+
}
|
|
250
|
+
code, out := e.call(alice, "bg.jobs.result", idp)
|
|
251
|
+
res := data(out)["result"].(map[string]any)
|
|
252
|
+
if code != "" || res["sha256"] != sum || res["bytes"].(float64) != 5 || res["worker"] != "sha256-v1" || res["jobId"] != id {
|
|
253
|
+
t.Fatalf("%s %v", code, out)
|
|
254
|
+
}
|
|
255
|
+
if code, _ := e.call(alice, "bg.jobs.cancel", idp); code != "conflict" {
|
|
256
|
+
t.Fatalf("cancel after completion: %q", code)
|
|
257
|
+
}
|
|
258
|
+
for _, m := range []string{"bg.jobs.get", "bg.jobs.cancel", "bg.jobs.result"} {
|
|
259
|
+
if code, _ := e.call(alice, m, `{"id":"`+strings.Repeat("0", 32)+`"}`); code != "not_found" {
|
|
260
|
+
t.Fatalf("%s unknown id: %q", m, code)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
func TestBackgroundCancelQueuedJob(t *testing.T) {
|
|
266
|
+
e := newBgEnv(t)
|
|
267
|
+
e.enable()
|
|
268
|
+
_, out := e.call(alice, "bg.jobs.submit", `{"key":"k1","folder":"/share","relative":"a.txt"}`)
|
|
269
|
+
id := data(out)["job"].(map[string]any)["id"].(string)
|
|
270
|
+
code, out := e.call(alice, "bg.jobs.cancel", `{"id":"`+id+`"}`)
|
|
271
|
+
if code != "" || data(out)["job"].(map[string]any)["state"] != "canceled" {
|
|
272
|
+
t.Fatalf("%s %v", code, out)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
func TestBackgroundModeOffCancelsQueuedWork(t *testing.T) {
|
|
277
|
+
e := newBgEnv(t)
|
|
278
|
+
e.enable()
|
|
279
|
+
_, out := e.call(alice, "bg.jobs.submit", `{"key":"k1","folder":"/share","relative":"a.txt"}`)
|
|
280
|
+
id := data(out)["job"].(map[string]any)["id"].(string)
|
|
281
|
+
if code, _ := e.call(alice, "bg.mode.set", `{"enabled":false}`); code != "" {
|
|
282
|
+
t.Fatal(code)
|
|
283
|
+
}
|
|
284
|
+
_, out = e.call(alice, "bg.jobs.get", `{"id":"`+id+`"}`)
|
|
285
|
+
if job := data(out)["job"].(map[string]any); job["state"] != "canceled" || job["errorCode"] != "disabled" {
|
|
286
|
+
t.Fatalf("%v", job)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
func TestBackgroundWorkerAliveExpires(t *testing.T) {
|
|
291
|
+
if workerAlive(background.WorkerInfo{At: time.Now().Add(-time.Minute)}, time.Now()) || !workerAlive(background.WorkerInfo{At: time.Now()}, time.Now()) {
|
|
292
|
+
t.Fatal("a stale heartbeat is not alive")
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
func TestBackgroundBrowseListsThroughTheCallersSession(t *testing.T) {
|
|
297
|
+
e := newBgEnv(t)
|
|
298
|
+
e.files.page = filestation.Page{Files: []filestation.Entry{{Name: "a.txt", Path: "/share/a.txt"}}, Total: 1}
|
|
299
|
+
code, out := e.call(alice, "bg.browse", `{"folder":"/share","offset":100}`)
|
|
300
|
+
if code != "" {
|
|
301
|
+
t.Fatalf("%s %v", code, out)
|
|
302
|
+
}
|
|
303
|
+
if e.files.folder != "/share" || e.files.offset != 100 {
|
|
304
|
+
t.Fatalf("browsed %q at %d", e.files.folder, e.files.offset)
|
|
305
|
+
}
|
|
306
|
+
files := data(out)["files"].([]any)
|
|
307
|
+
if len(files) != 1 || files[0].(map[string]any)["path"] != "/share/a.txt" {
|
|
308
|
+
t.Fatalf("page %v", out)
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
func TestBackgroundBrowseWithoutFolderListsTheShares(t *testing.T) {
|
|
313
|
+
e := newBgEnv(t)
|
|
314
|
+
if code, out := e.call(alice, "bg.browse", `{}`); code != "" {
|
|
315
|
+
t.Fatalf("%s %v", code, out)
|
|
316
|
+
}
|
|
317
|
+
if e.files.folder != "" || e.files.offset != 0 {
|
|
318
|
+
t.Fatalf("browsed %q at %d", e.files.folder, e.files.offset)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
func TestBackgroundBrowseValidatesParamsAndPassesRefusalsThrough(t *testing.T) {
|
|
323
|
+
e := newBgEnv(t)
|
|
324
|
+
for _, params := range []string{`{"offset":-1}`, `{"folder":"/share","extra":1}`, `{"offset":"1"}`} {
|
|
325
|
+
if code, _ := e.call(alice, "bg.browse", params); code != "bad_request" {
|
|
326
|
+
t.Errorf("%s: %q", params, code)
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if e.files.calls != 0 {
|
|
330
|
+
t.Fatal("invalid params must not reach the NAS")
|
|
331
|
+
}
|
|
332
|
+
e.files.err = &api.Error{Code: "denied", Message: "no"}
|
|
333
|
+
if code, _ := e.call(alice, "bg.browse", `{"folder":"/share"}`); code != "denied" {
|
|
334
|
+
t.Fatalf("got %q", code)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
func TestBackgroundListWithoutJobsIsAnEmptyArray(t *testing.T) {
|
|
339
|
+
e := newBgEnv(t)
|
|
340
|
+
e.enable()
|
|
341
|
+
_, out := e.call(alice, "bg.jobs.list", `{}`)
|
|
342
|
+
jobs, ok := data(out)["jobs"].([]any)
|
|
343
|
+
if !ok || len(jobs) != 0 {
|
|
344
|
+
t.Fatalf("jobs must be [] not null: %v", out)
|
|
345
|
+
}
|
|
346
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package app
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
|
|
6
|
+
"dsmapp/internal/helper"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// integrationState is the helper's trusted health, or, for an integration
|
|
10
|
+
// built without a helper, a fixed package-only state: there is nothing to approve.
|
|
11
|
+
func (cfg Config) integrationState(ctx context.Context) helper.State {
|
|
12
|
+
if cfg.PackageIntegration {
|
|
13
|
+
return helper.State{State: "ready", Reason: "package-only", PackageRunning: "running", Scheduler: "not-required"}
|
|
14
|
+
}
|
|
15
|
+
return helper.NewClient(cfg.HelperInventory).Status(ctx)
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package app
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"os"
|
|
5
|
+
|
|
6
|
+
"dsmapp/internal/datamigrate"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// Migrations returns this app's schema migrations. The template ships one
|
|
10
|
+
// empty example; replace it with your own steps. Versions start at 1 and never
|
|
11
|
+
// change meaning. Every step must be idempotent: a crash between Apply and the
|
|
12
|
+
// recorded version, or two CGI requests racing on the first run after an
|
|
13
|
+
// upgrade, can run one step twice. A failed step stops the run with the
|
|
14
|
+
// previous version still recorded, and the next run resumes from there; the
|
|
15
|
+
// utility itself never deletes or rewrites data.
|
|
16
|
+
func Migrations() []datamigrate.Migration {
|
|
17
|
+
return []datamigrate.Migration{
|
|
18
|
+
{
|
|
19
|
+
Version: 1,
|
|
20
|
+
Name: "example",
|
|
21
|
+
Apply: func(datamigrate.Context) error {
|
|
22
|
+
// Nothing to do yet. Read ctx.DataDir, rewrite files with a
|
|
23
|
+
// temporary file + rename, and keep the step idempotent.
|
|
24
|
+
return nil
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Migrate applies Migrations to the package's persistent var directory. The
|
|
31
|
+
// CGI calls it once per request; the recorded data-version makes that a cheap
|
|
32
|
+
// no-op. SYNOPKG_OLD_PKGVER is set when DSM starts the app from a lifecycle
|
|
33
|
+
// script; in a plain CGI request the version of the last successful run is
|
|
34
|
+
// used instead.
|
|
35
|
+
func Migrate(cfg Config) error {
|
|
36
|
+
_, err := datamigrate.Run(cfg.DataDir, datamigrate.Info{
|
|
37
|
+
OldPkgVer: os.Getenv("SYNOPKG_OLD_PKGVER"),
|
|
38
|
+
NewPkgVer: cfg.Version,
|
|
39
|
+
}, Migrations())
|
|
40
|
+
return err
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package app
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"testing"
|
|
5
|
+
|
|
6
|
+
"dsmapp/internal/datamigrate"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
func TestMigrationsAreOrderedUniqueAndValid(t *testing.T) {
|
|
10
|
+
migrations := Migrations()
|
|
11
|
+
if len(migrations) == 0 {
|
|
12
|
+
t.Fatal("the template must ship one example migration")
|
|
13
|
+
}
|
|
14
|
+
for i, migration := range migrations {
|
|
15
|
+
if migration.Version < 1 || migration.Apply == nil || migration.Name == "" {
|
|
16
|
+
t.Fatalf("migration %d is invalid: %+v", i, migration)
|
|
17
|
+
}
|
|
18
|
+
if i > 0 && migrations[i-1].Version >= migration.Version {
|
|
19
|
+
t.Fatalf("migrations are not strictly version-ascending: %+v", migrations)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
func TestMigrateRecordsTheSchemaAndPackageVersion(t *testing.T) {
|
|
25
|
+
dir := t.TempDir()
|
|
26
|
+
t.Setenv("SYNOPKG_OLD_PKGVER", "0.1.0-0001")
|
|
27
|
+
cfg := Config{DataDir: dir, Version: "0.2.0-0002"}
|
|
28
|
+
if err := Migrate(cfg); err != nil {
|
|
29
|
+
t.Fatalf("Migrate: %v", err)
|
|
30
|
+
}
|
|
31
|
+
state, err := datamigrate.Load(dir)
|
|
32
|
+
if err != nil {
|
|
33
|
+
t.Fatalf("Load: %v", err)
|
|
34
|
+
}
|
|
35
|
+
if state.Schema != 1 || state.PackageVersion != "0.2.0-0002" {
|
|
36
|
+
t.Fatalf("recorded state = %+v", state)
|
|
37
|
+
}
|
|
38
|
+
if err := Migrate(cfg); err != nil {
|
|
39
|
+
t.Fatalf("second Migrate must be a no-op: %v", err)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -103,6 +103,14 @@ func TestS8FinalCGIArtifactRefusal(t *testing.T) {
|
|
|
103
103
|
t.Fatal(err, string(b))
|
|
104
104
|
}
|
|
105
105
|
want := "unknown_method"
|
|
106
|
+
// Protocol 2 now installs the interactive File Station adapter. This
|
|
107
|
+
// historical fixture has only a fixture cookie, never a real DSM id cookie.
|
|
108
|
+
switch method {
|
|
109
|
+
case "nas.discovery", "nas.grants.confirm", "nas.grants.list", "nas.files.stat", "nas.files.list", "nas.files.read", "nas.files.create":
|
|
110
|
+
want = "session_required"
|
|
111
|
+
case "nas.files.publish":
|
|
112
|
+
want = "unsupported"
|
|
113
|
+
}
|
|
106
114
|
if method == "nas.files.read.binary" {
|
|
107
115
|
want = "unsupported"
|
|
108
116
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
//go:build !synopkgland_sdk_workers
|
|
2
|
+
|
|
1
3
|
// Package app holds this package's business operations. Add a route here and
|
|
2
4
|
// pick its policy: api.User (any signed-in DSM user), api.Admin (DSM
|
|
3
5
|
// administrators only) or, rarely, api.Public (no sign-in at all).
|
|
6
|
+
//
|
|
7
|
+
//line dsmapp/internal/app/routes.go:1
|
|
4
8
|
package app
|
|
5
9
|
|
|
6
10
|
import (
|
|
@@ -17,29 +21,42 @@ import (
|
|
|
17
21
|
"unicode/utf8"
|
|
18
22
|
|
|
19
23
|
"dsmapp/internal/api"
|
|
24
|
+
"dsmapp/internal/filestation"
|
|
20
25
|
"dsmapp/internal/helper"
|
|
21
26
|
)
|
|
22
27
|
|
|
23
28
|
// Config is fixed at build time and startup, never taken from a request.
|
|
24
29
|
type Config struct {
|
|
30
|
+
RootAuthorization string
|
|
31
|
+
|
|
32
|
+
// SessionFiles is the interactive File Station adapter; nil keeps legacy refusal.
|
|
33
|
+
SessionFiles *filestation.Service
|
|
25
34
|
PackageID string
|
|
26
35
|
Version string
|
|
27
36
|
HelperInventory helper.Inventory
|
|
37
|
+
// PackageIntegration marks an integration built without a privileged
|
|
38
|
+
// helper: its features run as the package account and are ready by themselves.
|
|
39
|
+
PackageIntegration bool
|
|
28
40
|
// Staged trusted adapter. Nil refuses; no production data transport is installed.
|
|
29
41
|
NASBinaryRead api.BinaryReadHandler
|
|
30
42
|
// DataDir is the package's persistent, package-owned directory
|
|
31
43
|
// (/var/packages/<package>/var). It survives upgrades.
|
|
32
44
|
DataDir string
|
|
45
|
+
// VolumeRoot is where /volumeN lives; empty means "/". Tests set it.
|
|
46
|
+
VolumeRoot string
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
func Routes(cfg Config) []api.Route {
|
|
36
|
-
routes :=
|
|
50
|
+
routes := cfg.authorizationRoutes()
|
|
51
|
+
routes = append(routes, []api.Route{
|
|
37
52
|
api.User("integration.status", cfg.integrationStatus),
|
|
38
53
|
api.BoundedRead(cfg.binaryRead),
|
|
39
54
|
api.User("app.status", cfg.status),
|
|
40
55
|
api.User("greeting.get", cfg.getGreeting),
|
|
41
56
|
api.Admin("greeting.set", cfg.setGreeting),
|
|
42
|
-
}
|
|
57
|
+
}...)
|
|
58
|
+
routes = append(routes, cfg.SessionFiles.Routes()...)
|
|
59
|
+
routes = append(routes, cfg.backgroundRoutes()...)
|
|
43
60
|
return append(routes, cfg.rootRoutes()...)
|
|
44
61
|
}
|
|
45
62
|
|
|
@@ -47,11 +64,11 @@ func (cfg Config) integrationStatus(ctx context.Context, _ api.Caller, params js
|
|
|
47
64
|
if err := decodeParams(params, &struct{}{}); err != nil {
|
|
48
65
|
return nil, err
|
|
49
66
|
}
|
|
50
|
-
return
|
|
67
|
+
return cfg.integrationState(ctx), nil
|
|
51
68
|
}
|
|
52
69
|
|
|
53
70
|
func (cfg Config) status(_ context.Context, caller api.Caller, _ json.RawMessage) (any, error) {
|
|
54
|
-
return map[string]any{
|
|
71
|
+
return cfg.withSharedFolders(map[string]any{
|
|
55
72
|
"package": cfg.PackageID,
|
|
56
73
|
"version": cfg.Version,
|
|
57
74
|
"user": caller.User(),
|
|
@@ -60,7 +77,7 @@ func (cfg Config) status(_ context.Context, caller api.Caller, _ json.RawMessage
|
|
|
60
77
|
"go_version": runtime.Version(),
|
|
61
78
|
"platform": runtime.GOOS + "/" + runtime.GOARCH,
|
|
62
79
|
"time": time.Now().UTC().Format(time.RFC3339),
|
|
63
|
-
}, nil
|
|
80
|
+
}), nil
|
|
64
81
|
}
|
|
65
82
|
|
|
66
83
|
type greeting struct {
|
|
@@ -64,6 +64,10 @@ var sampleParams = map[string]string{
|
|
|
64
64
|
"greeting.set": `{"text":"Hi"}`,
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
// sampleOutcome is the error code an administrator gets from a route's sample
|
|
68
|
+
// params; routes that are not listed (and not jobs.*) succeed.
|
|
69
|
+
var sampleOutcome = map[string]string{"nas.files.read.binary": "unsupported"}
|
|
70
|
+
|
|
67
71
|
func TestIntegrationStatusIsReadableByOrdinaryUsers(t *testing.T) {
|
|
68
72
|
code, out := call(t, testConfig(t), bob, "integration.status", `{}`)
|
|
69
73
|
if code != "" || out["data"].(map[string]any)["state"] != "not-enabled" {
|
|
@@ -75,6 +79,19 @@ func TestIntegrationStatusIsReadableByOrdinaryUsers(t *testing.T) {
|
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
|
|
82
|
+
func TestPackageOnlyIntegrationIsReadyWithoutAHelper(t *testing.T) {
|
|
83
|
+
cfg := testConfig(t)
|
|
84
|
+
cfg.PackageIntegration = true
|
|
85
|
+
code, out := call(t, cfg, bob, "integration.status", `{}`)
|
|
86
|
+
data, _ := out["data"].(map[string]any)
|
|
87
|
+
if code != "" || data["state"] != "ready" || data["reason"] != "package-only" || data["scheduler"] != "not-required" || data["packageRunning"] != "running" {
|
|
88
|
+
t.Fatalf("%s: %v", code, out)
|
|
89
|
+
}
|
|
90
|
+
if _, cleanup := data["cleanup"]; cleanup {
|
|
91
|
+
t.Fatal("no helper means no cleanup state")
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
78
95
|
func TestEveryRouteHasSampleParamsAndNoneIsPublic(t *testing.T) {
|
|
79
96
|
routes := Routes(testConfig(t))
|
|
80
97
|
if len(routes) != len(sampleParams) {
|
|
@@ -118,9 +135,9 @@ func TestEveryAdminRouteRefusesOrdinaryUsersAndChangesNothing(t *testing.T) {
|
|
|
118
135
|
func TestEveryRouteSucceedsForAnAdmin(t *testing.T) {
|
|
119
136
|
for _, r := range Routes(testConfig(t)) {
|
|
120
137
|
code, out := call(t, testConfig(t), alice, r.Method(), sampleParams[r.Method()])
|
|
121
|
-
want :=
|
|
122
|
-
if r.Method()
|
|
123
|
-
want = "
|
|
138
|
+
want := sampleOutcome[r.Method()]
|
|
139
|
+
if strings.HasPrefix(r.Method(), "jobs.") {
|
|
140
|
+
want = "unavailable"
|
|
124
141
|
}
|
|
125
142
|
if code != want {
|
|
126
143
|
t.Errorf("%s: %q %v", r.Method(), code, out)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//go:build synopkgland_sdk_workers
|
|
2
|
+
|
|
3
|
+
package app
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"bytes"
|
|
7
|
+
"context"
|
|
8
|
+
"dsmapp/internal/api"
|
|
9
|
+
"dsmapp/internal/helper"
|
|
10
|
+
"encoding/json"
|
|
11
|
+
"io"
|
|
12
|
+
"net"
|
|
13
|
+
"net/http"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
type sdkCarrierKey struct{}
|
|
17
|
+
|
|
18
|
+
// Only session carriers from the HTTP request are forwarded. The authenticated
|
|
19
|
+
// Caller and root NativeActor remain independent trust decisions.
|
|
20
|
+
func SDKHandler(next http.Handler) http.Handler {
|
|
21
|
+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
22
|
+
raw, err := io.ReadAll(http.MaxBytesReader(w, r.Body, api.MaxRequestBytes))
|
|
23
|
+
if err != nil || helper.ValidateSDKEnvelope(raw) != "" {
|
|
24
|
+
w.Header().Set("Content-Type", "application/json")
|
|
25
|
+
w.Header().Set("Cache-Control", "no-store")
|
|
26
|
+
io.WriteString(w, `{"success":false,"error":{"code":"invalid-request","message":"Invalid request"}}`)
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
r.Body = io.NopCloser(bytes.NewReader(raw))
|
|
30
|
+
address, _, err := net.SplitHostPort(r.RemoteAddr)
|
|
31
|
+
if err != nil {
|
|
32
|
+
address = r.RemoteAddr
|
|
33
|
+
}
|
|
34
|
+
c := helper.SessionCarriers{Cookie: r.Header.Get("Cookie"), SynoToken: r.Header.Get("X-SYNO-TOKEN"), ClientAddress: address}
|
|
35
|
+
next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), sdkCarrierKey{}, c)))
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
func (cfg Config) sdkJobRoutes() []api.Route {
|
|
39
|
+
routes := []api.Route{}
|
|
40
|
+
for _, method := range []string{"jobs.prepare", "jobs.submit", "jobs.status", "jobs.lookup", "jobs.result", "jobs.cancel", "jobs.revoke", "jobs.attach", "jobs.admin.status", "jobs.admin.cancel"} {
|
|
41
|
+
name := method
|
|
42
|
+
handler := func(ctx context.Context, caller api.Caller, args json.RawMessage) (any, error) {
|
|
43
|
+
if !caller.Authenticated() {
|
|
44
|
+
return nil, &api.Error{Code: "session_required", Message: "Sign in again"}
|
|
45
|
+
}
|
|
46
|
+
if code := helper.ValidateSDKArgs(name, args); code != "" {
|
|
47
|
+
return nil, &api.Error{Code: string(code), Message: "Job request refused"}
|
|
48
|
+
}
|
|
49
|
+
c, ok := ctx.Value(sdkCarrierKey{}).(helper.SessionCarriers)
|
|
50
|
+
if !ok {
|
|
51
|
+
return nil, &api.Error{Code: "unavailable", Message: "Native proof unavailable"}
|
|
52
|
+
}
|
|
53
|
+
invoke := cfg.SDKJobs
|
|
54
|
+
if invoke == nil {
|
|
55
|
+
invoke = helper.NewClient(cfg.HelperInventory).SDKJobs
|
|
56
|
+
}
|
|
57
|
+
data, code := invoke(ctx, name, c, args)
|
|
58
|
+
if code != "" {
|
|
59
|
+
return nil, &api.Error{Code: string(code), Message: "Job request refused"}
|
|
60
|
+
}
|
|
61
|
+
return data, nil
|
|
62
|
+
}
|
|
63
|
+
if name == "jobs.admin.status" || name == "jobs.admin.cancel" {
|
|
64
|
+
routes = append(routes, api.Admin(name, handler))
|
|
65
|
+
} else {
|
|
66
|
+
routes = append(routes, api.User(name, handler))
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return routes
|
|
70
|
+
}
|