graze-client 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dts/GrazeClient.d.ts +153 -0
- package/build/dts/GrazeClient.d.ts.map +1 -0
- package/build/dts/index.d.ts +17 -0
- package/build/dts/index.d.ts.map +1 -0
- package/build/dts/schema/UpdateAlgorithmPayload.d.ts +328 -0
- package/build/dts/schema/UpdateAlgorithmPayload.d.ts.map +1 -0
- package/build/dts/schema/index.d.ts +3 -0
- package/build/dts/schema/index.d.ts.map +1 -0
- package/build/dts/schema/shared.d.ts +147 -0
- package/build/dts/schema/shared.d.ts.map +1 -0
- package/build/esm/GrazeClient.js +67 -0
- package/build/esm/GrazeClient.js.map +1 -0
- package/build/esm/index.js +41 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/schema/UpdateAlgorithmPayload.js +101 -0
- package/build/esm/schema/UpdateAlgorithmPayload.js.map +1 -0
- package/build/esm/schema/index.js +3 -0
- package/build/esm/schema/index.js.map +1 -0
- package/build/esm/schema/shared.js +63 -0
- package/build/esm/schema/shared.js.map +1 -0
- package/package.json +14 -9
- package/.changeset/config.json +0 -16
- package/.github/actions/setup/action.yml +0 -21
- package/.github/workflows/check.yml +0 -57
- package/.github/workflows/release.yml +0 -34
- package/.github/workflows/snapshot.yml +0 -24
- package/.vscode/effect.code-snippets +0 -72
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -5
- package/CHANGELOG.md +0 -19
- package/eslint.config.mjs +0 -120
- package/patches/@changesets__get-github-info@0.6.0.patch +0 -48
- package/patches/babel-plugin-annotate-pure-calls@0.4.0.patch +0 -13
- package/scratchpad/tsconfig.json +0 -10
- package/setupTests.ts +0 -3
- package/test/Dummy.test.ts +0 -7
- package/vitest.config.ts +0 -17
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Schema as S } from "effect";
|
|
2
|
+
export declare const PartialAlgorithm: S.Struct<{
|
|
3
|
+
algorithm_uri: typeof S.String;
|
|
4
|
+
algorithm_manifest_id: S.Union<[typeof S.Null, typeof S.Number]>;
|
|
5
|
+
draft_algorithm_manifest_id: typeof S.Number;
|
|
6
|
+
record_name: typeof S.String;
|
|
7
|
+
display_name: typeof S.String;
|
|
8
|
+
description: typeof S.String;
|
|
9
|
+
feed_did: typeof S.String;
|
|
10
|
+
avatar_url: S.Union<[typeof S.String, typeof S.Null]>;
|
|
11
|
+
cpm_cents: S.Union<[typeof S.Number, typeof S.Null]>;
|
|
12
|
+
deleted: typeof S.Boolean;
|
|
13
|
+
active: typeof S.Boolean;
|
|
14
|
+
public: typeof S.Boolean;
|
|
15
|
+
monetization_available: typeof S.Boolean;
|
|
16
|
+
status: S.Union<[typeof S.String, typeof S.Null]>;
|
|
17
|
+
unique_operator_ids: S.Array$<typeof S.Number>;
|
|
18
|
+
user_id: typeof S.Number;
|
|
19
|
+
id: typeof S.Number;
|
|
20
|
+
created_at: typeof S.DateFromString;
|
|
21
|
+
updated_at: typeof S.DateFromString;
|
|
22
|
+
deleted_at: S.Union<[typeof S.DateFromString, typeof S.Null]>;
|
|
23
|
+
}>;
|
|
24
|
+
export type PartialAlgorithm = typeof PartialAlgorithm.Type;
|
|
25
|
+
export declare const AlgoUpdateResponse: S.Struct<{
|
|
26
|
+
message: typeof S.String;
|
|
27
|
+
algorithm: S.Struct<{
|
|
28
|
+
algorithm_uri: typeof S.String;
|
|
29
|
+
algorithm_manifest_id: S.Union<[typeof S.Null, typeof S.Number]>;
|
|
30
|
+
draft_algorithm_manifest_id: typeof S.Number;
|
|
31
|
+
record_name: typeof S.String;
|
|
32
|
+
display_name: typeof S.String;
|
|
33
|
+
description: typeof S.String;
|
|
34
|
+
feed_did: typeof S.String;
|
|
35
|
+
avatar_url: S.Union<[typeof S.String, typeof S.Null]>;
|
|
36
|
+
cpm_cents: S.Union<[typeof S.Number, typeof S.Null]>;
|
|
37
|
+
deleted: typeof S.Boolean;
|
|
38
|
+
active: typeof S.Boolean;
|
|
39
|
+
public: typeof S.Boolean;
|
|
40
|
+
monetization_available: typeof S.Boolean;
|
|
41
|
+
status: S.Union<[typeof S.String, typeof S.Null]>;
|
|
42
|
+
unique_operator_ids: S.Array$<typeof S.Number>;
|
|
43
|
+
user_id: typeof S.Number;
|
|
44
|
+
id: typeof S.Number;
|
|
45
|
+
created_at: typeof S.DateFromString;
|
|
46
|
+
updated_at: typeof S.DateFromString;
|
|
47
|
+
deleted_at: S.Union<[typeof S.DateFromString, typeof S.Null]>;
|
|
48
|
+
}>;
|
|
49
|
+
}>;
|
|
50
|
+
export type AlgoUpdateResponse = typeof AlgoUpdateResponse.Type;
|
|
51
|
+
export declare const GetAlgoResponse: S.SchemaClass<{
|
|
52
|
+
readonly algorithm_uri: string;
|
|
53
|
+
readonly algorithm_manifest_id: number | null;
|
|
54
|
+
readonly draft_algorithm_manifest_id: number;
|
|
55
|
+
readonly record_name: string;
|
|
56
|
+
readonly display_name: string;
|
|
57
|
+
readonly description: string;
|
|
58
|
+
readonly feed_did: string;
|
|
59
|
+
readonly avatar_url: string | null;
|
|
60
|
+
readonly cpm_cents: number | null;
|
|
61
|
+
readonly deleted: boolean;
|
|
62
|
+
readonly active: boolean;
|
|
63
|
+
readonly public: boolean;
|
|
64
|
+
readonly monetization_available: boolean;
|
|
65
|
+
readonly status: string | null;
|
|
66
|
+
readonly unique_operator_ids: readonly number[];
|
|
67
|
+
readonly user_id: number;
|
|
68
|
+
readonly id: number;
|
|
69
|
+
readonly created_at: Date;
|
|
70
|
+
readonly updated_at: Date;
|
|
71
|
+
readonly deleted_at: Date | null;
|
|
72
|
+
readonly stats: unknown;
|
|
73
|
+
readonly latest_error: unknown;
|
|
74
|
+
readonly latest_compute_cycle: unknown;
|
|
75
|
+
readonly subscriber_lists: unknown;
|
|
76
|
+
readonly draft_algorithm_manifest: unknown;
|
|
77
|
+
readonly algorithm_manifest: unknown;
|
|
78
|
+
}, string, never>;
|
|
79
|
+
export type GetAlgoResponse = typeof GetAlgoResponse.Type;
|
|
80
|
+
export declare const HidePostBody: S.Struct<{
|
|
81
|
+
algo_id: typeof S.Number;
|
|
82
|
+
at_uri: typeof S.String;
|
|
83
|
+
}>;
|
|
84
|
+
export type HidePostBody = typeof HidePostBody.Type;
|
|
85
|
+
export declare const AlgorithWithStats: S.Struct<{
|
|
86
|
+
stats: S.Struct<{
|
|
87
|
+
page_renders: typeof S.Number;
|
|
88
|
+
unique_users: typeof S.Number;
|
|
89
|
+
post_renders: typeof S.Number;
|
|
90
|
+
}>;
|
|
91
|
+
algorithm_uri: typeof S.String;
|
|
92
|
+
algorithm_manifest_id: S.Union<[typeof S.Null, typeof S.Number]>;
|
|
93
|
+
draft_algorithm_manifest_id: typeof S.Number;
|
|
94
|
+
record_name: typeof S.String;
|
|
95
|
+
display_name: typeof S.String;
|
|
96
|
+
description: typeof S.String;
|
|
97
|
+
feed_did: typeof S.String;
|
|
98
|
+
avatar_url: S.Union<[typeof S.String, typeof S.Null]>;
|
|
99
|
+
cpm_cents: S.Union<[typeof S.Number, typeof S.Null]>;
|
|
100
|
+
deleted: typeof S.Boolean;
|
|
101
|
+
active: typeof S.Boolean;
|
|
102
|
+
public: typeof S.Boolean;
|
|
103
|
+
monetization_available: typeof S.Boolean;
|
|
104
|
+
status: S.Union<[typeof S.String, typeof S.Null]>;
|
|
105
|
+
unique_operator_ids: S.Array$<typeof S.Number>;
|
|
106
|
+
user_id: typeof S.Number;
|
|
107
|
+
id: typeof S.Number;
|
|
108
|
+
created_at: typeof S.DateFromString;
|
|
109
|
+
updated_at: typeof S.DateFromString;
|
|
110
|
+
deleted_at: S.Union<[typeof S.DateFromString, typeof S.Null]>;
|
|
111
|
+
}>;
|
|
112
|
+
export type AlgorithmWithStats = typeof AlgorithWithStats.Type;
|
|
113
|
+
export declare const GetAlgorithmsResponse: S.Struct<{
|
|
114
|
+
page: typeof S.Number;
|
|
115
|
+
page_size: typeof S.Number;
|
|
116
|
+
total_items: typeof S.Number;
|
|
117
|
+
total_pages: typeof S.Number;
|
|
118
|
+
user_algos: S.Array$<S.Struct<{
|
|
119
|
+
stats: S.Struct<{
|
|
120
|
+
page_renders: typeof S.Number;
|
|
121
|
+
unique_users: typeof S.Number;
|
|
122
|
+
post_renders: typeof S.Number;
|
|
123
|
+
}>;
|
|
124
|
+
algorithm_uri: typeof S.String;
|
|
125
|
+
algorithm_manifest_id: S.Union<[typeof S.Null, typeof S.Number]>;
|
|
126
|
+
draft_algorithm_manifest_id: typeof S.Number;
|
|
127
|
+
record_name: typeof S.String;
|
|
128
|
+
display_name: typeof S.String;
|
|
129
|
+
description: typeof S.String;
|
|
130
|
+
feed_did: typeof S.String;
|
|
131
|
+
avatar_url: S.Union<[typeof S.String, typeof S.Null]>;
|
|
132
|
+
cpm_cents: S.Union<[typeof S.Number, typeof S.Null]>;
|
|
133
|
+
deleted: typeof S.Boolean;
|
|
134
|
+
active: typeof S.Boolean;
|
|
135
|
+
public: typeof S.Boolean;
|
|
136
|
+
monetization_available: typeof S.Boolean;
|
|
137
|
+
status: S.Union<[typeof S.String, typeof S.Null]>;
|
|
138
|
+
unique_operator_ids: S.Array$<typeof S.Number>;
|
|
139
|
+
user_id: typeof S.Number;
|
|
140
|
+
id: typeof S.Number;
|
|
141
|
+
created_at: typeof S.DateFromString;
|
|
142
|
+
updated_at: typeof S.DateFromString;
|
|
143
|
+
deleted_at: S.Union<[typeof S.DateFromString, typeof S.Null]>;
|
|
144
|
+
}>>;
|
|
145
|
+
}>;
|
|
146
|
+
export type GetAlgorithmsResponse = typeof GetAlgorithmsResponse.Type;
|
|
147
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/schema/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAqB3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;AAkB5D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;EAG7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;AAEhE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAyC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAE1D,eAAO,MAAM,YAAY;;;EAGvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AAIpD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;EAO5B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC;AAC/D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AlgoUpdateResponse, GetAlgoResponse, GetAlgorithmsResponse, HidePostBody, } from "./schema/shared.js";
|
|
2
|
+
import { FetchHttpClient, HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema, HttpClient, HttpClientRequest, } from "@effect/platform";
|
|
3
|
+
import { Config, Data, Effect, Redacted, Schema } from "effect";
|
|
4
|
+
import * as Form from "./schema/UpdateAlgorithmPayload.js";
|
|
5
|
+
function isStringOrBlob(val) {
|
|
6
|
+
return typeof val === "string" || val instanceof Blob;
|
|
7
|
+
}
|
|
8
|
+
const encodeForm = (obj) => Effect.gen(function* () {
|
|
9
|
+
const encoded = yield* Schema.encode(Form.FullForm)(obj);
|
|
10
|
+
const formData = new FormData();
|
|
11
|
+
for (const key in encoded) {
|
|
12
|
+
if (encoded.hasOwnProperty(key)) {
|
|
13
|
+
const val = encoded[key];
|
|
14
|
+
if (isStringOrBlob(val)) {
|
|
15
|
+
formData.append(key, val);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return formData;
|
|
20
|
+
});
|
|
21
|
+
const UserIdParam = HttpApiSchema.param("userId", Schema.NumberFromString);
|
|
22
|
+
const FeedIdParam = HttpApiSchema.param("feedId", Schema.NumberFromString);
|
|
23
|
+
const GrazeApiGroup = HttpApiGroup.make("graze", { topLevel: true })
|
|
24
|
+
.add(HttpApiEndpoint.get("getFeeds") `/app/my_feeds`
|
|
25
|
+
.addSuccess(GetAlgorithmsResponse)
|
|
26
|
+
.setPayload(Schema.Struct({
|
|
27
|
+
user_id: UserIdParam,
|
|
28
|
+
})))
|
|
29
|
+
.add(HttpApiEndpoint.get("getFeed") `/app/my_feeds/${FeedIdParam}`.addSuccess(GetAlgoResponse))
|
|
30
|
+
.add(HttpApiEndpoint.post("updateAlgorithm") `/app/edit_algo_image`
|
|
31
|
+
.setPayload(HttpApiSchema.Multipart(Form.FullForm))
|
|
32
|
+
.addSuccess(AlgoUpdateResponse))
|
|
33
|
+
.add(HttpApiEndpoint.get("publishAlgorithm") `/app/publish_algo/${FeedIdParam}`.addSuccess(Schema.Unknown))
|
|
34
|
+
.add(HttpApiEndpoint.post("hidePost") `/app/hide_post`
|
|
35
|
+
.setPayload(HidePostBody)
|
|
36
|
+
.addSuccess(Schema.Unknown));
|
|
37
|
+
class GrazeApiDef extends HttpApi.make("grazeApi").add(GrazeApiGroup) {
|
|
38
|
+
}
|
|
39
|
+
const grazeLive = Effect.gen(function* () {
|
|
40
|
+
const baseUrl = yield* Config.url("GRAZE_API_URL");
|
|
41
|
+
const cookie = yield* Config.redacted("GRAZE_COOKIE");
|
|
42
|
+
const client = yield* HttpApiClient.make(GrazeApiDef, {
|
|
43
|
+
baseUrl: baseUrl.toString(),
|
|
44
|
+
transformClient: (client) => client.pipe(HttpClient.filterStatusOk, HttpClient.mapRequest(HttpClientRequest.setHeaders({
|
|
45
|
+
cookie: Redacted.value(cookie),
|
|
46
|
+
}))),
|
|
47
|
+
});
|
|
48
|
+
const updateAlgorithm = (data) => Effect.gen(function* () {
|
|
49
|
+
const formData = yield* encodeForm(data);
|
|
50
|
+
return yield* client.updateAlgorithm({ payload: formData });
|
|
51
|
+
});
|
|
52
|
+
const userId = yield* Config.integer("GRAZE_USER_ID");
|
|
53
|
+
const getFeeds = () => client.getFeeds({ payload: { user_id: userId } });
|
|
54
|
+
return {
|
|
55
|
+
...client,
|
|
56
|
+
updateAlgorithm,
|
|
57
|
+
getFeeds,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
export class GrazeClient extends Effect.Service()("GrazeClient", {
|
|
61
|
+
effect: grazeLive,
|
|
62
|
+
dependencies: [FetchHttpClient.layer],
|
|
63
|
+
}) {
|
|
64
|
+
}
|
|
65
|
+
export class GrazeError extends Data.TaggedError("GrazeError") {
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=GrazeClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrazeClient.js","sourceRoot":"","sources":["../../src/GrazeClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,eAAe,EACf,OAAO,EACP,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhE,OAAO,KAAK,IAAI,MAAM,oCAAoC,CAAC;AAE3D,SAAS,cAAc,CAAC,GAAY;IAClC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,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GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEL,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAEzE,OAAO;QACL,GAAG,MAAM;QACT,eAAe;QACf,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,OAAO,EAAe,CAAC,aAAa,EAAE;IAC5E,MAAM,EAAE,SAAS;IACjB,YAAY,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;CACtC,CAAC;CAED;AAED,MAAM,OAAO,UAAW,SAAQ,IAAI,CAAC,WAAW,CAAC,YAAY,CAK3D;CAAG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ConfigProvider, Effect, Layer } from "effect";
|
|
2
|
+
import { GrazeClient } from "src/GrazeClient.js";
|
|
3
|
+
export class GrazeService {
|
|
4
|
+
getFeed;
|
|
5
|
+
getFeeds;
|
|
6
|
+
hidePost;
|
|
7
|
+
updateAlgorithm;
|
|
8
|
+
publishAlgorithm;
|
|
9
|
+
constructor({ apiUrl, cookie, userId, }) {
|
|
10
|
+
const envMap = new Map([
|
|
11
|
+
["GRAZE_API_URL", apiUrl],
|
|
12
|
+
["GRAZE_COOKIE", cookie],
|
|
13
|
+
["GRAZE_USER_ID", userId.toString()],
|
|
14
|
+
]);
|
|
15
|
+
const provider = ConfigProvider.fromMap(envMap);
|
|
16
|
+
const layer = Layer.setConfigProvider(provider);
|
|
17
|
+
const make = setup.pipe(Effect.provide(layer), Effect.provide(GrazeClient.Default));
|
|
18
|
+
const api = Effect.runSync(make);
|
|
19
|
+
this.getFeed = api.getFeed;
|
|
20
|
+
this.getFeeds = api.getFeeds;
|
|
21
|
+
this.hidePost = api.hidePost;
|
|
22
|
+
this.updateAlgorithm = api.updateAlgorithm;
|
|
23
|
+
this.publishAlgorithm = api.publishAlgorithm;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const setup = Effect.gen(function* () {
|
|
27
|
+
const client = yield* GrazeClient;
|
|
28
|
+
const getFeed = (...args) => client.getFeed(...args).pipe(Effect.runPromise);
|
|
29
|
+
const getFeeds = (...args) => client.getFeeds(...args).pipe(Effect.runPromise);
|
|
30
|
+
const hidePost = (...args) => client.hidePost(...args).pipe(Effect.runPromise);
|
|
31
|
+
const updateAlgorithm = (...args) => client.updateAlgorithm(...args).pipe(Effect.runPromise);
|
|
32
|
+
const publishAlgorithm = (...args) => client.publishAlgorithm(...args).pipe(Effect.runPromise);
|
|
33
|
+
return {
|
|
34
|
+
getFeed,
|
|
35
|
+
getFeeds,
|
|
36
|
+
hidePost,
|
|
37
|
+
updateAlgorithm,
|
|
38
|
+
publishAlgorithm,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAQjD,MAAM,OAAO,YAAY;IACvB,OAAO,CAAgD;IACvD,QAAQ,CAAiD;IACzD,QAAQ,CAAiD;IACzD,eAAe,CAAwD;IACvE,gBAAgB,CAAyD;IAEzE,YAAY,EACV,MAAM,EACN,MAA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C,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAwC,EAAE,EAAE,CAC/D,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnD,MAAM,eAAe,GAAG,CACtB,GAAG,IAA+C,EAClD,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,gBAAgB,GAAG,CACvB,GAAG,IAAgD,EACnD,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAE9D,OAAO;QACL,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,eAAe;QACf,gBAAgB;KACjB,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Schema as S } from "effect";
|
|
2
|
+
// ------------------- Primitives ---------------------------------
|
|
3
|
+
export const ListUri = S.String;
|
|
4
|
+
export const AttributeName = S.Union(S.Literal("text"), S.Literal("reply"), S.Literal("embed.images[*].alt"), S.Literal("embed.alt"), S.Literal("embed"), S.Literal("embed.external.uri"), S.Literal("embed.external.title"), S.Literal("embed.external.description"));
|
|
5
|
+
export const AttributeComparison = S.Literal("==");
|
|
6
|
+
export const AttributeValue = S.Null;
|
|
7
|
+
export const Filter = S.Union(S.suspend(() => And), S.suspend(() => Or), S.suspend(() => ListMemberFilter), S.suspend(() => AttributeCompare), S.suspend(() => RegexMatches), S.suspend(() => RegexNegationMatches), S.suspend(() => ContentModerationBlock), S.suspend(() => EntityExcludesLabels), S.suspend(() => EmbedType));
|
|
8
|
+
export const Or = S.Struct({ or: S.Array(Filter) });
|
|
9
|
+
export const And = S.Struct({ and: S.Array(Filter) });
|
|
10
|
+
export const ListMemberFilter = S.Struct({
|
|
11
|
+
list_member: S.Tuple(ListUri, S.Literal("in", "not_in")),
|
|
12
|
+
});
|
|
13
|
+
export const AttributeCompare = S.Struct({
|
|
14
|
+
attribute_compare: S.Tuple(AttributeName, AttributeComparison, AttributeValue),
|
|
15
|
+
});
|
|
16
|
+
const RegexMatchBase = S.Tuple(AttributeName, S.String.annotations({
|
|
17
|
+
title: "Regex Pattern",
|
|
18
|
+
description: "The source of the regex pattern to match against.",
|
|
19
|
+
}), S.Boolean.annotations({
|
|
20
|
+
title: "Case Insensitive?",
|
|
21
|
+
description: "True if the regex should be case insensitive.",
|
|
22
|
+
}));
|
|
23
|
+
export const RegexMatches = S.Struct({
|
|
24
|
+
regex_matches: RegexMatchBase,
|
|
25
|
+
});
|
|
26
|
+
export const RegexNegationMatches = S.Struct({
|
|
27
|
+
regex_negation_matches: RegexMatchBase,
|
|
28
|
+
});
|
|
29
|
+
export const ContentModerationBlock = S.Struct({
|
|
30
|
+
content_moderation: S.Tuple(S.Literal("OK"), S.Literal(">="), S.Number.annotations({
|
|
31
|
+
title: "Threshold",
|
|
32
|
+
description: "The threshold for content moderation.",
|
|
33
|
+
})),
|
|
34
|
+
});
|
|
35
|
+
export const EntityExcludesLabels = S.Struct({
|
|
36
|
+
entity_excludes: S.Tuple(S.Literal("labels"), S.Tuple(S.Literal("porn"), S.Literal("sexual"), S.Literal("nudity"))),
|
|
37
|
+
});
|
|
38
|
+
export const EmbedType = S.Struct({
|
|
39
|
+
embed_type: S.Tuple(S.Literal("==", "!="), S.Literal("video", "image", "link", "post", "gif", "image_group")),
|
|
40
|
+
});
|
|
41
|
+
// ---------------------- Sort Settings -----------------------------
|
|
42
|
+
export const SortSettings = S.Struct({
|
|
43
|
+
time_window: S.Number,
|
|
44
|
+
decay_penalty: S.Number,
|
|
45
|
+
like_count_multiplier: S.Number,
|
|
46
|
+
reply_count_multiplier: S.Number,
|
|
47
|
+
repost_count_multiplier: S.Number,
|
|
48
|
+
reader_like_count_multiplier: S.Number,
|
|
49
|
+
reader_reply_count_multiplier: S.Number,
|
|
50
|
+
reader_repost_count_multiplier: S.Number,
|
|
51
|
+
});
|
|
52
|
+
// ---------------------- Form Data ---------------------------------
|
|
53
|
+
export const DisplayName = S.String.annotations({
|
|
54
|
+
description: "The public name of the feed.",
|
|
55
|
+
});
|
|
56
|
+
export const RecordName = S.String.annotations({
|
|
57
|
+
description: "The slug of the feed url.",
|
|
58
|
+
});
|
|
59
|
+
export const Description = S.String.annotations({
|
|
60
|
+
description: "The description to be shown to users of the feed.",
|
|
61
|
+
});
|
|
62
|
+
export const Order = S.Union(S.Literal("new"), S.Literal("trending"), S.Literal("blend"));
|
|
63
|
+
export const FeedId = S.NumberFromString;
|
|
64
|
+
export const UserId = S.NumberFromString;
|
|
65
|
+
export const AlgorithmManifest = S.Struct({
|
|
66
|
+
filter: Filter,
|
|
67
|
+
sort_settings: S.optional(SortSettings),
|
|
68
|
+
});
|
|
69
|
+
export const Metadata = S.Struct({
|
|
70
|
+
document: S.optional(S.Unknown),
|
|
71
|
+
schema: S.optional(S.Struct({
|
|
72
|
+
schemaVersion: S.Literal(2),
|
|
73
|
+
sequences: S.Record({ key: S.String, value: S.Number }),
|
|
74
|
+
})),
|
|
75
|
+
session: S.optional(S.Unknown),
|
|
76
|
+
});
|
|
77
|
+
export const FullForm = S.Struct({
|
|
78
|
+
id: FeedId,
|
|
79
|
+
user_id: UserId,
|
|
80
|
+
file: S.optional(S.Unknown),
|
|
81
|
+
display_name: DisplayName,
|
|
82
|
+
record_name: RecordName,
|
|
83
|
+
description: S.optional(Description),
|
|
84
|
+
order: Order,
|
|
85
|
+
algorithm_manifest: S.parseJson(AlgorithmManifest),
|
|
86
|
+
metadata: S.optional(S.parseJson(Metadata)),
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* Actual structure of FormData
|
|
90
|
+
*
|
|
91
|
+
* display_name
|
|
92
|
+
* record_name
|
|
93
|
+
* description
|
|
94
|
+
* order
|
|
95
|
+
* algorithm_manifest
|
|
96
|
+
* metadata
|
|
97
|
+
* id
|
|
98
|
+
* user_id
|
|
99
|
+
* session_cookie
|
|
100
|
+
*/
|
|
101
|
+
//# sourceMappingURL=UpdateAlgorithmPayload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateAlgorithmPayload.js","sourceRoot":"","sources":["../../../src/schema/UpdateAlgorithmPayload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,mEAAmE;AAEnE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;AAGhC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAClC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EACjB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAClB,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAChC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EACtB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAClB,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAC/B,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,EACjC,CAAC,CAAC,OAAO,CAAC,4BAA4B,CAAC,CACxC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC;AA+CrC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAC3B,CAAC,CAAC,OAAO,CAAC,GAAkB,EAAE,CAAC,GAAG,CAAC,EACnC,CAAC,CAAC,OAAO,CAAC,GAAiB,EAAE,CAAC,EAAE,CAAC,EACjC,CAAC,CAAC,OAAO,CAAC,GAA+B,EAAE,CAAC,gBAAgB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,CAAC,MAAM,CAAC;IAC/B,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/B,MAAM,EAAE,CAAC,CAAC,QAAQ,CAChB,CAAC,CAAC,MAAM,CAAC;QACP,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;KACxD,CAAC,CACH;IACD,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;CAC/B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAE,MAAM;IACV,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;IAC3B,YAAY,EAAE,WAAW;IACzB,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;IACpC,KAAK,EAAE,KAAK;IACZ,kBAAkB,EAAE,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC;IAClD,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC5C,CAAC,CAAC;AAIH;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Schema as S } from "effect";
|
|
2
|
+
export const PartialAlgorithm = S.Struct({
|
|
3
|
+
algorithm_uri: S.String,
|
|
4
|
+
algorithm_manifest_id: S.Union(S.Null, S.Number),
|
|
5
|
+
draft_algorithm_manifest_id: S.Number,
|
|
6
|
+
record_name: S.String,
|
|
7
|
+
display_name: S.String,
|
|
8
|
+
description: S.String,
|
|
9
|
+
feed_did: S.String,
|
|
10
|
+
avatar_url: S.Union(S.String, S.Null),
|
|
11
|
+
cpm_cents: S.Union(S.Number, S.Null),
|
|
12
|
+
deleted: S.Boolean,
|
|
13
|
+
active: S.Boolean,
|
|
14
|
+
public: S.Boolean,
|
|
15
|
+
monetization_available: S.Boolean,
|
|
16
|
+
status: S.Union(S.String, S.Null),
|
|
17
|
+
unique_operator_ids: S.Array(S.Number),
|
|
18
|
+
user_id: S.Number,
|
|
19
|
+
id: S.Number,
|
|
20
|
+
created_at: S.DateFromString,
|
|
21
|
+
updated_at: S.DateFromString,
|
|
22
|
+
deleted_at: S.Union(S.DateFromString, S.Null),
|
|
23
|
+
});
|
|
24
|
+
const Stats = S.Unknown;
|
|
25
|
+
const LatestError = S.Unknown;
|
|
26
|
+
const FullAlgorithm = S.Struct({
|
|
27
|
+
...PartialAlgorithm.fields,
|
|
28
|
+
stats: Stats,
|
|
29
|
+
latest_error: LatestError,
|
|
30
|
+
latest_compute_cycle: S.Unknown,
|
|
31
|
+
subscriber_lists: S.Unknown,
|
|
32
|
+
});
|
|
33
|
+
const FullAlgorithmWithManifest = S.Struct({
|
|
34
|
+
...FullAlgorithm.fields,
|
|
35
|
+
draft_algorithm_manifest: S.Unknown,
|
|
36
|
+
algorithm_manifest: S.Unknown,
|
|
37
|
+
});
|
|
38
|
+
export const AlgoUpdateResponse = S.Struct({
|
|
39
|
+
message: S.String,
|
|
40
|
+
algorithm: PartialAlgorithm,
|
|
41
|
+
});
|
|
42
|
+
export const GetAlgoResponse = S.parseJson(FullAlgorithmWithManifest);
|
|
43
|
+
export const HidePostBody = S.Struct({
|
|
44
|
+
algo_id: S.Number,
|
|
45
|
+
at_uri: S.String,
|
|
46
|
+
});
|
|
47
|
+
// ----------------------- Get Algorithms Response -----------------------
|
|
48
|
+
export const AlgorithWithStats = S.Struct({
|
|
49
|
+
...PartialAlgorithm.fields,
|
|
50
|
+
stats: S.Struct({
|
|
51
|
+
page_renders: S.Number,
|
|
52
|
+
unique_users: S.Number,
|
|
53
|
+
post_renders: S.Number,
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
56
|
+
export const GetAlgorithmsResponse = S.Struct({
|
|
57
|
+
page: S.Number,
|
|
58
|
+
page_size: S.Number,
|
|
59
|
+
total_items: S.Number,
|
|
60
|
+
total_pages: S.Number,
|
|
61
|
+
user_algos: S.Array(AlgorithWithStats),
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/schema/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,aAAa,EAAE,CAAC,CAAC,MAAM;IACvB,qBAAqB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IAChD,2BAA2B,EAAE,CAAC,CAAC,MAAM;IACrC,WAAW,EAAE,CAAC,CAAC,MAAM;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM;IACtB,WAAW,EAAE,CAAC,CAAC,MAAM;IACrB,QAAQ,EAAE,CAAC,CAAC,MAAM;IAClB,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;IACrC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;IACpC,OAAO,EAAE,CAAC,CAAC,OAAO;IAClB,MAAM,EAAE,CAAC,CAAC,OAAO;IACjB,MAAM,EAAE,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AG,CAAC,CAAC,MAAM,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB,MAAM,EAAE,CAAC,CAAC,MAAM;CACjB,CAAC,CAAC;AAGH,0EAA0E;AAE1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,GAAG,gBAAgB,CAAC,MAAM;IAC1B,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,YAAY,EAAE,CAAC,CAAC,MAAM;QACtB,YAAY,EAAE,CAAC,CAAC,MAAM;QACtB,YAAY,EAAE,CAAC,CAAC,MAAM;KACvB,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,CAAC,CAAC,MAAM;IACd,SAAS,EAAE,CAAC,CAAC,MAAM;IACnB,WAAW,EAAE,CAAC,CAAC,MAAM;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM;IACrB,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;CACvC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graze-client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Typescript Graze API client.",
|
|
@@ -12,18 +12,24 @@
|
|
|
12
12
|
"access": "public",
|
|
13
13
|
"directory": "."
|
|
14
14
|
},
|
|
15
|
+
"files": [
|
|
16
|
+
"build",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.*",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
15
21
|
"exports": {
|
|
16
22
|
".": {
|
|
17
|
-
"import": "./build/esm/index.
|
|
18
|
-
"
|
|
23
|
+
"import": "./build/esm/index.js",
|
|
24
|
+
"types": "./build/dts/index.d.ts"
|
|
19
25
|
},
|
|
20
26
|
"./effect": {
|
|
21
|
-
"import": "./build/esm/
|
|
22
|
-
"
|
|
27
|
+
"import": "./build/esm/GrazeClient.js",
|
|
28
|
+
"types": "./build/dts/GrazeClient.d.ts"
|
|
23
29
|
},
|
|
24
30
|
"./schema": {
|
|
25
|
-
"import": "./build/esm/schema/index.
|
|
26
|
-
"
|
|
31
|
+
"import": "./build/esm/schema/index.js",
|
|
32
|
+
"types": "./build/dts/schema/index.d.ts"
|
|
27
33
|
}
|
|
28
34
|
},
|
|
29
35
|
"scripts": {
|
|
@@ -88,6 +94,5 @@
|
|
|
88
94
|
"patchedDependencies": {
|
|
89
95
|
"@changesets/get-github-info@0.6.0": "patches/@changesets__get-github-info@0.6.0.patch",
|
|
90
96
|
"babel-plugin-annotate-pure-calls@0.4.0": "patches/babel-plugin-annotate-pure-calls@0.4.0.patch"
|
|
91
|
-
}
|
|
92
|
-
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
|
|
97
|
+
}
|
|
93
98
|
}
|
package/.changeset/config.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json",
|
|
3
|
-
"changelog": [
|
|
4
|
-
"@changesets/changelog-git",
|
|
5
|
-
{
|
|
6
|
-
"repo": "kristojorg/graze-client"
|
|
7
|
-
}
|
|
8
|
-
],
|
|
9
|
-
"commit": false,
|
|
10
|
-
"fixed": [],
|
|
11
|
-
"linked": [],
|
|
12
|
-
"access": "restricted",
|
|
13
|
-
"baseBranch": "main",
|
|
14
|
-
"updateInternalDependencies": "patch",
|
|
15
|
-
"ignore": []
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: Setup
|
|
2
|
-
description: Perform standard setup and install dependencies using pnpm.
|
|
3
|
-
inputs:
|
|
4
|
-
node-version:
|
|
5
|
-
description: The version of Node.js to install
|
|
6
|
-
required: true
|
|
7
|
-
default: 20.16.0
|
|
8
|
-
|
|
9
|
-
runs:
|
|
10
|
-
using: composite
|
|
11
|
-
steps:
|
|
12
|
-
- name: Install pnpm
|
|
13
|
-
uses: pnpm/action-setup@v3
|
|
14
|
-
- name: Install node
|
|
15
|
-
uses: actions/setup-node@v4
|
|
16
|
-
with:
|
|
17
|
-
cache: pnpm
|
|
18
|
-
node-version: ${{ inputs.node-version }}
|
|
19
|
-
- name: Install dependencies
|
|
20
|
-
shell: bash
|
|
21
|
-
run: pnpm install
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
name: Check
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
pull_request:
|
|
6
|
-
branches: [main]
|
|
7
|
-
push:
|
|
8
|
-
branches: [main]
|
|
9
|
-
|
|
10
|
-
concurrency:
|
|
11
|
-
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
-
cancel-in-progress: true
|
|
13
|
-
|
|
14
|
-
permissions: {}
|
|
15
|
-
|
|
16
|
-
jobs:
|
|
17
|
-
build:
|
|
18
|
-
name: Build
|
|
19
|
-
runs-on: ubuntu-latest
|
|
20
|
-
timeout-minutes: 10
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v4
|
|
23
|
-
- name: Install dependencies
|
|
24
|
-
uses: ./.github/actions/setup
|
|
25
|
-
- run: pnpm codegen
|
|
26
|
-
- name: Check source state
|
|
27
|
-
run: git add packages/*/src && git diff-index --cached HEAD --exit-code packages/*/src
|
|
28
|
-
|
|
29
|
-
types:
|
|
30
|
-
name: Types
|
|
31
|
-
runs-on: ubuntu-latest
|
|
32
|
-
timeout-minutes: 10
|
|
33
|
-
steps:
|
|
34
|
-
- uses: actions/checkout@v4
|
|
35
|
-
- name: Install dependencies
|
|
36
|
-
uses: ./.github/actions/setup
|
|
37
|
-
- run: pnpm check
|
|
38
|
-
|
|
39
|
-
lint:
|
|
40
|
-
name: Lint
|
|
41
|
-
runs-on: ubuntu-latest
|
|
42
|
-
timeout-minutes: 10
|
|
43
|
-
steps:
|
|
44
|
-
- uses: actions/checkout@v4
|
|
45
|
-
- name: Install dependencies
|
|
46
|
-
uses: ./.github/actions/setup
|
|
47
|
-
- run: pnpm lint
|
|
48
|
-
|
|
49
|
-
test:
|
|
50
|
-
name: Test
|
|
51
|
-
runs-on: ubuntu-latest
|
|
52
|
-
timeout-minutes: 10
|
|
53
|
-
steps:
|
|
54
|
-
- uses: actions/checkout@v4
|
|
55
|
-
- name: Install dependencies
|
|
56
|
-
uses: ./.github/actions/setup
|
|
57
|
-
- run: pnpm test
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
concurrency:
|
|
8
|
-
group: ${{ github.workflow }}-${{ github.ref }}
|
|
9
|
-
|
|
10
|
-
permissions: {}
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
release:
|
|
14
|
-
if: github.repository_owner == 'Effect-Ts'
|
|
15
|
-
name: Release
|
|
16
|
-
runs-on: ubuntu-latest
|
|
17
|
-
timeout-minutes: 10
|
|
18
|
-
permissions:
|
|
19
|
-
contents: write
|
|
20
|
-
id-token: write
|
|
21
|
-
pull-requests: write
|
|
22
|
-
steps:
|
|
23
|
-
- uses: actions/checkout@v4
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
uses: ./.github/actions/setup
|
|
26
|
-
- name: Create Release Pull Request or Publish
|
|
27
|
-
id: changesets
|
|
28
|
-
uses: changesets/action@v1
|
|
29
|
-
with:
|
|
30
|
-
version: pnpm changeset-version
|
|
31
|
-
publish: pnpm changeset-publish
|
|
32
|
-
env:
|
|
33
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
34
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|