graze-client 0.8.0 → 0.8.1

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 (45) hide show
  1. package/build/dts/GrazeClient.d.ts.map +1 -1
  2. package/build/dts/builder.d.ts +8 -8
  3. package/build/dts/builder.d.ts.map +1 -1
  4. package/build/dts/common.d.ts.map +1 -1
  5. package/build/dts/index.d.ts +3 -3
  6. package/build/dts/index.d.ts.map +1 -1
  7. package/build/dts/schema/Post.d.ts.map +1 -1
  8. package/build/dts/schema/StickyPosts.d.ts +1 -1
  9. package/build/dts/schema/StickyPosts.d.ts.map +1 -1
  10. package/build/dts/schema/UpdateAlgorithmPayload.d.ts +90 -66
  11. package/build/dts/schema/UpdateAlgorithmPayload.d.ts.map +1 -1
  12. package/build/dts/schema/index.d.ts.map +1 -1
  13. package/build/dts/schema/shared.d.ts +28 -28
  14. package/build/dts/schema/shared.d.ts.map +1 -1
  15. package/build/dts/stickyposts.d.ts +1 -1
  16. package/build/dts/stickyposts.d.ts.map +1 -1
  17. package/build/esm/GrazeClient.js +9 -9
  18. package/build/esm/GrazeClient.js.map +1 -1
  19. package/build/esm/builder.js +20 -20
  20. package/build/esm/builder.js.map +1 -1
  21. package/build/esm/common.js.map +1 -1
  22. package/build/esm/index.js +5 -5
  23. package/build/esm/index.js.map +1 -1
  24. package/build/esm/schema/Post.js +3 -3
  25. package/build/esm/schema/Post.js.map +1 -1
  26. package/build/esm/schema/StickyPosts.js +7 -7
  27. package/build/esm/schema/StickyPosts.js.map +1 -1
  28. package/build/esm/schema/UpdateAlgorithmPayload.js +26 -26
  29. package/build/esm/schema/UpdateAlgorithmPayload.js.map +1 -1
  30. package/build/esm/schema/index.js.map +1 -1
  31. package/build/esm/schema/shared.js +9 -9
  32. package/build/esm/schema/shared.js.map +1 -1
  33. package/build/esm/stickyposts.js +3 -3
  34. package/build/esm/stickyposts.js.map +1 -1
  35. package/package.json +14 -14
  36. package/src/GrazeClient.ts +46 -45
  37. package/src/builder.ts +76 -80
  38. package/src/common.ts +4 -4
  39. package/src/index.ts +51 -55
  40. package/src/schema/Post.ts +10 -10
  41. package/src/schema/StickyPosts.ts +22 -22
  42. package/src/schema/UpdateAlgorithmPayload.ts +107 -102
  43. package/src/schema/index.ts +2 -2
  44. package/src/schema/shared.ts +28 -28
  45. package/src/stickyposts.ts +7 -7
@@ -1,10 +1,3 @@
1
- import {
2
- AlgoUpdateResponse,
3
- GetAlgoResponse,
4
- GetAlgorithmsResponse,
5
- HidePostBody,
6
- UnhidePostBody,
7
- } from "./schema/shared.js";
8
1
  import {
9
2
  FetchHttpClient,
10
3
  HttpApi,
@@ -13,32 +6,39 @@ import {
13
6
  HttpApiGroup,
14
7
  HttpApiSchema,
15
8
  HttpClient,
16
- HttpClientRequest,
17
- } from "@effect/platform";
18
- import { Config, Data, Effect, Redacted, Schema } from "effect";
9
+ HttpClientRequest
10
+ } from "@effect/platform"
11
+ import { Config, Data, Effect, Redacted, Schema } from "effect"
12
+ import {
13
+ AlgoUpdateResponse,
14
+ GetAlgoResponse,
15
+ GetAlgorithmsResponse,
16
+ HidePostBody,
17
+ UnhidePostBody
18
+ } from "./schema/shared.js"
19
19
 
