anpord 0.0.0 → 0.1.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/dist/cli.cjs ADDED
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+ const require_client = require("./client-Cno4LwRq.cjs");
3
+ const require_config = require("./config.cjs");
4
+ const require_errors = require("./errors-C0E5A8fN.cjs");
5
+ let _effect_platform = require("@effect/platform");
6
+ let effect = require("effect");
7
+ let _effect_cli = require("@effect/cli");
8
+ let _effect_platform_node = require("@effect/platform-node");
9
+ //#region src/cli/render.ts
10
+ const json = (value) => effect.Console.log(JSON.stringify(value, null, 2));
11
+ const promptContent = (prompt) => effect.Effect.sync(() => {
12
+ process.stdout.write(prompt.content);
13
+ if (!prompt.content.endsWith("\n")) process.stdout.write("\n");
14
+ });
15
+ const note = (message) => effect.Effect.sync(() => {
16
+ process.stderr.write(`${message}\n`);
17
+ });
18
+ //#endregion
19
+ //#region src/cli/commands.ts
20
+ const promptId = _effect_cli.Args.text({ name: "id" }).pipe(_effect_cli.Args.withDescription("The prompt's id, such as support-reply"), _effect_cli.Args.withSchema(require_client.PromptId));
21
+ const channel = _effect_cli.Options.text("channel").pipe(_effect_cli.Options.withDescription("Resolve the version a channel points at"), _effect_cli.Options.withSchema(require_client.ChannelName), _effect_cli.Options.optional);
22
+ const version = _effect_cli.Options.integer("at").pipe(_effect_cli.Options.withDescription("Pin an exact version"), _effect_cli.Options.withSchema(require_client.VersionNumber), _effect_cli.Options.optional);
23
+ const asJson = _effect_cli.Options.boolean("json").pipe(_effect_cli.Options.withDescription("Print the whole prompt as JSON"));
24
+ const message = _effect_cli.Options.text("message").pipe(_effect_cli.Options.withAlias("m"), _effect_cli.Options.withDescription("Why the content changed"), _effect_cli.Options.optional);
25
+ const get = _effect_cli.Command.make("get", {
26
+ asJson,
27
+ channel,
28
+ promptId,
29
+ version
30
+ }, ({ asJson: wantsJson, channel: wantedChannel, promptId: id, version: pin }) => effect.Effect.gen(function* () {
31
+ const prompt = yield* (yield* require_client.AnpordApi).prompts.get({ payload: {
32
+ channel: effect.Option.getOrUndefined(wantedChannel),
33
+ id,
34
+ version: effect.Option.getOrUndefined(pin)
35
+ } });
36
+ return yield* wantsJson ? json(prompt) : promptContent(prompt);
37
+ })).pipe(_effect_cli.Command.withDescription("Print a prompt's content"));
38
+ const list = _effect_cli.Command.make("list", { asJson }, ({ asJson: wantsJson }) => effect.Effect.gen(function* () {
39
+ const { data } = yield* (yield* require_client.AnpordApi).prompts.list({ payload: {} });
40
+ if (wantsJson) return yield* json(data);
41
+ return yield* effect.Effect.forEach(data, (row) => note(`${row.id}\tv${row.latestVersion ?? "-"}\t${row.name}`));
42
+ })).pipe(_effect_cli.Command.withDescription("List every prompt"));
43
+ const versions = _effect_cli.Command.make("versions", { promptId }, ({ promptId: id }) => effect.Effect.gen(function* () {
44
+ const prompt = yield* (yield* require_client.AnpordApi).prompts.get({ payload: {
45
+ id,
46
+ includeVersions: true
47
+ } });
48
+ return yield* json(prompt.versions ?? []);
49
+ })).pipe(_effect_cli.Command.withDescription("Show a prompt's history"));
50
+ const promote = _effect_cli.Command.make("promote", {
51
+ channel: _effect_cli.Options.text("to").pipe(_effect_cli.Options.withDescription("Channel to point at the version"), _effect_cli.Options.withSchema(require_client.ChannelName)),
52
+ promptId,
53
+ version: _effect_cli.Options.integer("at").pipe(_effect_cli.Options.withDescription("Version to promote"), _effect_cli.Options.withSchema(require_client.VersionNumber))
54
+ }, ({ channel: to, promptId: id, version: pin }) => effect.Effect.gen(function* () {
55
+ yield* (yield* require_client.AnpordApi).prompts.promote({ payload: {
56
+ channel: to,
57
+ id,
58
+ version: pin
59
+ } });
60
+ return yield* note(`${id} v${pin} is now ${to}`);
61
+ })).pipe(_effect_cli.Command.withDescription("Point a channel at a version"));
62
+ const readStdin = effect.Effect.flatMap(_effect_platform.FileSystem.FileSystem, (fs) => fs.readFileString("/dev/stdin"));
63
+ const target = _effect_cli.Args.all([promptId, _effect_cli.Args.text({ name: "content" }).pipe(_effect_cli.Args.withDescription("The new content, or - to read stdin"))]);
64
+ const commands = [
65
+ get,
66
+ list,
67
+ promote,
68
+ _effect_cli.Command.make("push", {
69
+ message,
70
+ target
71
+ }, ({ message: why, target: [id, content] }) => effect.Effect.gen(function* () {
72
+ const api = yield* require_client.AnpordApi;
73
+ const body = content === "-" ? yield* readStdin : content;
74
+ const prompt = yield* api.prompts.update({ payload: {
75
+ content: body,
76
+ id,
77
+ message: effect.Option.getOrUndefined(why)
78
+ } });
79
+ return yield* note(`${id} is now v${prompt.version}`);
80
+ })).pipe(_effect_cli.Command.withDescription("Add a version to a prompt")),
81
+ versions
82
+ ];
83
+ //#endregion
84
+ //#region src/cli/failure.ts
85
+ const MISSING_KEY = "Set ANPORD_API_KEY to an API key from https://www.anpord.com/settings/keys";
86
+ const describe = (error) => {
87
+ if (error._tag === "ConfigError") return MISSING_KEY;
88
+ const { message, status } = require_errors.asAnpordError(error);
89
+ return status === 401 ? `${message}. ${MISSING_KEY}` : message;
90
+ };
91
+ const reportFailure = (error) => effect.Effect.sync(() => {
92
+ process.stderr.write(`${describe(error)}\n`);
93
+ process.exitCode = 1;
94
+ });
95
+ //#endregion
96
+ //#region src/cli/main.ts
97
+ const anpord = _effect_cli.Command.make("anpord").pipe(_effect_cli.Command.withDescription("Read and publish prompts from the terminal"), _effect_cli.Command.withSubcommands(commands));
98
+ const ClientLayer = effect.Layer.unwrapEffect(effect.Effect.map(require_config.clientOptionsConfig, require_client.layer));
99
+ _effect_cli.Command.run(anpord, {
100
+ name: "Anpord",
101
+ version: "0.1.0"
102
+ })(process.argv).pipe(effect.Effect.provide(effect.Layer.mergeAll(ClientLayer, _effect_platform_node.NodeContext.layer)), effect.Effect.catchAllCause((cause) => effect.Cause.isInterruptedOnly(cause) ? effect.Effect.void : reportFailure(effect.Cause.failureOption(cause).pipe(effect.Option.getOrElse(() => effect.Cause.squash(cause))))), _effect_platform_node.NodeRuntime.runMain({ disableErrorReporting: true }));
103
+ //#endregion
package/dist/cli.d.cts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/cli.mjs ADDED
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env node
2
+ import { a as ChannelName, o as PromptId, r as layer, s as VersionNumber, t as AnpordApi } from "./client-bJBNwTKq.mjs";
3
+ import { clientOptionsConfig } from "./config.mjs";
4
+ import { r as asAnpordError } from "./errors-DEfS6oaQ.mjs";
5
+ import { FileSystem } from "@effect/platform";
6
+ import { Cause, Console, Effect, Layer, Option } from "effect";
7
+ import { Args, Command, Options } from "@effect/cli";
8
+ import { NodeContext, NodeRuntime } from "@effect/platform-node";
9
+ //#region src/cli/render.ts
10
+ const json = (value) => Console.log(JSON.stringify(value, null, 2));
11
+ const promptContent = (prompt) => Effect.sync(() => {
12
+ process.stdout.write(prompt.content);
13
+ if (!prompt.content.endsWith("\n")) process.stdout.write("\n");
14
+ });
15
+ const note = (message) => Effect.sync(() => {
16
+ process.stderr.write(`${message}\n`);
17
+ });
18
+ //#endregion
19
+ //#region src/cli/commands.ts
20
+ const promptId = Args.text({ name: "id" }).pipe(Args.withDescription("The prompt's id, such as support-reply"), Args.withSchema(PromptId));
21
+ const channel = Options.text("channel").pipe(Options.withDescription("Resolve the version a channel points at"), Options.withSchema(ChannelName), Options.optional);
22
+ const version = Options.integer("at").pipe(Options.withDescription("Pin an exact version"), Options.withSchema(VersionNumber), Options.optional);
23
+ const asJson = Options.boolean("json").pipe(Options.withDescription("Print the whole prompt as JSON"));
24
+ const message = Options.text("message").pipe(Options.withAlias("m"), Options.withDescription("Why the content changed"), Options.optional);
25
+ const get = Command.make("get", {
26
+ asJson,
27
+ channel,
28
+ promptId,
29
+ version
30
+ }, ({ asJson: wantsJson, channel: wantedChannel, promptId: id, version: pin }) => Effect.gen(function* () {
31
+ const prompt = yield* (yield* AnpordApi).prompts.get({ payload: {
32
+ channel: Option.getOrUndefined(wantedChannel),
33
+ id,
34
+ version: Option.getOrUndefined(pin)
35
+ } });
36
+ return yield* wantsJson ? json(prompt) : promptContent(prompt);
37
+ })).pipe(Command.withDescription("Print a prompt's content"));
38
+ const list = Command.make("list", { asJson }, ({ asJson: wantsJson }) => Effect.gen(function* () {
39
+ const { data } = yield* (yield* AnpordApi).prompts.list({ payload: {} });
40
+ if (wantsJson) return yield* json(data);
41
+ return yield* Effect.forEach(data, (row) => note(`${row.id}\tv${row.latestVersion ?? "-"}\t${row.name}`));
42
+ })).pipe(Command.withDescription("List every prompt"));
43
+ const versions = Command.make("versions", { promptId }, ({ promptId: id }) => Effect.gen(function* () {
44
+ const prompt = yield* (yield* AnpordApi).prompts.get({ payload: {
45
+ id,
46
+ includeVersions: true
47
+ } });
48
+ return yield* json(prompt.versions ?? []);
49
+ })).pipe(Command.withDescription("Show a prompt's history"));
50
+ const promote = Command.make("promote", {
51
+ channel: Options.text("to").pipe(Options.withDescription("Channel to point at the version"), Options.withSchema(ChannelName)),
52
+ promptId,
53
+ version: Options.integer("at").pipe(Options.withDescription("Version to promote"), Options.withSchema(VersionNumber))
54
+ }, ({ channel: to, promptId: id, version: pin }) => Effect.gen(function* () {
55
+ yield* (yield* AnpordApi).prompts.promote({ payload: {
56
+ channel: to,
57
+ id,
58
+ version: pin
59
+ } });
60
+ return yield* note(`${id} v${pin} is now ${to}`);
61
+ })).pipe(Command.withDescription("Point a channel at a version"));
62
+ const readStdin = Effect.flatMap(FileSystem.FileSystem, (fs) => fs.readFileString("/dev/stdin"));
63
+ const target = Args.all([promptId, Args.text({ name: "content" }).pipe(Args.withDescription("The new content, or - to read stdin"))]);
64
+ const commands = [
65
+ get,
66
+ list,
67
+ promote,
68
+ Command.make("push", {
69
+ message,
70
+ target
71
+ }, ({ message: why, target: [id, content] }) => Effect.gen(function* () {
72
+ const api = yield* AnpordApi;
73
+ const body = content === "-" ? yield* readStdin : content;
74
+ const prompt = yield* api.prompts.update({ payload: {
75
+ content: body,
76
+ id,
77
+ message: Option.getOrUndefined(why)
78
+ } });
79
+ return yield* note(`${id} is now v${prompt.version}`);
80
+ })).pipe(Command.withDescription("Add a version to a prompt")),
81
+ versions
82
+ ];
83
+ //#endregion
84
+ //#region src/cli/failure.ts
85
+ const MISSING_KEY = "Set ANPORD_API_KEY to an API key from https://www.anpord.com/settings/keys";
86
+ const describe = (error) => {
87
+ if (error._tag === "ConfigError") return MISSING_KEY;
88
+ const { message, status } = asAnpordError(error);
89
+ return status === 401 ? `${message}. ${MISSING_KEY}` : message;
90
+ };
91
+ const reportFailure = (error) => Effect.sync(() => {
92
+ process.stderr.write(`${describe(error)}\n`);
93
+ process.exitCode = 1;
94
+ });
95
+ //#endregion
96
+ //#region src/cli/main.ts
97
+ const anpord = Command.make("anpord").pipe(Command.withDescription("Read and publish prompts from the terminal"), Command.withSubcommands(commands));
98
+ const ClientLayer = Layer.unwrapEffect(Effect.map(clientOptionsConfig, layer));
99
+ Command.run(anpord, {
100
+ name: "Anpord",
101
+ version: "0.1.0"
102
+ })(process.argv).pipe(Effect.provide(Layer.mergeAll(ClientLayer, NodeContext.layer)), Effect.catchAllCause((cause) => Cause.isInterruptedOnly(cause) ? Effect.void : reportFailure(Cause.failureOption(cause).pipe(Option.getOrElse(() => Cause.squash(cause))))), NodeRuntime.runMain({ disableErrorReporting: true }));
103
+ //#endregion
104
+ export {};
@@ -0,0 +1,277 @@
1
+ let _effect_platform = require("@effect/platform");
2
+ let effect = require("effect");
3
+ //#region ../schema/src/domain/errors.ts
4
+ var NotFound = class extends effect.Schema.TaggedError()("NotFound", { message: effect.Schema.String }, _effect_platform.HttpApiSchema.annotations({ status: 404 })) {};
5
+ var Conflict = class extends effect.Schema.TaggedError()("Conflict", { message: effect.Schema.String }, _effect_platform.HttpApiSchema.annotations({ status: 409 })) {};
6
+ var BadRequest = class extends effect.Schema.TaggedError()("BadRequest", { message: effect.Schema.String }, _effect_platform.HttpApiSchema.annotations({ status: 400 })) {};
7
+ var Unauthorized = class extends effect.Schema.TaggedError()("Unauthorized", { message: effect.Schema.String }, _effect_platform.HttpApiSchema.annotations({ status: 401 })) {};
8
+ effect.Schema.TaggedError()("InternalError", { message: effect.Schema.String }, _effect_platform.HttpApiSchema.annotations({ status: 500 }));
9
+ //#endregion
10
+ //#region ../schema/src/internal/authentication.ts
11
+ var CurrentActor = class extends effect.Context.Tag("@anpord/schema/CurrentActor")() {};
12
+ _effect_platform.HttpApiMiddleware.Tag()("@anpord/schema/Authentication", {
13
+ failure: Unauthorized,
14
+ provides: CurrentActor,
15
+ security: { session: _effect_platform.HttpApiSecurity.apiKey({
16
+ in: "cookie",
17
+ key: "anpord.session_token"
18
+ }) }
19
+ });
20
+ //#endregion
21
+ //#region ../schema/src/public/authentication.ts
22
+ var ApiKeyAuthentication = class extends _effect_platform.HttpApiMiddleware.Tag()("@anpord/schema/ApiKeyAuthentication", {
23
+ failure: Unauthorized,
24
+ provides: CurrentActor,
25
+ security: { bearer: _effect_platform.HttpApiSecurity.bearer }
26
+ }) {};
27
+ //#endregion
28
+ //#region ../schema/src/domain/prompts.ts
29
+ const ChannelName = effect.Schema.String.pipe(effect.Schema.minLength(1), effect.Schema.maxLength(36), effect.Schema.pattern(/^[a-z0-9][a-z0-9_-]*$/, { message: () => "Channel must be lowercase alphanumeric, optionally with - or _" }), effect.Schema.brand("ChannelName")).annotations({ description: "Addresses a version. `latest` is derived from the highest version rather than stored, so it cannot drift from the version table." });
30
+ ChannelName.make("production");
31
+ ChannelName.make("latest");
32
+ const PromptId = effect.Schema.String.pipe(effect.Schema.minLength(1), effect.Schema.maxLength(255), effect.Schema.pattern(/^[a-z0-9][a-z0-9/_-]*$/, { message: () => "Prompt id must be lowercase alphanumeric, optionally with / _ or -" }), effect.Schema.brand("PromptId"));
33
+ const PromptName = effect.Schema.String.pipe(effect.Schema.minLength(1), effect.Schema.maxLength(255), effect.Schema.brand("PromptName"));
34
+ const VersionNumber = effect.Schema.Int.pipe(effect.Schema.positive(), effect.Schema.brand("VersionNumber"));
35
+ effect.Schema.NumberFromString.pipe(effect.Schema.int(), effect.Schema.positive(), effect.Schema.brand("VersionNumber"));
36
+ effect.Schema.NumberFromString.pipe(effect.Schema.int(), effect.Schema.positive(), effect.Schema.lessThanOrEqualTo(100));
37
+ const Timestamp = effect.Schema.Union(effect.Schema.DateFromSelf, effect.Schema.Date);
38
+ const CommitMessage = effect.Schema.String.pipe(effect.Schema.maxLength(500));
39
+ const PromptConfig = effect.Schema.Record({
40
+ key: effect.Schema.String,
41
+ value: effect.Schema.Unknown
42
+ });
43
+ const Author = effect.Schema.Struct({
44
+ image: effect.Schema.NullOr(effect.Schema.String),
45
+ name: effect.Schema.String
46
+ });
47
+ effect.Schema.Struct({
48
+ author: effect.Schema.NullOr(Author),
49
+ channel: effect.Schema.NullOr(ChannelName),
50
+ commitMessage: effect.Schema.NullOr(CommitMessage),
51
+ config: PromptConfig,
52
+ content: effect.Schema.String,
53
+ createdAt: Timestamp,
54
+ id: PromptId,
55
+ name: PromptName,
56
+ version: VersionNumber,
57
+ versionId: effect.Schema.String
58
+ });
59
+ effect.Schema.Struct({
60
+ channel: ChannelName,
61
+ updatedAt: Timestamp,
62
+ updatedBy: effect.Schema.NullOr(Author),
63
+ version: VersionNumber
64
+ });
65
+ const PromptSummary = effect.Schema.Struct({
66
+ description: effect.Schema.NullOr(effect.Schema.String),
67
+ id: PromptId,
68
+ latestVersion: effect.Schema.NullOr(VersionNumber),
69
+ name: PromptName,
70
+ productionVersion: effect.Schema.NullOr(VersionNumber),
71
+ updatedAt: Timestamp
72
+ });
73
+ effect.Schema.Struct({
74
+ id: PromptId,
75
+ updatedAt: Timestamp
76
+ });
77
+ effect.Schema.Literal("all", "draft", "live");
78
+ effect.Schema.Literal("name", "updated");
79
+ effect.Schema.Struct({
80
+ items: effect.Schema.Array(PromptSummary),
81
+ /** Opaque to callers, and null once the last page has been read. */
82
+ nextCursor: effect.Schema.NullOr(effect.Schema.String)
83
+ });
84
+ effect.Schema.Struct({
85
+ commitMessage: effect.Schema.optional(CommitMessage),
86
+ config: effect.Schema.optional(PromptConfig),
87
+ content: effect.Schema.String.pipe(effect.Schema.minLength(1)),
88
+ description: effect.Schema.optional(effect.Schema.String),
89
+ id: PromptId,
90
+ name: PromptName,
91
+ publish: effect.Schema.optional(effect.Schema.Boolean)
92
+ });
93
+ effect.Schema.Struct({
94
+ commitMessage: effect.Schema.optional(CommitMessage),
95
+ config: effect.Schema.optional(PromptConfig),
96
+ content: effect.Schema.String.pipe(effect.Schema.minLength(1)),
97
+ publish: effect.Schema.optional(effect.Schema.Boolean)
98
+ });
99
+ effect.Schema.Struct({
100
+ commitMessage: effect.Schema.optional(CommitMessage),
101
+ config: effect.Schema.optional(PromptConfig),
102
+ content: effect.Schema.String.pipe(effect.Schema.minLength(1))
103
+ });
104
+ effect.Schema.Struct({
105
+ description: effect.Schema.optional(effect.Schema.String),
106
+ id: effect.Schema.optional(PromptId),
107
+ name: effect.Schema.optional(PromptName)
108
+ });
109
+ effect.Schema.Struct({
110
+ channel: ChannelName,
111
+ version: VersionNumber
112
+ });
113
+ effect.Schema.Struct({
114
+ channel: effect.Schema.optional(ChannelName),
115
+ version: effect.Schema.optional(VersionNumber)
116
+ });
117
+ //#endregion
118
+ //#region ../schema/src/public/requests.ts
119
+ const GetPromptRequest = effect.Schema.Struct({
120
+ channel: effect.Schema.optional(ChannelName),
121
+ id: PromptId,
122
+ includeVersions: effect.Schema.optional(effect.Schema.Boolean),
123
+ version: effect.Schema.optional(VersionNumber)
124
+ }).annotations({
125
+ description: "Resolve a prompt. Give a version to pin one, a channel to follow one, or neither for production.",
126
+ identifier: "GetPromptRequest"
127
+ });
128
+ effect.Schema.Struct({ id: PromptId }).annotations({
129
+ description: "Show a prompt's version history.",
130
+ identifier: "ListVersionsRequest"
131
+ });
132
+ const ListPromptsRequest = effect.Schema.Struct({}).annotations({
133
+ description: "No parameters; returns every prompt in the organization.",
134
+ identifier: "ListPromptsRequest"
135
+ });
136
+ const CreatePromptRequest = effect.Schema.Struct({
137
+ config: effect.Schema.optional(PromptConfig),
138
+ content: effect.Schema.String.pipe(effect.Schema.minLength(1)),
139
+ description: effect.Schema.optional(effect.Schema.String),
140
+ id: PromptId,
141
+ message: effect.Schema.optional(CommitMessage),
142
+ name: PromptName
143
+ }).annotations({
144
+ description: "Create a prompt and its first version.",
145
+ identifier: "CreatePromptRequest"
146
+ });
147
+ const UpdatePromptRequest = effect.Schema.Struct({
148
+ config: effect.Schema.optional(PromptConfig),
149
+ content: effect.Schema.String.pipe(effect.Schema.minLength(1)),
150
+ id: PromptId,
151
+ message: effect.Schema.optional(CommitMessage)
152
+ }).annotations({
153
+ description: "Add a version to a prompt. The new version becomes the latest.",
154
+ identifier: "UpdatePromptRequest"
155
+ });
156
+ const PromotePromptRequest = effect.Schema.Struct({
157
+ channel: ChannelName,
158
+ id: PromptId,
159
+ version: VersionNumber
160
+ }).annotations({
161
+ description: "Point a channel at a version.",
162
+ identifier: "PromotePromptRequest"
163
+ });
164
+ const ArchivePromptRequest = effect.Schema.Struct({ id: PromptId }).annotations({
165
+ description: "Archive a prompt. Existing versions stay readable by number.",
166
+ identifier: "ArchivePromptRequest"
167
+ });
168
+ const Ok = effect.Schema.Struct({ ok: effect.Schema.Literal(true) }).annotations({
169
+ description: "The operation succeeded.",
170
+ identifier: "Ok"
171
+ });
172
+ //#endregion
173
+ //#region ../schema/src/public/shapes.ts
174
+ const Instant = effect.Schema.DateTimeUtc.annotations({
175
+ description: "An ISO-8601 timestamp in UTC.",
176
+ identifier: "Instant"
177
+ });
178
+ const PublicPrompt = effect.Schema.Struct({
179
+ channel: effect.Schema.NullOr(ChannelName),
180
+ config: PromptConfig,
181
+ content: effect.Schema.String,
182
+ createdAt: Instant,
183
+ id: PromptId,
184
+ message: effect.Schema.NullOr(CommitMessage),
185
+ name: PromptName,
186
+ version: VersionNumber
187
+ }).annotations({
188
+ description: "A prompt resolved at a specific version.",
189
+ identifier: "ResolvedPrompt"
190
+ });
191
+ const PublicVersion = effect.Schema.Struct({
192
+ createdAt: Instant,
193
+ message: effect.Schema.NullOr(CommitMessage),
194
+ version: VersionNumber
195
+ }).annotations({
196
+ description: "One entry in a prompt's history.",
197
+ identifier: "Version"
198
+ });
199
+ const PublicPromptWithVersions = effect.Schema.extend(PublicPrompt, effect.Schema.Struct({ versions: effect.Schema.optional(effect.Schema.Array(PublicVersion)) })).annotations({
200
+ description: "A prompt, with its version history when `includeVersions` is set.",
201
+ identifier: "Prompt"
202
+ });
203
+ const PublicPromptSummary = effect.Schema.Struct({
204
+ id: PromptId,
205
+ latestVersion: effect.Schema.NullOr(VersionNumber),
206
+ name: PromptName,
207
+ productionVersion: effect.Schema.NullOr(VersionNumber),
208
+ updatedAt: Instant
209
+ }).annotations({
210
+ description: "A prompt without its content.",
211
+ identifier: "PromptSummary"
212
+ });
213
+ const PromptList = effect.Schema.Struct({ data: effect.Schema.Array(PublicPromptSummary) }).annotations({
214
+ description: "Every prompt in the organization.",
215
+ identifier: "PromptList"
216
+ });
217
+ //#endregion
218
+ //#region ../schema/src/public/prompts-api.ts
219
+ var PublicPromptsGroup = class extends _effect_platform.HttpApiGroup.make("prompts").add(_effect_platform.HttpApiEndpoint.post("get", "/prompts.get").setPayload(GetPromptRequest).addSuccess(PublicPromptWithVersions).annotate(_effect_platform.OpenApi.Summary, "Resolve a prompt").annotate(_effect_platform.OpenApi.Description, "Returns the content a caller should send to a model. With no selector this is the production version.")).add(_effect_platform.HttpApiEndpoint.post("list", "/prompts.list").setPayload(ListPromptsRequest).addSuccess(PromptList).annotate(_effect_platform.OpenApi.Summary, "List prompts").annotate(_effect_platform.OpenApi.Description, "Every prompt in the organization, without content.")).add(_effect_platform.HttpApiEndpoint.post("create", "/prompts.create").setPayload(CreatePromptRequest).addSuccess(PublicPromptWithVersions).annotate(_effect_platform.OpenApi.Summary, "Create a prompt").annotate(_effect_platform.OpenApi.Description, "Creates the prompt and its first version in one call.")).add(_effect_platform.HttpApiEndpoint.post("update", "/prompts.update").setPayload(UpdatePromptRequest).addSuccess(PublicPromptWithVersions).annotate(_effect_platform.OpenApi.Summary, "Add a version").annotate(_effect_platform.OpenApi.Description, "Content is versioned, so updating a prompt appends a version rather than overwriting one. Earlier versions stay readable.")).add(_effect_platform.HttpApiEndpoint.post("promote", "/prompts.promote").setPayload(PromotePromptRequest).addSuccess(Ok).annotate(_effect_platform.OpenApi.Summary, "Promote a version to a channel").annotate(_effect_platform.OpenApi.Description, "Points a channel, such as production, at a version. This is how a version goes live without callers changing anything.")).add(_effect_platform.HttpApiEndpoint.post("archive", "/prompts.archive").setPayload(ArchivePromptRequest).addSuccess(Ok).annotate(_effect_platform.OpenApi.Summary, "Archive a prompt").annotate(_effect_platform.OpenApi.Description, "Hides the prompt from listings. Pinned versions keep resolving.")).addError(BadRequest).addError(Conflict).addError(NotFound).middleware(ApiKeyAuthentication).annotate(_effect_platform.OpenApi.Title, "Prompts").annotate(_effect_platform.OpenApi.Description, "Read and write prompts. Content is versioned, so writes append rather than overwrite, and channels decide which version callers receive.") {};
220
+ //#endregion
221
+ //#region ../schema/src/public/api.ts
222
+ var PublicApi = class extends _effect_platform.HttpApi.make("anpord-public").add(PublicPromptsGroup).prefix("/v1").annotate(_effect_platform.OpenApi.Title, "Anpord API").annotate(_effect_platform.OpenApi.Version, "1.0.0").annotate(_effect_platform.OpenApi.Description, "Prompt management. Every endpoint takes a JSON body over POST and authenticates with a bearer API key.").annotate(_effect_platform.OpenApi.Servers, [{
223
+ description: "Production",
224
+ url: "https://api.anpord.com"
225
+ }]) {};
226
+ //#endregion
227
+ //#region ../schema/src/public/client.ts
228
+ const DEFAULT_BASE_URL = "https://api.anpord.com";
229
+ const make = ({ apiKey, baseUrl = DEFAULT_BASE_URL }) => _effect_platform.HttpApiClient.make(PublicApi, {
230
+ baseUrl,
231
+ transformClient: _effect_platform.HttpClient.mapRequest(_effect_platform.HttpClientRequest.bearerToken(effect.Redacted.value(apiKey)))
232
+ });
233
+ var AnpordApi = class extends effect.Effect.Tag("@anpord/sdk/AnpordApi")() {};
234
+ const layer = (options) => effect.Layer.effect(AnpordApi, make(options)).pipe(effect.Layer.provide(_effect_platform.FetchHttpClient.layer));
235
+ //#endregion
236
+ Object.defineProperty(exports, "AnpordApi", {
237
+ enumerable: true,
238
+ get: function() {
239
+ return AnpordApi;
240
+ }
241
+ });
242
+ Object.defineProperty(exports, "ChannelName", {
243
+ enumerable: true,
244
+ get: function() {
245
+ return ChannelName;
246
+ }
247
+ });
248
+ Object.defineProperty(exports, "DEFAULT_BASE_URL", {
249
+ enumerable: true,
250
+ get: function() {
251
+ return DEFAULT_BASE_URL;
252
+ }
253
+ });
254
+ Object.defineProperty(exports, "PromptId", {
255
+ enumerable: true,
256
+ get: function() {
257
+ return PromptId;
258
+ }
259
+ });
260
+ Object.defineProperty(exports, "VersionNumber", {
261
+ enumerable: true,
262
+ get: function() {
263
+ return VersionNumber;
264
+ }
265
+ });
266
+ Object.defineProperty(exports, "layer", {
267
+ enumerable: true,
268
+ get: function() {
269
+ return layer;
270
+ }
271
+ });
272
+ Object.defineProperty(exports, "make", {
273
+ enumerable: true,
274
+ get: function() {
275
+ return make;
276
+ }
277
+ });