AppMage

ServicePackRpc

This endpoint group exposes RPC methods for creating, updating, archiving, retrieving, and listing service packs, plus a reference-data helper for populating field values in client forms. The file defines the request schemas for each method, but the referenced ServicePackSchema and ServicePackService implementations were not available for inspection, so only the behavior directly visible in this RPC class is documented here.

Endpoints

POST /api/rpc (Method: ServicePackRpc.create)

  • Description: Creates a new service pack by forwarding the validated request body to ServicePackService.createPack(...).

  • Request Body:

    {
      "method": "ServicePackRpc.create",
      "params": {
        "...": "fields defined by `ServicePackSchema` except `_id`, `createdAt`, and `updatedAt`"
      }
    }
  • Parameters:

    Name Type Required Description
    params Object Yes A service pack payload validated against ServicePackSchema.omit({ _id: true, createdAt: true, updatedAt: true }). Exact fields could not be confirmed because the imported schema was not inspected.
  • Response:

    {
      "success": true,
      "data": {
        "...": "value returned by `ServicePackService.createPack(...)`"
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ServicePackRpc.create",
        "params": {
          "...": "service pack fields"
        }
      }'

POST /api/rpc (Method: ServicePackRpc.update)

  • Description: Updates an existing service pack by extracting _id from the request body and forwarding the remaining fields to ServicePackService.updatePack(...).

  • Request Body:

    {
      "method": "ServicePackRpc.update",
      "params": {
        "_id": "string",
        "...": "other fields defined by `ServicePackSchema.partial()`"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Identifier of the service pack to update.
    params Object Yes Partial service pack data validated against ServicePackSchema.partial().extend({ _id: z.string() }). Exact optional fields could not be confirmed because the imported schema was not inspected.
  • Response:

    {
      "success": true,
      "data": {
        "...": "value returned by `ServicePackService.updatePack(...)`"
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ServicePackRpc.update",
        "params": {
          "_id": "service-pack-id",
          "...": "fields to update"
        }
      }'

POST /api/rpc (Method: ServicePackRpc.delete)

  • Description: Archives a service pack identified by _id and returns a confirmation object.

  • Request Body:

    {
      "method": "ServicePackRpc.delete",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Identifier of the service pack to archive.
  • Response:

    {
      "success": true,
      "data": {
        "success": true,
        "message": "Service pack archived."
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ServicePackRpc.delete",
        "params": {
          "_id": "service-pack-id"
        }
      }'

POST /api/rpc (Method: ServicePackRpc.findById)

  • Description: Retrieves a service pack by _id and returns the result from ServicePackService.getPackById(...).

  • Request Body:

    {
      "method": "ServicePackRpc.findById",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Identifier of the service pack to retrieve.
  • Response:

    {
      "success": true,
      "data": {
        "...": "value returned by `ServicePackService.getPackById(...)`"
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ServicePackRpc.findById",
        "params": {
          "_id": "service-pack-id"
        }
      }'

POST /api/rpc (Method: ServicePackRpc.getData)

  • Description: Returns a paginated list of service packs by translating page and pageSize into skip and limit, then forwarding the query to ServicePackService.listPacks(...).

  • Request Body:

    {
      "method": "ServicePackRpc.getData",
      "params": {
        "filter": {},
        "sort": {},
        "page": 1,
        "pageSize": 25
      }
    }
  • Parameters:

    Name Type Required Description
    filter Any Yes Filter object passed directly to ServicePackService.listPacks(...). The schema does not constrain its shape.
    sort Any Yes Sort specification passed directly to ServicePackService.listPacks(...). The schema does not constrain its shape.
    page Number Yes Page number used to calculate skip as (page - 1) * pageSize.
    pageSize Number Yes Number of records per page used as limit.
  • Response:

    {
      "success": true,
      "data": {
        "...": "value returned by `ServicePackService.listPacks(...)`"
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ServicePackRpc.getData",
        "params": {
          "filter": {},
          "sort": {},
          "page": 1,
          "pageSize": 25
        }
      }'

POST /api/rpc (Method: ServicePackRpc.getFieldValues)

  • Description: Provides reference values for fields by listing service packs with an optional filter and mapping each item to { value, label } using the configured value and display fields.

  • Request Body:

    {
      "method": "ServicePackRpc.getFieldValues",
      "params": {
        "fieldName": "string",
        "reference": {
          "valueField": "string",
          "displayField": "string",
          "filter": {}
        }
      }
    }
  • Parameters:

    Name Type Required Description
    fieldName String Yes Field name associated with the reference lookup. It is validated but not used in the method body.
    reference Object Yes Reference configuration object.
    reference.valueField String Yes Object property used as the returned value.
    reference.displayField String Yes Object property used as the returned label.
    reference.filter Record<String, Any> No Optional filter object passed to ServicePackService.listPacks(...).
  • Response:

    {
      "success": true,
      "data": [
        {
          "value": "string",
          "label": "string"
        }
      ]
    }

    The method limits the lookup to 1000 records and maps each returned item into a { value, label } object using the configured field names.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ServicePackRpc.getFieldValues",
        "params": {
          "fieldName": "servicePackId",
          "reference": {
            "valueField": "_id",
            "displayField": "name",
            "filter": {}
          }
        }
      }'