20
- import * as Form from "./schema/UpdateAlgorithmPayload.js";
21
- import { FeedIdParam, UserIdParam } from "./common.js";
22
- import { StickyPostsApiGroup } from "./stickyposts.js";
20
+ import { FeedIdParam, UserIdParam } from "./common.js"
21
+ import * as Form from "./schema/UpdateAlgorithmPayload.js"
22
+ import { StickyPostsApiGroup } from "./stickyposts.js"
23
23
 
24
24
  function isStringOrBlob(val: unknown): val is string | Blob {
25
- return typeof val === "string" || val instanceof Blob;
25
+ return typeof val === "string" || val instanceof Blob
26
26
  }
27
27
 
28
28
  const encodeForm = (obj: Form.FullForm) =>
29
- Effect.gen(function* () {
30
- const encoded = yield* Schema.encode(Form.FullForm)(obj);
31
- const formData = new FormData();
29
+ Effect.gen(function*() {
30
+ const encoded = yield* Schema.encode(Form.FullForm)(obj)
31
+ const formData = new FormData()
32
32
  for (const key in encoded) {
33
- if (encoded.hasOwnProperty(key)) {
34
- const val = encoded[key as keyof Form.FullForm];
33
+ if (Object.prototype.hasOwnProperty.call(encoded, key)) {
34
+ const val = encoded[key as keyof Form.FullForm]
35
35
  if (isStringOrBlob(val)) {
36
- formData.append(key, val);
36
+ formData.append(key, val)
37
37
  }
38
38
  }
39
39
  }
40
- return formData;
41
- });
40
+ return formData
41
+ })
42
42
 
43
43
  const GrazeApiGroup = HttpApiGroup.make("graze", { topLevel: true })
44
44
  .add(
@@ -46,7 +46,7 @@ const GrazeApiGroup = HttpApiGroup.make("graze", { topLevel: true })
46
46
  .addSuccess(GetAlgorithmsResponse)
47
47
  .setPayload(
48
48
  Schema.Struct({
49
- user_id: UserIdParam,
49
+ user_id: UserIdParam
50
50
  })
51
51
  )
52
52
  )
@@ -74,16 +74,17 @@ const GrazeApiGroup = HttpApiGroup.make("graze", { topLevel: true })
74
74
  HttpApiEndpoint.post("unhidePost")`/app/unhide_post`
75
75
  .setPayload(UnhidePostBody)
76
76
  .addSuccess(Schema.Unknown)
77
- );
77
+ )
78
78
 
79
79
  class GrazeApiDef extends HttpApi.make("grazeApi")
80
80
  .add(GrazeApiGroup)
81
81
  .add(StickyPostsApiGroup)
82
- .addError(Schema.Unknown) {}
82
+ .addError(Schema.Unknown)
83
+ {}
83
84
 
84
- const grazeLive = Effect.gen(function* () {
85
- const baseUrl = yield* Config.url("GRAZE_API_URL");
86
- const cookie = yield* Config.redacted("GRAZE_COOKIE");
85
+ const grazeLive = Effect.gen(function*() {
86
+ const baseUrl = yield* Config.url("GRAZE_API_URL")
87
+ const cookie = yield* Config.redacted("GRAZE_COOKIE")
87
88
 
88
89
  const client = yield* HttpApiClient.make(GrazeApiDef, {
89
90
  baseUrl: baseUrl.toString(),
@@ -92,38 +93,38 @@ const grazeLive = Effect.gen(function* () {
92
93
  HttpClient.filterStatusOk,
93
94
  HttpClient.mapRequest(
94
95
  HttpClientRequest.setHeaders({
95
- cookie: Redacted.value(cookie),
96
+ cookie: Redacted.value(cookie)
96
97
  })
97
98
  )
98
- ),
99
- });
99
+ )
100
+ })
100
101
 
101
102
  const updateAlgorithm = (data: Form.FullForm) =>
102
- Effect.gen(function* () {
103
- const formData = yield* encodeForm(data);
104
- return yield* client.updateAlgorithm({ payload: formData });
105
- });
103
+ Effect.gen(function*() {
104
+ const formData = yield* encodeForm(data)
105
+ return yield* client.updateAlgorithm({ payload: formData })
106
+ })
106
107
 
107
- const userId = yield* Config.integer("GRAZE_USER_ID");
108
- const getFeeds = () => client.getFeeds({ payload: { user_id: userId } });
108
+ const userId = yield* Config.integer("GRAZE_USER_ID")
109
+ const getFeeds = () => client.getFeeds({ payload: { user_id: userId } })
109
110
 
110
111
  return {
111
112
  ...client,
112
113
  updateAlgorithm,
113
- getFeeds,
114
- };
115
- });
114
+ getFeeds
115
+ }
116
+ })
116
117
 
