@upstart.gg/sdk 0.0.104 → 0.0.106

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.
Files changed (254) hide show
  1. package/dist/shared/ajv.d.ts +2 -0
  2. package/dist/shared/ajv.d.ts.map +1 -1
  3. package/dist/shared/ajv.js +1 -1
  4. package/dist/shared/attributes.js +1 -1
  5. package/dist/shared/brick-manifest.js +1 -1
  6. package/dist/shared/bricks/manifests/accordion.manifest.js +1 -1
  7. package/dist/shared/bricks/manifests/all-manifests.js +1 -1
  8. package/dist/shared/bricks/manifests/button.manifest.js +1 -1
  9. package/dist/shared/bricks/manifests/card.manifest.js +1 -1
  10. package/dist/shared/bricks/manifests/carousel.manifest.js +1 -1
  11. package/dist/shared/bricks/manifests/container.manifest.js +1 -1
  12. package/dist/shared/bricks/manifests/divider.manifest.js +1 -1
  13. package/dist/shared/bricks/manifests/footer.manifest.d.ts +1 -1
  14. package/dist/shared/bricks/manifests/footer.manifest.d.ts.map +1 -1
  15. package/dist/shared/bricks/manifests/footer.manifest.js +1 -1
  16. package/dist/shared/bricks/manifests/form.manifest.js +1 -1
  17. package/dist/shared/bricks/manifests/hero.manifest.js +1 -1
  18. package/dist/shared/bricks/manifests/icon.manifest.js +1 -1
  19. package/dist/shared/bricks/manifests/image.manifest.js +1 -1
  20. package/dist/shared/bricks/manifests/images-gallery.manifest.js +1 -1
  21. package/dist/shared/bricks/manifests/map.manifest.js +1 -1
  22. package/dist/shared/bricks/manifests/navbar.manifest.js +1 -1
  23. package/dist/shared/bricks/manifests/sidebar.manifest.js +1 -1
  24. package/dist/shared/bricks/manifests/social-links.manifest.js +1 -1
  25. package/dist/shared/bricks/manifests/testimonials.manifest.js +1 -1
  26. package/dist/shared/bricks/manifests/text.manifest.js +1 -1
  27. package/dist/shared/bricks/manifests/timeline.manifest.js +1 -1
  28. package/dist/shared/bricks/manifests/video.manifest.js +1 -1
  29. package/dist/shared/bricks/props/border.d.ts.map +1 -1
  30. package/dist/shared/bricks/props/border.js +1 -1
  31. package/dist/shared/bricks/props/container.js +1 -1
  32. package/dist/shared/bricks/props/effects.js +1 -1
  33. package/dist/shared/bricks.d.ts.map +1 -1
  34. package/dist/shared/bricks.js +1 -1
  35. package/dist/shared/{chunk-TCZBR3ZU.js → chunk-2DI5SIVV.js} +1 -1
  36. package/dist/shared/{chunk-O22VV7YR.js → chunk-33FU4KGU.js} +1 -1
  37. package/dist/shared/{chunk-WCNVFVDK.js → chunk-3ZGRY444.js} +1 -1
  38. package/dist/shared/{chunk-CUCUHPQ7.js → chunk-6OKXZL6R.js} +1 -1
  39. package/dist/shared/chunk-7E67XSKP.js +3 -0
  40. package/dist/shared/{chunk-LJQXN32B.js → chunk-AMGHA7QH.js} +1 -1
  41. package/dist/shared/{chunk-QALNFBY7.js → chunk-DC5DWF7B.js} +1 -1
  42. package/dist/shared/{chunk-I43NIQ2K.js → chunk-DY2YCYZ6.js} +1 -1
  43. package/dist/shared/{chunk-CEXHD4BO.js → chunk-E4UAVLKC.js} +2 -2
  44. package/dist/shared/{chunk-ZFTWLZ3G.js → chunk-EHH677K5.js} +1 -1
  45. package/dist/shared/{chunk-POYVTV5F.js → chunk-FD3KX2U7.js} +1 -1
  46. package/dist/shared/chunk-G3JO5DM5.js +3 -0
  47. package/dist/shared/{chunk-I5S2MPPR.js → chunk-H7OYUKBW.js} +1 -1
  48. package/dist/shared/{chunk-ATVHWZSA.js → chunk-HBM4DPIW.js} +1 -1
  49. package/dist/shared/chunk-HIBTEX2T.js +3 -0
  50. package/dist/shared/{chunk-E2EBTWJI.js → chunk-I3HSLGFA.js} +1 -1
  51. package/dist/shared/{chunk-UISES3HA.js → chunk-IXJX7EQ3.js} +1 -1
  52. package/dist/shared/{chunk-5IEGQ7YT.js → chunk-JAAPJQNK.js} +1 -1
  53. package/dist/shared/{chunk-UK6H3FDX.js → chunk-JDBVMPSI.js} +1 -1
  54. package/dist/shared/{chunk-F6MLW6DO.js → chunk-JH3NRO6M.js} +1 -1
  55. package/dist/shared/{chunk-ZNVRYEO7.js → chunk-L3TKLJKK.js} +1 -1
  56. package/dist/shared/{chunk-TEPFFY32.js → chunk-LOFXGDAK.js} +1 -1
  57. package/dist/shared/chunk-O3FJP65T.js +3 -0
  58. package/dist/shared/{chunk-7L3UOEMR.js → chunk-PX7QSNLO.js} +1 -1
  59. package/dist/shared/{chunk-22KRCQK5.js → chunk-U76JDFWJ.js} +1 -1
  60. package/dist/shared/{chunk-CW5FWW5W.js → chunk-UYZP24VV.js} +1 -1
  61. package/dist/shared/chunk-X42WBJTN.js +3 -0
  62. package/dist/shared/{chunk-OQIFFJ7I.js → chunk-XB3X4P3I.js} +1 -1
  63. package/dist/shared/chunk-XDCGA4WT.js +3 -0
  64. package/dist/shared/chunk-YGHBFXR6.js +3 -0
  65. package/dist/shared/{chunk-WEQRYCPD.js → chunk-ZWYLKIBI.js} +1 -1
  66. package/dist/shared/datasources/external/rss/fetcher.d.ts +1 -1
  67. package/dist/shared/datasources/external/rss/fetcher.d.ts.map +1 -1
  68. package/dist/shared/images.js +1 -1
  69. package/dist/shared/page.js +1 -1
  70. package/dist/shared/responsive.js +1 -1
  71. package/dist/shared/site.js +1 -1
  72. package/dist/shared/sitemap.js +1 -1
  73. package/dist/shared/theme.js +1 -1
  74. package/dist/shared/utils/schema.d.ts +6 -8
  75. package/dist/shared/utils/schema.d.ts.map +1 -1
  76. package/dist/shared/utils/schema.js +1 -1
  77. package/package.json +5 -9
  78. package/dist/shared/chunk-F63ANNAK.js +0 -3
  79. package/dist/shared/chunk-GPKRRX3D.js +0 -3
  80. package/dist/shared/chunk-HQQYIKTE.js +0 -3
  81. package/dist/shared/chunk-JFDOR3UH.js +0 -3
  82. package/dist/shared/chunk-OD2PRCLH.js +0 -3
  83. package/dist/shared/chunk-PK6UAFPW.js +0 -3
  84. package/dist/shared/chunk-VDHLON5R.js +0 -3
  85. package/src/node/cli/api.ts +0 -101
  86. package/src/node/cli/commands/cmd-build.ts +0 -64
  87. package/src/node/cli/commands/login/cmd-login.ts +0 -111
  88. package/src/node/cli/commands/logout/cmd-logout.ts +0 -11
  89. package/src/node/cli/commands/publish/cmd-publish.ts +0 -135
  90. package/src/node/cli/commands/publish/parse-gitignore.ts +0 -278
  91. package/src/node/cli/commands/publish/uploader.ts +0 -333
  92. package/src/node/cli/constants.ts +0 -14
  93. package/src/node/cli/is-logged-in.ts +0 -28
  94. package/src/node/cli/program.ts +0 -77
  95. package/src/node/cli/store.ts +0 -64
  96. package/src/node/cli/tests/api.test.ts +0 -161
  97. package/src/node/cli/types.ts +0 -34
  98. package/src/node/cli/utils.ts +0 -20
  99. package/src/node/shared/config.ts +0 -69
  100. package/src/node/shared/logger.ts +0 -44
  101. package/src/shared/ajv.ts +0 -103
  102. package/src/shared/analytics/init.ts +0 -14
  103. package/src/shared/analytics/track.ts +0 -21
  104. package/src/shared/analytics/types.ts +0 -13
  105. package/src/shared/attributes.ts +0 -211
  106. package/src/shared/brick-manifest.ts +0 -110
  107. package/src/shared/bricks/manifests/accordion.manifest.ts +0 -179
  108. package/src/shared/bricks/manifests/all-manifests.ts +0 -92
  109. package/src/shared/bricks/manifests/button.manifest.ts +0 -145
  110. package/src/shared/bricks/manifests/card.manifest.ts +0 -269
  111. package/src/shared/bricks/manifests/carousel.manifest.ts +0 -106
  112. package/src/shared/bricks/manifests/container.manifest.ts +0 -357
  113. package/src/shared/bricks/manifests/divider.manifest.ts +0 -121
  114. package/src/shared/bricks/manifests/footer.manifest.ts +0 -487
  115. package/src/shared/bricks/manifests/form.manifest.ts +0 -112
  116. package/src/shared/bricks/manifests/hero.manifest.ts +0 -132
  117. package/src/shared/bricks/manifests/icon.manifest.ts +0 -130
  118. package/src/shared/bricks/manifests/image.manifest.ts +0 -203
  119. package/src/shared/bricks/manifests/images-gallery.manifest.ts +0 -227
  120. package/src/shared/bricks/manifests/map.manifest.ts +0 -75
  121. package/src/shared/bricks/manifests/navbar.manifest.ts +0 -344
  122. package/src/shared/bricks/manifests/sidebar.manifest.ts +0 -90
  123. package/src/shared/bricks/manifests/social-links.manifest.ts +0 -370
  124. package/src/shared/bricks/manifests/testimonials.manifest.ts +0 -397
  125. package/src/shared/bricks/manifests/tests/header.manifest.test.ts +0 -10
  126. package/src/shared/bricks/manifests/text.manifest.ts +0 -164
  127. package/src/shared/bricks/manifests/timeline.manifest.ts +0 -456
  128. package/src/shared/bricks/manifests/video.manifest.ts +0 -59
  129. package/src/shared/bricks/props/_style-presets.ts +0 -352
  130. package/src/shared/bricks/props/align.ts +0 -59
  131. package/src/shared/bricks/props/background.ts +0 -118
  132. package/src/shared/bricks/props/boolean.ts +0 -11
  133. package/src/shared/bricks/props/border.ts +0 -84
  134. package/src/shared/bricks/props/color.ts +0 -24
  135. package/src/shared/bricks/props/common.ts +0 -37
  136. package/src/shared/bricks/props/container.ts +0 -356
  137. package/src/shared/bricks/props/css-length.ts +0 -25
  138. package/src/shared/bricks/props/datasource.ts +0 -60
  139. package/src/shared/bricks/props/date.ts +0 -24
  140. package/src/shared/bricks/props/effects.ts +0 -123
  141. package/src/shared/bricks/props/enum.ts +0 -42
  142. package/src/shared/bricks/props/file.ts +0 -12
  143. package/src/shared/bricks/props/geolocation.ts +0 -30
  144. package/src/shared/bricks/props/helpers.ts +0 -101
  145. package/src/shared/bricks/props/image.ts +0 -90
  146. package/src/shared/bricks/props/number.ts +0 -16
  147. package/src/shared/bricks/props/padding.ts +0 -21
  148. package/src/shared/bricks/props/position.ts +0 -27
  149. package/src/shared/bricks/props/preset.ts +0 -136
  150. package/src/shared/bricks/props/string.ts +0 -56
  151. package/src/shared/bricks/props/tests/align.test.ts +0 -37
  152. package/src/shared/bricks/props/tests/background.test.ts +0 -102
  153. package/src/shared/bricks/props/tests/border.test.ts +0 -38
  154. package/src/shared/bricks/props/tests/effects.test.ts +0 -37
  155. package/src/shared/bricks/props/tests/helpers.test.ts +0 -133
  156. package/src/shared/bricks/props/tests/image.test.ts +0 -71
  157. package/src/shared/bricks/props/tests/padding.ts +0 -12
  158. package/src/shared/bricks/props/tests/string.test.ts +0 -79
  159. package/src/shared/bricks/props/text.ts +0 -66
  160. package/src/shared/bricks/props/types.ts +0 -57
  161. package/src/shared/bricks.ts +0 -232
  162. package/src/shared/context.ts +0 -39
  163. package/src/shared/datarecords/external/airtable/handler.ts +0 -21
  164. package/src/shared/datarecords/external/airtable/options.ts +0 -22
  165. package/src/shared/datarecords/external/generic-webhook/handler.ts +0 -10
  166. package/src/shared/datarecords/external/generic-webhook/options.ts +0 -13
  167. package/src/shared/datarecords/external/google/oauth/config.ts +0 -30
  168. package/src/shared/datarecords/external/google/sheets/handler.ts +0 -26
  169. package/src/shared/datarecords/external/google/sheets/options.ts +0 -9
  170. package/src/shared/datarecords/types.ts +0 -120
  171. package/src/shared/datarecords.ts +0 -5
  172. package/src/shared/datasources/README.md +0 -3
  173. package/src/shared/datasources/external/facebook/posts/fetcher.ts +0 -52
  174. package/src/shared/datasources/external/facebook/posts/sample.ts +0 -35
  175. package/src/shared/datasources/external/facebook/posts/schema.ts +0 -33
  176. package/src/shared/datasources/external/facebook/posts/tests/fetcher.test.ts +0 -73
  177. package/src/shared/datasources/external/http-json/fetcher.ts +0 -28
  178. package/src/shared/datasources/external/http-json/options.ts +0 -12
  179. package/src/shared/datasources/external/http-json/schema.ts +0 -6
  180. package/src/shared/datasources/external/http-json/tests/fetcher.test.ts +0 -70
  181. package/src/shared/datasources/external/instagram/feed/fetcher.ts +0 -33
  182. package/src/shared/datasources/external/instagram/feed/sample.ts +0 -22
  183. package/src/shared/datasources/external/instagram/feed/schema.ts +0 -23
  184. package/src/shared/datasources/external/instagram/feed/tests/fetcher.test.ts +0 -64
  185. package/src/shared/datasources/external/mastodon/account/fetcher.ts +0 -24
  186. package/src/shared/datasources/external/mastodon/account/sample.ts +0 -33
  187. package/src/shared/datasources/external/mastodon/account/schema.ts +0 -45
  188. package/src/shared/datasources/external/mastodon/account/tests/fetcher.test.ts +0 -47
  189. package/src/shared/datasources/external/mastodon/options.ts +0 -11
  190. package/src/shared/datasources/external/mastodon/status/fetcher.ts +0 -35
  191. package/src/shared/datasources/external/mastodon/status/sample.array.ts +0 -59
  192. package/src/shared/datasources/external/mastodon/status/sample.single.ts +0 -55
  193. package/src/shared/datasources/external/mastodon/status/schema.ts +0 -130
  194. package/src/shared/datasources/external/mastodon/status/tests/fetcher.test.ts +0 -74
  195. package/src/shared/datasources/external/meta/oauth/config.ts +0 -16
  196. package/src/shared/datasources/external/meta/options.ts +0 -11
  197. package/src/shared/datasources/external/rss/fetcher.ts +0 -29
  198. package/src/shared/datasources/external/rss/options.ts +0 -11
  199. package/src/shared/datasources/external/rss/sample.ts +0 -22
  200. package/src/shared/datasources/external/rss/schema.ts +0 -42
  201. package/src/shared/datasources/external/threads/media/fetcher.ts +0 -53
  202. package/src/shared/datasources/external/threads/media/sample.ts +0 -44
  203. package/src/shared/datasources/external/threads/media/schema.ts +0 -37
  204. package/src/shared/datasources/external/tiktok/oauth/config.ts +0 -17
  205. package/src/shared/datasources/external/tiktok/video/fetcher.ts +0 -39
  206. package/src/shared/datasources/external/tiktok/video/options.ts +0 -12
  207. package/src/shared/datasources/external/tiktok/video/sample.ts +0 -26
  208. package/src/shared/datasources/external/tiktok/video/schema.ts +0 -27
  209. package/src/shared/datasources/external/youtube/list/fetcher.ts +0 -37
  210. package/src/shared/datasources/external/youtube/list/options.ts +0 -15
  211. package/src/shared/datasources/external/youtube/list/sample.ts +0 -33
  212. package/src/shared/datasources/external/youtube/list/schema.ts +0 -38
  213. package/src/shared/datasources/external/youtube/oauth/config.ts +0 -15
  214. package/src/shared/datasources/fetcher.ts +0 -17
  215. package/src/shared/datasources/internal/blog/schema.ts +0 -69
  216. package/src/shared/datasources/internal/changelog/schema.ts +0 -48
  217. package/src/shared/datasources/internal/contact-info/schema.ts +0 -20
  218. package/src/shared/datasources/internal/cv/schema.ts +0 -217
  219. package/src/shared/datasources/internal/faq/schema.ts +0 -27
  220. package/src/shared/datasources/internal/job-board/schema.ts +0 -228
  221. package/src/shared/datasources/internal/links/schema.ts +0 -15
  222. package/src/shared/datasources/internal/recipes/schema.ts +0 -42
  223. package/src/shared/datasources/internal/restaurant/schema.ts +0 -225
  224. package/src/shared/datasources/provider-options.ts +0 -7
  225. package/src/shared/datasources/samples.ts +0 -26
  226. package/src/shared/datasources/schemas.ts +0 -45
  227. package/src/shared/datasources/types.ts +0 -276
  228. package/src/shared/datasources/utils.ts +0 -16
  229. package/src/shared/datasources.ts +0 -42
  230. package/src/shared/env.ts +0 -23
  231. package/src/shared/errors.ts +0 -1
  232. package/src/shared/images.ts +0 -44
  233. package/src/shared/index.ts +0 -3
  234. package/src/shared/layout-constants.ts +0 -25
  235. package/src/shared/manifest.ts +0 -50
  236. package/src/shared/oauth.ts +0 -16
  237. package/src/shared/page.ts +0 -61
  238. package/src/shared/prompt.ts +0 -9
  239. package/src/shared/responsive.ts +0 -5
  240. package/src/shared/site.ts +0 -97
  241. package/src/shared/sitemap.ts +0 -66
  242. package/src/shared/social-icons.ts +0 -307
  243. package/src/shared/tests/attributes.test.ts +0 -37
  244. package/src/shared/theme.ts +0 -245
  245. package/src/shared/themes/README.md +0 -34
  246. package/src/shared/themes/color-system.ts +0 -127
  247. package/src/shared/utils/canvas-data-uri.ts +0 -2
  248. package/src/shared/utils/invariant.ts +0 -25
  249. package/src/shared/utils/json-date.ts +0 -8
  250. package/src/shared/utils/merge.ts +0 -12
  251. package/src/shared/utils/object-hash.ts +0 -7
  252. package/src/shared/utils/schema.ts +0 -35
  253. package/src/shared/utils/try-catch.ts +0 -12
  254. package/src/shared/utils/typed-ref.ts +0 -41
