@crosspost/types 0.1.3 → 0.1.4

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/index.js CHANGED
@@ -1,18 +1,20 @@
1
1
  // src/common.ts
2
2
  import { z } from "zod";
3
- var PlatformSchema = z.enum([
4
- "unknown",
5
- "twitter"
6
- // Add more platforms as they're implemented
7
- // 'linkedin',
8
- // 'facebook',
9
- // 'instagram',
10
- ]).describe("Social media platform");
11
3
  var Platform = /* @__PURE__ */ ((Platform2) => {
12
4
  Platform2["UNKNOWN"] = "unknown";
13
5
  Platform2["TWITTER"] = "twitter";
14
6
  return Platform2;
15
7
  })(Platform || {});
8
+ var PlatformSchema = z.nativeEnum(Platform).describe("Social media platform");
9
+ var SUPPORTED_PLATFORMS = [
10
+ "twitter" /* TWITTER */
11
+ // Add more platforms here as they're implemented
12
+ ];
13
+ var SupportedPlatformSchema = SUPPORTED_PLATFORMS.length > 0 ? z.enum(SUPPORTED_PLATFORMS) : z.never();
14
+ SupportedPlatformSchema.describe("Currently supported social media platforms");
15
+ function isPlatformSupported(platform) {
16
+ return SUPPORTED_PLATFORMS.includes(platform);
17
+ }
16
18
 
17
19
  // src/response.ts
18
20
  import { z as z2 } from "zod";
@@ -844,7 +846,9 @@ export {
844
846
  ReplyToPostResponseSchema,
845
847
  RepostRequestSchema,
846
848
  RepostResponseSchema,
849
+ SUPPORTED_PLATFORMS,
847
850
  SuccessDetailSchema,
851
+ SupportedPlatformSchema,
848
852
  TargetSchema,
849
853
  TimePeriod,
850
854
  UnlikePostRequestSchema,
@@ -857,5 +861,6 @@ export {
857
861
  createErrorDetail,
858
862
  createErrorResponse,
859
863
  createMultiStatusResponse,
860
- createSuccessDetail
864
+ createSuccessDetail,
865
+ isPlatformSupported
861
866
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crosspost/types",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Shared type definitions for Crosspost API",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/common.ts CHANGED
@@ -6,22 +6,7 @@
6
6
  import { z } from 'zod';
7
7
 
8
8
  /**
9
- * Platform schema
10
- */
11
- export const PlatformSchema = z.enum([
12
- 'unknown',
13
- 'twitter',
14
- // Add more platforms as they're implemented
15
- // 'linkedin',
16
- // 'facebook',
17
- // 'instagram',
18
- ]).describe('Social media platform');
19
-
20
- // Derive TypeScript types from Zod schemas
21
- export type PlatformName = z.infer<typeof PlatformSchema>;
22
-
23
- /**
24
- * Enum for supported platforms (for backward compatibility)
9
+ * Platform enum - All platforms (including planned ones)
25
10
  */
26
11
  export enum Platform {
27
12
  UNKNOWN = 'unknown',
@@ -31,3 +16,34 @@ export enum Platform {
31
16
  // FACEBOOK = 'facebook',
32
17
  // INSTAGRAM = 'instagram',
33
18
  }
19
+
20
+ export const PlatformSchema = z.nativeEnum(Platform)
21
+ .describe('Social media platform');
22
+
23
+ /**
24
+ * Platform type - Derived from the Platform enum
25
+ */
26
+ export type PlatformName = Platform;
27
+
28
+ /**
29
+ * Array of currently supported platforms
30
+ */
31
+ export const SUPPORTED_PLATFORMS = [
32
+ Platform.TWITTER,
33
+ // Add more platforms here as they're implemented
34
+ ] as const;
35
+
36
+ export type SupportedPlatformName = typeof SUPPORTED_PLATFORMS[number];
37
+
38
+ export const SupportedPlatformSchema = SUPPORTED_PLATFORMS.length > 0
39
+ ? z.enum(SUPPORTED_PLATFORMS)
40
+ : z.never();
41
+
42
+ SupportedPlatformSchema.describe('Currently supported social media platforms');
43
+
44
+ /**
45
+ * Check if a platform is currently supported
46
+ */
47
+ export function isPlatformSupported(platform: Platform): platform is SupportedPlatformName {
48
+ return (SUPPORTED_PLATFORMS as readonly Platform[]).includes(platform);
49
+ }