117
118
  export class GrazeClient extends Effect.Service<GrazeClient>()("GrazeClient", {
118
119
  effect: grazeLive,
119
- dependencies: [FetchHttpClient.layer],
120
+ dependencies: [FetchHttpClient.layer]
120
121
  }) {
121
122
  // TODO: test service
122
123
  }
123
124
 
124
125
  export class GrazeError extends Data.TaggedError("GrazeError")<{
125
- message: string;
126
- status: number;
127
- statusText: string;
128
- json: unknown;
126
+ message: string
127
+ status: number
128
+ statusText: string
129
+ json: unknown
129
130
  }> {}
package/src/builder.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  AttributeComparison,
3
3
  AttributeName,
4
4
  AttributeValue,
@@ -11,148 +11,144 @@ import {
11
11
  RegexNegationMatches,
12
12
  SocialGraph,
13
13
  TextMatchesAny,
14
- TextMatchesNone,
15
- } from "./schema/index.js";
14
+ TextMatchesNone
15
+ } from "./schema/index.js"
16
16
 
17
17
  const neverMatch: Filter = {
18
- or: [],
19
- };
18
+ or: []
19
+ }
20
20
 
21
- const and = (...filters: (Filter | null)[]): Filter => {
22
- const flatFilters: Filter[] = [];
21
+ const and = (...filters: Array<Filter | null>): Filter => {
22
+ const flatFilters: Array<Filter> = []
23
23
  filters.forEach((f) => {
24
24
  if (f === null) {
25
25
  // if the filter is null, we never want to match this block.
26
- flatFilters.push(neverMatch);
26
+ flatFilters.push(neverMatch)
27
27
  } else if ("and" in f) {
28
28
  // Automatically flatten nested ands.
29
- flatFilters.push(...f.and);
29
+ flatFilters.push(...f.and)
30
30
  } else {
31
- flatFilters.push(f);
31
+ flatFilters.push(f)
32
32
  }
33
- });
34
- return { and: flatFilters };
35
- };
36
- const or = (...filters: (Filter | null)[]): Filter => {
37
- const flatFilters: Filter[] = [];
33
+ })
34
+ return { and: flatFilters }
35
+ }
36
+ const or = (...filters: Array<Filter | null>): Filter => {
37
+ const flatFilters: Array<Filter> = []
38
38
  filters
39
39
  .filter((f) => f !== null)
40
40
  .forEach((f) => {
41
41
  if ("or" in f) {
42
- flatFilters.push(...f.or);
42
+ flatFilters.push(...f.or)
43
43
  } else {
44
- flatFilters.push(f);
44
+ flatFilters.push(f)
45
45
  }
46
- });
47
- return { or: flatFilters };
48
- };
46
+ })
47
+ return { or: flatFilters }
48
+ }
49
49
 
50
50
  const regexMatches = (
51
51
  attribute: RegexMatches["regex_matches"][0],
52
52
  regex: string
53
53
  ): RegexMatches => ({
54
- regex_matches: [attribute, regex, true],
55
- });
54
+ regex_matches: [attribute, regex, true]
55
+ })
56
56
 