@@ -1,64 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import fetchInstagramFeedDatasource from "../fetcher";
3
- import { UnauthorizedError } from "~/shared/errors";
4
-
5
- // Mock the fetch function
6
- global.fetch = vi.fn();
7
-
8
- describe("fetchInstagramFeedDatasource", () => {
9
- beforeEach(() => {
10
- vi.resetAllMocks();
11
- });
12
-
13
- it("should fetch Instagram feed successfully", async () => {
14
- const mockResponse = {
15
- data: [
16
- {
17
- id: "123",
18
- caption: "Test post",
19
- media_url: "https://example.com/image.jpg",
20
- permalink: "https://instagram.com/p/123",
21
- media_type: "IMAGE",
22
- timestamp: "2023-05-01T12:00:00+0000",
23
- },
24
- ],
25
- paging: {
26
- cursors: { before: "before-cursor", after: "after-cursor" },
27
- next: "https://example.com/next",
28
- },
29
- };
30
-
31
- (global.fetch as any).mockResolvedValueOnce({
32
- ok: true,
33
- json: () => Promise.resolve(mockResponse),
34
- });
35
-
36
- const result = await fetchInstagramFeedDatasource({
37
- options: { limit: 10 },
38
- oauth: { config: { accessToken: "test-token" } },
39
- env: {},
40
- pageConfig: {},
41
- } as any);
42
-
43
- expect(result).toEqual(mockResponse);
44
- expect(global.fetch).toHaveBeenCalledWith(
45
- expect.stringContaining("https://graph.instagram.com/me/media?"),
46
- );
47
- });
48
-
49
- it("should throw Http401Error on unauthorized response", async () => {
50
- (global.fetch as any).mockResolvedValueOnce({
51
- ok: false,
52
- status: 401,
53
- });
54
-
55
- await expect(
56
- fetchInstagramFeedDatasource({
57
- options: { limit: 10 },
58
- oauth: { config: { accessToken: "invalid-token" } },
59
- env: {},
60
- pageConfig: {},
61
- } as any),
62
- ).rejects.toThrow(UnauthorizedError);
63
- });
64
- });
@@ -1,24 +0,0 @@
1
- import type { MastodonAccountSchema } from "./schema";
2
- import type { MastodonCommonOptions } from "../options";
3
- import type { DatasourceFetcher } from "~/shared/datasources/fetcher";
4
-
5
- const fetchMastodonAccount: DatasourceFetcher<MastodonAccountSchema, null, MastodonCommonOptions> = async ({
6
- options,
7
- }) => {
8
- const params = new URLSearchParams({
9
- acct: options.username,
10
- });
11
-
12
- const url = `https://mastodon.social/api/v1/accounts/lookup?${params.toString()}`;
13
- const response = await fetch(url);
14
-
15
- if (!response.ok) {
16
- throw new Error(`fetchMastodonAccount Error: Response status: ${response.status}`);
17
- }
18
-
19
- const account = (await response.json()) as MastodonAccountSchema;
20
-
21
- return account;
22
- };
23
-
24
- export default fetchMastodonAccount;
@@ -1,33 +0,0 @@
1
- import type { MastodonAccountSchema } from "./schema";
2
-
3
- export const sample = {
4
- id: "1",
5
- acct: "Gargron",
6
- url: "https://mastodon.social/@Gargron",
7
- noindex: false,
8
- locked: false,
9
- discoverable: true,
10
- fields: [],
11
- followers_count: 0,
12
- following_count: 0,
13
- group: false,
14
- statuses_count: 0,
15
- note: "Admin of mastodon.social",
16
- username: "Gargron",
17
- header_static: "https://files.mastodon.social/accounts/headers/000/000/001/original/7b7e3c3e3e7e3e3e.png",
18
- header: "https://files.mastodon.social/accounts/headers/000/000/001/original/7b7e3c3e3e7e3e3e.png",
19
- avatar: "https://files.mastodon.social/accounts/avatars/000/000/001/original/7b7e3c3e3e7e3e3e.png",
20
- avatar_static: "https://files.mastodon.social/accounts/avatars/000/000/001/original/7b7e3c3e3e7e3e3e.png",
21
- bot: false,
22
- created_at: "2016-04-04T17:41:54.000Z",
23
- display_name: "Eugen",
24
- emojis: [
25
- {
26
- category: "custom",
27
- shortcode: "blobawave",
28
- static_url: "https://files.mastodon.social/custom_emojis/images/000/000/001/static/1f4a9.png",
29
- url: "https://files.mastodon.social/custom_emojis/images/000/000/001/original/1f4a9.png",
30
- visible_in_picker: true,
31
- },
32
- ],
33
- } satisfies MastodonAccountSchema;
@@ -1,45 +0,0 @@
1
- import { Type, type Static } from "@sinclair/typebox";
2
-
3
- export const mastodonAccountSchema = Type.Object({
4
- id: Type.String(),
5
- username: Type.String(),
6
- acct: Type.String(),
7
- url: Type.String(),
8
- display_name: Type.Optional(Type.String()),
9
- note: Type.String(),
10
- avatar: Type.String(),
11
- avatar_static: Type.String(),
12
- header: Type.String(),
13
- header_static: Type.String(),
14
- locked: Type.Boolean(),
15
- fields: Type.Array(
16
- Type.Object({
17
- name: Type.String(),
18
- value: Type.String(),
19
- verified_at: Type.Optional(Type.String()),
20
- }),
21
- ),
22
- emojis: Type.Array(
23
- Type.Object({
24
- shortcode: Type.String(),
25
- url: Type.String(),
26
- static_url: Type.String(),
27
- visible_in_picker: Type.Boolean(),
28
- category: Type.Optional(Type.String()),
29
- }),
30
- ),
31
- bot: Type.Boolean(),
32
- group: Type.Boolean(),
33
- discoverable: Type.Union([Type.Boolean(), Type.Null()]),
34
- noindex: Type.Optional(Type.Boolean()),
35
- moved: Type.Optional(Type.String()),
36
- suspended: Type.Optional(Type.Boolean()),
37
- limited: Type.Optional(Type.Boolean()),
38
- created_at: Type.String(),
39
- last_status_at: Type.Optional(Type.String()),
40
- statuses_count: Type.Number(),
41
- followers_count: Type.Number(),
42
- following_count: Type.Number(),
43
- });
44
-
45
- export type MastodonAccountSchema = Static<typeof mastodonAccountSchema>;
@@ -1,47 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import fetchMastodonAccount from "../fetcher";
3
- import { sample } from "../sample";
4
-
5
- // Mock the fetch function
6
- global.fetch = vi.fn();
7
-
8
- describe("fetchMastodonAccount", () => {
9
- beforeEach(() => {
10
- vi.resetAllMocks();
11
- });
12
-
13
- it("should fetch Mastodon account successfully", async () => {
14
- (global.fetch as any).mockResolvedValueOnce({
15
- ok: true,
16
- json: () => Promise.resolve(sample),
17
- });
18
-
19
- const result = await fetchMastodonAccount({
20
- options: { username: "testuser" },
21
- env: {},
22
- pageConfig: {},
23
- oauth: null,
24
- } as any);
25
-
26
- expect(result).toEqual(sample);
27
- expect(global.fetch).toHaveBeenCalledWith(
28
- expect.stringContaining("https://mastodon.social/api/v1/accounts/lookup?acct=testuser"),
29
- );
30
- });
31
-
32
- it("should throw error on non-OK response", async () => {
33
- (global.fetch as any).mockResolvedValueOnce({
34
- ok: false,
35
- status: 404,
36
- });
37
-
38
- await expect(
39
- fetchMastodonAccount({
40
- options: { username: "nonexistent" },
41
- env: {},
42
- pageConfig: {},
43
- oauth: null,
44
- } as any),
45
- ).rejects.toThrow("fetchMastodonAccount Error: Response status: 404");
46
- });
47
- });
@@ -1,11 +0,0 @@
1
- import { Type, type Static } from "@sinclair/typebox";
2
- import { providerOptions } from "../../provider-options";
3
-
4
- export const mastodonCommonOptions = Type.Composite([
5
- providerOptions,
6
- Type.Object({
7
- username: Type.String(),
8
- }),
9
- ]);
10
-
11
- export type MastodonCommonOptions = Static<typeof mastodonCommonOptions>;
@@ -1,35 +0,0 @@
1
- import { type MastodonStatusArraySchema, mastodonStatusArraySchema } from "./schema";
2
- import fetchMastodonAccount from "../account/fetcher";
3
- import { UnauthorizedError } from "~/shared/errors";
4
- import type { MastodonCommonOptions } from "../options";
5
- import type { DatasourceFetcher } from "~/shared/datasources/fetcher";
6
-
7
- const fetchMastodonStatus: DatasourceFetcher<
8
- MastodonStatusArraySchema,
9
- null,
10
- MastodonCommonOptions
11
- > = async ({ options, attr }) => {
12
- const account = await fetchMastodonAccount({
13
- options: { username: options.username },
14
- attr,
15
- oauth: null,
16
- });
17
-
18
- const accountUrl = new URL(account.url);
19
- const url = `https://${accountUrl.host}/api/v1/accounts/${account.id}/statuses`;
20
-
21
- const response = await fetch(url);
22
-
23
- if (!response.ok) {
24
- if (response.status === 401) {
25
- throw new UnauthorizedError(`fetchMastodonStatus Error: Unauthorized.`);
26
- }
27
- throw new Error(`fetchMastodonStatus Error: Response status: ${response.status}`);
28
- }
29
-
30
- const statuses = (await response.json()) as MastodonStatusArraySchema;
31
-
32
- return statuses;
33
- };
34
-
35
- export default fetchMastodonStatus;
@@ -1,59 +0,0 @@
1
- import type { MastodonStatusArraySchema } from "./schema";
2
-
3
- export const sample = [
4
- {
5
- account: {
6
- acct: "Gargron",
7
- avatar: "https://files.mastodon.social/accounts/avatars/000/000/001/original/7b7e3c3e3e7e3e3e.png",
8
- avatar_static:
9
- "https://files.mastodon.social/accounts/avatars/000/000/001/original/7b7e3c3e3e7e3e3e.png",
10
- bot: false,
11
- created_at: "2016-04-04T17:41:54.000Z",
12
- display_name: "Eugen",
13
- emojis: [
14
- {
15
- category: "custom",
16
- shortcode: "blobawave",
17
- static_url: "https://files.mastodon.social/custom_emojis/images/000/000/001/static/1f4a9.png",
18
- url: "https://files.mastodon.social/custom_emojis/images/000/000/001/original/1f4a9.png",
19
- visible_in_picker: true,
20
- },
21
- ],
22
- id: "1",
23
- url: "https://mastodon.social/@Gargron",
24
- username: "Gargron",
25
- discoverable: true,
26
- fields: [],
27
- followers_count: 100,
28
- following_count: 100,
29
- group: false,
30
- header: "https://files.mastodon.social/accounts/headers/000/000/001/original/7b7e3c3e3e7e3e3e.png",
31
- header_static:
32
- "https://files.mastodon.social/accounts/headers/000/000/001/original/7b7e3c3e3e7e3e3e.png",
33
- last_status_at: "2021-06-26T18:00:00",
34
- locked: false,
35
- note: "Admin of mastodon.social",
36
- noindex: false,
37
- statuses_count: 100,
38
- suspended: false,
39
- },
40
- content: "Hello, world!",
41
- created_at: "2021-06-26T18:00:00",
42
- id: "1",
43
- media_attachments: [],
44
- reblogs_count: 0,
45
- replies_count: 0,
46
- favourites_count: 0,
47
- tags: [],
48
- uri: "https://mastodon.social/@Gargron/1",
49
- visibility: "public",
50
- sensitive: false,
51
- application: {
52
- name: "Mastodon",
53
- website: "https://joinmastodon.org",
54
- },
55
- mentions: [],
56
- emojis: [],
57
- url: "https://mastodon.social/@Gargron/1",
58
- },
59
- ] satisfies MastodonStatusArraySchema;
@@ -1,55 +0,0 @@
1
- import type { MastodonStatusSchema } from "./schema";
2
-
3
- export const sample = {
4
- account: {
5
- acct: "Gargron",
6
- avatar: "https://files.mastodon.social/accounts/avatars/000/000/001/original/7b7e3c3e3e7e3e3e.png",
7
- avatar_static: "https://files.mastodon.social/accounts/avatars/000/000/001/original/7b7e3c3e3e7e3e3e.png",
8
- bot: false,
9
- created_at: "2016-04-04T17:41:54.000Z",
10
- display_name: "Eugen",
11
- emojis: [
12
- {
13
- category: "custom",
14
- shortcode: "blobawave",
15
- static_url: "https://files.mastodon.social/custom_emojis/images/000/000/001/static/1f4a9.png",
16
- url: "https://files.mastodon.social/custom_emojis/images/000/000/001/original/1f4a9.png",
17
- visible_in_picker: true,
18
- },
19
- ],
20
- id: "1",
21
- url: "https://mastodon.social/@Gargron",
22
- username: "Gargron",
23
- discoverable: true,
24
- fields: [],
25
- followers_count: 100,
26
- following_count: 100,
27
- group: false,
28
- header: "https://files.mastodon.social/accounts/headers/000/000/001/original/7b7e3c3e3e7e3e3e.png",
29
- header_static: "https://files.mastodon.social/accounts/headers/000/000/001/original/7b7e3c3e3e7e3e3e.png",
30
- last_status_at: "2021-06-26T18:00:00",
31
- locked: false,
32
- note: "Admin of mastodon.social",
33
- noindex: false,
34
- statuses_count: 100,
35
- suspended: false,
36
- },
37
- content: "Hello, world!",
38
- created_at: "2021-06-26T18:00:00",
39
- id: "1",
40
- media_attachments: [],
41
- reblogs_count: 0,
42
- replies_count: 0,
43
- favourites_count: 0,
44
- tags: [],
45
- uri: "https://mastodon.social/@Gargron/1",
46
- visibility: "public",
47
- sensitive: false,
48
- application: {
49
- name: "Mastodon",
50
- website: "https://joinmastodon.org",
51
- },
52
- mentions: [],
53
- emojis: [],
54
- url: "https://mastodon.social/@Gargron/1",
55
- } satisfies MastodonStatusSchema;
@@ -1,130 +0,0 @@
1
- import { Type, type Static } from "@sinclair/typebox";
2
- import { mastodonAccountSchema } from "../account/schema";
3
-
4
- const mastodonMediaAttachmentSchema = Type.Object({
5
- id: Type.String(),
6
- type: Type.Union([
7
- Type.Literal("audio"),
8
- Type.Literal("image"),
9
- Type.Literal("video"),
10
- Type.Literal("gifv"),
11
- Type.Literal("unknown"),
12
- ]),
13
- url: Type.String(),
14
- preview_url: Type.Optional(Type.String()),
15
- remote_url: Type.Optional(Type.String()),
16
- meta: Type.Record(Type.String(), Type.Any()),
17
- description: Type.Optional(Type.String()),
18
- blurhash: Type.Optional(Type.String()),
19
- });
20
-
21
- const mastodonEmojiSchema = Type.Object({
22
- shortcode: Type.String(),
23
- url: Type.String(),
24
- static_url: Type.String(),
25
- visible_in_picker: Type.Boolean(),
26
- category: Type.Optional(Type.String()),
27
- });
28
-
29
- const mastodonPreviewCardSchema = Type.Object({
30
- url: Type.String(),
31
- title: Type.String(),
32
- description: Type.String(),
33
- type: Type.Union([
34
- Type.Literal("link"),
35
- Type.Literal("photo"),
36
- Type.Literal("video"),
37
- Type.Literal("rich"),
38
- ]),
39
- author_name: Type.String(),
40
- author_url: Type.String(),
41
- provider_name: Type.String(),
42
- provider_url: Type.String(),
43
- html: Type.String(),
44
- width: Type.Number(),
45
- height: Type.Number(),
46
- image: Type.Optional(Type.String()),
47
- embed_url: Type.String(),
48
- blurhash: Type.Optional(Type.String()),
49
- });
50
-
51
- const mastodonPollSchema = Type.Object({
52
- id: Type.String(),
53
- expires_at: Type.String(),
54
- expired: Type.Boolean(),
55
- multiple: Type.Boolean(),
56
- votes_count: Type.Number(),
57
- options: Type.Array(
58
- Type.Object({
59
- title: Type.String(),
60
- votes_count: Type.Number(),
61
- }),
62
- ),
63
- voted: Type.Optional(Type.Boolean()),
64
- own_votes: Type.Optional(Type.Array(Type.Number())),
65
- emojis: Type.Array(mastodonEmojiSchema),
66
- });
67
-
68
- export const mastodonStatusSchema = Type.Object(
69
- {
70
- id: Type.String(),
71
- uri: Type.String(),
72
- created_at: Type.String(),
73
- account: mastodonAccountSchema,
74
- content: Type.String(),
75
- visibility: Type.Union([
76
- Type.Literal("public"),
77
- Type.Literal("unlisted"),
78
- Type.Literal("private"),
79
- Type.Literal("direct"),
80
- ]),
81
- sensitive: Type.Boolean(),
82
- media_attachments: Type.Array(mastodonMediaAttachmentSchema),
83
- application: Type.Optional(
84
- Type.Object({
85
- name: Type.String(),
86
- website: Type.Optional(Type.String()),
87
- }),
88
- ),
89
- mentions: Type.Array(
90
- Type.Object({
91
- id: Type.String(),
92
- username: Type.String(),
93
- acct: Type.String(),
94
- url: Type.String(),
95
- }),
96
- ),
97
- tags: Type.Array(
98
- Type.Object({
99
- name: Type.String(),
100
- url: Type.String(),
101
- }),
102
- ),
103
- emojis: Type.Array(mastodonEmojiSchema),
104
- reblogs_count: Type.Number(),
105
- favourites_count: Type.Number(),
106
- replies_count: Type.Number(),
107
- url: Type.String(),
108
- in_reply_to_id: Type.Optional(Type.String()),
109
- in_reply_to_account_id: Type.Optional(Type.String()),
110
- reblog: Type.Optional(Type.Ref("mastodonStatus")),
111
- poll: Type.Optional(mastodonPollSchema),
112
- card: Type.Optional(mastodonPreviewCardSchema),
113
- language: Type.Optional(Type.String()),
114
- text: Type.Optional(Type.String()),
115
- edited_at: Type.Optional(Type.String()),
116
- favourited: Type.Optional(Type.Boolean()),
117
- reblogged: Type.Optional(Type.Boolean()),
118
- muted: Type.Optional(Type.Boolean()),
119
- bookmarked: Type.Optional(Type.Boolean()),
120
- pinned: Type.Optional(Type.Boolean()),
121
- },
122
- {
123
- $id: "mastodonStatus",
124
- },
125
- );
126
-
127
- export type MastodonStatusSchema = Static<typeof mastodonStatusSchema>;
128
-
129
- export const mastodonStatusArraySchema = Type.Array(mastodonStatusSchema);
130
- export type MastodonStatusArraySchema = Static<typeof mastodonStatusArraySchema>;
@@ -1,74 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import fetchMastodonStatus from "../fetcher";
3
- import { UnauthorizedError } from "~/shared/errors";
4
- import { sample } from "../sample.array";
5
- import fetchMastodonAccount from "../../account/fetcher";
6
- import { sample as accountSample } from "../../account/sample";
7
-
8
- // Mock the fetch function and fetchMastodonAccount
9
- global.fetch = vi.fn();
10
- // Mock the entire module
11
- vi.mock("../../account/fetcher", () => ({
12
- default: vi.fn(),
13
- }));
14
-
15
- describe("fetchMastodonStatus", () => {
16
- beforeEach(() => {
17
- vi.resetAllMocks();
18
- });
19
-
20
- it("should fetch Mastodon statuses successfully", async () => {
21
- (global.fetch as any).mockResolvedValueOnce({
22
- ok: true,
23
- json: () => Promise.resolve(sample),
24
- });
25
-
26
- vi.mocked(fetchMastodonAccount).mockResolvedValueOnce(accountSample);
27
-
28
- const result = await fetchMastodonStatus({
29
- options: { username: "testuser" },
30
- env: {},
31
- pageConfig: {},
32
- oauth: null,
33
- } as any);
34
-
35
- expect(result).toEqual(sample);
36
- expect(global.fetch).toHaveBeenCalledWith("https://mastodon.social/api/v1/accounts/1/statuses");
37
- });
38
-
39
- it("should throw UnauthorizedError on unauthorized response", async () => {
40
- (global.fetch as any).mockResolvedValueOnce({
41
- ok: false,
42
- status: 401,
43
- });
44
-
45
- vi.mocked(fetchMastodonAccount).mockResolvedValueOnce(accountSample);
46
-
47
- await expect(
48
- fetchMastodonStatus({
49
- options: { username: "testuser" },
50
- env: {},
51
- pageConfig: {},
52
- oauth: null,
53
- } as any),
54
- ).rejects.toThrow(UnauthorizedError);
55
- });
56
-
57
- it("should throw error on invalid response data", async () => {
58
- const invalidResponse = [{ invalid: "data" }];
59
-
60
- (global.fetch as any).mockResolvedValueOnce({
61
- ok: true,
62
- json: () => Promise.resolve(invalidResponse),
63
- });
64
-
65
- await expect(
66
- fetchMastodonStatus({
67
- options: { username: "testuser" },
68
- env: {},
69
- pageConfig: {},
70
- oauth: null,
71
- } as any),
72
- ).rejects.toThrow();
73
- });
74
- });
@@ -1,16 +0,0 @@
1
- import { Type, type Static, type StaticDecode } from "@sinclair/typebox";
2
- import { buildOAuthConfigSchema } from "~/shared/oauth";
3
-
4
- const metaOAuthConfig = Type.Object({
5
- type: Type.Union([Type.Literal("short-lived"), Type.Literal("long-lived")]),
6
- accessToken: Type.String(),
7
- userId: Type.String(),
8
- permissions: Type.Array(Type.String()),
9
- expiresIn: Type.Number(),
10
- tokenType: Type.String(),
11
- });
12
-
13
- export type MetaOAuthConfig = Static<typeof metaOAuthConfig>;
14
-
15
- const metaFullOAuthConfig = buildOAuthConfigSchema(metaOAuthConfig);
16
- export type MetaFullOAuthConfig = StaticDecode<typeof metaFullOAuthConfig>;
@@ -1,11 +0,0 @@
1
- import { Type, type Static } from "@sinclair/typebox";
2
- import { providerOptions } from "../../provider-options";
3
-
4
- export const metaOptions = Type.Composite([
5
- providerOptions,
6
- Type.Object({
7
- limit: Type.Optional(Type.Number()),
8
- }),
9
- ]);
10
-
11
- export type MetaOptions = Static<typeof metaOptions>;
@@ -1,29 +0,0 @@
1
- import type { RssOptions } from "./options";
2
- import { parseFeed } from "htmlparser2";
3
- import { type RssSchema, rssSchema } from "./schema";
4
- // import { ajv, serializeAjvErrors } from "~/shared/ajv";
5
- import type { DatasourceFetcher } from "../../fetcher";
6
- import { createPlaceholderReplacer, placeholderRx } from "../../utils";
7
-
8
- const fetchRss: DatasourceFetcher<RssSchema, null, RssOptions> = async ({ options, attr }) => {
9
- const replacer = createPlaceholderReplacer(attr);
10
- const url = options.url.replace(placeholderRx, replacer);
11
- const content = await (await fetch(url)).text();
12
- const feed = parseFeed(content);
13
-
14
- const newFeed: RssSchema =
15
- feed?.items.map((item) => ({
16
- ...item,
17
- pubDate: item.pubDate ? item.pubDate.toISOString() : new Date().toISOString(),
18
- })) ?? [];
19
-
20
- // const isValid = ajv.validate<RssSchema>(rssSchema, newFeed);
21
-
22
- // if (!isValid) {
23
- // throw new Error(`fetchRss Error: Invalid Feed data (${url}): ${serializeAjvErrors(ajv.errors)}`);
24
- // }
25
-
26
- return newFeed;
27
- };
28
-
29
- export default fetchRss;
@@ -1,11 +0,0 @@
1
- import { Type, type Static } from "@sinclair/typebox";
2
- import { providerOptions } from "../../provider-options";
3
-
4
- export const rssOptions = Type.Composite([
5
- providerOptions,
6
- Type.Object({
7
- url: Type.String({ format: "uri" }),
8
- }),
9
- ]);
10
-
11
- export type RssOptions = Static<typeof rssOptions>;
@@ -1,22 +0,0 @@
1
- import type { RssSchema } from "./schema";
2
-
3
- export const sample = [
4
- {
5
- title: "Example title",
6
- link: "https://example.com",
7
- pubDate: "2022-01-01T00:00:00Z",
8
- content: "Example content",
9
- },
10
- {
11
- title: "Another example title",
12
- link: "https://example.com",
13
- pubDate: "2022-01-02T00:00:00Z",
14
- content: "Another example content",
15
- },
16
- {
17
- title: "Yet another example title",
18
- link: "https://example.com",
19
- pubDate: "2022-01-03T00:00:00Z",
20
- content: "Yet another example content",
21
- },
22
- ] as RssSchema;