|
| 1 | +import type { |
| 2 | + CursorPaginatedCollectionProp, |
| 3 | + GetFragmentParams, |
| 4 | + GetSpaceEnvironmentParams, |
| 5 | +} from '../../common-types' |
| 6 | +import type { |
| 7 | + CreateFragmentProps, |
| 8 | + FragmentProps, |
| 9 | + FragmentQueryOptions, |
| 10 | + UpdateFragmentProps, |
| 11 | +} from '../../entities/fragment' |
| 12 | +import type { OptionalDefaults } from '../wrappers/wrap' |
| 13 | + |
| 14 | +export type FragmentPlainClientAPI = { |
| 15 | + /** |
| 16 | + * Fetches all fragments for a space and environment |
| 17 | + * @param params the space, environment IDs and query options (see {@link FragmentQueryOptions}) |
| 18 | + * @returns a collection of fragments |
| 19 | + * @throws if the request fails, or the space or environment is not found |
| 20 | + * @internal - Experimental endpoint, subject to breaking changes without notice |
| 21 | + * @example |
| 22 | + * ```javascript |
| 23 | + * const fragments = await client.fragment.getMany({ |
| 24 | + * spaceId: '<space_id>', |
| 25 | + * environmentId: '<environment_id>', |
| 26 | + * query: { |
| 27 | + * limit: 10, |
| 28 | + * }, |
| 29 | + * }); |
| 30 | + * ``` |
| 31 | + */ |
| 32 | + getMany( |
| 33 | + params: OptionalDefaults<GetSpaceEnvironmentParams & { query: FragmentQueryOptions }>, |
| 34 | + ): Promise<CursorPaginatedCollectionProp<FragmentProps>> |
| 35 | + |
| 36 | + /** |
| 37 | + * Fetches a single fragment by ID |
| 38 | + * @param params the space, environment, and fragment IDs |
| 39 | + * @returns the fragment |
| 40 | + * @throws if the request fails, or the space, environment, or fragment is not found |
| 41 | + * @internal - Experimental endpoint, subject to breaking changes without notice |
| 42 | + * @example |
| 43 | + * ```javascript |
| 44 | + * const fragment = await client.fragment.get({ |
| 45 | + * spaceId: '<space_id>', |
| 46 | + * environmentId: '<environment_id>', |
| 47 | + * fragmentId: '<fragment_id>', |
| 48 | + * }); |
| 49 | + * ``` |
| 50 | + */ |
| 51 | + get(params: OptionalDefaults<GetFragmentParams>): Promise<FragmentProps> |
| 52 | + |
| 53 | + /** |
| 54 | + * Creates a new fragment |
| 55 | + * @param params the space and environment IDs |
| 56 | + * @param data the fragment data |
| 57 | + * @returns the created fragment |
| 58 | + * @throws if the request fails, or the space or environment is not found |
| 59 | + * @internal - Experimental endpoint, subject to breaking changes without notice |
| 60 | + * @example |
| 61 | + * ```javascript |
| 62 | + * const fragment = await client.fragment.create({ |
| 63 | + * spaceId: '<space_id>', |
| 64 | + * environmentId: '<environment_id>', |
| 65 | + * }, { |
| 66 | + * name: 'My Fragment', |
| 67 | + * description: 'A new fragment', |
| 68 | + * componentTypeId: '<component_type_id>', |
| 69 | + * viewports: [], |
| 70 | + * designProperties: {}, |
| 71 | + * dimensionKeyMap: { designProperties: {} }, |
| 72 | + * }); |
| 73 | + * ``` |
| 74 | + */ |
| 75 | + create( |
| 76 | + params: OptionalDefaults<GetSpaceEnvironmentParams>, |
| 77 | + data: CreateFragmentProps, |
| 78 | + ): Promise<FragmentProps> |
| 79 | + |
| 80 | + /** |
| 81 | + * Updates a fragment |
| 82 | + * @param params the space, environment, and fragment IDs |
| 83 | + * @param data the fragment data (including sys.version) |
| 84 | + * @returns the updated fragment |
| 85 | + * @throws if the request fails, or the space, environment, or fragment is not found |
| 86 | + * @internal - Experimental endpoint, subject to breaking changes without notice |
| 87 | + * @example |
| 88 | + * ```javascript |
| 89 | + * const fragment = await client.fragment.update({ |
| 90 | + * spaceId: '<space_id>', |
| 91 | + * environmentId: '<environment_id>', |
| 92 | + * fragmentId: '<fragment_id>', |
| 93 | + * }, fragmentData); |
| 94 | + * ``` |
| 95 | + */ |
| 96 | + update( |
| 97 | + params: OptionalDefaults<GetFragmentParams>, |
| 98 | + data: UpdateFragmentProps, |
| 99 | + ): Promise<FragmentProps> |
| 100 | + |
| 101 | + /** |
| 102 | + * Deletes a fragment |
| 103 | + * @param params the space, environment, and fragment IDs |
| 104 | + * @throws if the request fails, or the space, environment, or fragment is not found |
| 105 | + * @internal - Experimental endpoint, subject to breaking changes without notice |
| 106 | + * @example |
| 107 | + * ```javascript |
| 108 | + * await client.fragment.delete({ |
| 109 | + * spaceId: '<space_id>', |
| 110 | + * environmentId: '<environment_id>', |
| 111 | + * fragmentId: '<fragment_id>', |
| 112 | + * }); |
| 113 | + * ``` |
| 114 | + */ |
| 115 | + delete(params: OptionalDefaults<GetFragmentParams>): Promise<void> |
| 116 | + |
| 117 | + /** |
| 118 | + * Publishes a fragment |
| 119 | + * @param params the space, environment, and fragment IDs, plus the current version |
| 120 | + * @returns the published fragment |
| 121 | + * @throws if the request fails, or the space, environment, or fragment is not found |
| 122 | + * @internal - Experimental endpoint, subject to breaking changes without notice |
| 123 | + * @example |
| 124 | + * ```javascript |
| 125 | + * const fragment = await client.fragment.publish({ |
| 126 | + * spaceId: '<space_id>', |
| 127 | + * environmentId: '<environment_id>', |
| 128 | + * fragmentId: '<fragment_id>', |
| 129 | + * version: 1, |
| 130 | + * }); |
| 131 | + * ``` |
| 132 | + */ |
| 133 | + publish(params: OptionalDefaults<GetFragmentParams & { version: number }>): Promise<FragmentProps> |
| 134 | + |
| 135 | + /** |
| 136 | + * Unpublishes a fragment |
| 137 | + * @param params the space, environment, and fragment IDs, plus the current version |
| 138 | + * @returns the unpublished fragment |
| 139 | + * @throws if the request fails, or the space, environment, or fragment is not found |
| 140 | + * @internal - Experimental endpoint, subject to breaking changes without notice |
| 141 | + * @example |
| 142 | + * ```javascript |
| 143 | + * const fragment = await client.fragment.unpublish({ |
| 144 | + * spaceId: '<space_id>', |
| 145 | + * environmentId: '<environment_id>', |
| 146 | + * fragmentId: '<fragment_id>', |
| 147 | + * version: 2, |
| 148 | + * }); |
| 149 | + * ``` |
| 150 | + */ |
| 151 | + unpublish( |
| 152 | + params: OptionalDefaults<GetFragmentParams & { version: number }>, |
| 153 | + ): Promise<FragmentProps> |
| 154 | +} |
0 commit comments