57
57
  const regexNegationMatches = (
58
58
  attribute: RegexNegationMatches["regex_negation_matches"][0],
59
59
  regex: string
60
60
  ): RegexNegationMatches => ({
61
- regex_negation_matches: [attribute, regex, true],
62
- });
61
+ regex_negation_matches: [attribute, regex, true]
62
+ })
63
63
 
64
64
  const textMatchesAny = ({
65
65
  attribute,
66
- patterns,
67
66
  caseInsensitive = true,
68
- useRegex = false,
67
+ patterns,
68
+ useRegex = false
69
69
  }: {
70
- attribute: AttributeName;
71
- patterns: string[];
72
- caseInsensitive?: boolean;
73
- useRegex?: boolean;
70
+ attribute: AttributeName
71
+ patterns: Array<string>
72
+ caseInsensitive?: boolean
73
+ useRegex?: boolean
74
74
  }): TextMatchesAny => ({
75
- regex_any: [attribute, patterns, caseInsensitive, useRegex],
76
- });
75
+ regex_any: [attribute, patterns, caseInsensitive, useRegex]
76
+ })
77
77
 
78
78
  const textMatchesNone = ({
79
79
  attribute,
80
- patterns,
81
80
  caseInsensitive = true,
82
- useRegex = false,
81
+ patterns,
82
+ useRegex = false
83
83
  }: {
84
- attribute: AttributeName;
85
- patterns: string[];
86
- caseInsensitive?: boolean;
87
- useRegex?: boolean;
84
+ attribute: AttributeName
85
+ patterns: Array<string>
86
+ caseInsensitive?: boolean
87
+ useRegex?: boolean
88
88
  }): TextMatchesNone => ({
89
- regex_none: [attribute, patterns, caseInsensitive, useRegex],
90
- });
89
+ regex_none: [attribute, patterns, caseInsensitive, useRegex]
90
+ })
91
91
 
92
92
  const isListMember = (uri: string): ListMemberFilter => ({
93
- list_member: [uri, "in"],
94
- });
93
+ list_member: [uri, "in"]
94
+ })
95
95
  const isNotListMember = (uri: string): ListMemberFilter => ({
96
- list_member: [uri, "not_in"],
97
- });
96
+ list_member: [uri, "not_in"]
97
+ })
98
98
  const socialGraph = (
99
99
  identifier: string,
100
100
  op: SocialGraph["social_graph"][1],
101
101
  relation: SocialGraph["social_graph"][2]
102
102
  ): SocialGraph => ({
103
- social_graph: [identifier, op, relation],
104
- });
105
- const posterIsFollowedBy = (identifier: string) =>
106
- socialGraph(identifier, "in", "followers");
107
- const posterFollows = (identifier: string) =>
108
- socialGraph(identifier, "in", "follows");
109
- const posterIsNotFollowedBy = (identifier: string) =>
110
- socialGraph(identifier, "not_in", "followers");
111
- const posterDoesNotFollow = (identifier: string) =>
112
- socialGraph(identifier, "not_in", "follows");
103
+ social_graph: [identifier, op, relation]
104
+ })
105
+ const posterIsFollowedBy = (identifier: string) => socialGraph(identifier, "in", "followers")
106
+ const posterFollows = (identifier: string) => socialGraph(identifier, "in", "follows")
107
+ const posterIsNotFollowedBy = (identifier: string) => socialGraph(identifier, "not_in", "followers")
108
+ const posterDoesNotFollow = (identifier: string) => socialGraph(identifier, "not_in", "follows")
113
109
 
114
110
  const embedContains = (type: EmbedType["embed_type"][1]): Filter => ({
115
- embed_type: ["==", type],
116
- });
111
+ embed_type: ["==", type]
112
+ })
117
113
  const embedDoesNotContain = (type: EmbedType["embed_type"][1]): Filter => ({
118
- embed_type: ["!=", type],
119
- });
114
+ embed_type: ["!=", type]
115
+ })
120
116
 
121
117
  const postTypeIs = (...types: PostTypeFilter["post_type"][1]): Filter => ({
122
- post_type: ["in", types],
123
- });
118
+ post_type: ["in", types]
119
+ })
124
120
  const postTypeIsNot = (...types: PostTypeFilter["post_type"][1]): Filter => ({
125
- post_type: ["not_in", types],
126
- });
121
+ post_type: ["not_in", types]
122
+ })
127
123
 
128
- const hasVideo: Filter = embedContains("video");
124
+ const hasVideo: Filter = embedContains("video")
129
125
 
130
126
  const hasNoNSFWLabels: Filter = {
131
- entity_excludes: ["labels", ["porn", "sexual", "nudity"]],
132
- };
127
+ entity_excludes: ["labels", ["porn", "sexual", "nudity"]]
128
+ }
133
129
  const attributeCompare = (
134
130
  attr: AttributeName,
135
131
  op: AttributeComparison,
136
132
  value: AttributeValue
137
133
  ): Filter => ({
138
- attribute_compare: [attr, op, value],
139
- });
134
+ attribute_compare: [attr, op, value]
135
+ })
140
136
 
141
- const isPost: Filter = postTypeIsNot("reply", "quote");
142
- const isReply: Filter = postTypeIs("reply");
143
- const isQuote: Filter = postTypeIs("quote");
144
- const isNotReply: Filter = postTypeIsNot("reply");
145
- const isNotQuote: Filter = postTypeIsNot("quote");
137
+ const isPost: Filter = postTypeIsNot("reply", "quote")
138
+ const isReply: Filter = postTypeIs("reply")
139
+ const isQuote: Filter = postTypeIs("quote")
140
+ const isNotReply: Filter = postTypeIsNot("reply")
141
+ const isNotQuote: Filter = postTypeIsNot("quote")
146
142
 
147
143
  const isContentOk = (threshold: number = 0.9): ContentModerationBlock => ({
148
- content_moderation: ["OK", ">=", threshold],
149
- });
144
+ content_moderation: ["OK", ">=", threshold]
145
+ })
150
146
 
151
147
  export const Algo = {
152
- filter: (...filters: Filter[]): { filter: Filter } => ({
153
- filter: and(...filters),
154
- }),
155
- };
148
+ filter: (...filters: Array<Filter>): { filter: Filter } => ({
149
+ filter: and(...filters)
150
+ })
151
+ }
156
152
 
157
153
  export const F = {
158
154
  and,
@@ -180,5 +176,5 @@ export const F = {
180
176
  isNotQuote,
181
177
  isContentOk,
182
178
  embedContains,
183
- embedDoesNotContain,
184
- };
179
+ embedDoesNotContain
180
+ }
package/src/common.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { HttpApiSchema } from "@effect/platform";
2
- import { Schema } from "effect";
1
+ import { HttpApiSchema } from "@effect/platform"
2
+ import { Schema } from "effect"
3
3
 
4
4
  export const UserIdParam = HttpApiSchema.param(
5
5
  "userId",
6
6
  Schema.NumberFromString
7
- );
7
+ )
8
8
  export const FeedIdParam = HttpApiSchema.param(
9
9
  "feedId",
10
10
  Schema.NumberFromString
11
- );
11
+ )
package/src/index.ts CHANGED
@@ -1,89 +1,85 @@
1
- import { ConfigProvider, Effect, Layer } from "effect";
2
- import { GrazeClient } from "./GrazeClient.js";
1
+ import { ConfigProvider, Effect, Layer } from "effect"
2
+ import { GrazeClient } from "./GrazeClient.js"
3
3
 
4
4
  type Promisify<T> = T extends (
5
- ...args: any[]
6
- ) => Effect.Effect<infer A, infer E, never>
7
- ? (...args: Parameters<T>) => Promise<A>
8
- : never;
5
+ ...args: Array<any>
6
+ ) => Effect.Effect<infer A, infer _E, never> ? (...args: Parameters<T>) => Promise<A>
7
+ : never
9
8
 
10
9
  export class GrazeService {
11
- getFeed: Promisify<typeof GrazeClient.Service.getFeed>;
12
- getFeeds: Promisify<typeof GrazeClient.Service.getFeeds>;
13
- hidePost: Promisify<typeof GrazeClient.Service.hidePost>;
14
- unhidePost: Promisify<typeof GrazeClient.Service.unhidePost>;
15
- updateAlgorithm: Promisify<typeof GrazeClient.Service.updateAlgorithm>;
16
- publishAlgorithm: Promisify<typeof GrazeClient.Service.publishAlgorithm>;
10
+ getFeed: Promisify<typeof GrazeClient.Service.getFeed>
11
+ getFeeds: Promisify<typeof GrazeClient.Service.getFeeds>
12
+ hidePost: Promisify<typeof GrazeClient.Service.hidePost>
13
+ unhidePost: Promisify<typeof GrazeClient.Service.unhidePost>
14
+ updateAlgorithm: Promisify<typeof GrazeClient.Service.updateAlgorithm>
15
+ publishAlgorithm: Promisify<typeof GrazeClient.Service.publishAlgorithm>
17
16
  stickyposts: {
18
- get: Promisify<typeof GrazeClient.Service.stickyposts.get>;
19
- create: Promisify<typeof GrazeClient.Service.stickyposts.create>;
20
- delete: Promisify<typeof GrazeClient.Service.stickyposts.delete>;
21
- update: Promisify<typeof GrazeClient.Service.stickyposts.update>;
22
- };
17
+ get: Promisify<typeof GrazeClient.Service.stickyposts.get>
18
+ create: Promisify<typeof GrazeClient.Service.stickyposts.create>
19
+ delete: Promisify<typeof GrazeClient.Service.stickyposts.delete>
20
+ update: Promisify<typeof GrazeClient.Service.stickyposts.update>
21
+ }
23
22
 
24
23
  constructor({
25
24
  apiUrl,
26
25
  cookie,
27
- userId,
26
+ userId
28
27
  }: {
29
- apiUrl: string;
30
- cookie: string;
31
- userId: number;
28
+ apiUrl: string
29
+ cookie: string
30
+ userId: number
32
31
  }) {
33
32
  const envMap = new Map([
34
33
  ["GRAZE_API_URL", apiUrl],
35
34
  ["GRAZE_COOKIE", cookie],
36
- ["GRAZE_USER_ID", userId.toString()],
37
- ]);
38
- const provider = ConfigProvider.fromMap(envMap);
39
- const layer = Layer.setConfigProvider(provider);
35
+ ["GRAZE_USER_ID", userId.toString()]
36
+ ])
37
+ const provider = ConfigProvider.fromMap(envMap)
38
+ const layer = Layer.setConfigProvider(provider)
40
39
  const make = setup.pipe(
41
40
  Effect.provide(GrazeClient.Default),
42
41
  Effect.provide(layer)
43
- );
44
- const api = Effect.runSync(make);
45
- this.getFeed = api.getFeed;
46
- this.getFeeds = api.getFeeds;
47
- this.hidePost = api.hidePost;
48
- this.unhidePost = api.unhidePost;
49
- this.updateAlgorithm = api.updateAlgorithm;
50
- this.publishAlgorithm = api.publishAlgorithm;
42
+ )
43
+ const api = Effect.runSync(make)
44
+ this.getFeed = api.getFeed
45
+ this.getFeeds = api.getFeeds
46
+ this.hidePost = api.hidePost
47
+ this.unhidePost = api.unhidePost
48
+ this.updateAlgorithm = api.updateAlgorithm
49
+ this.publishAlgorithm = api.publishAlgorithm
51
50
  this.stickyposts = {
52
51
  get: api.getStickyPosts,
53
52
  create: api.createStickyPost,
54
53
  delete: api.deleteStickyPost,
55
- update: api.updateStickyPost,
56
- };
54
+ update: api.updateStickyPost
55
+ }
57
56
  }
58
57
  }
59
58
 
60
- const setup = Effect.gen(function* () {
61
- const client = yield* GrazeClient;
62
- const getFeed = (...args: Parameters<typeof client.getFeed>) =>
63
- client.getFeed(...args).pipe(Effect.runPromise);
64
- const getFeeds = (...args: Parameters<typeof client.getFeeds>) =>
65
- client.getFeeds(...args).pipe(Effect.runPromise);
66
- const hidePost = (...args: Parameters<typeof client.hidePost>) =>
67
- client.hidePost(...args).pipe(Effect.runPromise);
59
+ const setup = Effect.gen(function*() {
60
+ const client = yield* GrazeClient
61
+ const getFeed = (...args: Parameters<typeof client.getFeed>) => client.getFeed(...args).pipe(Effect.runPromise)
62
+ const getFeeds = (...args: Parameters<typeof client.getFeeds>) => client.getFeeds(...args).pipe(Effect.runPromise)
63
+ const hidePost = (...args: Parameters<typeof client.hidePost>) => client.hidePost(...args).pipe(Effect.runPromise)
68
64
  const unhidePost = (...args: Parameters<typeof client.unhidePost>) =>
69
- client.unhidePost(...args).pipe(Effect.runPromise);
65
+ client.unhidePost(...args).pipe(Effect.runPromise)
70
66
  const updateAlgorithm = (
71
67
  ...args: Parameters<typeof client.updateAlgorithm>
72
- ) => client.updateAlgorithm(...args).pipe(Effect.runPromise);
68
+ ) => client.updateAlgorithm(...args).pipe(Effect.runPromise)
73
69
  const publishAlgorithm = (
74
70
  ...args: Parameters<typeof client.publishAlgorithm>
75
- ) => client.publishAlgorithm(...args).pipe(Effect.runPromise);
71
+ ) => client.publishAlgorithm(...args).pipe(Effect.runPromise)
76
72
  const getStickyPosts = (...args: Parameters<typeof client.stickyposts.get>) =>
77
- client.stickyposts.get(...args).pipe(Effect.runPromise);
73
+ client.stickyposts.get(...args).pipe(Effect.runPromise)
78
74
  const createStickyPost = (
79
75
  ...args: Parameters<typeof client.stickyposts.create>
80
- ) => client.stickyposts.create(...args).pipe(Effect.runPromise);
76
+ ) => client.stickyposts.create(...args).pipe(Effect.runPromise)
81
77
  const deleteStickyPost = (
82
78
  ...args: Parameters<typeof client.stickyposts.delete>
83
- ) => client.stickyposts.delete(...args).pipe(Effect.runPromise);
79
+ ) => client.stickyposts.delete(...args).pipe(Effect.runPromise)
84
80
  const updateStickyPost = (
85
81
  ...args: Parameters<typeof client.stickyposts.update>
86
- ) => client.stickyposts.update(...args).pipe(Effect.runPromise);
82
+ ) => client.stickyposts.update(...args).pipe(Effect.runPromise)
87
83
 
88
84
  return {
89
85
  getFeed,
@@ -95,9 +91,9 @@ const setup = Effect.gen(function* () {
95
91
  getStickyPosts,
96
92
  createStickyPost,
97
93
  deleteStickyPost,
98
- updateStickyPost,
99
- };
100
- });
94
+ updateStickyPost
95
+ }
96
+ })
101
97
 
102
- export * from "./schema/index.js";
103
- export { F, Algo } from "./builder.js";
98
+ export { Algo, F } from "./builder.js"
99
+ export * from "./schema/index.js"
@@ -1,4 +1,4 @@
1
- import { Schema as S } from "effect";
1
+ import { Schema as S } from "effect"
2
2
 
