Skip to content

Commit

Permalink
chore: update jsdoc for NER (#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
msieroslawska authored Sep 30, 2024
1 parent d2ed401 commit d1e49e7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 38 deletions.
25 changes: 14 additions & 11 deletions lib/plain/entities/resource-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import type { OptionalDefaults } from '../wrappers/wrap'

export type ResourceProviderPlainClientAPI = {
/**
* Fetch a Resource Provider
* Fetches a Resource Provider
* @param params entity IDs to identify the Resource Provider
* @returns the App Definition config
* @throws if the request fails, or the Resource Provider is not found
* @returns the Resource Provider
* @throws if the request fails or the Resource Provider is not found
* @example
* ```javascript
* const resourceProvider = await client.resourceProvider.get({
Expand All @@ -23,15 +23,17 @@ export type ResourceProviderPlainClientAPI = {
get(params: OptionalDefaults<GetResourceProviderParams>): Promise<ResourceProviderProps>

/**
* Creates or updates a Resource Provider
* Creates a Resource Provider
* @param params entity IDs to identify the Resource Provider
* @param rawData the ResourceProvider
* @returns the created or updated Resource Provider
* @throws if the request fails, the App Definition or Resource Provider is not found, or the payload is malformed
* @param rawData the Resource Provider data
* @returns the created Resource Provider
* @throws if the request fails, the App Definition is not found,
* a Resource Provider associated with the organization and app definition already exists,
* or the payload is malformed
* @example
* ```javascript
* // You need a valid AppDefinition with an activated AppBundle that has a contentful function configured
* const appInstallation = await client.resourceProvider.upsert(
* // You need a valid AppDefinition with an activated AppBundle that has a configured Contentful function
* const resourceProvider = await client.resourceProvider.upsert(
* {
* organizationId: '<organization_id>',
* appDefinitionId: '<app_definition_id>',
Expand All @@ -51,9 +53,10 @@ export type ResourceProviderPlainClientAPI = {
): Promise<ResourceProviderProps>

/**
* Delete a ResourceProvider
* Deletes a ResourceProvider
* @param params entity IDs to identify the Resource Provider
* @throws if the request fails, or the Resource Provider is not found
* @throws if the request fails, the Resource Provider is not found
* or the Resource Provider is associated with an existing Resource Type
* @example
* ```javascript
* await client.resourceProvider.delete({
Expand Down
49 changes: 29 additions & 20 deletions lib/plain/entities/resource-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import type { SpaceEnvResourceTypeProps } from '../../entities/resource-type'

export type ResourceTypePlainClientAPI = {
/*
* Fetch a Resource Type
* Fetches a Resource Type
* @param params entity IDs to identify the Resource Type
* @returns the Resource Type
* @throws if the request fails, or the Resource Type is not found
* @throws if the request fails or the Resource Type is not found
* @example
* ```javascript
* const resourceType = await client.resourceType.get({
* organizationId: '<organization_id>',
* appDefinitionId: '<app_definition_id>',
* resourceTypeId: '<resource_type_id>',
* resourceTypeId: '<resource_provider_id>:<resource_type_name>',
* });
* ```
*/
Expand All @@ -31,23 +31,30 @@ export type ResourceTypePlainClientAPI = {
/*
* Creates or updates a Resource Type
* @param params entity IDs to identify the Resource Type
* @param rawData the ResourceType
* @param rawData the Resource Type data
* @returns the created or updated Resource Type
* @throws if the request fails, the App Definition or Resource Provider is not found, or the payload is malformed
* @throws if the request fails, the App Definition or Resource Provider is not found,
* default field mapping has invalid properties or the payload is malformed
* @example
* ```javascript
* // You need a valid AppDefinition with an activated AppBundle that has a contentful function configured
* // You need a valid AppDefinition with an activated AppBundle that has a configured Contentful function
* const resourceType = await client.resourceType.upsert(
* {
* organizationId: '<organization_id>',
* appDefinitionId: '<app_definition_id>',
* resourceTypeId: '<resource_type_id>',
* resourceTypeId: '<resource_provider_id>:<resource_type_name>',
* },
* rawData: {
* name: '<resource_type_name>',
* defaultFieldMapping: {
* title: '<field_id>',
* },
* defaultFieldMapping: {
* externalUrl: '{ /externalUrl }',
* title: '{ /name }',
* subtitle: 'Entity ID: { /urn }',
* image: {
* altText: '{ /name }',
* url: '{ /image/url }'
* }
* },
* }
* );
* ```
Expand All @@ -59,26 +66,26 @@ export type ResourceTypePlainClientAPI = {
): Promise<ResourceTypeProps>

/*
* Delete a ResourceType
* Deletes a ResourceType
* @param params entity IDs to identify the Resource Type
* @throws if the request fails, or the Resource Type is not found
* @throws if the request fails or the Resource Type is not found
* @example
* ```javascript
* await client.resourceType.delete({
* organizationId: '<organization_id>',
* appDefinitionId: '<app_definition_id>',
* resourceTypeId: '<resource_type_id>',
* resourceTypeId: '<resource_provider_id>:<resource_type_name>',
* });
* ```
*/
delete(params: OptionalDefaults<GetResourceTypeParams>): Promise<any>

/*
* Fetch all Resource Types for an environment
* @param params entity IDs to identify the Resource Type
* @params Optional query params for cursor pagination
* @returns all Resource Types based on the last NER app installed in the environment
* @throws if the request fails, or no Resource Type is found
* Fetches all Resource Types for an environment, based on the most recent installed NER app
* @param params entity IDs to identify the Resource Type collection
* @params optional query params for cursor pagination
* @returns Resource Types collection
* @throws if the request fails or there are no apps installed in the environment
* @example
* ```javascript
* const resourceTypes = await client.resourceType.getForEnvironment({
Expand All @@ -92,8 +99,10 @@ export type ResourceTypePlainClientAPI = {
): Promise<CursorPaginatedCollectionProp<SpaceEnvResourceTypeProps>>

/*
* Fetch all Resource Types
* @returns all Resource Types
* Fetches all Resource Types
* @param params entity IDs to identify the Resource Type collection
* @returns Resource Type collection
* @throws if the request fails
* @example
* ```javascript
* const resourceTypes = await client.resourceType.getMany({
Expand Down
16 changes: 9 additions & 7 deletions lib/plain/entities/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ import type { ResourceProps, ResourceQueryOptions } from '../../entities/resourc

export type ResourcePlainAPI = {
/**
* Fetch Resources
* Fetches all Resources.
* Supports fetching specific Resources by URNs or searching by a text query.
* @param params entity IDs to identify the Resources
* @returns the App Definition config
* @throws if the request fails, or the Resource Type is not found
* @params optional query params for search or lookup events
* @returns the Resources collection
* @throws if the request fails or the Resource Type is not found
* @example
* ```javascript
* // Lookup example
* const resourceProvider = await client.resource.getMany({
* const resources = await client.resource.getMany({
* spaceId: '<space_id>',
* environmentId: '<environment_id>',
* resourceTypeId: '<resource_type_id>',
* resourceTypeId: '<resource_provider_id>:<resource_type_name>',
* query: {
* 'sys.urn[in]': '<resource_urn1>,<resource_urn2>',
* limit': <number>,
* }
* });
*
* // Search example
* const resourceProvider = await client.resource.getMany({
* const resources = await client.resource.getMany({
* spaceId: '<space_id>',
* environmentId: '<environment_id>',
* resourceTypeId: '<resource_type_id>',
* resourceTypeId: '<resource_provider_id>:<resource_type_name>',
* query: {
* 'query': 'text',
* 'limit': <number>,
Expand Down

0 comments on commit d1e49e7

Please sign in to comment.