@mybe/sdk 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +11 -0
- package/dist/client.js +24 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -31,4 +31,15 @@ export declare class MybeSDK {
|
|
|
31
31
|
* Get all content entries for a project
|
|
32
32
|
*/
|
|
33
33
|
getContentByProject(projectId: string, options?: ContentFilterOptions): Promise<ContentListResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Get a single content entry by field value
|
|
36
|
+
* Similar to Contentful's getEntries with field filters
|
|
37
|
+
* @example
|
|
38
|
+
* // Get service by href field
|
|
39
|
+
* const service = await sdk.getContentByField('service-type-id', 'href', '/services/web-dev');
|
|
40
|
+
*
|
|
41
|
+
* // Get blog post by slug field
|
|
42
|
+
* const post = await sdk.getContentByField('blog-type-id', 'slug', 'my-first-post');
|
|
43
|
+
*/
|
|
44
|
+
getContentByField(contentTypeId: string, fieldName: string, fieldValue: string): Promise<ContentEntry | null>;
|
|
34
45
|
}
|
package/dist/client.js
CHANGED
|
@@ -126,4 +126,28 @@ export class MybeSDK {
|
|
|
126
126
|
const queryString = this.buildQueryString(options);
|
|
127
127
|
return await this.request(`/content-entry/project/${projectId}${queryString}`);
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Get a single content entry by field value
|
|
131
|
+
* Similar to Contentful's getEntries with field filters
|
|
132
|
+
* @example
|
|
133
|
+
* // Get service by href field
|
|
134
|
+
* const service = await sdk.getContentByField('service-type-id', 'href', '/services/web-dev');
|
|
135
|
+
*
|
|
136
|
+
* // Get blog post by slug field
|
|
137
|
+
* const post = await sdk.getContentByField('blog-type-id', 'slug', 'my-first-post');
|
|
138
|
+
*/
|
|
139
|
+
async getContentByField(contentTypeId, fieldName, fieldValue) {
|
|
140
|
+
try {
|
|
141
|
+
const encodedValue = encodeURIComponent(fieldValue);
|
|
142
|
+
const response = await this.request(`/type/${contentTypeId}/field/${fieldName}/${encodedValue}`);
|
|
143
|
+
return response.data;
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
// If it's a 404, return null instead of throwing
|
|
147
|
+
if (error instanceof NotFoundError) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
129
153
|
}
|