@pgfsm/api 0.0.0-stage → 0.0.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/esm/_dnt.polyfills.d.ts +17 -0
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/_dnt.shims.d.ts +5 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/database-src/generated/database.types.d.ts +2131 -0
- package/esm/database-src/generated/database.types.js +21 -0
- package/esm/deps/jsr.io/@std/cli/1.0.31/parse_args.d.ts +342 -0
- package/esm/deps/jsr.io/@std/cli/1.0.31/parse_args.js +372 -0
- package/esm/fsm-api-ts/env.d.ts +143 -0
- package/esm/fsm-api-ts/env.js +72 -0
- package/esm/fsm-api-ts/lib/configure-open-api.d.ts +3 -0
- package/esm/fsm-api-ts/lib/configure-open-api.js +25 -0
- package/esm/fsm-api-ts/lib/constants.d.ts +15 -0
- package/esm/fsm-api-ts/lib/constants.js +11 -0
- package/esm/fsm-api-ts/lib/create-app.d.ts +19 -0
- package/esm/fsm-api-ts/lib/create-app.js +137 -0
- package/esm/fsm-api-ts/lib/create-router.d.ts +3 -0
- package/esm/fsm-api-ts/lib/create-router.js +10 -0
- package/esm/fsm-api-ts/lib/license.d.ts +13 -0
- package/esm/fsm-api-ts/lib/license.js +15 -0
- package/esm/fsm-api-ts/lib/types.d.ts +19 -0
- package/esm/fsm-api-ts/lib/types.js +1 -0
- package/esm/fsm-api-ts/logger.d.ts +3 -0
- package/esm/fsm-api-ts/logger.js +20 -0
- package/esm/fsm-api-ts/middlewares/api-key-auth.d.ts +34 -0
- package/esm/fsm-api-ts/middlewares/api-key-auth.js +70 -0
- package/esm/fsm-api-ts/middlewares/logtape-logger.d.ts +2 -0
- package/esm/fsm-api-ts/middlewares/logtape-logger.js +33 -0
- package/esm/fsm-api-ts/middlewares/otel-trace.d.ts +2 -0
- package/esm/fsm-api-ts/middlewares/otel-trace.js +29 -0
- package/esm/fsm-api-ts/middlewares/supabase.d.ts +10 -0
- package/esm/fsm-api-ts/middlewares/supabase.js +34 -0
- package/esm/fsm-api-ts/mod.d.ts +2 -0
- package/esm/fsm-api-ts/mod.js +6 -0
- package/esm/fsm-api-ts/routes/admin/admin.handlers.d.ts +8 -0
- package/esm/fsm-api-ts/routes/admin/admin.handlers.js +98 -0
- package/esm/fsm-api-ts/routes/admin/admin.index.d.ts +189 -0
- package/esm/fsm-api-ts/routes/admin/admin.index.js +11 -0
- package/esm/fsm-api-ts/routes/admin/admin.routes.d.ts +473 -0
- package/esm/fsm-api-ts/routes/admin/admin.routes.js +130 -0
- package/esm/fsm-api-ts/routes/definitions/definitions.handlers.d.ts +5 -0
- package/esm/fsm-api-ts/routes/definitions/definitions.handlers.js +29 -0
- package/esm/fsm-api-ts/routes/definitions/definitions.index.d.ts +86 -0
- package/esm/fsm-api-ts/routes/definitions/definitions.index.js +8 -0
- package/esm/fsm-api-ts/routes/definitions/definitions.routes.d.ts +204 -0
- package/esm/fsm-api-ts/routes/definitions/definitions.routes.js +56 -0
- package/esm/fsm-api-ts/routes/index.route.d.ts +19 -0
- package/esm/fsm-api-ts/routes/index.route.js +31 -0
- package/esm/fsm-api-ts/routes/instances/instances.handlers.d.ts +8 -0
- package/esm/fsm-api-ts/routes/instances/instances.handlers.js +108 -0
- package/esm/fsm-api-ts/routes/instances/instances.index.d.ts +237 -0
- package/esm/fsm-api-ts/routes/instances/instances.index.js +11 -0
- package/esm/fsm-api-ts/routes/instances/instances.routes.d.ts +411 -0
- package/esm/fsm-api-ts/routes/instances/instances.routes.js +104 -0
- package/esm/fsm-api-ts/src/cli/index.d.ts +2 -0
- package/esm/fsm-api-ts/src/cli/index.js +197 -0
- package/esm/fsm-api-ts/src/cli/invocation.node.d.ts +1 -0
- package/esm/fsm-api-ts/src/cli/invocation.node.js +4 -0
- package/esm/fsm-api-ts/src/cli/key-bootstrap.d.ts +14 -0
- package/esm/fsm-api-ts/src/cli/key-bootstrap.js +35 -0
- package/esm/fsm-api-ts/src/cli/serve.node.d.ts +6 -0
- package/esm/fsm-api-ts/src/cli/serve.node.js +20 -0
- package/esm/fsm-api-ts/src/cli/version.node.d.ts +1 -0
- package/esm/fsm-api-ts/src/cli/version.node.js +2 -0
- package/esm/fsm-api-ts/stoker-src/http-status-codes.d.ts +354 -0
- package/esm/fsm-api-ts/stoker-src/http-status-codes.js +356 -0
- package/esm/fsm-api-ts/stoker-src/http-status-phrases.d.ts +354 -0
- package/esm/fsm-api-ts/stoker-src/http-status-phrases.js +356 -0
- package/esm/fsm-api-ts/stoker-src/middlewares/index.d.ts +3 -0
- package/esm/fsm-api-ts/stoker-src/middlewares/index.js +3 -0
- package/esm/fsm-api-ts/stoker-src/middlewares/not-found.d.ts +3 -0
- package/esm/fsm-api-ts/stoker-src/middlewares/not-found.js +8 -0
- package/esm/fsm-api-ts/stoker-src/middlewares/on-error.d.ts +3 -0
- package/esm/fsm-api-ts/stoker-src/middlewares/on-error.js +19 -0
- package/esm/fsm-api-ts/stoker-src/middlewares/serve-emoji-favicon.d.ts +3 -0
- package/esm/fsm-api-ts/stoker-src/middlewares/serve-emoji-favicon.js +10 -0
- package/esm/fsm-api-ts/stoker-src/openapi/default-hook.d.ts +3 -0
- package/esm/fsm-api-ts/stoker-src/openapi/default-hook.js +11 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/index.d.ts +4 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/index.js +4 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content-one-of.d.ts +12 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content-one-of.js +14 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content-required.d.ts +11 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content-required.js +8 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content.d.ts +10 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/json-content.js +11 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/one-of.d.ts +3 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/one-of.js +13 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/types.d.ts +2 -0
- package/esm/fsm-api-ts/stoker-src/openapi/helpers/types.js +1 -0
- package/esm/fsm-api-ts/stoker-src/openapi/index.d.ts +3 -0
- package/esm/fsm-api-ts/stoker-src/openapi/index.js +3 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/create-error-schema.d.ts +56 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/create-error-schema.js +25 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/create-message-object.d.ts +9 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/create-message-object.js +11 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/id-params.d.ts +9 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/id-params.js +13 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/id-uuid-params.d.ts +9 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/id-uuid-params.js +13 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/index.d.ts +5 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/index.js +5 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/slug-params.d.ts +9 -0
- package/esm/fsm-api-ts/stoker-src/openapi/schemas/slug-params.js +18 -0
- package/esm/fsm-core-db-ts/src/database.types.d.ts +4 -0
- package/esm/fsm-core-db-ts/src/database.types.js +17 -0
- package/esm/package.json +3 -0
- package/package.json +45 -3
- package/script/_dnt.polyfills.d.ts +17 -0
- package/script/_dnt.polyfills.js +16 -0
- package/script/_dnt.shims.d.ts +5 -0
- package/script/_dnt.shims.js +65 -0
- package/script/fsm-api-ts/mod.d.ts +2 -0
- package/script/fsm-api-ts/mod.js +10 -0
- package/script/fsm-api-ts/src/cli/version.node.d.ts +1 -0
- package/script/fsm-api-ts/src/cli/version.node.js +5 -0
- package/script/package.json +3 -0
- package/README.md +0 -3
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import * as HttpStatusCodes from "../../stoker-src/http-status-codes.js";
|
|
3
|
+
import { jsonContent, jsonContentRequired, } from "../../stoker-src/openapi/helpers/index.js";
|
|
4
|
+
// Admin API (SPEC-009 §3): only mounted with --enable-admin-api, and every
|
|
5
|
+
// route needs an admin key.
|
|
6
|
+
const tags = ["admin"];
|
|
7
|
+
const messageSchema = z.object({ message: z.string() });
|
|
8
|
+
const problemsSchema = z.object({
|
|
9
|
+
message: z.string(),
|
|
10
|
+
problems: z.array(z.string()),
|
|
11
|
+
});
|
|
12
|
+
const apiKeyRoleSchema = z.enum(["fsm_admin", "fsm_operator"]);
|
|
13
|
+
export const loadDefinitions = createRoute({
|
|
14
|
+
path: "/admin/definitions",
|
|
15
|
+
method: "post",
|
|
16
|
+
tags,
|
|
17
|
+
request: {
|
|
18
|
+
body: jsonContentRequired(z.object({
|
|
19
|
+
definitions: z.array(z.object({
|
|
20
|
+
fsmName: z.string().min(1),
|
|
21
|
+
fsmVersion: z.string().min(1),
|
|
22
|
+
fsmJson: z.record(z.unknown()),
|
|
23
|
+
})).min(1),
|
|
24
|
+
}), "FSM definitions to load in one transaction (SPEC-006): the same batch `pgfsmctl fsm load` builds from <folder>/<fsmName>/<vNN>/fsm.json"),
|
|
25
|
+
},
|
|
26
|
+
responses: {
|
|
27
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({
|
|
28
|
+
data: z.array(z.object({
|
|
29
|
+
fsmName: z.string(),
|
|
30
|
+
fsmVersion: z.string(),
|
|
31
|
+
status: z.enum(["loaded", "unchanged"]),
|
|
32
|
+
})),
|
|
33
|
+
}), "Every definition loaded (or already loaded with identical content)"),
|
|
34
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(problemsSchema, "The batch was rejected; nothing was written"),
|
|
35
|
+
[HttpStatusCodes.FORBIDDEN]: jsonContent(problemsSchema, "The database denied the load (the request's role lacks the grant)"),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export const listKeys = createRoute({
|
|
39
|
+
path: "/admin/keys",
|
|
40
|
+
method: "get",
|
|
41
|
+
tags,
|
|
42
|
+
responses: {
|
|
43
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({
|
|
44
|
+
data: z.array(z.object({
|
|
45
|
+
id: z.string(),
|
|
46
|
+
name: z.string(),
|
|
47
|
+
role: apiKeyRoleSchema,
|
|
48
|
+
prefix: z.string(),
|
|
49
|
+
created_at: z.string(),
|
|
50
|
+
last_used_at: z.string().nullable(),
|
|
51
|
+
revoked_at: z.string().nullable(),
|
|
52
|
+
})),
|
|
53
|
+
}), "Every API key, newest first, without hashes"),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
export const createKey = createRoute({
|
|
57
|
+
path: "/admin/keys",
|
|
58
|
+
method: "post",
|
|
59
|
+
tags,
|
|
60
|
+
request: {
|
|
61
|
+
body: jsonContentRequired(z.object({
|
|
62
|
+
name: z.string().min(1),
|
|
63
|
+
role: apiKeyRoleSchema,
|
|
64
|
+
}), "Name and role of the new key"),
|
|
65
|
+
},
|
|
66
|
+
responses: {
|
|
67
|
+
[HttpStatusCodes.CREATED]: jsonContent(z.object({
|
|
68
|
+
data: z.object({
|
|
69
|
+
id: z.string(),
|
|
70
|
+
name: z.string(),
|
|
71
|
+
role: apiKeyRoleSchema,
|
|
72
|
+
prefix: z.string(),
|
|
73
|
+
key: z.string().describe("The only copy of the key; store it now"),
|
|
74
|
+
}),
|
|
75
|
+
}), "Key created"),
|
|
76
|
+
[HttpStatusCodes.CONFLICT]: jsonContent(messageSchema, "A key with that name exists"),
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
export const revokeKey = createRoute({
|
|
80
|
+
path: "/admin/keys/{idOrName}",
|
|
81
|
+
method: "delete",
|
|
82
|
+
tags,
|
|
83
|
+
request: {
|
|
84
|
+
params: z.object({ idOrName: z.string().min(1) }),
|
|
85
|
+
},
|
|
86
|
+
responses: {
|
|
87
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({ data: z.object({ revoked: z.literal(true) }) }), "Key revoked"),
|
|
88
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(messageSchema, "No live key with that id or name"),
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
// The fsm_schedule_all_pending pg_cron job (SPEC-016): the install registers
|
|
92
|
+
// it; these report it and (re)register it through SECURITY DEFINER functions
|
|
93
|
+
// granted to fsm_admin, so the API never logs in as the schema owner.
|
|
94
|
+
const schedulerJobSchema = z.object({
|
|
95
|
+
jobname: z.string(),
|
|
96
|
+
registered: z.boolean(),
|
|
97
|
+
jobid: z.number().optional(),
|
|
98
|
+
schedule: z.string().optional(),
|
|
99
|
+
command: z.string().optional(),
|
|
100
|
+
active: z.boolean().optional(),
|
|
101
|
+
});
|
|
102
|
+
export const getScheduler = createRoute({
|
|
103
|
+
path: "/admin/scheduler",
|
|
104
|
+
method: "get",
|
|
105
|
+
tags,
|
|
106
|
+
responses: {
|
|
107
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({ data: schedulerJobSchema }), "The scheduler's pg_cron job, or registered: false when there's none"),
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
export const registerScheduler = createRoute({
|
|
111
|
+
path: "/admin/scheduler",
|
|
112
|
+
method: "post",
|
|
113
|
+
tags,
|
|
114
|
+
request: {
|
|
115
|
+
body: {
|
|
116
|
+
content: {
|
|
117
|
+
"application/json": {
|
|
118
|
+
schema: z.object({
|
|
119
|
+
schedule: z.string().min(1).optional().describe("pg_cron schedule, e.g. '10 seconds' or '*/1 * * * *' (default '5 seconds')"),
|
|
120
|
+
}),
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
required: false,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
responses: {
|
|
127
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({ data: schedulerJobSchema }), "The job, registered (replacing any existing one)"),
|
|
128
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(messageSchema, "pg_cron rejected the schedule"),
|
|
129
|
+
},
|
|
130
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AppRouteHandler } from "../../lib/types.js";
|
|
2
|
+
import type { GetOneRoute, ListRoute, VersionsRoute } from "./definitions.routes.js";
|
|
3
|
+
export declare const list: AppRouteHandler<ListRoute>;
|
|
4
|
+
export declare const versions: AppRouteHandler<VersionsRoute>;
|
|
5
|
+
export declare const getOne: AppRouteHandler<GetOneRoute>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as HttpStatusCodes from "../../stoker-src/http-status-codes.js";
|
|
2
|
+
import { getFsmDefinition, listFsmDefinitions } from "@pgfsm/db";
|
|
3
|
+
export const list = async (c) => {
|
|
4
|
+
const deps = { db: c.get("db"), useSupabase: false };
|
|
5
|
+
const q = c.req.valid("query");
|
|
6
|
+
const data = await listFsmDefinitions(deps, {
|
|
7
|
+
fsmName: q.fsm_name,
|
|
8
|
+
fsmVersion: q.fsm_version,
|
|
9
|
+
});
|
|
10
|
+
return c.json({ data }, HttpStatusCodes.OK);
|
|
11
|
+
};
|
|
12
|
+
export const versions = async (c) => {
|
|
13
|
+
const deps = { db: c.get("db"), useSupabase: false };
|
|
14
|
+
const { fsmName } = c.req.valid("param");
|
|
15
|
+
const data = await listFsmDefinitions(deps, { fsmName });
|
|
16
|
+
if (data.length === 0) {
|
|
17
|
+
return c.json({ message: `No version of FSM ${fsmName} is loaded` }, HttpStatusCodes.NOT_FOUND);
|
|
18
|
+
}
|
|
19
|
+
return c.json({ data }, HttpStatusCodes.OK);
|
|
20
|
+
};
|
|
21
|
+
export const getOne = async (c) => {
|
|
22
|
+
const deps = { db: c.get("db"), useSupabase: false };
|
|
23
|
+
const { fsmName, fsmVersion } = c.req.valid("param");
|
|
24
|
+
const row = await getFsmDefinition(deps, fsmName, fsmVersion);
|
|
25
|
+
if (!row) {
|
|
26
|
+
return c.json({ message: `FSM ${fsmName}/${fsmVersion} isn't loaded` }, HttpStatusCodes.NOT_FOUND);
|
|
27
|
+
}
|
|
28
|
+
return c.json({ data: row }, HttpStatusCodes.OK);
|
|
29
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../lib/types.js").AppBindings, {
|
|
2
|
+
"/definitions": {
|
|
3
|
+
$get: {
|
|
4
|
+
input: {
|
|
5
|
+
query: {
|
|
6
|
+
fsm_name?: string | undefined;
|
|
7
|
+
fsm_version?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
output: {
|
|
11
|
+
data: {
|
|
12
|
+
fsm_name: string;
|
|
13
|
+
fsm_version: string;
|
|
14
|
+
fsm_type: string | null;
|
|
15
|
+
fsm_json_sha256: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
outputFormat: "json";
|
|
19
|
+
status: 200;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
} & {
|
|
23
|
+
"/definitions/:fsmName": {
|
|
24
|
+
$get: {
|
|
25
|
+
input: {
|
|
26
|
+
param: {
|
|
27
|
+
fsmName: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
output: {
|
|
31
|
+
message: string;
|
|
32
|
+
};
|
|
33
|
+
outputFormat: "json";
|
|
34
|
+
status: 404;
|
|
35
|
+
} | {
|
|
36
|
+
input: {
|
|
37
|
+
param: {
|
|
38
|
+
fsmName: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
output: {
|
|
42
|
+
data: {
|
|
43
|
+
fsm_name: string;
|
|
44
|
+
fsm_version: string;
|
|
45
|
+
fsm_type: string | null;
|
|
46
|
+
fsm_json_sha256: string;
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
outputFormat: "json";
|
|
50
|
+
status: 200;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
} & {
|
|
54
|
+
"/definitions/:fsmName/versions/:fsmVersion": {
|
|
55
|
+
$get: {
|
|
56
|
+
input: {
|
|
57
|
+
param: {
|
|
58
|
+
fsmName: string;
|
|
59
|
+
fsmVersion: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
output: {
|
|
63
|
+
message: string;
|
|
64
|
+
};
|
|
65
|
+
outputFormat: "json";
|
|
66
|
+
status: 404;
|
|
67
|
+
} | {
|
|
68
|
+
input: {
|
|
69
|
+
param: {
|
|
70
|
+
fsmName: string;
|
|
71
|
+
fsmVersion: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
output: {
|
|
75
|
+
data: {
|
|
76
|
+
fsm_name: string;
|
|
77
|
+
fsm_version: string;
|
|
78
|
+
fsm_json?: import("hono/utils/types").JSONValue | undefined;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
outputFormat: "json";
|
|
82
|
+
status: 200;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}, "/">;
|
|
86
|
+
export default router;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRouter } from "../../lib/create-router.js";
|
|
2
|
+
import * as handlers from "./definitions.handlers.js";
|
|
3
|
+
import * as routes from "./definitions.routes.js";
|
|
4
|
+
const router = createRouter()
|
|
5
|
+
.openapi(routes.list, handlers.list)
|
|
6
|
+
.openapi(routes.versions, handlers.versions)
|
|
7
|
+
.openapi(routes.getOne, handlers.getOne);
|
|
8
|
+
export default router;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
export declare const list: {
|
|
3
|
+
path: "/definitions";
|
|
4
|
+
method: "get";
|
|
5
|
+
request: {
|
|
6
|
+
query: z.ZodObject<{
|
|
7
|
+
fsm_name: z.ZodOptional<z.ZodString>;
|
|
8
|
+
fsm_version: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
fsm_name?: string | undefined;
|
|
11
|
+
fsm_version?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
fsm_name?: string | undefined;
|
|
14
|
+
fsm_version?: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
tags: string[];
|
|
18
|
+
responses: {
|
|
19
|
+
200: {
|
|
20
|
+
content: {
|
|
21
|
+
"application/json": {
|
|
22
|
+
schema: z.ZodObject<{
|
|
23
|
+
data: z.ZodArray<z.ZodObject<{
|
|
24
|
+
fsm_name: z.ZodString;
|
|
25
|
+
fsm_version: z.ZodString;
|
|
26
|
+
fsm_type: z.ZodNullable<z.ZodString>;
|
|
27
|
+
fsm_json_sha256: z.ZodString;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
fsm_name: string;
|
|
30
|
+
fsm_version: string;
|
|
31
|
+
fsm_type: string | null;
|
|
32
|
+
fsm_json_sha256: string;
|
|
33
|
+
}, {
|
|
34
|
+
fsm_name: string;
|
|
35
|
+
fsm_version: string;
|
|
36
|
+
fsm_type: string | null;
|
|
37
|
+
fsm_json_sha256: string;
|
|
38
|
+
}>, "many">;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
data: {
|
|
41
|
+
fsm_name: string;
|
|
42
|
+
fsm_version: string;
|
|
43
|
+
fsm_type: string | null;
|
|
44
|
+
fsm_json_sha256: string;
|
|
45
|
+
}[];
|
|
46
|
+
}, {
|
|
47
|
+
data: {
|
|
48
|
+
fsm_name: string;
|
|
49
|
+
fsm_version: string;
|
|
50
|
+
fsm_type: string | null;
|
|
51
|
+
fsm_json_sha256: string;
|
|
52
|
+
}[];
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
} & {
|
|
60
|
+
getRoutingPath(): "/definitions";
|
|
61
|
+
};
|
|
62
|
+
export declare const versions: {
|
|
63
|
+
path: "/definitions/{fsmName}";
|
|
64
|
+
method: "get";
|
|
65
|
+
request: {
|
|
66
|
+
params: z.ZodObject<{
|
|
67
|
+
fsmName: z.ZodString;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
fsmName: string;
|
|
70
|
+
}, {
|
|
71
|
+
fsmName: string;
|
|
72
|
+
}>;
|
|
73
|
+
};
|
|
74
|
+
tags: string[];
|
|
75
|
+
responses: {
|
|
76
|
+
200: {
|
|
77
|
+
content: {
|
|
78
|
+
"application/json": {
|
|
79
|
+
schema: z.ZodObject<{
|
|
80
|
+
data: z.ZodArray<z.ZodObject<{
|
|
81
|
+
fsm_name: z.ZodString;
|
|
82
|
+
fsm_version: z.ZodString;
|
|
83
|
+
fsm_type: z.ZodNullable<z.ZodString>;
|
|
84
|
+
fsm_json_sha256: z.ZodString;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
fsm_name: string;
|
|
87
|
+
fsm_version: string;
|
|
88
|
+
fsm_type: string | null;
|
|
89
|
+
fsm_json_sha256: string;
|
|
90
|
+
}, {
|
|
91
|
+
fsm_name: string;
|
|
92
|
+
fsm_version: string;
|
|
93
|
+
fsm_type: string | null;
|
|
94
|
+
fsm_json_sha256: string;
|
|
95
|
+
}>, "many">;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
data: {
|
|
98
|
+
fsm_name: string;
|
|
99
|
+
fsm_version: string;
|
|
100
|
+
fsm_type: string | null;
|
|
101
|
+
fsm_json_sha256: string;
|
|
102
|
+
}[];
|
|
103
|
+
}, {
|
|
104
|
+
data: {
|
|
105
|
+
fsm_name: string;
|
|
106
|
+
fsm_version: string;
|
|
107
|
+
fsm_type: string | null;
|
|
108
|
+
fsm_json_sha256: string;
|
|
109
|
+
}[];
|
|
110
|
+
}>;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
description: string;
|
|
114
|
+
};
|
|
115
|
+
404: {
|
|
116
|
+
content: {
|
|
117
|
+
"application/json": {
|
|
118
|
+
schema: z.ZodObject<{
|
|
119
|
+
message: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
message: string;
|
|
122
|
+
}, {
|
|
123
|
+
message: string;
|
|
124
|
+
}>;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
description: string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
} & {
|
|
131
|
+
getRoutingPath(): "/definitions/:fsmName";
|
|
132
|
+
};
|
|
133
|
+
export declare const getOne: {
|
|
134
|
+
path: "/definitions/{fsmName}/versions/{fsmVersion}";
|
|
135
|
+
method: "get";
|
|
136
|
+
request: {
|
|
137
|
+
params: z.ZodObject<{
|
|
138
|
+
fsmName: z.ZodString;
|
|
139
|
+
fsmVersion: z.ZodString;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
fsmName: string;
|
|
142
|
+
fsmVersion: string;
|
|
143
|
+
}, {
|
|
144
|
+
fsmName: string;
|
|
145
|
+
fsmVersion: string;
|
|
146
|
+
}>;
|
|
147
|
+
};
|
|
148
|
+
tags: string[];
|
|
149
|
+
responses: {
|
|
150
|
+
200: {
|
|
151
|
+
content: {
|
|
152
|
+
"application/json": {
|
|
153
|
+
schema: z.ZodObject<{
|
|
154
|
+
data: z.ZodObject<{
|
|
155
|
+
fsm_name: z.ZodString;
|
|
156
|
+
fsm_version: z.ZodString;
|
|
157
|
+
fsm_json: z.ZodUnknown;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
fsm_name: string;
|
|
160
|
+
fsm_version: string;
|
|
161
|
+
fsm_json?: unknown;
|
|
162
|
+
}, {
|
|
163
|
+
fsm_name: string;
|
|
164
|
+
fsm_version: string;
|
|
165
|
+
fsm_json?: unknown;
|
|
166
|
+
}>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
data: {
|
|
169
|
+
fsm_name: string;
|
|
170
|
+
fsm_version: string;
|
|
171
|
+
fsm_json?: unknown;
|
|
172
|
+
};
|
|
173
|
+
}, {
|
|
174
|
+
data: {
|
|
175
|
+
fsm_name: string;
|
|
176
|
+
fsm_version: string;
|
|
177
|
+
fsm_json?: unknown;
|
|
178
|
+
};
|
|
179
|
+
}>;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
description: string;
|
|
183
|
+
};
|
|
184
|
+
404: {
|
|
185
|
+
content: {
|
|
186
|
+
"application/json": {
|
|
187
|
+
schema: z.ZodObject<{
|
|
188
|
+
message: z.ZodString;
|
|
189
|
+
}, "strip", z.ZodTypeAny, {
|
|
190
|
+
message: string;
|
|
191
|
+
}, {
|
|
192
|
+
message: string;
|
|
193
|
+
}>;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
description: string;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
} & {
|
|
200
|
+
getRoutingPath(): "/definitions/:fsmName/versions/:fsmVersion";
|
|
201
|
+
};
|
|
202
|
+
export type ListRoute = typeof list;
|
|
203
|
+
export type VersionsRoute = typeof versions;
|
|
204
|
+
export type GetOneRoute = typeof getOne;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import * as HttpStatusCodes from "../../stoker-src/http-status-codes.js";
|
|
3
|
+
import { jsonContent } from "../../stoker-src/openapi/helpers/index.js";
|
|
4
|
+
import { notFoundSchema } from "../../lib/constants.js";
|
|
5
|
+
// Loaded FSM definitions (fsm_core.fsm_json), read-only, for `pgfsmctl fsm
|
|
6
|
+
// list|get` with an operator key (#661). Loading them is POST
|
|
7
|
+
// /admin/fsm/load, admin only.
|
|
8
|
+
const tags = ["definitions"];
|
|
9
|
+
const summary = z.object({
|
|
10
|
+
fsm_name: z.string(),
|
|
11
|
+
fsm_version: z.string(),
|
|
12
|
+
fsm_type: z.string().nullable(),
|
|
13
|
+
fsm_json_sha256: z.string(),
|
|
14
|
+
});
|
|
15
|
+
export const list = createRoute({
|
|
16
|
+
path: "/definitions",
|
|
17
|
+
method: "get",
|
|
18
|
+
request: {
|
|
19
|
+
query: z.object({
|
|
20
|
+
fsm_name: z.string().optional().describe("Only this FSM"),
|
|
21
|
+
fsm_version: z.string().optional().describe("Only this version"),
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
tags,
|
|
25
|
+
responses: {
|
|
26
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({ data: z.array(summary) }), "Loaded definitions, by name then version"),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export const versions = createRoute({
|
|
30
|
+
path: "/definitions/{fsmName}",
|
|
31
|
+
method: "get",
|
|
32
|
+
request: { params: z.object({ fsmName: z.string() }) },
|
|
33
|
+
tags,
|
|
34
|
+
responses: {
|
|
35
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({ data: z.array(summary) }), "The FSM's loaded versions"),
|
|
36
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "No version of that FSM is loaded"),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
export const getOne = createRoute({
|
|
40
|
+
path: "/definitions/{fsmName}/versions/{fsmVersion}",
|
|
41
|
+
method: "get",
|
|
42
|
+
request: {
|
|
43
|
+
params: z.object({ fsmName: z.string(), fsmVersion: z.string() }),
|
|
44
|
+
},
|
|
45
|
+
tags,
|
|
46
|
+
responses: {
|
|
47
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({
|
|
48
|
+
data: z.object({
|
|
49
|
+
fsm_name: z.string(),
|
|
50
|
+
fsm_version: z.string(),
|
|
51
|
+
fsm_json: z.unknown(),
|
|
52
|
+
}),
|
|
53
|
+
}), "One loaded definition and its fsm.json"),
|
|
54
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "That FSM version isn't loaded"),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type LicenseNotice } from "../lib/license.js";
|
|
2
|
+
/**
|
|
3
|
+
* GET /: the API index, unauthenticated, and the readiness probe. It also
|
|
4
|
+
* reports the API's licence and where its source is (SPEC-017, AGPL-3.0 §13).
|
|
5
|
+
*/
|
|
6
|
+
export declare function createIndexRouter(notice?: LicenseNotice): import("@hono/zod-openapi").OpenAPIHono<import("../lib/types.js").AppBindings, {
|
|
7
|
+
"/": {
|
|
8
|
+
$get: {
|
|
9
|
+
input: {};
|
|
10
|
+
output: {
|
|
11
|
+
message: string;
|
|
12
|
+
license: string;
|
|
13
|
+
source: string;
|
|
14
|
+
};
|
|
15
|
+
outputFormat: "json";
|
|
16
|
+
status: 200;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}, "/">;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import * as HttpStatusCodes from "../stoker-src/http-status-codes.js";
|
|
3
|
+
import { jsonContent } from "../stoker-src/openapi/helpers/index.js";
|
|
4
|
+
import { createRouter } from "../lib/create-router.js";
|
|
5
|
+
import { licenseNotice } from "../lib/license.js";
|
|
6
|
+
const IndexSchema = z.object({
|
|
7
|
+
message: z.string().openapi({ example: "pgfsm API" }),
|
|
8
|
+
license: z.string().openapi({ example: "AGPL-3.0-only" }),
|
|
9
|
+
source: z.string().url().openapi({ example: "https://github.com/pgfsm/fsm" }),
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* GET /: the API index, unauthenticated, and the readiness probe. It also
|
|
13
|
+
* reports the API's licence and where its source is (SPEC-017, AGPL-3.0 §13).
|
|
14
|
+
*/
|
|
15
|
+
export function createIndexRouter(notice = licenseNotice()) {
|
|
16
|
+
return createRouter()
|
|
17
|
+
.openapi(createRoute({
|
|
18
|
+
tags: ["Index"],
|
|
19
|
+
method: "get",
|
|
20
|
+
path: "/",
|
|
21
|
+
responses: {
|
|
22
|
+
[HttpStatusCodes.OK]: jsonContent(IndexSchema, "pgfsm API index (unauthenticated; also the readiness probe), with the API's licence and source URL"),
|
|
23
|
+
},
|
|
24
|
+
}), (c) => {
|
|
25
|
+
return c.json({
|
|
26
|
+
message: "pgfsm API",
|
|
27
|
+
license: notice.license,
|
|
28
|
+
source: notice.source,
|
|
29
|
+
}, HttpStatusCodes.OK);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppRouteHandler } from "../../lib/types.js";
|
|
2
|
+
import type { CreateRoute, GetOneRoute, ListRoute, ResumeRoute, SendEventRoute, StopRoute } from "./instances.routes.js";
|
|
3
|
+
export declare const list: AppRouteHandler<ListRoute>;
|
|
4
|
+
export declare const getOne: AppRouteHandler<GetOneRoute>;
|
|
5
|
+
export declare const create: AppRouteHandler<CreateRoute>;
|
|
6
|
+
export declare const sendEvent: AppRouteHandler<SendEventRoute>;
|
|
7
|
+
export declare const resume: AppRouteHandler<ResumeRoute>;
|
|
8
|
+
export declare const stop: AppRouteHandler<StopRoute>;
|