@mybe/sdk 1.1.1 → 1.1.2
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/README.md +31 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/types.d.ts +53 -2
- package/dist/types.js +51 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -471,22 +471,23 @@ console.log(`${stagingOnly.length} posts only in staging`);
|
|
|
471
471
|
|
|
472
472
|
### Multi-locale Content
|
|
473
473
|
|
|
474
|
-
Fetch content in different languages using the locale filter:
|
|
474
|
+
Fetch content in different languages using the locale filter. **TypeScript will autocomplete all supported locale codes** when you type `locale: ''`:
|
|
475
475
|
|
|
476
476
|
```typescript
|
|
477
477
|
const sdk = new MybeSDK({ apiKey: 'your-api-key' });
|
|
478
478
|
|
|
479
479
|
// Fetch English content
|
|
480
|
+
// TypeScript autocompletes: 'en-US', 'en-GB', 'en-CA', 'en-AU'
|
|
480
481
|
const englishPosts = await sdk.getContentByType('blog-post-type-id', {
|
|
481
482
|
status: 'published',
|
|
482
|
-
locale: 'en-US',
|
|
483
|
+
locale: 'en-US', // ✨ Autocomplete suggests all 31 supported locales!
|
|
483
484
|
limit: 10
|
|
484
485
|
});
|
|
485
486
|
|
|
486
487
|
// Fetch Bangla content
|
|
487
488
|
const banglaPosts = await sdk.getContentByType('blog-post-type-id', {
|
|
488
489
|
status: 'published',
|
|
489
|
-
locale: 'bn-BD',
|
|
490
|
+
locale: 'bn-BD', // ✨ Type-safe locale codes
|
|
490
491
|
limit: 10
|
|
491
492
|
});
|
|
492
493
|
|
|
@@ -505,6 +506,22 @@ const spanishPosts = await sdk.getContentByType('blog-post-type-id', {
|
|
|
505
506
|
});
|
|
506
507
|
```
|
|
507
508
|
|
|
509
|
+
**TypeScript Autocomplete Support:**
|
|
510
|
+
|
|
511
|
+
The SDK provides full TypeScript autocomplete for all 31 supported locales:
|
|
512
|
+
|
|
513
|
+
```typescript
|
|
514
|
+
import { SUPPORTED_LOCALES, type SupportedLocale } from '@mybe/sdk';
|
|
515
|
+
|
|
516
|
+
// View all supported locales
|
|
517
|
+
console.log(SUPPORTED_LOCALES);
|
|
518
|
+
// ['en-US', 'bn-BD', 'fr-FR', 'es-ES', 'de-DE', 'it-IT', ...]
|
|
519
|
+
|
|
520
|
+
// Use the type for type-safe locale handling
|
|
521
|
+
const userLocale: SupportedLocale = 'ja-JP'; // ✅ Valid
|
|
522
|
+
const invalidLocale: SupportedLocale = 'invalid'; // ❌ TypeScript error!
|
|
523
|
+
```
|
|
524
|
+
|
|
508
525
|
**Building a Multi-language Website:**
|
|
509
526
|
|
|
510
527
|
```typescript
|
|
@@ -525,12 +542,17 @@ localizedContent.data.forEach(item => {
|
|
|
525
542
|
});
|
|
526
543
|
```
|
|
527
544
|
|
|
528
|
-
**Supported Locales:**
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
- `
|
|
533
|
-
-
|
|
545
|
+
**All Supported Locales:**
|
|
546
|
+
|
|
547
|
+
The SDK supports 31 locales with full TypeScript autocomplete:
|
|
548
|
+
|
|
549
|
+
- **English**: `en-US`, `en-GB`, `en-CA`, `en-AU`
|
|
550
|
+
- **European**: `fr-FR`, `es-ES`, `de-DE`, `it-IT`, `pt-PT`, `nl-NL`, `sv-SE`, `pl-PL`, `ru-RU`
|
|
551
|
+
- **Americas**: `pt-BR`, `es-MX`, `es-AR`, `fr-CA`
|
|
552
|
+
- **Asia-Pacific**: `ja-JP`, `ko-KR`, `zh-CN`, `zh-TW`, `hi-IN`, `th-TH`, `vi-VN`, `id-ID`, `ms-MY`, `fil-PH`, `bn-BD`
|
|
553
|
+
- **Middle East & Africa**: `ar-SA`, `tr-TR`, `he-IL`
|
|
554
|
+
|
|
555
|
+
**Note:** When you type `locale: ''` in your IDE, TypeScript will show all available options!
|
|
534
556
|
|
|
535
557
|
## GraphQL API
|
|
536
558
|
|
package/dist/index.d.ts
CHANGED
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export { MybeSDK } from './client.js';
|
|
23
|
-
export { MybeSDKConfig, ContentType, ContentEntry, ContentFilterOptions, PaginationOptions, PaginationResponse, APIResponse, ContentListResponse, } from './types.js';
|
|
23
|
+
export { MybeSDKConfig, ContentType, ContentEntry, ContentFilterOptions, PaginationOptions, PaginationResponse, APIResponse, ContentListResponse, SupportedLocale, SUPPORTED_LOCALES, } from './types.js';
|
|
24
24
|
export { MybeSDKError, NotFoundError, UnauthorizedError, ValidationError, ServerError, ForbiddenError, } from './errors.js';
|
package/dist/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported locale codes for content localization.
|
|
3
|
+
*
|
|
4
|
+
* These locales are supported by Mybe CMS for multi-language content.
|
|
5
|
+
* When you specify a locale in your queries, TypeScript will autocomplete
|
|
6
|
+
* with these values.
|
|
7
|
+
*
|
|
8
|
+
* Source: Synced from apps/web/lib/locales.ts
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // TypeScript will autocomplete locale values
|
|
13
|
+
* const content = await sdk.getContentByType('blog-post-id', {
|
|
14
|
+
* locale: 'en-US', // Autocomplete suggests all supported locales
|
|
15
|
+
* status: 'published'
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const SUPPORTED_LOCALES: readonly ["en-US", "bn-BD", "fr-FR", "es-ES", "de-DE", "it-IT", "pt-PT", "nl-NL", "sv-SE", "pl-PL", "ru-RU", "pt-BR", "es-MX", "es-AR", "en-CA", "fr-CA", "ja-JP", "ko-KR", "zh-CN", "zh-TW", "hi-IN", "th-TH", "vi-VN", "id-ID", "ms-MY", "fil-PH", "ar-SA", "tr-TR", "he-IL", "en-GB", "en-AU"];
|
|
20
|
+
/**
|
|
21
|
+
* Type representing all supported locale codes.
|
|
22
|
+
*
|
|
23
|
+
* This type provides autocomplete for locale values in your IDE.
|
|
24
|
+
*
|
|
25
|
+
* @example 'en-US' | 'fr-FR' | 'es-ES' | 'bn-BD' | ...
|
|
26
|
+
*/
|
|
27
|
+
export type SupportedLocale = typeof SUPPORTED_LOCALES[number];
|
|
1
28
|
/**
|
|
2
29
|
* SDK Configuration
|
|
3
30
|
*/
|
|
@@ -64,7 +91,14 @@ export interface ContentEntry {
|
|
|
64
91
|
status: 'draft' | 'published' | 'archived';
|
|
65
92
|
contentType?: ContentTypeMetadata;
|
|
66
93
|
data: Record<string, any>;
|
|
67
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Locale code for this content entry.
|
|
96
|
+
*
|
|
97
|
+
* TypeScript will autocomplete with all supported locale codes.
|
|
98
|
+
*
|
|
99
|
+
* @example 'en-US' | 'fr-FR' | 'es-ES' | 'bn-BD' | ...
|
|
100
|
+
*/
|
|
101
|
+
locale?: SupportedLocale;
|
|
68
102
|
created_by: string;
|
|
69
103
|
updated_by?: string;
|
|
70
104
|
published_at?: string;
|
|
@@ -83,7 +117,24 @@ export interface PaginationOptions {
|
|
|
83
117
|
*/
|
|
84
118
|
export interface ContentFilterOptions extends PaginationOptions {
|
|
85
119
|
status?: 'draft' | 'published' | 'archived';
|
|
86
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Filter content by locale.
|
|
122
|
+
*
|
|
123
|
+
* TypeScript will autocomplete with all supported locale codes when you type.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* // Get English content
|
|
128
|
+
* await sdk.getContentByType('blog-id', { locale: 'en-US' });
|
|
129
|
+
*
|
|
130
|
+
* // Get French content
|
|
131
|
+
* await sdk.getContentByType('blog-id', { locale: 'fr-FR' });
|
|
132
|
+
*
|
|
133
|
+
* // Get Bangla content
|
|
134
|
+
* await sdk.getContentByType('blog-id', { locale: 'bn-BD' });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
locale?: SupportedLocale;
|
|
87
138
|
include?: number;
|
|
88
139
|
}
|
|
89
140
|
/**
|
package/dist/types.js
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Supported locale codes for content localization.
|
|
3
|
+
*
|
|
4
|
+
* These locales are supported by Mybe CMS for multi-language content.
|
|
5
|
+
* When you specify a locale in your queries, TypeScript will autocomplete
|
|
6
|
+
* with these values.
|
|
7
|
+
*
|
|
8
|
+
* Source: Synced from apps/web/lib/locales.ts
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // TypeScript will autocomplete locale values
|
|
13
|
+
* const content = await sdk.getContentByType('blog-post-id', {
|
|
14
|
+
* locale: 'en-US', // Autocomplete suggests all supported locales
|
|
15
|
+
* status: 'published'
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export const SUPPORTED_LOCALES = [
|
|
20
|
+
"en-US",
|
|
21
|
+
"bn-BD",
|
|
22
|
+
"fr-FR",
|
|
23
|
+
"es-ES",
|
|
24
|
+
"de-DE",
|
|
25
|
+
"it-IT",
|
|
26
|
+
"pt-PT",
|
|
27
|
+
"nl-NL",
|
|
28
|
+
"sv-SE",
|
|
29
|
+
"pl-PL",
|
|
30
|
+
"ru-RU",
|
|
31
|
+
"pt-BR",
|
|
32
|
+
"es-MX",
|
|
33
|
+
"es-AR",
|
|
34
|
+
"en-CA",
|
|
35
|
+
"fr-CA",
|
|
36
|
+
"ja-JP",
|
|
37
|
+
"ko-KR",
|
|
38
|
+
"zh-CN",
|
|
39
|
+
"zh-TW",
|
|
40
|
+
"hi-IN",
|
|
41
|
+
"th-TH",
|
|
42
|
+
"vi-VN",
|
|
43
|
+
"id-ID",
|
|
44
|
+
"ms-MY",
|
|
45
|
+
"fil-PH",
|
|
46
|
+
"ar-SA",
|
|
47
|
+
"tr-TR",
|
|
48
|
+
"he-IL",
|
|
49
|
+
"en-GB",
|
|
50
|
+
"en-AU",
|
|
51
|
+
];
|