Skip to content

A free open source IT asset/license management system

Move PushableAdapter into PushableSyncAdapter, and move push-reloated methods over

Brady Wetherington44a6b4742707
diff --git a/app/Console/Commands/PushInventory.php b/app/Console/Commands/PushInventory.php
index 128038b843..db4b3f4a43 100644
--- a/app/Console/Commands/PushInventory.php
+++ b/app/Console/Commands/PushInventory.php
@@ -4,7 +4,7 @@ namespace App\Console\Commands;
use App\Models\AssetExternalSource;
use App\Models\SyncAdapterInstance;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\Traits\LocksLongRunningOperation;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
@@ -56,7 +56,7 @@ class PushInventory extends Command
foreach ($instances as $instance) {
$adapter = $instance->adapter();
- if (! $adapter instanceof PushableAdapter) {
+ if (!$adapter instanceof PushableSyncAdapter) {
continue;
}
if (! $adapter->isEnabled() || ! $adapter->canPush()) {
@@ -94,7 +94,7 @@ class PushInventory extends Command
$startedAt = microtime(true);
$adapter = $instance->adapter();
- if (! $adapter instanceof PushableAdapter) {
+ if (!$adapter instanceof PushableSyncAdapter) {
$this->error("Adapter \"{$slug}\" does not support push.");
$rows[] = [$slug, 'Not pushable', '-', '-', self::formatElapsed($startedAt)];
diff --git a/app/Http/Controllers/SyncAdapterController.php b/app/Http/Controllers/SyncAdapterController.php
index 4deb78e44f..83e144f31b 100644
--- a/app/Http/Controllers/SyncAdapterController.php
+++ b/app/Http/Controllers/SyncAdapterController.php
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Models\Actionlog;
use App\SyncAdapters\SyncErrorFormatter;
use App\Traits\LocksLongRunningOperation;
+use App\SyncAdapters\PushableSyncAdapter;
use Illuminate\Contracts\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
@@ -393,7 +394,7 @@ class SyncAdapterController extends Controller
/**
* Push Snipe-IT-authoritative fields to the vendor for every asset
* already linked to this adapter instance. Only meaningful for
- * adapters that implement PushableAdapter. Iterates the instance's
+ * adapters that implement PushableSyncAdapter. Iterates the instance's
* asset_external_sources rows so we only touch assets the vendor
* actually knows about. A fresh Snipe-IT asset that's never been
* synced from this instance gets no push (we'd have no vendor id
@@ -410,7 +411,7 @@ class SyncAdapterController extends Controller
// Hidden mirror from the panel's push-dry-run checkbox so the
// admin's live intent is honored for this one click without
// needing to Save the config form first.
- if ($request->has('dry_run_override')) {
+ if ($request->has('dry_run_override') && $adapter instanceof PushableSyncAdapter) {
$adapter->withPushDryRunOverride($request->boolean('dry_run_override'));
}
@@ -420,7 +421,7 @@ class SyncAdapterController extends Controller
// nothing. The flash message alone is one-shot and vanishes on
// reload or on the next action - admins need something they
// can go back and read.
- if (! $adapter instanceof \App\SyncAdapters\PushableAdapter) {
+ if (!$adapter instanceof \App\SyncAdapters\PushableSyncAdapter) {
$message = trans('admin/settings/sync_adapters.push_not_supported');
$this->captureSyncRunLog($instance->slug, 'push', function () use ($instance, $message) {
Log::channel('sync-adapters')->warning($instance->slug.' push aborted before run: push_not_supported - '.$message);
@@ -771,7 +772,7 @@ class SyncAdapterController extends Controller
public function postPreviewPushPayload(\App\Models\SyncAdapterInstance $instance): JsonResponse
{
$adapter = $instance->adapter();
- if (! $adapter instanceof \App\SyncAdapters\PushableAdapter) {
+ if (!$adapter instanceof \App\SyncAdapters\PushableSyncAdapter) {
return response()->json(['error' => trans('admin/settings/sync_adapters.push_not_supported')], 400);
}
if (! $adapter->isEnabled()) {
@@ -797,7 +798,7 @@ class SyncAdapterController extends Controller
];
// Keep the method_exists check: peekPushPayload lives on
- // CustomHttpAdapter today, not on the PushableAdapter
+ // CustomHttpAdapter today, not on the PushableSyncAdapter
// interface. Other adapters fall back to the dry-run log
// capture below.
if (method_exists($adapter, 'peekPushPayload')) {
@@ -834,7 +835,7 @@ class SyncAdapterController extends Controller
public function postTest1Push(\App\Models\SyncAdapterInstance $instance): JsonResponse
{
$adapter = $instance->adapter();
- if (! $adapter instanceof \App\SyncAdapters\PushableAdapter) {
+ if (!$adapter instanceof \App\SyncAdapters\PushableSyncAdapter) {
return response()->json(['error' => trans('admin/settings/sync_adapters.push_not_supported')], 400);
}
if (! $adapter->isEnabled()) {
diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index 330c83510e..469d6260f5 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -46,6 +46,7 @@ use Watson\Validating\ValidatingTrait;
* @property \Carbon\Carbon|string|null $last_checkin
* @property bool $requestable
* @property Asset|Location|User|null $assigned Current checkout target. morphTo relation named `assigned` (declared on method `assignedTo()`). Eloquent resolves the dynamic property by the morphTo name arg, not the method name, so this `@property` is distinct from `@property ... $assignedTo` written by ide-helper.
+ * @property Asset|Location|User|null $assignedTo Current checkout target. morphTo relation named `assigned` (declared on method `assignedTo()`). Eloquent resolves the dynamic property by the morphTo name arg, not the method name, so this `@property` is distinct from `@property ... $assigned` written by ide-helper.
*
* @mixin IdeHelperAsset
*/
@@ -960,9 +961,8 @@ class Asset extends Depreciable implements Importable
*
* @since [v4.0]
*
- * @return \ArrayObject
*/
- public function assetLoc($iterations = 1, $first_asset = null)
+ public function assetLoc($iterations = 1, $first_asset = null): ?Location
{
if (! empty($this->assignedType())) {
if ($this->assignedType() == self::ASSET) {
diff --git a/app/SyncAdapters/CustomHttp/CustomHttpAdapter.php b/app/SyncAdapters/CustomHttp/CustomHttpAdapter.php
index 147cfae6c9..bed08005fc 100644
--- a/app/SyncAdapters/CustomHttp/CustomHttpAdapter.php
+++ b/app/SyncAdapters/CustomHttp/CustomHttpAdapter.php
@@ -5,7 +5,7 @@ namespace App\SyncAdapters\CustomHttp;
use App\Models\Asset;
use App\Models\SyncAdapterConfig;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -20,7 +20,7 @@ use Illuminate\Support\Facades\Log;
* generic pull() walks the response, extracts values by dot-path,
* and yields normalized records the framework can save.
*/
-class CustomHttpAdapter extends SyncAdapter implements PushableAdapter
+class CustomHttpAdapter extends PushableSyncAdapter
{
/**
* Cap on pagination loop iterations, to keep a misconfigured
diff --git a/app/SyncAdapters/GoogleWorkspace/GoogleWorkspaceAdapter.php b/app/SyncAdapters/GoogleWorkspace/GoogleWorkspaceAdapter.php
index ce35a26f3a..2541bbafce 100644
--- a/app/SyncAdapters/GoogleWorkspace/GoogleWorkspaceAdapter.php
+++ b/app/SyncAdapters/GoogleWorkspace/GoogleWorkspaceAdapter.php
@@ -4,7 +4,7 @@ namespace App\SyncAdapters\GoogleWorkspace;
use App\Models\Asset;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -36,7 +36,7 @@ use Illuminate\Support\Facades\Log;
* endpoint (admin.googleapis.com), and token exchange lives at
* oauth2.googleapis.com. Neither has regional variants.
*/
-class GoogleWorkspaceAdapter extends SyncAdapter implements PushableAdapter
+class GoogleWorkspaceAdapter extends PushableSyncAdapter
{
public static function typeLabel(): string
{
diff --git a/app/SyncAdapters/Intune/IntuneAdapter.php b/app/SyncAdapters/Intune/IntuneAdapter.php
index 0aa66d2e1f..0eb5855f0d 100644
--- a/app/SyncAdapters/Intune/IntuneAdapter.php
+++ b/app/SyncAdapters/Intune/IntuneAdapter.php
@@ -4,7 +4,7 @@ namespace App\SyncAdapters\Intune;
use App\Models\Asset;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -28,7 +28,7 @@ use Illuminate\Support\Facades\Log;
* so admins can audit which Azure app registration a Snipe-IT instance
* is talking to without a decrypt step. Only client_secret is encrypted.
*/
-class IntuneAdapter extends SyncAdapter implements PushableAdapter
+class IntuneAdapter extends PushableSyncAdapter
{
public static function typeLabel(): string
{
diff --git a/app/SyncAdapters/Jamf/JamfAdapter.php b/app/SyncAdapters/Jamf/JamfAdapter.php
index 7c700ab604..39c92865c3 100644
--- a/app/SyncAdapters/Jamf/JamfAdapter.php
+++ b/app/SyncAdapters/Jamf/JamfAdapter.php
@@ -4,7 +4,7 @@ namespace App\SyncAdapters\Jamf;
use App\Models\Asset;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -19,7 +19,7 @@ use Illuminate\Support\Arr;
* /api/v1/computers-inventory-detail/{id} PATCH endpoint using the
* same exchanged bearer.
*/
-class JamfAdapter extends SyncAdapter implements PushableAdapter
+class JamfAdapter extends PushableSyncAdapter
{
public static function typeLabel(): string
{
diff --git a/app/SyncAdapters/Kandji/KandjiAdapter.php b/app/SyncAdapters/Kandji/KandjiAdapter.php
index 11bb24c84f..58f14444b4 100644
--- a/app/SyncAdapters/Kandji/KandjiAdapter.php
+++ b/app/SyncAdapters/Kandji/KandjiAdapter.php
@@ -4,7 +4,7 @@ namespace App\SyncAdapters\Kandji;
use App\Models\Asset;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -16,7 +16,7 @@ use Illuminate\Support\Facades\Log;
* objects. Also pushes Snipe-IT-authoritative fields back to Kandji
* (asset_tag today) when the admin marks the mapping row as 'push'.
*/
-class KandjiAdapter extends SyncAdapter implements PushableAdapter
+class KandjiAdapter extends PushableSyncAdapter
{
public static function typeLabel(): string
{
diff --git a/app/SyncAdapters/Mosyle/MosyleAdapter.php b/app/SyncAdapters/Mosyle/MosyleAdapter.php
index 99d46cd1ee..6cf3ac212d 100644
--- a/app/SyncAdapters/Mosyle/MosyleAdapter.php
+++ b/app/SyncAdapters/Mosyle/MosyleAdapter.php
@@ -4,7 +4,7 @@ namespace App\SyncAdapters\Mosyle;
use App\Models\Asset;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -22,7 +22,7 @@ use Illuminate\Support\Facades\Log;
* expect Manager-shaped payloads, so Business tenants will see the
* login succeed and device calls fail. See issue #19790.
*/
-class MosyleAdapter extends SyncAdapter implements PushableAdapter
+class MosyleAdapter extends PushableSyncAdapter
{
/**
* Per-category-selector config keys -> friendly display name. Same
diff --git a/app/SyncAdapters/MosyleBusiness/MosyleBusinessAdapter.php b/app/SyncAdapters/MosyleBusiness/MosyleBusinessAdapter.php
index eef3689ca6..c9814f2bb1 100644
--- a/app/SyncAdapters/MosyleBusiness/MosyleBusinessAdapter.php
+++ b/app/SyncAdapters/MosyleBusiness/MosyleBusinessAdapter.php
@@ -4,7 +4,7 @@ namespace App\SyncAdapters\MosyleBusiness;
use App\Models\Asset;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -27,7 +27,7 @@ use Illuminate\Support\Facades\Log;
* field. This adapter wires that up through the composed-notes
* framework.
*/
-class MosyleBusinessAdapter extends SyncAdapter implements PushableAdapter
+class MosyleBusinessAdapter extends PushableSyncAdapter
{
public static function typeLabel(): string
{
diff --git a/app/SyncAdapters/NinjaOne/NinjaOneAdapter.php b/app/SyncAdapters/NinjaOne/NinjaOneAdapter.php
index 38b58ce38d..baa5aad37b 100644
--- a/app/SyncAdapters/NinjaOne/NinjaOneAdapter.php
+++ b/app/SyncAdapters/NinjaOne/NinjaOneAdapter.php
@@ -4,7 +4,7 @@ namespace App\SyncAdapters\NinjaOne;
use App\Models\Asset;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -31,7 +31,7 @@ use Illuminate\Support\Facades\Log;
* the admin puts in the "Asset Tag Custom Field Name" schema slot. If
* empty, push silently no-ops (nothing to write to).
*/
-class NinjaOneAdapter extends SyncAdapter implements PushableAdapter
+class NinjaOneAdapter extends PushableSyncAdapter
{
public static function typeLabel(): string
{
diff --git a/app/SyncAdapters/PushableAdapter.php b/app/SyncAdapters/PushableAdapter.php
deleted file mode 100644
index e1a589d1c0..0000000000
--- a/app/SyncAdapters/PushableAdapter.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-
-namespace App\SyncAdapters;
-
-use App\Models\Asset;
-
-/**
- * Marker + contract for adapters that support pushing Snipe-IT-owned
- * field values back to the vendor (Snipe-IT asset_tag -> vendor
- * asset_tag, Snipe-IT notes -> vendor notes, etc.). Kept separate
- * from SyncAdapter so pull-only vendors (osctrl, Zentral,
- * UniFi) don't have to stub anything.
- *
- * Adapters that implement this ALSO implement SyncAdapter
- * in practice — the two directions share credentials, base URL, and
- * asset identity (asset_external_sources.external_id). The interfaces
- * stay separate so an adapter can be pull-only, push-only, or both.
- */
-interface PushableAdapter
-{
- /**
- * Runtime check: is push actually available for this instance
- * right now? Adapters return false when a vendor-side gate is
- * in effect (Fleet manual labels are Premium-only, Jamf writes
- * need extra role scopes, etc.) so the settings-page UI hides
- * the push controls instead of letting admins configure a path
- * that will 403 at execution time.
- *
- * Default implementations may return true unconditionally. The
- * check is opt-in per adapter.
- */
- public function canPush(): bool;
-
- /**
- * Name (or dotted path) of the vendor's single freeform notes
- * field that admins can compose from a template. Return null
- * when the vendor has no such field (or when routing composed
- * notes would be a semantic stretch, e.g. hostname).
- *
- * Push implementations call SyncAdapter::composeNotesForPush()
- * and set the returned ['value'] on the returned ['target']
- * position in the outgoing payload.
- */
- public function notesFieldTarget(): ?string;
-
- /**
- * Push the currently-configured `push`-direction fields for one
- * asset to the vendor. Implementations are responsible for:
- * - Resolving the vendor-side external_id from the asset's
- * asset_external_sources row scoped to this adapter's instance
- * - Filtering the field set to those directed 'push' via
- * SyncAdapter::directionFor()
- * - Serializing each field into the vendor's expected shape
- * - Sending the write call
- *
- * Silent no-op is acceptable when the asset has no external_source
- * row for this instance (never synced from here, so we have no
- * vendor-side id to write against).
- *
- * Return true when the adapter actually reached out to the vendor
- * (or logged a dry-run payload). Return false when the call was
- * skipped for any reason (nothing to push for this asset, no
- * external-source row, empty payload, etc.). The controller's
- * batch runner uses the return value to distinguish "successfully
- * pushed" from "skipped" so the flash message reflects reality
- * instead of counting every silent no-op as a success.
- *
- * @param array<int, string> $changedFields
- * Optional list of source-field names (hostname, asset_tag,
- * etc.) that changed and prompted this push. Implementations
- * may use this to skip an API call when no push-direction field
- * is in the changed set. When empty, treat as "push everything
- * marked push-direction".
- */
- public function push(Asset $asset, array $changedFields = []): bool;
-}
diff --git a/app/SyncAdapters/PushableSyncAdapter.php b/app/SyncAdapters/PushableSyncAdapter.php
new file mode 100644
index 0000000000..afecffeb02
--- /dev/null
+++ b/app/SyncAdapters/PushableSyncAdapter.php
@@ -0,0 +1,755 @@
+<?php
+
+namespace App\SyncAdapters;
+
+use App\Models\Asset;
+use App\Models\CustomField;
+use App\Models\SyncAdapterConfig;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * Marker + contract for adapters that support pushing Snipe-IT-owned
+ * field values back to the vendor (Snipe-IT asset_tag -> vendor
+ * asset_tag, Snipe-IT notes -> vendor notes, etc.). Kept separate
+ * from SyncAdapter so pull-only vendors (osctrl, Zentral,
+ * UniFi) don't have to stub anything.
+ *
+ * Adapters that implement this ALSO implement SyncAdapter
+ * in practice — the two directions share credentials, base URL, and
+ * asset identity (asset_external_sources.external_id). The interfaces
+ * stay separate so an adapter can be pull-only, push-only, or both.
+ */
+abstract class PushableSyncAdapter extends SyncAdapter
+{
+ /**
+ * Runtime check: is push actually available for this instance
+ * right now? Adapters return false when a vendor-side gate is
+ * in effect (Fleet manual labels are Premium-only, Jamf writes
+ * need extra role scopes, etc.) so the settings-page UI hides
+ * the push controls instead of letting admins configure a path
+ * that will 403 at execution time.
+ *
+ * Default implementations may return true unconditionally. The
+ * check is opt-in per adapter.
+ */
+ abstract public function canPush(): bool;
+
+ /**
+ * Name (or dotted path) of the vendor's single freeform notes
+ * field that admins can compose from a template. Return null
+ * when the vendor has no such field (or when routing composed
+ * notes would be a semantic stretch, e.g. hostname).
+ *
+ * Push implementations call SyncAdapter::composeNotesForPush()
+ * and set the returned ['value'] on the returned ['target']
+ * position in the outgoing payload.
+ */
+ abstract public function notesFieldTarget(): ?string;
+
+ /**
+ * Push the currently-configured `push`-direction fields for one
+ * asset to the vendor. Implementations are responsible for:
+ * - Resolving the vendor-side external_id from the asset's
+ * asset_external_sources row scoped to this adapter's instance
+ * - Filtering the field set to those directed 'push' via
+ * SyncAdapter::directionFor()
+ * - Serializing each field into the vendor's expected shape
+ * - Sending the write call
+ *
+ * Silent no-op is acceptable when the asset has no external_source
+ * row for this instance (never synced from here, so we have no
+ * vendor-side id to write against).
+ *
+ * Return true when the adapter actually reached out to the vendor
+ * (or logged a dry-run payload). Return false when the call was
+ * skipped for any reason (nothing to push for this asset, no
+ * external-source row, empty payload, etc.). The controller's
+ * batch runner uses the return value to distinguish "successfully
+ * pushed" from "skipped" so the flash message reflects reality
+ * instead of counting every silent no-op as a success.
+ *
+ * @param array<int, string> $changedFields
+ * Optional list of source-field names (hostname, asset_tag,
+ * etc.) that changed and prompted this push. Implementations
+ * may use this to skip an API call when no push-direction field
+ * is in the changed set. When empty, treat as "push everything
+ * marked push-direction".
+ */
+ abstract public function push(Asset $asset, array $changedFields = []): bool;
+
+ // default implementations for 'push', can be overridden
+
+
+ public function pushableFields(): array
+ {
+ return MappingTargets::FIELDS;
+ }
+
+ protected function persistOperationalSettings(Request $request, string $slug): void
+ {
+ parent::persistOperationalSettings($request, $slug);
+ // Push dry-run flag. When on, adapters log the push payload
+ // instead of sending it, so admins can verify mapping +
+ // direction config against real assets without any vendor
+ // side effect.
+ SyncAdapterConfig::put(
+ $this->instance->id,
+ 'push_dry_run',
+ $request->boolean($slug . '_push_dry_run') ? '1' : '0',
+ );
+
+ // Push notes template. Blade-ish {placeholder} string that
+ // adapters with a notes-shape vendor field (Intune, Kandji,
+ // Jamf, etc.) render + push to that field. Blank = don't push
+ // a notes field. Empty-string save clears the template.
+ SyncAdapterConfig::put(
+ $this->instance->id,
+ 'push_notes_template',
+ (string) $request->input($slug . '_push_notes_template', ''),
+ );
+
+ // Optional override for which vendor field the composed
+ // notes get pushed to. Blank = use the adapter's default
+ // (Kandji: notes, Jamf: general.notes, Intune: notes, etc.).
+ // Admin sets this when their vendor has multiple candidate
+ // fields (Kandji's `notes` vs a specific custom field, WS1's
+ // Custom Attribute name, Ninja's Custom Field name).
+ SyncAdapterConfig::put(
+ $this->instance->id,
+ 'push_notes_target',
+ (string) $request->input($slug . '_push_notes_target', ''),
+ );
+ }
+
+ /**
+ * Per-field direction (pull / push / skip). Orthogonal to the
+ * target column stored above so admins can flip direction without
+ * re-picking the target. Only meaningful for adapters that
+ * implement PushableSyncAdapter. For pull-only adapters the form
+ * doesn't render the direction column, and the default is always pull.
+ *
+ * @param array<int, string> $validFields
+ */
+ protected function persistFieldDirections(Request $request, string $slug, array $validFields): void
+ {
+ $posted = (array) $request->input($slug . '_direction', []);
+
+ // Widgets' picker rows submit their unfinished pair under
+ // <slug>_<map_key>_pending[key|value] so admins can save
+ // without clicking + to commit the row first.
+ $pairedMapKeys = [$slug . '_mapping_pending'];
+ foreach ($this->settingsSchema() as $field) {
+ if (($field['type'] ?? '') === 'field_map') {
+ $pairedMapKeys[] = $slug . '_' . $field['key'] . '_pending';
+ }
+ }
+ $directionPending = (array) $request->input($slug . '_direction_pending', []);
+ $pendingDir = is_string($directionPending['value'] ?? null) ? trim($directionPending['value']) : '';
+ foreach ($pairedMapKeys as $pendingField) {
+ $pairedPending = (array) $request->input($pendingField, []);
+ $pendingKey = is_string($pairedPending['key'] ?? null) ? trim($pairedPending['key']) : '';
+ $pendingValue = is_string($pairedPending['value'] ?? null) ? trim($pairedPending['value']) : '';
+ if ($pendingKey !== '' && $pendingValue !== '' && $pendingDir !== '' && !array_key_exists($pendingKey, $posted)) {
+ $posted[$pendingKey] = $pendingDir;
+ }
+ }
+
+ // Standard-field pushability gate. Adapters that only know
+ // how to push a subset of fields (CustomHttp) coerce
+ // push/both on non-pushable standard fields down to pull so
+ // we don't persist an unenforceable direction. Extras are
+ // defined by the adapter and assumed pushable.
+ $pushable = $this->pushableFields();
+
+ foreach ($posted as $field => $direction) {
+ if (!in_array($field, $validFields, true)) {
+ continue;
+ }
+ if (!in_array($direction, ['pull', 'push', 'skip', 'both'], true)) {
+ continue;
+ }
+ if (
+ in_array($field, MappingTargets::FIELDS, true)
+ && !in_array($field, $pushable, true)
+ && in_array($direction, ['push', 'both'], true)
+ ) {
+ $direction = 'pull';
+ }
+ SyncAdapterConfig::put($this->instance->id, 'direction.' . $field, (string) $direction);
+ }
+
+ // Same forget-on-omit rule as persistFieldMappings for extras:
+ // rows removed via the mapping-picker widget are absent from
+ // POST, and their direction needs clearing so it doesn't
+ // linger on the next sync if the extra gets re-added.
+ foreach (array_keys($this->extraFields()) as $extraKey) {
+ if (!array_key_exists($extraKey, $posted)) {
+ SyncAdapterConfig::forget($this->instance->id, 'direction.' . $extraKey);
+ }
+ }
+ }
+
+
+ /**
+ * Dry-run mode for push: when true, PushableSyncAdapter::push()
+ * implementations should build the payload and log it via the
+ * sync-adapters channel but skip the actual vendor API call.
+ * Lets admins verify their mapping + direction configuration
+ * end-to-end without touching the vendor. Off by default.
+ */
+ public function isPushDryRun(): bool
+ {
+ if ($this->pushDryRunOverride !== null) {
+ return $this->pushDryRunOverride;
+ }
+
+ return SyncAdapterConfig::get($this->instance->id, 'push_dry_run') === '1';
+ }
+
+ /**
+ * Per-request override for the dry-run flags. Set by callers that
+ * want to force a dry run without flipping the persisted config
+ * (CLI --dry-run flag on snipeit:push-inventory, UI toggle inside
+ * a single click, etc.).
+ * Null means "fall back to the persisted config value". Lives on
+ * the adapter instance so it's scoped to one adapter object for
+ * the current request.
+ */
+ protected ?bool $pushDryRunOverride = null;
+
+ public function withPushDryRunOverride(?bool $override): static
+ {
+ $this->pushDryRunOverride = $override;
+
+ return $this;
+ }
+
+ /**
+ * Valid placeholder keys for the composed-notes push template.
+ * Admins wrap these tokens in {curly-braces} inside their
+ * push_notes_template to build a single-field notes blob from
+ * many Snipe-IT fields. `{custom.Field Name}` accesses any
+ * CustomField by its exact display name (case-sensitive).
+ * Unknown placeholders and null values render as empty so a
+ * template referencing missing fields degrades gracefully.
+ *
+ * Admin-facing descriptions of each placeholder live in the
+ * `push_notes_template_help` translation, not here, so the
+ * catalog stays translator-friendly.
+ *
+ * @var array<int, string>
+ */
+ public const NOTES_TEMPLATE_PLACEHOLDERS = [
+ 'asset_tag',
+ 'name',
+ 'serial',
+ 'model',
+ 'model_number',
+ 'manufacturer',
+ 'category',
+ 'status',
+ 'status_type',
+ 'assigned_to',
+ 'assigned_to_email',
+ 'assigned_to_username',
+ 'location',
+ 'company',
+ 'supplier',
+ 'last_checkout',
+ 'last_checkin',
+ 'expected_checkin',
+ 'notes',
+ 'order_number',
+ 'purchase_date',
+ 'purchase_cost',
+ 'warranty_months',
+ 'warranty_expires',
+ ];
+
+ public function pushDirectedFields(): array
+ {
+ $out = [];
+ $candidates = array_merge(MappingTargets::FIELDS, array_keys($this->extraFields()));
+ foreach ($candidates as $field) {
+ // Standard-field target "Skip (do not sync)" wins over
+ // whatever the paired direction dropdown says - the field
+ // is explicitly opted out of syncing in either direction.
+ // The direction value may still be 'push' in the stored
+ // config from before the target was flipped to skip, but
+ // we treat the field as excluded from the push set
+ // regardless. Also protects against stale state on
+ // direction=push + mapping=skip combos the UI used to be
+ // able to produce.
+ //
+ // Extras skip this gate because their mapping default is
+ // 'skip' (no stored row = "not configured, not synced")
+ // and their direction toggle is the only control the
+ // admin has to pick push on them.
+ if (in_array($field, MappingTargets::FIELDS, true) && $this->mappingFor($field) === 'skip') {
+ continue;
+ }
+ if (in_array($this->directionFor($field), ['push', 'both'], true)) {
+ $out[] = $field;
+ }
+ }
+
+ return $out;
+ }
+
+
+ /**
+ * Resolve one of the standard source-field names (hostname,
+ * asset_tag, serial, model, notes, etc.) to the matching value
+ * on the asset. Push implementations call this when building
+ * their outgoing payload so every adapter reads Snipe-IT values
+ * the same way. Returns null for unknown source-field names,
+ * for extras (vendor-specific keys the base class can't map),
+ * or when the asset has no value for that field.
+ *
+ * Adapters with a vendor-specific extra that needs pushing
+ * override in the subclass, call parent for the standard fields,
+ * and handle the vendor-specific keys in the child branch.
+ */
+ protected function assetValueForSourceField(Asset $asset, string $field): mixed
+ {
+ // Native fast-path: the four fields every adapter can push
+ // without consulting a mapping target. Pre-dates the mapping-
+ // target resolver below so adapters that call this with
+ // non-mapped fields (test harnesses, future callers) still get
+ // a sensible answer.
+ $native = match ($field) {
+ 'hostname', 'name' => $asset->name,
+ 'serial' => $asset->serial,
+ 'asset_tag' => $asset->asset_tag,
+ 'model' => $asset->model?->name,
+ 'notes' => $asset->notes,
+ default => null,
+ };
+ if ($native !== null) {
+ return $native;
+ }
+
+ // For other source fields (os, os_version, last_seen, mac,
+ // custom:X, etc.) consult the per-field mapping target so the
+ // middleman push scenario (pull from vendor A, push to vendor
+ // B) can actually surface the stored value. The mapping is
+ // the admin's choice of "where in Snipe-IT does this field
+ // live" - we read from that slot.
+ $target = $this->mappingFor($field);
+ if ($target === '' || $target === 'skip') {
+ return null;
+ }
+
+ if (str_starts_with($target, 'custom:')) {
+ $customFieldId = (int) substr($target, 7);
+ $customField = CustomField::find($customFieldId);
+ if ($customField === null || $customField->db_column === null) {
+ return null;
+ }
+
+ return $asset->getAttribute($customField->db_column);
+ }
+
+ if (str_starts_with($target, 'external:')) {
+ $column = substr($target, 9);
+ $row = \Illuminate\Support\Facades\DB::table('asset_external_sources')
+ ->where('asset_id', $asset->id)
+ ->where('source', $this->name())
+ ->first();
+
+ return $row->{$column} ?? null;
+ }
+
+ if (str_starts_with($target, 'native:')) {
+ // Direct read from the asset column named after the
+ // target. The sync writers use the same convention, so
+ // native:foo stored by pull is readable as $asset->foo.
+ $column = substr($target, 7);
+
+ return $asset->getAttribute($column);
+ }
+
+ return null;
+ }
+
+ /**
+ * Standard push() implementation for single-endpoint adapters. An
+ * adapter whose push() writes one payload to one endpoint (Kandji,
+ * Jamf, NinjaOne) overrides two hooks (buildPushPayload,
+ * dispatchPush) and delegates push() to this template.
+ *
+ * Adapters with split-endpoint pushes (Mosyle posts asset_tag and
+ * notes to separate operations, Workspace ONE splits device fields
+ * from Custom Attributes) implement push() directly and don't call
+ * this. CustomHttp also implements push() directly because its
+ * dry-run log and dispatch depend on admin-configured HTTP method
+ * and endpoint that the template can't parameterize.
+ *
+ * Success and dry-run log lines use typeLabel() plus the flat
+ * $touched list (falling back to array_keys($payload) when the
+ * adapter builds a flat-keyed payload and doesn't populate
+ * $touched). Adapters wanting vendor-specific log wording override
+ * push() directly instead of using the template.
+ *
+ * @param array<int, string> $changedFields
+ */
+ protected function pushViaSinglePayload(Asset $asset, array $changedFields): bool
+ {
+ $externalSource = $this->pushPrologue($asset, $changedFields);
+ if ($externalSource === null) {
+ return false;
+ }
+
+ [$payload, $touched] = $this->buildPushPayload($asset);
+ $this->applyComposedNotesToPayload($asset, $payload, $touched);
+
+ if ($payload === []) {
+ return false;
+ }
+
+ $written = $touched !== [] ? $touched : array_keys($payload);
+
+ if ($this->isPushDryRun()) {
+ Log::channel('sync-adapters')->info(sprintf(
+ '%s push [dry-run]: would send %s to %s device %s',
+ $this->name(),
+ json_encode($payload, JSON_UNESCAPED_SLASHES),
+ static::typeLabel(),
+ $externalSource->external_id,
+ ));
+
+ return true;
+ }
+
+ $this->dispatchPush($externalSource, $payload);
+
+ Log::channel('sync-adapters')->info(sprintf(
+ '%s push: updated %s device %s [%s]',
+ $this->name(),
+ static::typeLabel(),
+ $externalSource->external_id,
+ implode(', ', $written),
+ ));
+
+ return true;
+ }
+
+ /**
+ * Build the outgoing vendor payload for pushViaSinglePayload().
+ * Adapters that call pushViaSinglePayload() override this to
+ * return their payload and the flat list of dot-paths / keys that
+ * were written (for the post-push audit log). Empty payload signals
+ * "nothing to send" and the template short-circuits.
+ *
+ * @return array{0: array<string, mixed>, 1: array<int, string>}
+ */
+ protected function buildPushPayload(Asset $asset): array
+ {
+ throw new \LogicException(static::class . ' calls pushViaSinglePayload() but does not override buildPushPayload().');
+ }
+
+ /**
+ * Fire the vendor HTTP call for pushViaSinglePayload(). Adapters
+ * that call pushViaSinglePayload() override this. Failures throw
+ * (the outer controller catches and renders a red-flash summary,
+ * matching the pull path). No return value: presence of the call
+ * is enough, the template logs success on its own.
+ *
+ * @param array<string, mixed> $payload
+ */
+ protected function dispatchPush(\App\Models\AssetExternalSource $externalSource, array $payload): void
+ {
+ throw new \LogicException(static::class . ' calls pushViaSinglePayload() but does not override dispatchPush().');
+ }
+
+ /**
+ * Shared prologue for every PushableSyncAdapter::push() implementation.
+ * Runs the three identical guards each adapter's push() started with
+ * and returns the AssetExternalSource row when the push should
+ * proceed, or null when any guard rejects it. Callers early-return
+ * on null.
+ *
+ * The three guards, in order:
+ * 1. pushDirectedFields is empty AND no composed-notes template is
+ * configured (nothing to send, skip).
+ * 2. Caller-provided $changedFields is non-empty but doesn't
+ * intersect pushDirectedFields (the caller told us which
+ * fields changed and none of them are push-directed on this
+ * instance, so skip the vendor call).
+ * 3. asset_external_sources row missing (the asset was never
+ * synced from this instance, so we have no vendor device id
+ * to write against).
+ *
+ * @param array<int, string> $changedFields
+ */
+ public function pushPrologue(Asset $asset, array $changedFields): ?\App\Models\AssetExternalSource
+ {
+ $pushFields = $this->pushDirectedFields();
+ $notesConfigured = $this->hasComposedNotesConfigured();
+
+ if ($pushFields === [] && !$notesConfigured) {
+ // Nothing directed push and no composed-notes template.
+ // Logged at info because this is a config-shape issue
+ // the admin should see in the per-run log + file log
+ // instead of just "0 pushed, N skipped" with no reason.
+ Log::channel('sync-adapters')->info(sprintf(
+ '%s push: skipped asset %d (asset_tag=%s) - no push-directed fields and no composed-notes template configured',
+ $this->name(),
+ $asset->id,
+ $asset->asset_tag ?? '(none)',
+ ));
+
+ return null;
+ }
+
+ if ($pushFields !== [] && $changedFields !== []
+ && array_intersect($changedFields, $pushFields) === []) {
+ Log::channel('sync-adapters')->info(sprintf(
+ '%s push: skipped asset %d (asset_tag=%s) - changed fields [%s] do not intersect push-directed fields [%s]',
+ $this->name(),
+ $asset->id,
+ $asset->asset_tag ?? '(none)',
+ implode(', ', $changedFields),
+ implode(', ', $pushFields),
+ ));
+
+ return null;
+ }
+
+ $externalSource = \App\Models\AssetExternalSource::query()
+ ->where('asset_id', $asset->id)
+ ->where('source', $this->name())
+ ->first();
+
+ if ($externalSource === null) {
+ Log::channel('sync-adapters')->info(sprintf(
+ '%s push: skipped asset %d (asset_tag=%s) - no asset_external_sources row for this adapter instance',
+ $this->name(),
+ $asset->id,
+ $asset->asset_tag ?? '(none)',
+ ));
+ }
+
+ return $externalSource;
+ }
+
+ /**
+ * Composed notes payload for a push, or null when nothing to
+ * push. Reads the admin's push_notes_template from config,
+ * resolves the target vendor field (admin override or
+ * PushableSyncAdapter::notesFieldTarget() default), then substitutes
+ * every {placeholder} against the given asset.
+ *
+ * Placeholders are enumerated in NOTES_TEMPLATE_PLACEHOLDERS.
+ * `{custom.Field Name}` resolves any CustomField by exact
+ * display name. Unknown keys and null values render as empty,
+ * so a template referencing missing fields degrades gracefully
+ * instead of throwing.
+ *
+ * Adapter push() implementations call this and check for null:
+ * non-null returns give both the vendor field name (`target`)
+ * and the rendered string (`value`), so the caller can splice
+ * both into its payload in one hit.
+ *
+ * @return array{target: string, value: string}|null
+ */
+ public function composeNotesForPush(Asset $asset): ?array
+ {
+ $template = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_template');
+ if (trim($template) === '') {
+ // Blank template is the common "feature not in use" case,
+ // so log at debug - skipping it on every asset push would
+ // just noise up the file log on fleets that haven't set
+ // up composed notes.
+ Log::channel('sync-adapters')->debug(sprintf(
+ '%s push: asset %d (asset_tag=%s) - composed notes not applied: push_notes_template is blank',
+ $this->name(),
+ $asset->id,
+ $asset->asset_tag ?? '(none)',
+ ));
+
+ return null;
+ }
+
+ $target = $this->resolveComposedNotesTarget();
+ if ($target === null) {
+ // Template is set but target field path is not. This IS
+ // worth surfacing at info - the admin wrote a template
+ // expecting it to be pushed somewhere and the destination
+ // config is missing.
+ Log::channel('sync-adapters')->info(sprintf(
+ '%s push: asset %d (asset_tag=%s) - composed notes not applied: push_notes_template is set but no target field is configured (push_notes_target)',
+ $this->name(),
+ $asset->id,
+ $asset->asset_tag ?? '(none)',
+ ));
+
+ return null;
+ }
+
+ // Match anything between braces that isn't itself a brace.
+ // Permissive so custom-field names with spaces or punctuation
+ // ({custom.Cost Center}, {custom.Warranty (extended)}) match
+ // cleanly. The inner match block below decides validity.
+ $value = preg_replace_callback(
+ '/\{([^{}]+)\}/',
+ function (array $m) use ($asset): string {
+ $key = $m[1];
+
+ if (str_starts_with($key, 'custom.')) {
+ $field = CustomField::query()->where('name', substr($key, 7))->first();
+ if ($field === null || $field->db_column === null) {
+ return '';
+ }
+ $stored = $asset->getAttribute($field->db_column);
+
+ return $stored === null ? '' : (string) $stored;
+ }
+
+ return match ($key) {
+ 'asset_tag' => (string) ($asset->asset_tag ?? ''),
+ 'name' => (string) ($asset->name ?? ''),
+ 'serial' => (string) ($asset->serial ?? ''),
+ 'model' => (string) ($asset->model->name ?? ''),
+ 'model_number' => (string) ($asset->model->model_number ?? ''),
+ 'manufacturer' => (string) ($asset->model->manufacturer->name ?? ''),
+ 'category' => (string) ($asset->model->category->name ?? ''),
+ 'status' => (string) ($asset->status->name ?? ''),
+ 'status_type' => (string) ($asset->status?->getStatuslabelType() ?? ''),
+ 'assigned_to' => (string) ($asset->assignedTo?->present()?->name() ?? ''),
+ 'assigned_to_email' => (string) ($asset->assignedTo->email ?? ''),
+ 'assigned_to_username' => (string) ($asset->assignedTo->username ?? ''),
+ 'location' => (string) ($asset->location->name ?? ''),
+ 'company' => (string) ($asset->company->name ?? ''),
+ 'supplier' => (string) ($asset->supplier->name ?? ''),
+ 'last_checkout' => (string) ($asset->last_checkout ?? ''),
+ 'last_checkin' => (string) ($asset->last_checkin ?? ''),
+ 'expected_checkin' => (string) ($asset->expected_checkin ?? ''),
+ 'notes' => (string) ($asset->notes ?? ''),
+ 'order_number' => (string) ($asset->order_number ?? ''),
+ 'purchase_date' => (string) ($asset->purchase_date ?? ''),
+ 'purchase_cost' => (string) ($asset->purchase_cost ?? ''),
+ 'warranty_months' => (string) ($asset->warranty_months ?? ''),
+ 'warranty_expires' => (string) ($asset->warranty_expires ?? ''),
+ default => '',
+ };
+ },
+ $template,
+ ) ?? '';
+
+ return ['target' => $target, 'value' => $value];
+ }
+
+ /**
+ * Splice the composed-notes payload (from composeNotesForPush)
+ * into an outgoing vendor payload. Returns true when composed
+ * notes were configured and spliced, false when there was
+ * nothing to send. Callers that track which fields they pushed
+ * (for post-push logging or event dispatch) pass their $touched
+ * array by reference. The target field name gets appended to
+ * it on success.
+ *
+ * Uses Arr::set so dotted target paths (Jamf's "general.notes"
+ * shape) branch into nested payload structures rather than
+ * writing a literal key with a dot in it.
+ *
+ * @param array<mixed> $payload
+ * @param array<int, string> $touched
+ */
+ public function applyComposedNotesToPayload(Asset $asset, array &$payload, array &$touched = []): bool
+ {
+ $composedNotes = $this->composeNotesForPush($asset);
+ if ($composedNotes === null) {
+ return false;
+ }
+
+ \Illuminate\Support\Arr::set($payload, $composedNotes['target'], $composedNotes['value']);
+ $touched[] = $composedNotes['target'];
+
+ return true;
+ }
+
+ /**
+ * Stored composed-notes template + target-override, exposed for
+ * the settings-page form so it can pre-fill the two inputs.
+ * Runtime callers use composeNotesForPush() instead, which
+ * resolves the effective target (falling back to
+ * PushableSyncAdapter::notesFieldTarget()) and does the substitution
+ * in one hit.
+ *
+ * @return array{template: string, target_override: ?string}
+ */
+ public function storedPushNotesConfig(): array
+ {
+ $template = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_template');
+ $target = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_target');
+
+ return [
+ 'template' => $template,
+ 'target_override' => $target === '' ? null : $target,
+ ];
+ }
+
+ /**
+ * True when this instance has ANY push configuration in place
+ * (at least one field directed 'push' OR a composed-notes
+ * template + target). Used by the controller's Push Now handler
+ * to abort with a clear error before iterating asset rows when
+ * the admin hit the button on a fresh or incorrectly-configured
+ * adapter, instead of iterating N rows that each silent-no-op
+ * and reporting an inaccurate success.
+ */
+ public function hasPushConfiguration(): bool
+ {
+ return $this->pushDirectedFields() !== [] || $this->hasComposedNotesConfigured();
+ }
+
+ /**
+ * Cheap "should we bother trying to push composed notes?" check
+ * used by pushPrologue to gate the vendor call without paying
+ * the cost of rendering the template. True when the admin has a
+ * non-blank push_notes_template AND a resolvable target field.
+ */
+ private function hasComposedNotesConfigured(): bool
+ {
+ $template = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_template');
+
+ return trim($template) !== '' && $this->resolveComposedNotesTarget() !== null;
+ }
+
+ /**
+ * Vendor field name for the composed-notes push. Admin's
+ * override (push_notes_target config key) wins if set. Falls
+ * back to the adapter's suggested default via
+ * PushableSyncAdapter::notesFieldTarget(). Null when neither is
+ * set (adapter has no notes concept AND admin didn't name a
+ * target field).
+ */
+ private function resolveComposedNotesTarget(): ?string
+ {
+ $stored = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_target');
+ if ($stored !== '') {
+ return $stored;
+ }
+
+ return $this->notesFieldTarget();
+ }
+
+ /**
+ * Whether the composed-notes push UI should appear on this
+ * adapter's settings page. Default is "yes if the adapter is
+ * pushable at all" so existing adapters stay unchanged. Adapters
+ * targeting APIs that have no notes-like field anywhere in their
+ * push payload (Mosyle Manager v2's push elements, for example)
+ * override this to false so admins don't fill in a template that
+ * can never land. notesFieldTarget() returning null doesn't carry
+ * this meaning (Workspace ONE / NinjaOne return null legitimately
+ * because the admin picks the target).
+ */
+ public function supportsComposedNotesPush(): bool
+ {
+ return $this->canPush();
+ }
+
+}
diff --git a/app/SyncAdapters/SyncAdapter.php b/app/SyncAdapters/SyncAdapter.php
index 2afd8c2051..ec449c0ea0 100644
--- a/app/SyncAdapters/SyncAdapter.php
+++ b/app/SyncAdapters/SyncAdapter.php
@@ -819,7 +819,7 @@ abstract class SyncAdapter
* Grouped here so saveConfig() reads as a list of intent rather
* than a wall of SyncAdapterConfig::put() calls.
*/
- private function persistOperationalSettings(Request $request, string $slug): void
+ protected function persistOperationalSettings(Request $request, string $slug): void
{
SyncAdapterConfig::put(
$this->instance->id,
@@ -926,16 +926,6 @@ abstract class SyncAdapter
);
}
- // Push dry-run flag. When on, adapters log the push payload
- // instead of sending it, so admins can verify mapping +
- // direction config against real assets without any vendor
- // side effect.
- SyncAdapterConfig::put(
- $this->instance->id,
- 'push_dry_run',
- $request->boolean($slug.'_push_dry_run') ? '1' : '0',
- );
-
// Pull dry-run flag. When on, Sync Now still calls pull() so
// vendor-side fetch, mapping, and normalization all run - but
// the consumer logs each HostInventoryRecord instead of handing
@@ -946,28 +936,6 @@ abstract class SyncAdapter
'pull_dry_run',
$request->boolean($slug.'_pull_dry_run') ? '1' : '0',
);
-
- // Push notes template. Blade-ish {placeholder} string that
- // adapters with a notes-shape vendor field (Intune, Kandji,
- // Jamf, etc.) render + push to that field. Blank = don't push
- // a notes field. Empty-string save clears the template.
- SyncAdapterConfig::put(
- $this->instance->id,
- 'push_notes_template',
- (string) $request->input($slug.'_push_notes_template', ''),
- );
-
- // Optional override for which vendor field the composed
- // notes get pushed to. Blank = use the adapter's default
- // (Kandji: notes, Jamf: general.notes, Intune: notes, etc.).
- // Admin sets this when their vendor has multiple candidate
- // fields (Kandji's `notes` vs a specific custom field, WS1's
- // Custom Attribute name, Ninja's Custom Field name).
- SyncAdapterConfig::put(
- $this->instance->id,
- 'push_notes_target',
- (string) $request->input($slug.'_push_notes_target', ''),
- );
}
/**
@@ -1046,31 +1014,35 @@ abstract class SyncAdapter
* Per-field direction (pull / push / skip). Orthogonal to the
* target column stored above so admins can flip direction without
* re-picking the target. Only meaningful for adapters that
- * implement PushableAdapter. For pull-only adapters the form
- * doesn't render the direction column, and the default is always pull.
+ * implement PushableSyncAdapter. For pull-only adapters the form
+ * doesn't render the direction column, and the default is always pull, and
+ * this method is a no-op.
*
* @param array<int, string> $validFields
*/
- private function persistFieldDirections(Request $request, string $slug, array $validFields): void
+ protected function persistFieldDirections(Request $request, string $slug, array $validFields): void
{
- $posted = (array) $request->input($slug.'_direction', []);
+ \Log::debug("This should never be called - there's no such thing as 'direction' for pull-only SyncAdapters");
+ // Though, maybe, there is? 'skip' is a direction, and you might use that?
+ // TODO - this is copypasta from PushableSyncAdapter, but without it, tests won't pass
+ $posted = (array) $request->input($slug . '_direction', []);
// Widgets' picker rows submit their unfinished pair under
// <slug>_<map_key>_pending[key|value] so admins can save
// without clicking + to commit the row first.
- $pairedMapKeys = [$slug.'_mapping_pending'];
+ $pairedMapKeys = [$slug . '_mapping_pending'];
foreach ($this->settingsSchema() as $field) {
if (($field['type'] ?? '') === 'field_map') {
- $pairedMapKeys[] = $slug.'_'.$field['key'].'_pending';
+ $pairedMapKeys[] = $slug . '_' . $field['key'] . '_pending';
}
}
- $directionPending = (array) $request->input($slug.'_direction_pending', []);
+ $directionPending = (array) $request->input($slug . '_direction_pending', []);
$pendingDir = is_string($directionPending['value'] ?? null) ? trim($directionPending['value']) : '';
foreach ($pairedMapKeys as $pendingField) {
$pairedPending = (array) $request->input($pendingField, []);
$pendingKey = is_string($pairedPending['key'] ?? null) ? trim($pairedPending['key']) : '';
$pendingValue = is_string($pairedPending['value'] ?? null) ? trim($pairedPending['value']) : '';
- if ($pendingKey !== '' && $pendingValue !== '' && $pendingDir !== '' && ! array_key_exists($pendingKey, $posted)) {
+ if ($pendingKey !== '' && $pendingValue !== '' && $pendingDir !== '' && !array_key_exists($pendingKey, $posted)) {
$posted[$pendingKey] = $pendingDir;
}
}
@@ -1080,23 +1052,23 @@ abstract class SyncAdapter
// push/both on non-pushable standard fields down to pull so
// we don't persist an unenforceable direction. Extras are
// defined by the adapter and assumed pushable.
- $pushable = $this->pushableFields();
+ $pushable = MappingTargets::FIELDS;
foreach ($posted as $field => $direction) {
- if (! in_array($field, $validFields, true)) {
+ if (!in_array($field, $validFields, true)) {
continue;
}
- if (! in_array($direction, ['pull', 'push', 'skip', 'both'], true)) {
+ if (!in_array($direction, ['pull', 'push', 'skip', 'both'], true)) {
continue;
}
if (
in_array($field, MappingTargets::FIELDS, true)
- && ! in_array($field, $pushable, true)
+ && !in_array($field, $pushable, true)
&& in_array($direction, ['push', 'both'], true)
) {
$direction = 'pull';
}
- SyncAdapterConfig::put($this->instance->id, 'direction.'.$field, (string) $direction);
+ SyncAdapterConfig::put($this->instance->id, 'direction.' . $field, (string) $direction);
}
// Same forget-on-omit rule as persistFieldMappings for extras:
@@ -1104,8 +1076,8 @@ abstract class SyncAdapter
// POST, and their direction needs clearing so it doesn't
// linger on the next sync if the extra gets re-added.
foreach (array_keys($this->extraFields()) as $extraKey) {
- if (! array_key_exists($extraKey, $posted)) {
- SyncAdapterConfig::forget($this->instance->id, 'direction.'.$extraKey);
+ if (!array_key_exists($extraKey, $posted)) {
+ SyncAdapterConfig::forget($this->instance->id, 'direction.' . $extraKey);
}
}
}
@@ -1122,22 +1094,6 @@ abstract class SyncAdapter
// no-op by default
}
- /**
- * Dry-run mode for push: when true, PushableAdapter::push()
- * implementations should build the payload and log it via the
- * sync-adapters channel but skip the actual vendor API call.
- * Lets admins verify their mapping + direction configuration
- * end-to-end without touching the vendor. Off by default.
- */
- public function isPushDryRun(): bool
- {
- if ($this->pushDryRunOverride !== null) {
- return $this->pushDryRunOverride;
- }
-
- return SyncAdapterConfig::get($this->instance->id, 'push_dry_run') === '1';
- }
-
/**
* Dry-run mode for pull: when true, Sync Now still fetches from
* the vendor and runs the adapter's normalization, but the pull
@@ -1158,23 +1114,14 @@ abstract class SyncAdapter
/**
* Per-request override for the dry-run flags. Set by callers that
* want to force a dry run without flipping the persisted config
- * (CLI --dry-run flag on snipeit:pull-inventory /
- * snipeit:push-inventory, UI toggle inside a single click, etc.).
+ * (CLI --dry-run flag on snipeit:pull-inventory, UI toggle inside a
+ * single click, etc.).
* Null means "fall back to the persisted config value". Lives on
* the adapter instance so it's scoped to one adapter object for
* the current request.
*/
- protected ?bool $pushDryRunOverride = null;
-
protected ?bool $pullDryRunOverride = null;
- public function withPushDryRunOverride(?bool $override): static
- {
- $this->pushDryRunOverride = $override;
-
- return $this;
- }
-
public function withPullDryRunOverride(?bool $override): static
{
$this->pullDryRunOverride = $override;
@@ -1182,48 +1129,7 @@ abstract class SyncAdapter
return $this;
}
- /**
- * Valid placeholder keys for the composed-notes push template.
- * Admins wrap these tokens in {curly-braces} inside their
- * push_notes_template to build a single-field notes blob from
- * many Snipe-IT fields. `{custom.Field Name}` accesses any
- * CustomField by its exact display name (case-sensitive).
- * Unknown placeholders and null values render as empty so a
- * template referencing missing fields degrades gracefully.
- *
- * Admin-facing descriptions of each placeholder live in the
- * `push_notes_template_help` translation, not here, so the
- * catalog stays translator-friendly.
- *
- * @var array<int, string>
- */
- public const NOTES_TEMPLATE_PLACEHOLDERS = [
- 'asset_tag',
- 'name',
- 'serial',
- 'model',
- 'model_number',
- 'manufacturer',
- 'category',
- 'status',
- 'status_type',
- 'assigned_to',
- 'assigned_to_email',
- 'assigned_to_username',
- 'location',
- 'company',
- 'supplier',
- 'last_checkout',
- 'last_checkin',
- 'expected_checkin',
- 'notes',
- 'order_number',
- 'purchase_date',
- 'purchase_cost',
- 'warranty_months',
- 'warranty_expires',
- ];
-
+ // FIXME - do we want to do this differently here versus elsewhere?
public function directionFor(string $field): string
{
$stored = SyncAdapterConfig::get($this->instance->id, 'direction.'.$field);
@@ -1231,29 +1137,6 @@ abstract class SyncAdapter
return in_array($stored, ['pull', 'push', 'skip', 'both'], true) ? $stored : 'pull';
}
- /**
- * Enumeration of source-field names currently directed 'push' or
- * 'both' on this instance. Used by push() implementations to
- * build the PATCH payload without scanning every possible field.
- *
- * @return array<int, string>
- */
- /**
- * Standard fields this adapter actually knows how to push TO the
- * vendor. The direction dropdown in the settings UI only offers
- * push/both for fields in this list - picking push for a field
- * the adapter can't push would silently drop at buildPushPayload
- * time, confusing the admin.
- *
- * Default: every MappingTargets::FIELDS entry, which matches the
- * behavior adapters had before this hook existed. CustomHttp
- * overrides to just its hard-coded PUSHABLE_STANDARD_FIELDS set
- * (hostname / serial / asset_tag / model - the only four we can
- * resolve to an Asset-side value). Other adapters that fully
- * handle every standard field don't need to override.
- *
- * @return array<int, string>
- */
/**
* Whether this adapter's settings form should render the
* "<Adapter>-specific fields" mapping-picker section. True by
@@ -1268,497 +1151,6 @@ abstract class SyncAdapter
return true;
}
- public function pushableFields(): array
- {
- return MappingTargets::FIELDS;
- }
-
- public function pushDirectedFields(): array
- {
- $out = [];
- $candidates = array_merge(MappingTargets::FIELDS, array_keys($this->extraFields()));
- foreach ($candidates as $field) {
- // Standard-field target "Skip (do not sync)" wins over
- // whatever the paired direction dropdown says - the field
- // is explicitly opted out of syncing in either direction.
- // The direction value may still be 'push' in the stored
- // config from before the target was flipped to skip, but
- // we treat the field as excluded from the push set
- // regardless. Also protects against stale state on
- // direction=push + mapping=skip combos the UI used to be
- // able to produce.
- //
- // Extras skip this gate because their mapping default is
- // 'skip' (no stored row = "not configured, not synced")
- // and their direction toggle is the only control the
- // admin has to pick push on them.
- if (in_array($field, MappingTargets::FIELDS, true) && $this->mappingFor($field) === 'skip') {
- continue;
- }
- if (in_array($this->directionFor($field), ['push', 'both'], true)) {
- $out[] = $field;
- }
- }
-
- return $out;
- }
-
- /**
- * Resolve one of the standard source-field names (hostname,
- * asset_tag, serial, model, notes, etc.) to the matching value
- * on the asset. Push implementations call this when building
- * their outgoing payload so every adapter reads Snipe-IT values
- * the same way. Returns null for unknown source-field names,
- * for extras (vendor-specific keys the base class can't map),
- * or when the asset has no value for that field.
- *
- * Adapters with a vendor-specific extra that needs pushing
- * override in the subclass, call parent for the standard fields,
- * and handle the vendor-specific keys in the child branch.
- */
- protected function assetValueForSourceField(Asset $asset, string $field): mixed
- {
- // Native fast-path: the four fields every adapter can push
- // without consulting a mapping target. Pre-dates the mapping-
- // target resolver below so adapters that call this with
- // non-mapped fields (test harnesses, future callers) still get
- // a sensible answer.
- $native = match ($field) {
- 'hostname', 'name' => $asset->name,
- 'serial' => $asset->serial,
- 'asset_tag' => $asset->asset_tag,
- 'model' => $asset->model?->name,
- 'notes' => $asset->notes,
- default => null,
- };
- if ($native !== null) {
- return $native;
- }
-
- // For other source fields (os, os_version, last_seen, mac,
- // custom:X, etc.) consult the per-field mapping target so the
- // middleman push scenario (pull from vendor A, push to vendor
- // B) can actually surface the stored value. The mapping is
- // the admin's choice of "where in Snipe-IT does this field
- // live" - we read from that slot.
- $target = $this->mappingFor($field);
- if ($target === '' || $target === 'skip') {
- return null;
- }
-
- if (str_starts_with($target, 'custom:')) {
- $customFieldId = (int) substr($target, 7);
- $customField = CustomField::find($customFieldId);
- if ($customField === null || $customField->db_column === null) {
- return null;
- }
-
- return $asset->getAttribute($customField->db_column);
- }
-
- if (str_starts_with($target, 'external:')) {
- $column = substr($target, 9);
- $row = \Illuminate\Support\Facades\DB::table('asset_external_sources')
- ->where('asset_id', $asset->id)
- ->where('source', $this->name())
- ->first();
-
- return $row->{$column} ?? null;
- }
-
- if (str_starts_with($target, 'native:')) {
- // Direct read from the asset column named after the
- // target. The sync writers use the same convention, so
- // native:foo stored by pull is readable as $asset->foo.
- $column = substr($target, 7);
-
- return $asset->getAttribute($column);
- }
-
- return null;
- }
-
- /**
- * Standard push() implementation for single-endpoint adapters. An
- * adapter whose push() writes one payload to one endpoint (Kandji,
- * Jamf, NinjaOne) overrides two hooks (buildPushPayload,
- * dispatchPush) and delegates push() to this template.
- *
- * Adapters with split-endpoint pushes (Mosyle posts asset_tag and
- * notes to separate operations, Workspace ONE splits device fields
- * from Custom Attributes) implement push() directly and don't call
- * this. CustomHttp also implements push() directly because its
- * dry-run log and dispatch depend on admin-configured HTTP method
- * and endpoint that the template can't parameterize.
- *
- * Success and dry-run log lines use typeLabel() plus the flat
- * $touched list (falling back to array_keys($payload) when the
- * adapter builds a flat-keyed payload and doesn't populate
- * $touched). Adapters wanting vendor-specific log wording override
- * push() directly instead of using the template.
- *
- * @param array<int, string> $changedFields
- */
- protected function pushViaSinglePayload(Asset $asset, array $changedFields): bool
- {
- $externalSource = $this->pushPrologue($asset, $changedFields);
- if ($externalSource === null) {
- return false;
- }
-
- [$payload, $touched] = $this->buildPushPayload($asset);
- $this->applyComposedNotesToPayload($asset, $payload, $touched);
-
- if ($payload === []) {
- return false;
- }
-
- $written = $touched !== [] ? $touched : array_keys($payload);
-
- if ($this->isPushDryRun()) {
- Log::channel('sync-adapters')->info(sprintf(
- '%s push [dry-run]: would send %s to %s device %s',
- $this->name(),
- json_encode($payload, JSON_UNESCAPED_SLASHES),
- static::typeLabel(),
- $externalSource->external_id,
- ));
-
- return true;
- }
-
- $this->dispatchPush($externalSource, $payload);
-
- Log::channel('sync-adapters')->info(sprintf(
- '%s push: updated %s device %s [%s]',
- $this->name(),
- static::typeLabel(),
- $externalSource->external_id,
- implode(', ', $written),
- ));
-
- return true;
- }
-
- /**
- * Build the outgoing vendor payload for pushViaSinglePayload().
- * Adapters that call pushViaSinglePayload() override this to
- * return their payload and the flat list of dot-paths / keys that
- * were written (for the post-push audit log). Empty payload signals
- * "nothing to send" and the template short-circuits.
- *
- * @return array{0: array<string, mixed>, 1: array<int, string>}
- */
- protected function buildPushPayload(Asset $asset): array
- {
- throw new \LogicException(static::class.' calls pushViaSinglePayload() but does not override buildPushPayload().');
- }
-
- /**
- * Fire the vendor HTTP call for pushViaSinglePayload(). Adapters
- * that call pushViaSinglePayload() override this. Failures throw
- * (the outer controller catches and renders a red-flash summary,
- * matching the pull path). No return value: presence of the call
- * is enough, the template logs success on its own.
- *
- * @param array<string, mixed> $payload
- */
- protected function dispatchPush(\App\Models\AssetExternalSource $externalSource, array $payload): void
- {
- throw new \LogicException(static::class.' calls pushViaSinglePayload() but does not override dispatchPush().');
- }
-
- /**
- * Shared prologue for every PushableAdapter::push() implementation.
- * Runs the three identical guards each adapter's push() started with
- * and returns the AssetExternalSource row when the push should
- * proceed, or null when any guard rejects it. Callers early-return
- * on null.
- *
- * The three guards, in order:
- * 1. pushDirectedFields is empty AND no composed-notes template is
- * configured (nothing to send, skip).
- * 2. Caller-provided $changedFields is non-empty but doesn't
- * intersect pushDirectedFields (the caller told us which
- * fields changed and none of them are push-directed on this
- * instance, so skip the vendor call).
- * 3. asset_external_sources row missing (the asset was never
- * synced from this instance, so we have no vendor device id
- * to write against).
- *
- * @param array<int, string> $changedFields
- */
- public function pushPrologue(Asset $asset, array $changedFields): ?\App\Models\AssetExternalSource
- {
- $pushFields = $this->pushDirectedFields();
- $notesConfigured = $this->hasComposedNotesConfigured();
-
- if ($pushFields === [] && ! $notesConfigured) {
- // Nothing directed push and no composed-notes template.
- // Logged at info because this is a config-shape issue
- // the admin should see in the per-run log + file log
- // instead of just "0 pushed, N skipped" with no reason.
- Log::channel('sync-adapters')->info(sprintf(
- '%s push: skipped asset %d (asset_tag=%s) - no push-directed fields and no composed-notes template configured',
- $this->name(),
- $asset->id,
- $asset->asset_tag ?? '(none)',
- ));
-
- return null;
- }
-
- if ($pushFields !== [] && $changedFields !== []
- && array_intersect($changedFields, $pushFields) === []) {
- Log::channel('sync-adapters')->info(sprintf(
- '%s push: skipped asset %d (asset_tag=%s) - changed fields [%s] do not intersect push-directed fields [%s]',
- $this->name(),
- $asset->id,
- $asset->asset_tag ?? '(none)',
- implode(', ', $changedFields),
- implode(', ', $pushFields),
- ));
-
- return null;
- }
-
- $externalSource = \App\Models\AssetExternalSource::query()
- ->where('asset_id', $asset->id)
- ->where('source', $this->name())
- ->first();
-
- if ($externalSource === null) {
- Log::channel('sync-adapters')->info(sprintf(
- '%s push: skipped asset %d (asset_tag=%s) - no asset_external_sources row for this adapter instance',
- $this->name(),
- $asset->id,
- $asset->asset_tag ?? '(none)',
- ));
- }
-
- return $externalSource;
- }
-
- /**
- * Composed notes payload for a push, or null when nothing to
- * push. Reads the admin's push_notes_template from config,
- * resolves the target vendor field (admin override or
- * PushableAdapter::notesFieldTarget() default), then substitutes
- * every {placeholder} against the given asset.
- *
- * Placeholders are enumerated in NOTES_TEMPLATE_PLACEHOLDERS.
- * `{custom.Field Name}` resolves any CustomField by exact
- * display name. Unknown keys and null values render as empty,
- * so a template referencing missing fields degrades gracefully
- * instead of throwing.
- *
- * Adapter push() implementations call this and check for null:
- * non-null returns give both the vendor field name (`target`)
- * and the rendered string (`value`), so the caller can splice
- * both into its payload in one hit.
- *
- * @return array{target: string, value: string}|null
- */
- public function composeNotesForPush(Asset $asset): ?array
- {
- $template = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_template');
- if (trim($template) === '') {
- // Blank template is the common "feature not in use" case,
- // so log at debug - skipping it on every asset push would
- // just noise up the file log on fleets that haven't set
- // up composed notes.
- Log::channel('sync-adapters')->debug(sprintf(
- '%s push: asset %d (asset_tag=%s) - composed notes not applied: push_notes_template is blank',
- $this->name(),
- $asset->id,
- $asset->asset_tag ?? '(none)',
- ));
-
- return null;
- }
-
- $target = $this->resolveComposedNotesTarget();
- if ($target === null) {
- // Template is set but target field path is not. This IS
- // worth surfacing at info - the admin wrote a template
- // expecting it to be pushed somewhere and the destination
- // config is missing.
- Log::channel('sync-adapters')->info(sprintf(
- '%s push: asset %d (asset_tag=%s) - composed notes not applied: push_notes_template is set but no target field is configured (push_notes_target)',
- $this->name(),
- $asset->id,
- $asset->asset_tag ?? '(none)',
- ));
-
- return null;
- }
-
- // Match anything between braces that isn't itself a brace.
- // Permissive so custom-field names with spaces or punctuation
- // ({custom.Cost Center}, {custom.Warranty (extended)}) match
- // cleanly. The inner match block below decides validity.
- $value = preg_replace_callback(
- '/\{([^{}]+)\}/',
- function (array $m) use ($asset): string {
- $key = $m[1];
-
- if (str_starts_with($key, 'custom.')) {
- $field = CustomField::query()->where('name', substr($key, 7))->first();
- if ($field === null || $field->db_column === null) {
- return '';
- }
- $stored = $asset->getAttribute($field->db_column);
-
- return $stored === null ? '' : (string) $stored;
- }
-
- return match ($key) {
- 'asset_tag' => (string) ($asset->asset_tag ?? ''),
- 'name' => (string) ($asset->name ?? ''),
- 'serial' => (string) ($asset->serial ?? ''),
- 'model' => (string) ($asset->model?->name ?? ''),
- 'model_number' => (string) ($asset->model?->model_number ?? ''),
- 'manufacturer' => (string) ($asset->model?->manufacturer?->name ?? ''),
- 'category' => (string) ($asset->model?->category?->name ?? ''),
- 'status' => (string) ($asset->status?->name ?? ''),
- 'status_type' => (string) ($asset->status?->getStatuslabelType() ?? ''),
- 'assigned_to' => (string) ($asset->assignedTo?->present()?->name() ?? ''),
- 'assigned_to_email' => (string) ($asset->assignedTo?->email ?? ''),
- 'assigned_to_username' => (string) ($asset->assignedTo?->username ?? ''),
- 'location' => (string) ($asset->location?->name ?? ''),
- 'company' => (string) ($asset->company?->name ?? ''),
- 'supplier' => (string) ($asset->supplier?->name ?? ''),
- 'last_checkout' => (string) ($asset->last_checkout ?? ''),
- 'last_checkin' => (string) ($asset->last_checkin ?? ''),
- 'expected_checkin' => (string) ($asset->expected_checkin ?? ''),
- 'notes' => (string) ($asset->notes ?? ''),
- 'order_number' => (string) ($asset->order_number ?? ''),
- 'purchase_date' => (string) ($asset->purchase_date ?? ''),
- 'purchase_cost' => (string) ($asset->purchase_cost ?? ''),
- 'warranty_months' => (string) ($asset->warranty_months ?? ''),
- 'warranty_expires' => (string) ($asset->warranty_expires ?? ''),
- default => '',
- };
- },
- $template,
- ) ?? '';
-
- return ['target' => $target, 'value' => $value];
- }
-
- /**
- * Splice the composed-notes payload (from composeNotesForPush)
- * into an outgoing vendor payload. Returns true when composed
- * notes were configured and spliced, false when there was
- * nothing to send. Callers that track which fields they pushed
- * (for post-push logging or event dispatch) pass their $touched
- * array by reference. The target field name gets appended to
- * it on success.
- *
- * Uses Arr::set so dotted target paths (Jamf's "general.notes"
- * shape) branch into nested payload structures rather than
- * writing a literal key with a dot in it.
- *
- * @param array<mixed> $payload
- * @param array<int, string> $touched
- */
- public function applyComposedNotesToPayload(Asset $asset, array &$payload, array &$touched = []): bool
- {
- $composedNotes = $this->composeNotesForPush($asset);
- if ($composedNotes === null) {
- return false;
- }
-
- \Illuminate\Support\Arr::set($payload, $composedNotes['target'], $composedNotes['value']);
- $touched[] = $composedNotes['target'];
-
- return true;
- }
-
- /**
- * Stored composed-notes template + target-override, exposed for
- * the settings-page form so it can pre-fill the two inputs.
- * Runtime callers use composeNotesForPush() instead, which
- * resolves the effective target (falling back to
- * PushableAdapter::notesFieldTarget()) and does the substitution
- * in one hit.
- *
- * @return array{template: string, target_override: ?string}
- */
- public function storedPushNotesConfig(): array
- {
- $template = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_template');
- $target = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_target');
-
- return [
- 'template' => $template,
- 'target_override' => $target === '' ? null : $target,
- ];
- }
-
- /**
- * True when this instance has ANY push configuration in place
- * (at least one field directed 'push' OR a composed-notes
- * template + target). Used by the controller's Push Now handler
- * to abort with a clear error before iterating asset rows when
- * the admin hit the button on a fresh or incorrectly-configured
- * adapter, instead of iterating N rows that each silent-no-op
- * and reporting an inaccurate success.
- */
- public function hasPushConfiguration(): bool
- {
- return $this->pushDirectedFields() !== [] || $this->hasComposedNotesConfigured();
- }
-
- /**
- * Cheap "should we bother trying to push composed notes?" check
- * used by pushPrologue to gate the vendor call without paying
- * the cost of rendering the template. True when the admin has a
- * non-blank push_notes_template AND a resolvable target field.
- */
- private function hasComposedNotesConfigured(): bool
- {
- $template = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_template');
-
- return trim($template) !== '' && $this->resolveComposedNotesTarget() !== null;
- }
-
- /**
- * Vendor field name for the composed-notes push. Admin's
- * override (push_notes_target config key) wins if set. Falls
- * back to the adapter's suggested default via
- * PushableAdapter::notesFieldTarget(). Null when neither is
- * set (adapter has no notes concept AND admin didn't name a
- * target field).
- */
- private function resolveComposedNotesTarget(): ?string
- {
- $stored = (string) SyncAdapterConfig::get($this->instance->id, 'push_notes_target');
- if ($stored !== '') {
- return $stored;
- }
-
- return $this instanceof PushableAdapter
- ? $this->notesFieldTarget()
- : null;
- }
-
- /**
- * Whether the composed-notes push UI should appear on this
- * adapter's settings page. Default is "yes if the adapter is
- * pushable at all" so existing adapters stay unchanged. Adapters
- * targeting APIs that have no notes-like field anywhere in their
- * push payload (Mosyle Manager v2's push elements, for example)
- * override this to false so admins don't fill in a template that
- * can never land. notesFieldTarget() returning null doesn't carry
- * this meaning (Workspace ONE / NinjaOne return null legitimately
- * because the admin picks the target).
- */
- public function supportsComposedNotesPush(): bool
- {
- return $this instanceof PushableAdapter && $this->canPush();
- }
-
/**
* Currently-selected target for a field, or the shipped default
* when no per-instance override exists. Standard fields fall back
diff --git a/app/SyncAdapters/WorkspaceOne/WorkspaceOneAdapter.php b/app/SyncAdapters/WorkspaceOne/WorkspaceOneAdapter.php
index 7947fa3d63..e945178a28 100644
--- a/app/SyncAdapters/WorkspaceOne/WorkspaceOneAdapter.php
+++ b/app/SyncAdapters/WorkspaceOne/WorkspaceOneAdapter.php
@@ -4,7 +4,7 @@ namespace App\SyncAdapters\WorkspaceOne;
use App\Models\Asset;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Carbon\Carbon;
use Illuminate\Support\Arr;
@@ -34,7 +34,7 @@ use Illuminate\Support\Facades\Log;
* sibling with a different schema is the right shape rather than
* making this schema conditional on auth mode.
*/
-class WorkspaceOneAdapter extends SyncAdapter implements PushableAdapter
+class WorkspaceOneAdapter extends PushableSyncAdapter
{
public static function typeLabel(): string
{
diff --git a/resources/views/blade/sync-adapter/form.blade.php b/resources/views/blade/sync-adapter/form.blade.php
index 65e406e1c0..7ae12bd813 100644
--- a/resources/views/blade/sync-adapter/form.blade.php
+++ b/resources/views/blade/sync-adapter/form.blade.php
@@ -368,9 +368,9 @@
{{-- Per-field target mapping. --}}
@php
// Show push controls only when the adapter implements
- // PushableAdapter AND canPush() (instance-level runtime check
+ // PushableSyncAdapter AND canPush() (instance-level runtime check
// (Fleet Free returns false because manual labels are Premium).
- $supportsPush = $adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush();
+ $supportsPush = $adapter instanceof \App\SyncAdapters\PushableSyncAdapter && $adapter->canPush();
$directionOptions = [
'pull' => trans('admin/settings/sync_adapters.direction_pull'),
'push' => trans('admin/settings/sync_adapters.direction_push'),
@@ -584,7 +584,7 @@
multiple candidates. Positioned after the standard + extras
mapping so admins finish configuring the per-field targets
before deciding what goes into the composed notes blob. --}}
- @if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush() && $adapter->supportsComposedNotesPush())
+ @if ($adapter instanceof \App\SyncAdapters\PushableSyncAdapter && $adapter->canPush() && $adapter->supportsComposedNotesPush())
<fieldset>
<x-form.legend icon="tip" help_text="{{ trans('admin/settings/sync_adapters.push_notes_section_intro') }}">
{{ trans('admin/settings/sync_adapters.push_notes_section_title') }}
@@ -640,7 +640,7 @@
<div class="form-group">
<div class="col-md-12">
- @if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush())
+ @if ($adapter instanceof \App\SyncAdapters\PushableSyncAdapter && $adapter->canPush())
<button
type="button"
class="btn btn-theme js-sync-diagnostic-button"
diff --git a/resources/views/blade/sync-adapter/panel.blade.php b/resources/views/blade/sync-adapter/panel.blade.php
index 806fc0eaf9..290292e10e 100644
--- a/resources/views/blade/sync-adapter/panel.blade.php
+++ b/resources/views/blade/sync-adapter/panel.blade.php
@@ -72,7 +72,7 @@
/>
{{ trans('admin/settings/sync_adapters.pull_dry_run_label') }}
</label>
- @if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush())
+ @if ($adapter instanceof \App\SyncAdapters\PushableSyncAdapter && $adapter->canPush())
<label class="form-control">
<x-input.checkbox
:name="$slug . '_push_dry_run'"
@@ -144,7 +144,7 @@
</span>
</form>
- @if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush())
+ @if ($adapter instanceof \App\SyncAdapters\PushableSyncAdapter && $adapter->canPush())
<form
method="POST"
action="{{ route('settings.adapters.push', $slug) }}"
@@ -183,7 +183,7 @@
{{-- Full-width tip callout --}}
<x-callout type="info" icon="tip" live="polite" style="margin-top: 10px;">
- @if ($adapter instanceof \App\SyncAdapters\PushableAdapter && $adapter->canPush())
+ @if ($adapter instanceof \App\SyncAdapters\PushableSyncAdapter && $adapter->canPush())
{!! trans('admin/settings/sync_adapters.large_fleet_note', [
'pull_command' => '<code>php artisan snipeit:pull-inventory '.e($slug).'</code>',
'push_command' => '<code>php artisan snipeit:push-inventory '.e($slug).'</code>',
diff --git a/tests/Feature/SyncAdapters/ComposedNotesForPushTest.php b/tests/Feature/SyncAdapters/ComposedNotesForPushTest.php
index 22ed1ff465..ccb0e657a8 100644
--- a/tests/Feature/SyncAdapters/ComposedNotesForPushTest.php
+++ b/tests/Feature/SyncAdapters/ComposedNotesForPushTest.php
@@ -10,7 +10,7 @@ use App\Models\Manufacturer;
use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
-use App\SyncAdapters\Fleet\FleetAdapter;
+use App\SyncAdapters\Jamf\JamfAdapter;
use Illuminate\Support\Facades\Crypt;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
@@ -28,7 +28,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function returns_null_when_no_template_configured(): void
{
- $adapter = $this->configuredFleetAdapter();
+ $adapter = $this->configuredJamfAdapter();
$asset = $this->makeAsset(['asset_tag' => 'ABC-123']);
$this->assertNull($adapter->composeNotesForPush($asset));
@@ -37,7 +37,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function returns_null_when_template_is_whitespace_only(): void
{
- $adapter = $this->configuredFleetAdapter();
+ $adapter = $this->configuredJamfAdapter();
SyncAdapterConfig::put($adapter->getInstanceId(), 'push_notes_template', " \n\t");
$asset = $this->makeAsset(['asset_tag' => 'ABC-123']);
@@ -47,9 +47,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function returns_null_when_no_target_can_be_resolved(): void
{
- // Fleet doesn't ship a notesFieldTarget default, so with no
- // admin override for push_notes_target we can't resolve one.
- $adapter = $this->configuredFleetAdapter();
+ $adapter = $this->configuredJamfAdapter();
SyncAdapterConfig::put($adapter->getInstanceId(), 'push_notes_template', 'Tag: {asset_tag}');
$asset = $this->makeAsset(['asset_tag' => 'ABC-123']);
@@ -59,7 +57,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function substitutes_native_placeholders_from_asset_columns(): void
{
- $adapter = $this->configuredFleetAdapterWithNotesTarget();
+ $adapter = $this->configuredJamfAdapterWithNotesTarget();
SyncAdapterConfig::put(
$adapter->getInstanceId(),
'push_notes_template',
@@ -86,7 +84,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function admin_target_override_wins_over_adapter_default(): void
{
- $adapter = $this->configuredFleetAdapter();
+ $adapter = $this->configuredJamfAdapter();
SyncAdapterConfig::put($adapter->getInstanceId(), 'push_notes_template', 'Tag: {asset_tag}');
SyncAdapterConfig::put($adapter->getInstanceId(), 'push_notes_target', 'custom.notes_field');
$asset = $this->makeAsset(['asset_tag' => 'ABC-123']);
@@ -101,7 +99,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function unknown_placeholders_render_blank(): void
{
- $adapter = $this->configuredFleetAdapterWithNotesTarget();
+ $adapter = $this->configuredJamfAdapterWithNotesTarget();
SyncAdapterConfig::put(
$adapter->getInstanceId(),
'push_notes_template',
@@ -118,7 +116,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function null_native_values_render_blank_not_literal(): void
{
- $adapter = $this->configuredFleetAdapterWithNotesTarget();
+ $adapter = $this->configuredJamfAdapterWithNotesTarget();
SyncAdapterConfig::put(
$adapter->getInstanceId(),
'push_notes_template',
@@ -136,7 +134,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function custom_field_placeholder_resolves_by_display_name(): void
{
- $adapter = $this->configuredFleetAdapterWithNotesTarget();
+ $adapter = $this->configuredJamfAdapterWithNotesTarget();
$field = CustomField::factory()->create([
'element' => 'text',
@@ -161,7 +159,7 @@ class ComposedNotesForPushTest extends TestCase
#[Test]
public function custom_field_with_unknown_name_renders_blank(): void
{
- $adapter = $this->configuredFleetAdapterWithNotesTarget();
+ $adapter = $this->configuredJamfAdapterWithNotesTarget();
SyncAdapterConfig::put(
$adapter->getInstanceId(),
'push_notes_template',
@@ -198,18 +196,24 @@ class ComposedNotesForPushTest extends TestCase
], $overrides));
}
- private function configuredFleetAdapter(): FleetAdapter
+ private function configuredJamfAdapter(): JamfAdapter
{
$instance = SyncAdapterInstance::create([
- 'adapter_type' => 'fleet',
- 'label' => 'Test Fleet '.uniqid(),
+ 'adapter_type' => 'jamf',
+ 'label' => 'Test Jamf ' . uniqid(),
'active' => true,
]);
- SyncAdapterConfig::put($instance->id, 'url', 'https://fleet.example.test');
+ SyncAdapterConfig::put($instance->id, 'url', 'https://jamf.example.test');
SyncAdapterConfig::put($instance->id, 'token', Crypt::encrypt('fake-token'));
- return new class($instance) extends FleetAdapter
+ // Jamf *does* ship a notesFieldTarget default, so we need to disable it
+ return new class($instance) extends JamfAdapter
{
+ public function notesFieldTarget(): ?string
+ {
+ return null;
+ }
+
public function getInstanceId(): int
{
return $this->instance->id;
@@ -218,12 +222,12 @@ class ComposedNotesForPushTest extends TestCase
}
/**
- * Fleet with an admin-set notes target so composeNotesForPush()
+ * Jamf with an admin-set notes target so composeNotesForPush()
* can resolve `target` and actually build a payload.
*/
- private function configuredFleetAdapterWithNotesTarget(): FleetAdapter
+ private function configuredJamfAdapterWithNotesTarget(): JamfAdapter
{
- $adapter = $this->configuredFleetAdapter();
+ $adapter = $this->configuredJamfAdapter();
SyncAdapterConfig::put($adapter->getInstanceId(), 'push_notes_target', 'notes');
return $adapter;
diff --git a/tests/Feature/SyncAdapters/CustomHttp/CustomHttpAdapterTest.php b/tests/Feature/SyncAdapters/CustomHttp/CustomHttpAdapterTest.php
index bcd229451c..0b7b5859e4 100644
--- a/tests/Feature/SyncAdapters/CustomHttp/CustomHttpAdapterTest.php
+++ b/tests/Feature/SyncAdapters/CustomHttp/CustomHttpAdapterTest.php
@@ -8,7 +8,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\CustomHttp\CustomHttpAdapter;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
@@ -783,7 +783,7 @@ class CustomHttpAdapterTest extends TestCase
'push_method' => 'PATCH',
]);
- $this->assertInstanceOf(PushableAdapter::class, $adapter);
+ $this->assertInstanceOf(PushableSyncAdapter::class, $adapter);
$this->assertTrue($adapter->canPush());
}
diff --git a/tests/Feature/SyncAdapters/GoogleWorkspace/GoogleWorkspacePushTest.php b/tests/Feature/SyncAdapters/GoogleWorkspace/GoogleWorkspacePushTest.php
index 57d1a98429..d767a6a5dc 100644
--- a/tests/Feature/SyncAdapters/GoogleWorkspace/GoogleWorkspacePushTest.php
+++ b/tests/Feature/SyncAdapters/GoogleWorkspace/GoogleWorkspacePushTest.php
@@ -8,7 +8,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\GoogleWorkspace\GoogleWorkspaceAdapter;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -41,7 +41,7 @@ class GoogleWorkspacePushTest extends TestCase
public function test_adapter_implements_pushable_interface(): void
{
- $this->assertInstanceOf(PushableAdapter::class, $this->configuredAdapter());
+ $this->assertInstanceOf(PushableSyncAdapter::class, $this->configuredAdapter());
}
public function test_composed_notes_template_patches_google_chrome_device(): void
diff --git a/tests/Feature/SyncAdapters/Intune/IntunePushTest.php b/tests/Feature/SyncAdapters/Intune/IntunePushTest.php
index 1a745299cc..38d6956002 100644
--- a/tests/Feature/SyncAdapters/Intune/IntunePushTest.php
+++ b/tests/Feature/SyncAdapters/Intune/IntunePushTest.php
@@ -8,7 +8,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Intune\IntuneAdapter;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -30,7 +30,7 @@ class IntunePushTest extends TestCase
public function test_intune_adapter_implements_pushable_interface()
{
- $this->assertInstanceOf(PushableAdapter::class, $this->configuredIntune());
+ $this->assertInstanceOf(PushableSyncAdapter::class, $this->configuredIntune());
}
public function test_push_notes_template_patches_intune_managed_device()
diff --git a/tests/Feature/SyncAdapters/Jamf/JamfPushTest.php b/tests/Feature/SyncAdapters/Jamf/JamfPushTest.php
index a7f39928b7..68efe22487 100644
--- a/tests/Feature/SyncAdapters/Jamf/JamfPushTest.php
+++ b/tests/Feature/SyncAdapters/Jamf/JamfPushTest.php
@@ -8,14 +8,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Jamf\JamfAdapter;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the Jamf Pro push path. Verifies the
- * PushableAdapter interface, the PATCH payload shape (asset_tag
+ * PushableSyncAdapter interface, the PATCH payload shape (asset_tag
* writes to general.assetTag per Jamf's ComputerGeneralUpdate
* schema), and dry-run behavior.
*/
@@ -29,7 +29,7 @@ class JamfPushTest extends TestCase
public function test_jamf_adapter_implements_pushable_interface()
{
- $this->assertInstanceOf(PushableAdapter::class, $this->configuredJamf());
+ $this->assertInstanceOf(PushableSyncAdapter::class, $this->configuredJamf());
}
public function test_push_asset_tag_writes_to_general_asset_tag_path()
diff --git a/tests/Feature/SyncAdapters/Kandji/KandjiPushTest.php b/tests/Feature/SyncAdapters/Kandji/KandjiPushTest.php
index 5dbd0b2ee1..a5bef8177a 100644
--- a/tests/Feature/SyncAdapters/Kandji/KandjiPushTest.php
+++ b/tests/Feature/SyncAdapters/Kandji/KandjiPushTest.php
@@ -7,7 +7,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Kandji\KandjiAdapter;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
@@ -15,7 +15,7 @@ use Tests\TestCase;
/**
* End-to-end coverage for the Kandji push path. Verifies the mapping
- * table's direction column, PushableAdapter dispatch, and the actual
+ * table's direction column, PushableSyncAdapter dispatch, and the actual
* PATCH shape (form-encoded asset_tag) that goes to Kandji.
*/
class KandjiPushTest extends TestCase
@@ -30,7 +30,7 @@ class KandjiPushTest extends TestCase
{
$adapter = $this->configuredKandji();
- $this->assertInstanceOf(PushableAdapter::class, $adapter);
+ $this->assertInstanceOf(PushableSyncAdapter::class, $adapter);
}
public function test_push_asset_tag_sends_patch_to_kandji()
diff --git a/tests/Feature/SyncAdapters/Mosyle/MosylePushTest.php b/tests/Feature/SyncAdapters/Mosyle/MosylePushTest.php
index 47cf1538d7..fcadc0db12 100644
--- a/tests/Feature/SyncAdapters/Mosyle/MosylePushTest.php
+++ b/tests/Feature/SyncAdapters/Mosyle/MosylePushTest.php
@@ -8,7 +8,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Mosyle\MosyleAdapter;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -29,7 +29,7 @@ class MosylePushTest extends TestCase
public function test_mosyle_adapter_implements_pushable_interface(): void
{
- $this->assertInstanceOf(PushableAdapter::class, $this->configuredMosyle());
+ $this->assertInstanceOf(PushableSyncAdapter::class, $this->configuredMosyle());
}
public function test_push_asset_tag_sends_elements_array_keyed_by_serial(): void
diff --git a/tests/Feature/SyncAdapters/MosyleBusiness/MosyleBusinessPushTest.php b/tests/Feature/SyncAdapters/MosyleBusiness/MosyleBusinessPushTest.php
index 9b31dfbb60..966cc025bd 100644
--- a/tests/Feature/SyncAdapters/MosyleBusiness/MosyleBusinessPushTest.php
+++ b/tests/Feature/SyncAdapters/MosyleBusiness/MosyleBusinessPushTest.php
@@ -8,7 +8,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\MosyleBusiness\MosyleBusinessAdapter;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -29,7 +29,7 @@ class MosyleBusinessPushTest extends TestCase
public function test_adapter_implements_pushable_interface(): void
{
- $this->assertInstanceOf(PushableAdapter::class, $this->configured());
+ $this->assertInstanceOf(PushableSyncAdapter::class, $this->configured());
}
public function test_push_asset_tag_sends_update_device_operation_at_top_level(): void
diff --git a/tests/Feature/SyncAdapters/NinjaOne/NinjaOnePushTest.php b/tests/Feature/SyncAdapters/NinjaOne/NinjaOnePushTest.php
index 30e747bd59..363d5aa17e 100644
--- a/tests/Feature/SyncAdapters/NinjaOne/NinjaOnePushTest.php
+++ b/tests/Feature/SyncAdapters/NinjaOne/NinjaOnePushTest.php
@@ -8,7 +8,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\NinjaOne\NinjaOneAdapter;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -30,7 +30,7 @@ class NinjaOnePushTest extends TestCase
public function test_ninjaone_adapter_implements_pushable_interface()
{
- $this->assertInstanceOf(PushableAdapter::class, $this->configuredNinja());
+ $this->assertInstanceOf(PushableSyncAdapter::class, $this->configuredNinja());
}
public function test_push_asset_tag_writes_to_configured_custom_field()
diff --git a/tests/Feature/SyncAdapters/WorkspaceOne/WorkspaceOnePushTest.php b/tests/Feature/SyncAdapters/WorkspaceOne/WorkspaceOnePushTest.php
index b2be14e7c6..f0f86e6ada 100644
--- a/tests/Feature/SyncAdapters/WorkspaceOne/WorkspaceOnePushTest.php
+++ b/tests/Feature/SyncAdapters/WorkspaceOne/WorkspaceOnePushTest.php
@@ -7,7 +7,7 @@ use App\Models\AssetExternalSource;
use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
-use App\SyncAdapters\PushableAdapter;
+use App\SyncAdapters\PushableSyncAdapter;
use App\SyncAdapters\WorkspaceOne\WorkspaceOneAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
@@ -28,7 +28,7 @@ class WorkspaceOnePushTest extends TestCase
public function test_workspace_one_adapter_implements_pushable_interface()
{
- $this->assertInstanceOf(PushableAdapter::class, $this->configuredWs1());
+ $this->assertInstanceOf(PushableSyncAdapter::class, $this->configuredWs1());
}
public function test_push_asset_tag_puts_asset_number_field()