3
3
  /**
4
4
  * Schema for Bluesky objects
@@ -13,9 +13,9 @@ export const Author = S.Struct({
13
13
  viewer: S.Any,
14
14
  createdAt: S.String,
15
15
  associated: S.Union(S.Null, S.Any),
16
- displayName: S.String,
17
- });
18
- export type Author = typeof Author.Type;
16
+ displayName: S.String
17
+ })
18
+ export type Author = typeof Author.Type
19
19
 
20
20
  export const Record = S.Struct({
21
21
  tags: S.Union(S.Null, S.Any),
@@ -27,9 +27,9 @@ export const Record = S.Struct({
27
27
  facets: S.NullOr(S.Array(S.Any)),
28
28
  labels: S.Union(S.Null, S.Any),
29
29
  entities: S.Union(S.Null, S.Any),
30
- createdAt: S.String,
31
- });
32
- export type Record = typeof Record.Type;
30
+ createdAt: S.String
31
+ })
32
+ export type Record = typeof Record.Type
33
33
 
34
34
  export const Post = S.Struct({
35
35
  cid: S.String,
@@ -45,6 +45,6 @@ export const Post = S.Struct({
45
45
  quoteCount: S.Number,
46
46
  replyCount: S.Number,
47
47
  threadgate: S.Union(S.Null, S.Unknown),
48
- repostCount: S.Number,
49
- });
50
- export type Post = typeof Post.Type;
48
+ repostCount: S.Number
49
+ })
50
+ export type Post = typeof Post.Type
@@ -1,33 +1,33 @@
1
- import { Schema as S } from "effect";
2
- import { Post } from "./Post.js";
3
- import { HttpApiSchema } from "@effect/platform";
1
+ import { HttpApiSchema } from "@effect/platform"
2
+ import { Schema as S } from "effect"
3
+ import { Post } from "./Post.js"
4
4
 
5
5
  export const StickyPostIdParam = HttpApiSchema.param(
6
6
  "stickyPostId",
7
7
  S.NumberFromString
8
- );
9
- export type StickyPostIdParam = typeof StickyPostIdParam.Type;
8
+ )
9
+ export type StickyPostIdParam = typeof StickyPostIdParam.Type
10
10
 
11
11
  export const StoppingCriteria = S.Struct({
12
- expiration_time: S.Number.pipe(S.optional),
13
- });
14
- export type StoppingCriteria = typeof StoppingCriteria.Type;
12
+ expiration_time: S.Number.pipe(S.optional)
13
+ })
14
+ export type StoppingCriteria = typeof StoppingCriteria.Type
15
15
 
16
- export const StickyType = S.Literal("pinned", "rotating");
17
- export type StickyType = typeof StickyType.Type;
16
+ export const StickyType = S.Literal("pinned", "rotating")
17
+ export type StickyType = typeof StickyType.Type
18
18
 
19
19
  const StickyPostBase = S.Struct({
20
20
  is_active: S.Boolean,
21
- sticky_type: StickyType,
22
- });
21
+ sticky_type: StickyType
22
+ })
23
23
 
24
24
  export const CreateStickyPostBody = S.Struct({
25
25
  algo_id: S.Number,
26
26
  post_url: S.String,
27
27
  stopping_criteria: StoppingCriteria.pipe(S.optional),
28
- ...StickyPostBase.fields,
29
- });
30
- export type CreateStickyPostBody = typeof CreateStickyPostBody.Type;
28
+ ...StickyPostBase.fields
29
+ })
30
+ export type CreateStickyPostBody = typeof CreateStickyPostBody.Type
31
31
 
32
32
  export const GetStickyPostsBody = S.Struct({
33
33
  sticky_posts: S.Array(
@@ -40,13 +40,13 @@ export const GetStickyPostsBody = S.Struct({
40
40
  post: Post,
41
41
  author: S.String,
42
42
  created_at: S.String,
43
- updated_at: S.String,
43
+ updated_at: S.String
44
44
  })
45
- ),
46
- });
47
- export type GetStickyPostsBody = typeof GetStickyPostsBody.Type;
45
+ )
46
+ })
47
+ export type GetStickyPostsBody = typeof GetStickyPostsBody.Type
48
48
 
49
49
  export const StickyPostSuccess = S.Struct({
50
- message: S.String,
51
- });
52
- export type StickyPostSuccess = typeof StickyPostSuccess.Type;
50
+ message: S.String
51
+ })
52
+ export type StickyPostSuccess = typeof StickyPostSuccess.Type