graze-client 0.2.4 → 0.3.0
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/build/cjs/builder.js +91 -0
- package/build/cjs/builder.js.map +1 -0
- package/build/cjs/schema/UpdateAlgorithmPayload.js +5 -2
- package/build/cjs/schema/UpdateAlgorithmPayload.js.map +1 -1
- package/build/dts/builder.d.ts +42 -0
- package/build/dts/builder.d.ts.map +1 -0
- package/build/dts/schema/UpdateAlgorithmPayload.d.ts +25 -1
- package/build/dts/schema/UpdateAlgorithmPayload.d.ts.map +1 -1
- package/build/esm/builder.js +85 -0
- package/build/esm/builder.js.map +1 -0
- package/build/esm/schema/UpdateAlgorithmPayload.js +4 -1
- package/build/esm/schema/UpdateAlgorithmPayload.js.map +1 -1
- package/package.json +5 -13
- package/src/builder.ts +119 -0
- package/src/schema/UpdateAlgorithmPayload.ts +14 -2
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.F = exports.Algo = void 0;
|
|
7
|
+
const and = (...filters) => {
|
|
8
|
+
const flatFilters = [];
|
|
9
|
+
filters.forEach(f => {
|
|
10
|
+
if ("and" in f) {
|
|
11
|
+
// Automatically flatten nested ands.
|
|
12
|
+
flatFilters.push(...f.and);
|
|
13
|
+
} else {
|
|
14
|
+
flatFilters.push(f);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
and: flatFilters
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const or = (...filters) => {
|
|
22
|
+
const flatFilters = [];
|
|
23
|
+
filters.forEach(f => {
|
|
24
|
+
if ("or" in f) {
|
|
25
|
+
flatFilters.push(...f.or);
|
|
26
|
+
} else {
|
|
27
|
+
flatFilters.push(f);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
or: flatFilters
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const regexMatches = (attribute, regex) => ({
|
|
35
|
+
regex_matches: [attribute, regex, true]
|
|
36
|
+
});
|
|
37
|
+
const regexNegationMatches = (attribute, regex) => ({
|
|
38
|
+
regex_negation_matches: [attribute, regex, true]
|
|
39
|
+
});
|
|
40
|
+
const isListMember = uri => ({
|
|
41
|
+
list_member: [uri, "in"]
|
|
42
|
+
});
|
|
43
|
+
const isNotListMember = uri => ({
|
|
44
|
+
list_member: [uri, "not_in"]
|
|
45
|
+
});
|
|
46
|
+
const socialGraph = (identifier, op, relation) => ({
|
|
47
|
+
social_graph: [identifier, op, relation]
|
|
48
|
+
});
|
|
49
|
+
const posterIsFollowedBy = identifier => socialGraph(identifier, "in", "followers");
|
|
50
|
+
const posterFollows = identifier => socialGraph(identifier, "in", "follows");
|
|
51
|
+
const posterIsNotFollowedBy = identifier => socialGraph(identifier, "not_in", "followers");
|
|
52
|
+
const posterDoesNotFollow = identifier => socialGraph(identifier, "not_in", "follows");
|
|
53
|
+
const hasVideo = {
|
|
54
|
+
embed_type: ["==", "video"]
|
|
55
|
+
};
|
|
56
|
+
const hasNoNSFWLabels = {
|
|
57
|
+
entity_excludes: ["labels", ["porn", "sexual", "nudity"]]
|
|
58
|
+
};
|
|
59
|
+
const attributeCompare = (attr, op, value) => ({
|
|
60
|
+
attribute_compare: [attr, op, value]
|
|
61
|
+
});
|
|
62
|
+
const isPost = /*#__PURE__*/attributeCompare("reply", "==", null);
|
|
63
|
+
const isReply = /*#__PURE__*/attributeCompare("reply", "!=", null);
|
|
64
|
+
const isContentOk = (threshold = 0.9) => ({
|
|
65
|
+
content_moderation: ["OK", ">=", threshold]
|
|
66
|
+
});
|
|
67
|
+
const Algo = exports.Algo = {
|
|
68
|
+
filter: (...filters) => ({
|
|
69
|
+
filter: and(...filters)
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
const F = exports.F = {
|
|
73
|
+
and,
|
|
74
|
+
or,
|
|
75
|
+
regexMatches,
|
|
76
|
+
regexNegationMatches,
|
|
77
|
+
attributeCompare,
|
|
78
|
+
isListMember,
|
|
79
|
+
isNotListMember,
|
|
80
|
+
socialGraph,
|
|
81
|
+
posterIsFollowedBy,
|
|
82
|
+
posterFollows,
|
|
83
|
+
posterIsNotFollowedBy,
|
|
84
|
+
posterDoesNotFollow,
|
|
85
|
+
hasVideo,
|
|
86
|
+
hasNoNSFWLabels,
|
|
87
|
+
isPost,
|
|
88
|
+
isReply,
|
|
89
|
+
isContentOk
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","names":["and","filters","flatFilters","forEach","f","push","or","regexMatches","attribute","regex","regex_matches","regexNegationMatches","regex_negation_matches","isListMember","uri","list_member","isNotListMember","socialGraph","identifier","op","relation","social_graph","posterIsFollowedBy","posterFollows","posterIsNotFollowedBy","posterDoesNotFollow","hasVideo","embed_type","hasNoNSFWLabels","entity_excludes","attributeCompare","attr","value","attribute_compare","isPost","isReply","isContentOk","threshold","content_moderation","Algo","exports","filter","F"],"sources":["../../src/builder.ts"],"sourcesContent":[null],"mappings":";;;;;;AAYA,MAAMA,GAAG,GAAGA,CAAC,GAAGC,OAAiB,KAAI;EACnC,MAAMC,WAAW,GAAa,EAAE;EAChCD,OAAO,CAACE,OAAO,CAAEC,CAAC,IAAI;IACpB,IAAI,KAAK,IAAIA,CAAC,EAAE;MACd;MACAF,WAAW,CAACG,IAAI,CAAC,GAAGD,CAAC,CAACJ,GAAG,CAAC;IAC5B,CAAC,MAAM;MACLE,WAAW,CAACG,IAAI,CAACD,CAAC,CAAC;IACrB;EACF,CAAC,CAAC;EACF,OAAO;IAAEJ,GAAG,EAAEE;EAAW,CAAE;AAC7B,CAAC;AACD,MAAMI,EAAE,GAAGA,CAAC,GAAGL,OAAiB,KAAI;EAClC,MAAMC,WAAW,GAAa,EAAE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= exports.RegexNegationMatches = exports.RegexMatches = exports.RecordName = exports.Order = exports.Or = exports.Metadata = exports.ListUri = exports.ListMemberFilter = exports.FullForm = exports.Filter = exports.FeedId = exports.EntityExcludesLabels = exports.EmbedType = exports.DisplayName = exports.Description = exports.ContentModerationBlock = exports.AttributeValue = exports.AttributeName = exports.AttributeComparison = exports.AttributeCompare = exports.And = exports.AlgorithmManifest = void 0;
|
|
6
|
+
exports.UserId = exports.SortSettings = exports.SocialGraph = exports.RegexNegationMatches = exports.RegexMatches = exports.RecordName = exports.Order = exports.Or = exports.Metadata = exports.ListUri = exports.ListMemberFilter = exports.FullForm = exports.Filter = exports.FeedId = exports.EntityExcludesLabels = exports.EmbedType = exports.DisplayName = exports.Description = exports.ContentModerationBlock = exports.AttributeValue = exports.AttributeName = exports.AttributeComparison = exports.AttributeCompare = exports.And = exports.AlgorithmManifest = void 0;
|
|
7
7
|
var _effect = require("effect");
|
|
8
8
|
// ------------------- Primitives ---------------------------------
|
|
9
9
|
const ListUri = exports.ListUri = _effect.Schema.String;
|
|
10
10
|
const AttributeName = exports.AttributeName = /*#__PURE__*/_effect.Schema.Union(/*#__PURE__*/_effect.Schema.Literal("text"), /*#__PURE__*/_effect.Schema.Literal("reply"), /*#__PURE__*/_effect.Schema.Literal("embed.images[*].alt"), /*#__PURE__*/_effect.Schema.Literal("embed.alt"), /*#__PURE__*/_effect.Schema.Literal("embed"), /*#__PURE__*/_effect.Schema.Literal("embed.external.uri"), /*#__PURE__*/_effect.Schema.Literal("embed.external.title"), /*#__PURE__*/_effect.Schema.Literal("embed.external.description"));
|
|
11
11
|
const AttributeComparison = exports.AttributeComparison = /*#__PURE__*/_effect.Schema.Literal("==", "!=", ">", "<", ">=", "<=");
|
|
12
12
|
const AttributeValue = exports.AttributeValue = _effect.Schema.Null;
|
|
13
|
-
const Filter = exports.Filter = /*#__PURE__*/_effect.Schema.Union(/*#__PURE__*/_effect.Schema.suspend(() => And), /*#__PURE__*/_effect.Schema.suspend(() => Or), /*#__PURE__*/_effect.Schema.suspend(() => ListMemberFilter), /*#__PURE__*/_effect.Schema.suspend(() => AttributeCompare), /*#__PURE__*/_effect.Schema.suspend(() => RegexMatches), /*#__PURE__*/_effect.Schema.suspend(() => RegexNegationMatches), /*#__PURE__*/_effect.Schema.suspend(() => ContentModerationBlock), /*#__PURE__*/_effect.Schema.suspend(() => EntityExcludesLabels), /*#__PURE__*/_effect.Schema.suspend(() => EmbedType));
|
|
13
|
+
const Filter = exports.Filter = /*#__PURE__*/_effect.Schema.Union(/*#__PURE__*/_effect.Schema.suspend(() => And), /*#__PURE__*/_effect.Schema.suspend(() => Or), /*#__PURE__*/_effect.Schema.suspend(() => ListMemberFilter), /*#__PURE__*/_effect.Schema.suspend(() => AttributeCompare), /*#__PURE__*/_effect.Schema.suspend(() => RegexMatches), /*#__PURE__*/_effect.Schema.suspend(() => RegexNegationMatches), /*#__PURE__*/_effect.Schema.suspend(() => ContentModerationBlock), /*#__PURE__*/_effect.Schema.suspend(() => EntityExcludesLabels), /*#__PURE__*/_effect.Schema.suspend(() => EmbedType), /*#__PURE__*/_effect.Schema.suspend(() => SocialGraph));
|
|
14
14
|
const Or = exports.Or = /*#__PURE__*/_effect.Schema.Struct({
|
|
15
15
|
or: /*#__PURE__*/_effect.Schema.Array(Filter)
|
|
16
16
|
});
|
|
@@ -48,6 +48,9 @@ const EntityExcludesLabels = exports.EntityExcludesLabels = /*#__PURE__*/_effect
|
|
|
48
48
|
const EmbedType = exports.EmbedType = /*#__PURE__*/_effect.Schema.Struct({
|
|
49
49
|
embed_type: /*#__PURE__*/_effect.Schema.Tuple(/*#__PURE__*/_effect.Schema.Literal("==", "!="), /*#__PURE__*/_effect.Schema.Literal("video", "image", "link", "post", "gif", "image_group"))
|
|
50
50
|
});
|
|
51
|
+
const SocialGraph = exports.SocialGraph = /*#__PURE__*/_effect.Schema.Struct({
|
|
52
|
+
social_graph: /*#__PURE__*/_effect.Schema.Tuple(_effect.Schema.String, /*#__PURE__*/_effect.Schema.Literal("in", "not_in"), /*#__PURE__*/_effect.Schema.Literal("follows", "followers"))
|
|
53
|
+
});
|
|
51
54
|
// ---------------------- Sort Settings -----------------------------
|
|
52
55
|
const SortSettings = exports.SortSettings = /*#__PURE__*/_effect.Schema.Struct({
|
|
53
56
|
time_window: _effect.Schema.Number,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateAlgorithmPayload.js","names":["_effect","require","ListUri","exports","S","String","AttributeName","Union","Literal","AttributeComparison","AttributeValue","Null","Filter","suspend","And","Or","ListMemberFilter","AttributeCompare","RegexMatches","RegexNegationMatches","ContentModerationBlock","EntityExcludesLabels","EmbedType","Struct","or","Array","and","list_member","Tuple","attribute_compare","RegexMatchBase","annotations","title","description","Boolean","regex_matches","regex_negation_matches","content_moderation","Number","entity_excludes","embed_type","SortSettings","time_window","decay_penalty","like_count_multiplier","reply_count_multiplier","repost_count_multiplier","reader_like_count_multiplier","reader_reply_count_multiplier","reader_repost_count_multiplier","DisplayName","RecordName","Description","Order","FeedId","NumberFromString","UserId","AlgorithmManifest","filter","sort_settings","optional","Metadata","document","Unknown","schema","schemaVersion","sequences","Record","key","value","session","FullForm","id","user_id","file","display_name","record_name","order","algorithm_manifest","parseJson","metadata"],"sources":["../../../src/schema/UpdateAlgorithmPayload.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AAEO,MAAMC,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAGE,cAAC,CAACC,MAAM;AAGxB,MAAMC,aAAa,GAAAH,OAAA,CAAAG,aAAA,gBAAGF,cAAC,CAACG,KAAK,cAClCH,cAAC,CAACI,OAAO,CAAC,MAAM,CAAC,eACjBJ,cAAC,CAACI,OAAO,CAAC,OAAO,CAAC,eAClBJ,cAAC,CAACI,OAAO,CAAC,qBAAqB,CAAC,eAChCJ,cAAC,CAACI,OAAO,CAAC,WAAW,CAAC,eACtBJ,cAAC,CAACI,OAAO,CAAC,OAAO,CAAC,eAClBJ,cAAC,CAACI,OAAO,CAAC,oBAAoB,CAAC,eAC/BJ,cAAC,CAACI,OAAO,CAAC,sBAAsB,CAAC,eACjCJ,cAAC,CAACI,OAAO,CAAC,4BAA4B,CAAC,CACxC;AAEM,MAAMC,mBAAmB,GAAAN,OAAA,CAAAM,mBAAA,gBAAGL,cAAC,CAACI,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;AAEvE,MAAME,cAAc,GAAAP,OAAA,CAAAO,cAAA,GAAGN,cAAC,CAACO,IAAI;
|
|
1
|
+
{"version":3,"file":"UpdateAlgorithmPayload.js","names":["_effect","require","ListUri","exports","S","String","AttributeName","Union","Literal","AttributeComparison","AttributeValue","Null","Filter","suspend","And","Or","ListMemberFilter","AttributeCompare","RegexMatches","RegexNegationMatches","ContentModerationBlock","EntityExcludesLabels","EmbedType","SocialGraph","Struct","or","Array","and","list_member","Tuple","attribute_compare","RegexMatchBase","annotations","title","description","Boolean","regex_matches","regex_negation_matches","content_moderation","Number","entity_excludes","embed_type","social_graph","SortSettings","time_window","decay_penalty","like_count_multiplier","reply_count_multiplier","repost_count_multiplier","reader_like_count_multiplier","reader_reply_count_multiplier","reader_repost_count_multiplier","DisplayName","RecordName","Description","Order","FeedId","NumberFromString","UserId","AlgorithmManifest","filter","sort_settings","optional","Metadata","document","Unknown","schema","schemaVersion","sequences","Record","key","value","session","FullForm","id","user_id","file","display_name","record_name","order","algorithm_manifest","parseJson","metadata"],"sources":["../../../src/schema/UpdateAlgorithmPayload.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AAEO,MAAMC,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAGE,cAAC,CAACC,MAAM;AAGxB,MAAMC,aAAa,GAAAH,OAAA,CAAAG,aAAA,gBAAGF,cAAC,CAACG,KAAK,cAClCH,cAAC,CAACI,O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 @@
|
|
|
1
|
+
import { AttributeComparison, AttributeName, AttributeValue, ContentModerationBlock, Filter, ListMemberFilter, RegexMatches, RegexNegationMatches, SocialGraph } from "./schema/index.js";
|
|
2
|
+
export declare const Algo: {
|
|
3
|
+
filter: (...filters: Filter[]) => {
|
|
4
|
+
filter: Filter;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export declare const F: {
|
|
8
|
+
and: (...filters: Filter[]) => {
|
|
9
|
+
and: Filter[];
|
|
10
|
+
};
|
|
11
|
+
or: (...filters: Filter[]) => {
|
|
12
|
+
or: Filter[];
|
|
13
|
+
};
|
|
14
|
+
regexMatches: (attribute: RegexMatches["regex_matches"][0], regex: string) => RegexMatches;
|
|
15
|
+
regexNegationMatches: (attribute: RegexNegationMatches["regex_negation_matches"][0], regex: string) => RegexNegationMatches;
|
|
16
|
+
attributeCompare: (attr: AttributeName, op: AttributeComparison, value: AttributeValue) => Filter;
|
|
17
|
+
isListMember: (uri: string) => ListMemberFilter;
|
|
18
|
+
isNotListMember: (uri: string) => ListMemberFilter;
|
|
19
|
+
socialGraph: (identifier: string, op: SocialGraph["social_graph"][1], relation: SocialGraph["social_graph"][2]) => SocialGraph;
|
|
20
|
+
posterIsFollowedBy: (identifier: string) => Readonly<{
|
|
21
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
22
|
+
}>;
|
|
23
|
+
posterFollows: (identifier: string) => Readonly<{
|
|
24
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
25
|
+
}>;
|
|
26
|
+
posterIsNotFollowedBy: (identifier: string) => Readonly<{
|
|
27
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
28
|
+
}>;
|
|
29
|
+
posterDoesNotFollow: (identifier: string) => Readonly<{
|
|
30
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
31
|
+
}>;
|
|
32
|
+
hasVideo: Readonly<{
|
|
33
|
+
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
34
|
+
}>;
|
|
35
|
+
hasNoNSFWLabels: Readonly<{
|
|
36
|
+
entity_excludes: readonly ["labels", readonly ["porn", "sexual", "nudity"]];
|
|
37
|
+
}>;
|
|
38
|
+
isPost: Filter;
|
|
39
|
+
isReply: Filter;
|
|
40
|
+
isContentOk: (threshold?: number) => ContentModerationBlock;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAoF3B,eAAO,MAAM,IAAI;yBACM,MAAM,EAAE,KAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;CAGnD,CAAC;AAEF,eAAO,MAAM,CAAC;sBAxFW,MAAM,EAAE;;;qBAYT,MAAM,EAAE;;;8BAanB,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SACpC,MAAM,KACZ,YAAY;sCAKF,oBAAoB,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,SACrD,MAAM,KACZ,oBAAoB;6BAkCf,aAAa,MACf,mBAAmB,SAChB,cAAc,KACpB,MAAM;wBAjCkB,MAAM,KAAG,gBAAgB;2BAGtB,MAAM,KAAG,gBAAgB;8BAIzC,MAAM,MACd,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,YACxB,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KACvC,WAAW;qCAG0B,MAAM;;;gCAEX,MAAM;;;wCAEE,MAAM;;;sCAER,MAAM;;;;;;;;;;;8BAqBf,MAAM,KAAS,sBAAsB;CA4BpE,CAAC"}
|
|
@@ -7,7 +7,7 @@ export declare const AttributeComparison: S.Literal<["==", "!=", ">", "<", ">=",
|
|
|
7
7
|
export type AttributeComparison = typeof AttributeComparison.Type;
|
|
8
8
|
export declare const AttributeValue: typeof S.Null;
|
|
9
9
|
export type AttributeValue = typeof AttributeValue.Type;
|
|
10
|
-
export type Filter = And | Or | ListMemberFilter | AttributeCompare | RegexMatches | RegexNegationMatches | ContentModerationBlock | EntityExcludesLabels | EmbedType;
|
|
10
|
+
export type Filter = And | Or | ListMemberFilter | AttributeCompare | RegexMatches | RegexNegationMatches | ContentModerationBlock | EntityExcludesLabels | EmbedType | SocialGraph;
|
|
11
11
|
export type And = Readonly<{
|
|
12
12
|
and: ReadonlyArray<Filter>;
|
|
13
13
|
}>;
|
|
@@ -42,6 +42,9 @@ export type EmbedType = Readonly<{
|
|
|
42
42
|
"video" | "image" | "link" | "post" | "gif" | "image_group"
|
|
43
43
|
];
|
|
44
44
|
}>;
|
|
45
|
+
export type SocialGraph = Readonly<{
|
|
46
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
47
|
+
}>;
|
|
45
48
|
export declare const Filter: S.Union<[S.suspend<Readonly<{
|
|
46
49
|
and: ReadonlyArray<Filter>;
|
|
47
50
|
}>, Readonly<{
|
|
@@ -78,6 +81,10 @@ export declare const Filter: S.Union<[S.suspend<Readonly<{
|
|
|
78
81
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
79
82
|
}>, Readonly<{
|
|
80
83
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
84
|
+
}>, never>, S.suspend<Readonly<{
|
|
85
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
86
|
+
}>, Readonly<{
|
|
87
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
81
88
|
}>, never>]>;
|
|
82
89
|
export declare const Or: S.Struct<{
|
|
83
90
|
or: S.Array$<S.Union<[S.suspend<Readonly<{
|
|
@@ -116,6 +123,10 @@ export declare const Or: S.Struct<{
|
|
|
116
123
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
117
124
|
}>, Readonly<{
|
|
118
125
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
126
|
+
}>, never>, S.suspend<Readonly<{
|
|
127
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
128
|
+
}>, Readonly<{
|
|
129
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
119
130
|
}>, never>]>>;
|
|
120
131
|
}>;
|
|
121
132
|
export declare const And: S.Struct<{
|
|
@@ -155,6 +166,10 @@ export declare const And: S.Struct<{
|
|
|
155
166
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
156
167
|
}>, Readonly<{
|
|
157
168
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
169
|
+
}>, never>, S.suspend<Readonly<{
|
|
170
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
171
|
+
}>, Readonly<{
|
|
172
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
158
173
|
}>, never>]>>;
|
|
159
174
|
}>;
|
|
160
175
|
export declare const ListMemberFilter: S.Struct<{
|
|
@@ -178,6 +193,9 @@ export declare const EntityExcludesLabels: S.Struct<{
|
|
|
178
193
|
export declare const EmbedType: S.Struct<{
|
|
179
194
|
embed_type: S.Tuple<[S.Literal<["==", "!="]>, S.Literal<["video", "image", "link", "post", "gif", "image_group"]>]>;
|
|
180
195
|
}>;
|
|
196
|
+
export declare const SocialGraph: S.Struct<{
|
|
197
|
+
social_graph: S.Tuple<[typeof S.String, S.Literal<["in", "not_in"]>, S.Literal<["follows", "followers"]>]>;
|
|
198
|
+
}>;
|
|
181
199
|
export declare const SortSettings: S.Struct<{
|
|
182
200
|
time_window: typeof S.Number;
|
|
183
201
|
decay_penalty: typeof S.Number;
|
|
@@ -238,6 +256,10 @@ export declare const AlgorithmManifest: S.Struct<{
|
|
|
238
256
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
239
257
|
}>, Readonly<{
|
|
240
258
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
259
|
+
}>, never>, S.suspend<Readonly<{
|
|
260
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
261
|
+
}>, Readonly<{
|
|
262
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
241
263
|
}>, never>]>;
|
|
242
264
|
sort_settings: S.optional<S.Struct<{
|
|
243
265
|
time_window: typeof S.Number;
|
|
@@ -287,6 +309,8 @@ export declare const FullForm: S.Struct<{
|
|
|
287
309
|
entity_excludes: readonly ["labels", readonly ["porn", "sexual", "nudity"]];
|
|
288
310
|
}> | Readonly<{
|
|
289
311
|
embed_type: readonly ["==" | "!=", "video" | "image" | "link" | "post" | "gif" | "image_group"];
|
|
312
|
+
}> | Readonly<{
|
|
313
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
290
314
|
}>;
|
|
291
315
|
readonly sort_settings?: {
|
|
292
316
|
readonly time_window: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateAlgorithmPayload.d.ts","sourceRoot":"","sources":["../../../src/schema/UpdateAlgorithmPayload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAIrC,eAAO,MAAM,OAAO,iBAAW,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,eAAO,MAAM,aAAa,6PASzB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAA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AC,OAAO,CAAC;AAEtD;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const and = (...filters) => {
|
|
2
|
+
const flatFilters = [];
|
|
3
|
+
filters.forEach(f => {
|
|
4
|
+
if ("and" in f) {
|
|
5
|
+
// Automatically flatten nested ands.
|
|
6
|
+
flatFilters.push(...f.and);
|
|
7
|
+
} else {
|
|
8
|
+
flatFilters.push(f);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
and: flatFilters
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const or = (...filters) => {
|
|
16
|
+
const flatFilters = [];
|
|
17
|
+
filters.forEach(f => {
|
|
18
|
+
if ("or" in f) {
|
|
19
|
+
flatFilters.push(...f.or);
|
|
20
|
+
} else {
|
|
21
|
+
flatFilters.push(f);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
or: flatFilters
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const regexMatches = (attribute, regex) => ({
|
|
29
|
+
regex_matches: [attribute, regex, true]
|
|
30
|
+
});
|
|
31
|
+
const regexNegationMatches = (attribute, regex) => ({
|
|
32
|
+
regex_negation_matches: [attribute, regex, true]
|
|
33
|
+
});
|
|
34
|
+
const isListMember = uri => ({
|
|
35
|
+
list_member: [uri, "in"]
|
|
36
|
+
});
|
|
37
|
+
const isNotListMember = uri => ({
|
|
38
|
+
list_member: [uri, "not_in"]
|
|
39
|
+
});
|
|
40
|
+
const socialGraph = (identifier, op, relation) => ({
|
|
41
|
+
social_graph: [identifier, op, relation]
|
|
42
|
+
});
|
|
43
|
+
const posterIsFollowedBy = identifier => socialGraph(identifier, "in", "followers");
|
|
44
|
+
const posterFollows = identifier => socialGraph(identifier, "in", "follows");
|
|
45
|
+
const posterIsNotFollowedBy = identifier => socialGraph(identifier, "not_in", "followers");
|
|
46
|
+
const posterDoesNotFollow = identifier => socialGraph(identifier, "not_in", "follows");
|
|
47
|
+
const hasVideo = {
|
|
48
|
+
embed_type: ["==", "video"]
|
|
49
|
+
};
|
|
50
|
+
const hasNoNSFWLabels = {
|
|
51
|
+
entity_excludes: ["labels", ["porn", "sexual", "nudity"]]
|
|
52
|
+
};
|
|
53
|
+
const attributeCompare = (attr, op, value) => ({
|
|
54
|
+
attribute_compare: [attr, op, value]
|
|
55
|
+
});
|
|
56
|
+
const isPost = /*#__PURE__*/attributeCompare("reply", "==", null);
|
|
57
|
+
const isReply = /*#__PURE__*/attributeCompare("reply", "!=", null);
|
|
58
|
+
const isContentOk = (threshold = 0.9) => ({
|
|
59
|
+
content_moderation: ["OK", ">=", threshold]
|
|
60
|
+
});
|
|
61
|
+
export const Algo = {
|
|
62
|
+
filter: (...filters) => ({
|
|
63
|
+
filter: and(...filters)
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
export const F = {
|
|
67
|
+
and,
|
|
68
|
+
or,
|
|
69
|
+
regexMatches,
|
|
70
|
+
regexNegationMatches,
|
|
71
|
+
attributeCompare,
|
|
72
|
+
isListMember,
|
|
73
|
+
isNotListMember,
|
|
74
|
+
socialGraph,
|
|
75
|
+
posterIsFollowedBy,
|
|
76
|
+
posterFollows,
|
|
77
|
+
posterIsNotFollowedBy,
|
|
78
|
+
posterDoesNotFollow,
|
|
79
|
+
hasVideo,
|
|
80
|
+
hasNoNSFWLabels,
|
|
81
|
+
isPost,
|
|
82
|
+
isReply,
|
|
83
|
+
isContentOk
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","names":["and","filters","flatFilters","forEach","f","push","or","regexMatches","attribute","regex","regex_matches","regexNegationMatches","regex_negation_matches","isListMember","uri","list_member","isNotListMember","socialGraph","identifier","op","relation","social_graph","posterIsFollowedBy","posterFollows","posterIsNotFollowedBy","posterDoesNotFollow","hasVideo","embed_type","hasNoNSFWLabels","entity_excludes","attributeCompare","attr","value","attribute_compare","isPost","isReply","isContentOk","threshold","content_moderation","Algo","filter","F"],"sources":["../../src/builder.ts"],"sourcesContent":[null],"mappings":"AAYA,MAAMA,GAAG,GAAGA,CAAC,GAAGC,OAAiB,KAAI;EACnC,MAAMC,WAAW,GAAa,EAAE;EAChCD,OAAO,CAACE,OAAO,CAAEC,CAAC,IAAI;IACpB,IAAI,KAAK,IAAIA,CAAC,EAAE;MACd;MACAF,WAAW,CAACG,IAAI,CAAC,GAAGD,CAAC,CAACJ,GAAG,CAAC;IAC5B,CAAC,MAAM;MACLE,WAAW,CAACG,IAAI,CAACD,CAAC,CAAC;IACrB;EACF,CAAC,CAAC;EACF,OAAO;IAAEJ,GAAG,EAAEE;EAAW,CAAE;AAC7B,CAAC;AACD,MAAMI,EAAE,GAAGA,CAAC,GAAGL,OAAiB,KAAI;EAClC,MAAMC,WAAW,GAAa,EAAE;EAChCD,OAAO,CAACE,OAAO,CAAEC,CAAC,IAAI;IACpB,IAAI,IAAI,IAAIA,CAAC,EAAE;MACbF,WAAW,CAACG,IAAI,CAAC,GAAGD,CAAC,CAACE,EAAE,CAAC;IAC3B,CAAC,MAAM;MACLJ,WAAW,CAACG,IAAI,CAACD,CAAC,CAAC;IACrB;EACF,CAAC,CAAC;EACF,OAAO;IAAEE,EAAE,EAAEJ;EAAW,CAAE;AAC5B,CAAC;AAED,MAAMK,YAAY,GAAGA,CACnBC,SAA2C,EAC3CC,KAAa,MACK;EAClBC,aAAa,EAAE,CAACF,SAAS,EAAEC,KAAK,EAAE,IAAI;CACvC,CAAC;AAEF,MAAME,oBAAoB,GAAGA,CAC3BH,SAA4D,EAC5DC,KAAa,MACa;EAC1BG,sBAAsB,EAAE,CAACJ,SAAS,EAAEC,KAAK,EAAE,IAAI;CAChD,CAAC;AAEF,MAAMI,YAAY,GAAIC,GAAW,KAAwB;EACvDC,WAAW,EAAE,CAACD,GAAG,EAAE,IAAI;CACxB,CAAC;AACF,MAAME,eAAe,GAAIF,GAAW,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IAAI,GAAG;EAClBC,MAAM,EAAEA,CAAC,GAAGvC,OAAiB,MAA0B;IACrDuC,MAAM,EAAExC,GAAG,CAAC,GAAGC,OAAO;GACvB;CACF;AAED,OAAO,MAAMwC,CAAC,GAAG;EACfzC,GAAG;EACHM,EAAE;EACFC,YAAY;EACZI,oBAAoB;EACpBmB,gBAAgB;EAChBjB,YAAY;EACZG,eAAe;EACfC,WAAW;EACXK,kBAAkB;EAClBC,aAAa;EACbC,qBAAqB;EACrBC,mBAAmB;EACnBC,QAAQ;EACRE,eAAe;EACfM,MAAM;EACNC,OAAO;EACPC;CACD","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ export const ListUri = S.String;
|
|
|
4
4
|
export const AttributeName = /*#__PURE__*/S.Union(/*#__PURE__*/S.Literal("text"), /*#__PURE__*/S.Literal("reply"), /*#__PURE__*/S.Literal("embed.images[*].alt"), /*#__PURE__*/S.Literal("embed.alt"), /*#__PURE__*/S.Literal("embed"), /*#__PURE__*/S.Literal("embed.external.uri"), /*#__PURE__*/S.Literal("embed.external.title"), /*#__PURE__*/S.Literal("embed.external.description"));
|
|
5
5
|
export const AttributeComparison = /*#__PURE__*/S.Literal("==", "!=", ">", "<", ">=", "<=");
|
|
6
6
|
export const AttributeValue = S.Null;
|
|
7
|
-
export const Filter = /*#__PURE__*/S.Union(/*#__PURE__*/S.suspend(() => And), /*#__PURE__*/S.suspend(() => Or), /*#__PURE__*/S.suspend(() => ListMemberFilter), /*#__PURE__*/S.suspend(() => AttributeCompare), /*#__PURE__*/S.suspend(() => RegexMatches), /*#__PURE__*/S.suspend(() => RegexNegationMatches), /*#__PURE__*/S.suspend(() => ContentModerationBlock), /*#__PURE__*/S.suspend(() => EntityExcludesLabels), /*#__PURE__*/S.suspend(() => EmbedType));
|
|
7
|
+
export const Filter = /*#__PURE__*/S.Union(/*#__PURE__*/S.suspend(() => And), /*#__PURE__*/S.suspend(() => Or), /*#__PURE__*/S.suspend(() => ListMemberFilter), /*#__PURE__*/S.suspend(() => AttributeCompare), /*#__PURE__*/S.suspend(() => RegexMatches), /*#__PURE__*/S.suspend(() => RegexNegationMatches), /*#__PURE__*/S.suspend(() => ContentModerationBlock), /*#__PURE__*/S.suspend(() => EntityExcludesLabels), /*#__PURE__*/S.suspend(() => EmbedType), /*#__PURE__*/S.suspend(() => SocialGraph));
|
|
8
8
|
export const Or = /*#__PURE__*/S.Struct({
|
|
9
9
|
or: /*#__PURE__*/S.Array(Filter)
|
|
10
10
|
});
|
|
@@ -42,6 +42,9 @@ export const EntityExcludesLabels = /*#__PURE__*/S.Struct({
|
|
|
42
42
|
export const EmbedType = /*#__PURE__*/S.Struct({
|
|
43
43
|
embed_type: /*#__PURE__*/S.Tuple(/*#__PURE__*/S.Literal("==", "!="), /*#__PURE__*/S.Literal("video", "image", "link", "post", "gif", "image_group"))
|
|
44
44
|
});
|
|
45
|
+
export const SocialGraph = /*#__PURE__*/S.Struct({
|
|
46
|
+
social_graph: /*#__PURE__*/S.Tuple(S.String, /*#__PURE__*/S.Literal("in", "not_in"), /*#__PURE__*/S.Literal("follows", "followers"))
|
|
47
|
+
});
|
|
45
48
|
// ---------------------- Sort Settings -----------------------------
|
|
46
49
|
export const SortSettings = /*#__PURE__*/S.Struct({
|
|
47
50
|
time_window: S.Number,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateAlgorithmPayload.js","names":["Schema","S","ListUri","String","AttributeName","Union","Literal","AttributeComparison","AttributeValue","Null","Filter","suspend","And","Or","ListMemberFilter","AttributeCompare","RegexMatches","RegexNegationMatches","ContentModerationBlock","EntityExcludesLabels","EmbedType","Struct","or","Array","and","list_member","Tuple","attribute_compare","RegexMatchBase","annotations","title","description","Boolean","regex_matches","regex_negation_matches","content_moderation","Number","entity_excludes","embed_type","SortSettings","time_window","decay_penalty","like_count_multiplier","reply_count_multiplier","repost_count_multiplier","reader_like_count_multiplier","reader_reply_count_multiplier","reader_repost_count_multiplier","DisplayName","RecordName","Description","Order","FeedId","NumberFromString","UserId","AlgorithmManifest","filter","sort_settings","optional","Metadata","document","Unknown","schema","schemaVersion","sequences","Record","key","value","session","FullForm","id","user_id","file","display_name","record_name","order","algorithm_manifest","parseJson","metadata"],"sources":["../../../src/schema/UpdateAlgorithmPayload.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,IAAIC,CAAC,QAAQ,QAAQ;AAEpC;AAEA,OAAO,MAAMC,OAAO,GAAGD,CAAC,CAACE,MAAM;AAG/B,OAAO,MAAMC,aAAa,gBAAGH,CAAC,CAACI,KAAK,cAClCJ,CAAC,CAACK,OAAO,CAAC,MAAM,CAAC,eACjBL,CAAC,CAACK,OAAO,CAAC,OAAO,CAAC,eAClBL,CAAC,CAACK,OAAO,CAAC,qBAAqB,CAAC,eAChCL,CAAC,CAACK,OAAO,CAAC,WAAW,CAAC,eACtBL,CAAC,CAACK,OAAO,CAAC,OAAO,CAAC,eAClBL,CAAC,CAACK,OAAO,CAAC,oBAAoB,CAAC,eAC/BL,CAAC,CAACK,OAAO,CAAC,sBAAsB,CAAC,eACjCL,CAAC,CAACK,OAAO,CAAC,4BAA4B,CAAC,CACxC;AAED,OAAO,MAAMC,mBAAmB,gBAAGN,CAAC,CAACK,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;AAE9E,OAAO,MAAME,cAAc,GAAGP,CAAC,CAACQ,IAAI;
|
|
1
|
+
{"version":3,"file":"UpdateAlgorithmPayload.js","names":["Schema","S","ListUri","String","AttributeName","Union","Literal","AttributeComparison","AttributeValue","Null","Filter","suspend","And","Or","ListMemberFilter","AttributeCompare","RegexMatches","RegexNegationMatches","ContentModerationBlock","EntityExcludesLabels","EmbedType","SocialGraph","Struct","or","Array","and","list_member","Tuple","attribute_compare","RegexMatchBase","annotations","title","description","Boolean","regex_matches","regex_negation_matches","content_moderation","Number","entity_excludes","embed_type","social_graph","SortSettings","time_window","decay_penalty","like_count_multiplier","reply_count_multiplier","repost_count_multiplier","reader_like_count_multiplier","reader_reply_count_multiplier","reader_repost_count_multiplier","DisplayName","RecordName","Description","Order","FeedId","NumberFromString","UserId","AlgorithmManifest","filter","sort_settings","optional","Metadata","document","Unknown","schema","schemaVersion","sequences","Record","key","value","session","FullForm","id","user_id","file","display_name","record_name","order","algorithm_manifest","parseJson","metadata"],"sources":["../../../src/schema/UpdateAlgorithmPayload.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,IAAIC,CAAC,QAAQ,QAAQ;AAEpC;AAEA,OAAO,MAAMC,OAAO,GAAGD,CAAC,CAACE,MAAM;AAG/B,OAAO,MAAMC,aAAa,gBAAGH,CAAC,CAACI,KAAK,cAClCJ,CAAC,CAACK,OAAO,CAAC,MAAM,CAAC,eACjBL,CAAC,CAACK,OAAO,CAAC,OAAO,CAAC,eAClBL,CAAC,CAACK,OAAO,CAAC,qBAAqB,CAAC,eAChCL,CAAC,CAACK,OAAO,CAAC,WAAW,CAAC,eACtBL,CAAC,CAACK,OAAO,CAAC,OAAO,CAAC,eAClBL,CAAC,CAACK,OAAO,CAAC,oBAAoB,CAAC,eAC/BL,CAAC,CAACK,OAAO,CAAC,sBAAsB,CAAC,eACjCL,CAAC,CAACK,OAAO,CAAC,4BAA4B,CAAC,CACxC;AAED,OAAO,MAAMC,mBAAmB,gBAAGN,CAAC,CAACK,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;AAE9E,OAAO,MAAME,cAAc,GAAGP,CAAC,CAACQ,IAAI;AAmDpC,OAAO,MAAMC,MAAM,gBAAGT,CAAC,CAACI,KAAK,cAC3BJ,CAAC,CAACU,OAAO,CAAC,MAAqBC,GAAG,CAAC,eACnCX,CAAC,CAACU,OAAO,CAAC,MAAoBE,EAAE,CAAC,eACjCZ,CAAC,CAACU,OAAO,CAAC,MAAkCG,gBAAgB,CAAC,eAC7Db,CAAC,CAACU,OA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": "graze-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Typescript Graze API client.",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"./schema": {
|
|
31
31
|
"import": "./build/esm/schema/index.js",
|
|
32
32
|
"types": "./build/dts/schema/index.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./builder": {
|
|
35
|
+
"import": "./build/esm/builder/index.js",
|
|
36
|
+
"types": "./build/dts/builder/index.d.ts"
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
39
|
"scripts": {
|
|
@@ -79,18 +83,6 @@
|
|
|
79
83
|
"typescript": "^5.6.2",
|
|
80
84
|
"vitest": "^2.0.5"
|
|
81
85
|
},
|
|
82
|
-
"effect": {
|
|
83
|
-
"generateExports": {
|
|
84
|
-
"include": [
|
|
85
|
-
"**/*.ts"
|
|
86
|
-
]
|
|
87
|
-
},
|
|
88
|
-
"generateIndex": {
|
|
89
|
-
"include": [
|
|
90
|
-
"**/*.ts"
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
86
|
"patchedDependencies": {
|
|
95
87
|
"@changesets/get-github-info@0.6.0": "patches/@changesets__get-github-info@0.6.0.patch",
|
|
96
88
|
"babel-plugin-annotate-pure-calls@0.4.0": "patches/babel-plugin-annotate-pure-calls@0.4.0.patch"
|
package/src/builder.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AttributeComparison,
|
|
3
|
+
AttributeName,
|
|
4
|
+
AttributeValue,
|
|
5
|
+
ContentModerationBlock,
|
|
6
|
+
Filter,
|
|
7
|
+
ListMemberFilter,
|
|
8
|
+
RegexMatches,
|
|
9
|
+
RegexNegationMatches,
|
|
10
|
+
SocialGraph,
|
|
11
|
+
} from "./schema/index.js";
|
|
12
|
+
|
|
13
|
+
const and = (...filters: Filter[]) => {
|
|
14
|
+
const flatFilters: Filter[] = [];
|
|
15
|
+
filters.forEach((f) => {
|
|
16
|
+
if ("and" in f) {
|
|
17
|
+
// Automatically flatten nested ands.
|
|
18
|
+
flatFilters.push(...f.and);
|
|
19
|
+
} else {
|
|
20
|
+
flatFilters.push(f);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return { and: flatFilters };
|
|
24
|
+
};
|
|
25
|
+
const or = (...filters: Filter[]) => {
|
|
26
|
+
const flatFilters: Filter[] = [];
|
|
27
|
+
filters.forEach((f) => {
|
|
28
|
+
if ("or" in f) {
|
|
29
|
+
flatFilters.push(...f.or);
|
|
30
|
+
} else {
|
|
31
|
+
flatFilters.push(f);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return { or: flatFilters };
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const regexMatches = (
|
|
38
|
+
attribute: RegexMatches["regex_matches"][0],
|
|
39
|
+
regex: string
|
|
40
|
+
): RegexMatches => ({
|
|
41
|
+
regex_matches: [attribute, regex, true],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const regexNegationMatches = (
|
|
45
|
+
attribute: RegexNegationMatches["regex_negation_matches"][0],
|
|
46
|
+
regex: string
|
|
47
|
+
): RegexNegationMatches => ({
|
|
48
|
+
regex_negation_matches: [attribute, regex, true],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const isListMember = (uri: string): ListMemberFilter => ({
|
|
52
|
+
list_member: [uri, "in"],
|
|
53
|
+
});
|
|
54
|
+
const isNotListMember = (uri: string): ListMemberFilter => ({
|
|
55
|
+
list_member: [uri, "not_in"],
|
|
56
|
+
});
|
|
57
|
+
const socialGraph = (
|
|
58
|
+
identifier: string,
|
|
59
|
+
op: SocialGraph["social_graph"][1],
|
|
60
|
+
relation: SocialGraph["social_graph"][2]
|
|
61
|
+
): SocialGraph => ({
|
|
62
|
+
social_graph: [identifier, op, relation],
|
|
63
|
+
});
|
|
64
|
+
const posterIsFollowedBy = (identifier: string) =>
|
|
65
|
+
socialGraph(identifier, "in", "followers");
|
|
66
|
+
const posterFollows = (identifier: string) =>
|
|
67
|
+
socialGraph(identifier, "in", "follows");
|
|
68
|
+
const posterIsNotFollowedBy = (identifier: string) =>
|
|
69
|
+
socialGraph(identifier, "not_in", "followers");
|
|
70
|
+
const posterDoesNotFollow = (identifier: string) =>
|
|
71
|
+
socialGraph(identifier, "not_in", "follows");
|
|
72
|
+
|
|
73
|
+
const hasVideo: Filter = {
|
|
74
|
+
embed_type: ["==", "video"],
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const hasNoNSFWLabels: Filter = {
|
|
78
|
+
entity_excludes: ["labels", ["porn", "sexual", "nudity"]],
|
|
79
|
+
};
|
|
80
|
+
const attributeCompare = (
|
|
81
|
+
attr: AttributeName,
|
|
82
|
+
op: AttributeComparison,
|
|
83
|
+
value: AttributeValue
|
|
84
|
+
): Filter => ({
|
|
85
|
+
attribute_compare: [attr, op, value],
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const isPost: Filter = attributeCompare("reply", "==", null);
|
|
89
|
+
const isReply: Filter = attributeCompare("reply", "!=", null);
|
|
90
|
+
|
|
91
|
+
const isContentOk = (threshold: number = 0.9): ContentModerationBlock => ({
|
|
92
|
+
content_moderation: ["OK", ">=", threshold],
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export const Algo = {
|
|
96
|
+
filter: (...filters: Filter[]): { filter: Filter } => ({
|
|
97
|
+
filter: and(...filters),
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const F = {
|
|
102
|
+
and,
|
|
103
|
+
or,
|
|
104
|
+
regexMatches,
|
|
105
|
+
regexNegationMatches,
|
|
106
|
+
attributeCompare,
|
|
107
|
+
isListMember,
|
|
108
|
+
isNotListMember,
|
|
109
|
+
socialGraph,
|
|
110
|
+
posterIsFollowedBy,
|
|
111
|
+
posterFollows,
|
|
112
|
+
posterIsNotFollowedBy,
|
|
113
|
+
posterDoesNotFollow,
|
|
114
|
+
hasVideo,
|
|
115
|
+
hasNoNSFWLabels,
|
|
116
|
+
isPost,
|
|
117
|
+
isReply,
|
|
118
|
+
isContentOk,
|
|
119
|
+
};
|
|
@@ -32,7 +32,8 @@ export type Filter =
|
|
|
32
32
|
| RegexNegationMatches
|
|
33
33
|
| ContentModerationBlock
|
|
34
34
|
| EntityExcludesLabels
|
|
35
|
-
| EmbedType
|
|
35
|
+
| EmbedType
|
|
36
|
+
| SocialGraph;
|
|
36
37
|
|
|
37
38
|
export type And = Readonly<{ and: ReadonlyArray<Filter> }>;
|
|
38
39
|
export type Or = Readonly<{ or: ReadonlyArray<Filter> }>;
|
|
@@ -64,6 +65,9 @@ export type EmbedType = Readonly<{
|
|
|
64
65
|
"video" | "image" | "link" | "post" | "gif" | "image_group"
|
|
65
66
|
];
|
|
66
67
|
}>;
|
|
68
|
+
export type SocialGraph = Readonly<{
|
|
69
|
+
social_graph: readonly [string, "in" | "not_in", "follows" | "followers"];
|
|
70
|
+
}>;
|
|
67
71
|
|
|
68
72
|
export const Filter = S.Union(
|
|
69
73
|
S.suspend((): S.Schema<And> => And),
|
|
@@ -74,7 +78,8 @@ export const Filter = S.Union(
|
|
|
74
78
|
S.suspend((): S.Schema<RegexNegationMatches> => RegexNegationMatches),
|
|
75
79
|
S.suspend((): S.Schema<ContentModerationBlock> => ContentModerationBlock),
|
|
76
80
|
S.suspend((): S.Schema<EntityExcludesLabels> => EntityExcludesLabels),
|
|
77
|
-
S.suspend((): S.Schema<EmbedType> => EmbedType)
|
|
81
|
+
S.suspend((): S.Schema<EmbedType> => EmbedType),
|
|
82
|
+
S.suspend((): S.Schema<SocialGraph> => SocialGraph)
|
|
78
83
|
);
|
|
79
84
|
|
|
80
85
|
export const Or = S.Struct({ or: S.Array(Filter) });
|
|
@@ -128,6 +133,13 @@ export const EmbedType = S.Struct({
|
|
|
128
133
|
S.Literal("video", "image", "link", "post", "gif", "image_group")
|
|
129
134
|
),
|
|
130
135
|
});
|
|
136
|
+
export const SocialGraph = S.Struct({
|
|
137
|
+
social_graph: S.Tuple(
|
|
138
|
+
S.String,
|
|
139
|
+
S.Literal("in", "not_in"),
|
|
140
|
+
S.Literal("follows", "followers")
|
|
141
|
+
),
|
|
142
|
+
});
|
|
131
143
|
|
|
132
144
|
// ---------------------- Sort Settings -----------------------------
|
|
133
145
|
|