Skip to content
Snippets Groups Projects
Verified Commit 35216902 authored by Coby Sher's avatar Coby Sher
Browse files

Issue #3280391:

- Refactor interfaces for GetObjectParams and GetObjectByPathParams
to share some types
- Add more detailed comments in params interface to enhance DX
- Add the optional anon type to the shared params to make requests anonymous
parent e883bbd4
Branches
Tags
3 merge requests!50Issue #3280391: Add anon support to getObjectByPath,!49Add Production Docs Config,!47Issue #3280391: Allow anonymous requests when valid credentials are supplied
......@@ -117,29 +117,63 @@ export interface jsonapiLinkObject {
__typename: string;
}
/**
* Describes get object parameters.
*/
export interface GetObjectParams {
interface SharedParams {
/**
* The name of the object in Drupal
* @example 'node--article'
*/
objectName: string;
id?: string;
/**
* If included, the server response is passed to allow DrupalState to set headers
* among other things.
* @see {@link https://nodejs.org/docs/latest-v16.x/api/http.html#class-httpserverresponse}
*/
res?: ServerResponse | boolean;
/**
* A string of Drupal JSON:API parameters.
* @example 'include=field_media_image,
* Or an instance of DrupalJsonApi Params.
* @see {@link https://www.npmjs.com/package/drupal-jsonapi-params}
*/
params?: string | DrupalJsonApiParams;
/**
* If true, data will be fetched from Drupal regardless of its existence in state
*/
refresh?: boolean;
/**
* If true and valid credentials are passed in when creating the instance of
* DrupalState, the request will be made anonymously
*/
anon?: boolean;
/**
* @deprecated since 4.0.0
*/
query?: string | boolean;
}
/**
* Describes get object parameters.
*/
export interface GetObjectParams extends SharedParams {
/**
* The id of the object in Drupal
*/
id?: string;
/**
* If true, DrupalState fetches all pages of an object if there is more than one.
*/
all?: boolean;
refresh?: boolean;
}
/**
* Describes get object by Path alias.
*/
export interface GetObjectByPathParams {
objectName: string;
export interface GetObjectByPathParams extends SharedParams {
/**
* The path to the object that Decoupled Router resolves to
* @see {@link https://www.drupal.org/project/decoupled_router}
* @example '/recipes/fiery-chili-sauce'
*/
path: string;
res?: ServerResponse | boolean;
params?: string | DrupalJsonApiParams;
query?: string | boolean;
refresh?: boolean;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment