@syra.fm/contracts 0.0.0-stage → 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/index.d.ts +152 -0
- package/dist/index.js +78 -0
- package/package.json +17 -4
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Opaque handles; the bound also limits request and log sizes. */
|
|
3
|
+
export declare const podcastIdSchema: z.ZodString;
|
|
4
|
+
export declare const publicPodcastCardsRequestSchema: z.ZodObject<{
|
|
5
|
+
ids: z.ZodArray<z.ZodString>;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export declare const publicPodcastCardSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
title: z.ZodString;
|
|
10
|
+
author: z.ZodOptional<z.ZodString>;
|
|
11
|
+
artworkUrl: z.ZodOptional<z.ZodURL>;
|
|
12
|
+
showUrl: z.ZodURL;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const publicPodcastCardsResponseSchema: z.ZodObject<{
|
|
15
|
+
items: z.ZodArray<z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
title: z.ZodString;
|
|
18
|
+
author: z.ZodOptional<z.ZodString>;
|
|
19
|
+
artworkUrl: z.ZodOptional<z.ZodURL>;
|
|
20
|
+
showUrl: z.ZodURL;
|
|
21
|
+
}, z.core.$strict>>;
|
|
22
|
+
unavailableIds: z.ZodArray<z.ZodString>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export declare const publicApiErrorSchema: z.ZodObject<{
|
|
25
|
+
error: z.ZodObject<{
|
|
26
|
+
code: z.ZodEnum<{
|
|
27
|
+
bad_request: "bad_request";
|
|
28
|
+
validation_failed: "validation_failed";
|
|
29
|
+
rate_limited: "rate_limited";
|
|
30
|
+
internal_error: "internal_error";
|
|
31
|
+
service_unavailable: "service_unavailable";
|
|
32
|
+
}>;
|
|
33
|
+
message: z.ZodString;
|
|
34
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export type PublicPodcastCard = z.infer<typeof publicPodcastCardSchema>;
|
|
38
|
+
export type PublicPodcastCardsResponse = z.infer<typeof publicPodcastCardsResponseSchema>;
|
|
39
|
+
export type PublicApiErrorCode = z.infer<typeof publicApiErrorSchema>['error']['code'];
|
|
40
|
+
export declare const publicRoutes: readonly [{
|
|
41
|
+
readonly method: "post";
|
|
42
|
+
readonly path: "/api/podcasts/public-cards";
|
|
43
|
+
readonly request: z.ZodObject<{
|
|
44
|
+
ids: z.ZodArray<z.ZodString>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
readonly responses: {
|
|
47
|
+
readonly 200: z.ZodObject<{
|
|
48
|
+
items: z.ZodArray<z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
title: z.ZodString;
|
|
51
|
+
author: z.ZodOptional<z.ZodString>;
|
|
52
|
+
artworkUrl: z.ZodOptional<z.ZodURL>;
|
|
53
|
+
showUrl: z.ZodURL;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
unavailableIds: z.ZodArray<z.ZodString>;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
readonly 400: z.ZodObject<{
|
|
58
|
+
error: z.ZodObject<{
|
|
59
|
+
code: z.ZodEnum<{
|
|
60
|
+
bad_request: "bad_request";
|
|
61
|
+
validation_failed: "validation_failed";
|
|
62
|
+
rate_limited: "rate_limited";
|
|
63
|
+
internal_error: "internal_error";
|
|
64
|
+
service_unavailable: "service_unavailable";
|
|
65
|
+
}>;
|
|
66
|
+
message: z.ZodString;
|
|
67
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
readonly 429: z.ZodObject<{
|
|
71
|
+
error: z.ZodObject<{
|
|
72
|
+
code: z.ZodEnum<{
|
|
73
|
+
bad_request: "bad_request";
|
|
74
|
+
validation_failed: "validation_failed";
|
|
75
|
+
rate_limited: "rate_limited";
|
|
76
|
+
internal_error: "internal_error";
|
|
77
|
+
service_unavailable: "service_unavailable";
|
|
78
|
+
}>;
|
|
79
|
+
message: z.ZodString;
|
|
80
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
81
|
+
}, z.core.$strict>;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
readonly 500: z.ZodObject<{
|
|
84
|
+
error: z.ZodObject<{
|
|
85
|
+
code: z.ZodEnum<{
|
|
86
|
+
bad_request: "bad_request";
|
|
87
|
+
validation_failed: "validation_failed";
|
|
88
|
+
rate_limited: "rate_limited";
|
|
89
|
+
internal_error: "internal_error";
|
|
90
|
+
service_unavailable: "service_unavailable";
|
|
91
|
+
}>;
|
|
92
|
+
message: z.ZodString;
|
|
93
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
94
|
+
}, z.core.$strict>;
|
|
95
|
+
}, z.core.$strict>;
|
|
96
|
+
};
|
|
97
|
+
}];
|
|
98
|
+
export declare function publicOpenApi(): {
|
|
99
|
+
openapi: string;
|
|
100
|
+
info: {
|
|
101
|
+
title: string;
|
|
102
|
+
version: string;
|
|
103
|
+
};
|
|
104
|
+
paths: {
|
|
105
|
+
[k: string]: {
|
|
106
|
+
post: {
|
|
107
|
+
description: string;
|
|
108
|
+
requestBody: {
|
|
109
|
+
required: boolean;
|
|
110
|
+
content: {
|
|
111
|
+
'application/json': {
|
|
112
|
+
schema: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
113
|
+
ids: z.ZodArray<z.ZodString>;
|
|
114
|
+
}, z.core.$strict>>;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
responses: {
|
|
119
|
+
[k: string]: {
|
|
120
|
+
description: string;
|
|
121
|
+
content: {
|
|
122
|
+
'application/json': {
|
|
123
|
+
schema: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
124
|
+
items: z.ZodArray<z.ZodObject<{
|
|
125
|
+
id: z.ZodString;
|
|
126
|
+
title: z.ZodString;
|
|
127
|
+
author: z.ZodOptional<z.ZodString>;
|
|
128
|
+
artworkUrl: z.ZodOptional<z.ZodURL>;
|
|
129
|
+
showUrl: z.ZodURL;
|
|
130
|
+
}, z.core.$strict>>;
|
|
131
|
+
unavailableIds: z.ZodArray<z.ZodString>;
|
|
132
|
+
}, z.core.$strict> | z.ZodObject<{
|
|
133
|
+
error: z.ZodObject<{
|
|
134
|
+
code: z.ZodEnum<{
|
|
135
|
+
bad_request: "bad_request";
|
|
136
|
+
validation_failed: "validation_failed";
|
|
137
|
+
rate_limited: "rate_limited";
|
|
138
|
+
internal_error: "internal_error";
|
|
139
|
+
service_unavailable: "service_unavailable";
|
|
140
|
+
}>;
|
|
141
|
+
message: z.ZodString;
|
|
142
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
143
|
+
}, z.core.$strict>;
|
|
144
|
+
}, z.core.$strict>>;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publicRoutes = exports.publicApiErrorSchema = exports.publicPodcastCardsResponseSchema = exports.publicPodcastCardSchema = exports.publicPodcastCardsRequestSchema = exports.podcastIdSchema = void 0;
|
|
4
|
+
exports.publicOpenApi = publicOpenApi;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
/** Opaque handles; the bound also limits request and log sizes. */
|
|
7
|
+
exports.podcastIdSchema = zod_1.z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.max(256)
|
|
11
|
+
.refine((id) => id.trim() === id);
|
|
12
|
+
exports.publicPodcastCardsRequestSchema = zod_1.z.strictObject({
|
|
13
|
+
ids: zod_1.z.array(exports.podcastIdSchema).min(1).max(100),
|
|
14
|
+
});
|
|
15
|
+
exports.publicPodcastCardSchema = zod_1.z.strictObject({
|
|
16
|
+
id: exports.podcastIdSchema,
|
|
17
|
+
title: zod_1.z.string(),
|
|
18
|
+
author: zod_1.z.string().optional(),
|
|
19
|
+
artworkUrl: zod_1.z.url().optional(),
|
|
20
|
+
showUrl: zod_1.z.url(),
|
|
21
|
+
});
|
|
22
|
+
exports.publicPodcastCardsResponseSchema = zod_1.z.strictObject({
|
|
23
|
+
items: zod_1.z.array(exports.publicPodcastCardSchema).max(100),
|
|
24
|
+
unavailableIds: zod_1.z.array(exports.podcastIdSchema).max(100),
|
|
25
|
+
});
|
|
26
|
+
exports.publicApiErrorSchema = zod_1.z.strictObject({
|
|
27
|
+
error: zod_1.z.strictObject({
|
|
28
|
+
code: zod_1.z.enum([
|
|
29
|
+
'bad_request',
|
|
30
|
+
'validation_failed',
|
|
31
|
+
'rate_limited',
|
|
32
|
+
'internal_error',
|
|
33
|
+
'service_unavailable',
|
|
34
|
+
]),
|
|
35
|
+
message: zod_1.z.string(),
|
|
36
|
+
details: zod_1.z
|
|
37
|
+
.record(zod_1.z.string(), zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]))
|
|
38
|
+
.optional(),
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
exports.publicRoutes = [
|
|
42
|
+
{
|
|
43
|
+
method: 'post',
|
|
44
|
+
path: '/api/podcasts/public-cards',
|
|
45
|
+
request: exports.publicPodcastCardsRequestSchema,
|
|
46
|
+
responses: {
|
|
47
|
+
200: exports.publicPodcastCardsResponseSchema,
|
|
48
|
+
400: exports.publicApiErrorSchema,
|
|
49
|
+
429: exports.publicApiErrorSchema,
|
|
50
|
+
500: exports.publicApiErrorSchema,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
function publicOpenApi() {
|
|
55
|
+
return {
|
|
56
|
+
openapi: '3.1.0',
|
|
57
|
+
info: { title: 'Syra public reference cards', version: '0.1.0' },
|
|
58
|
+
paths: Object.fromEntries(exports.publicRoutes.map((route) => [
|
|
59
|
+
route.path,
|
|
60
|
+
{
|
|
61
|
+
[route.method]: {
|
|
62
|
+
description: 'Current active public shows, independent of caller identity. Maximum 100 opaque IDs; duplicates are deduplicated. Missing, private, unlisted and withdrawn shows are unavailable. No content is cached.',
|
|
63
|
+
requestBody: {
|
|
64
|
+
required: true,
|
|
65
|
+
content: { 'application/json': { schema: zod_1.z.toJSONSchema(route.request) } },
|
|
66
|
+
},
|
|
67
|
+
responses: Object.fromEntries(Object.entries(route.responses).map(([status, schema]) => [
|
|
68
|
+
status,
|
|
69
|
+
{
|
|
70
|
+
description: status === '200' ? 'Current public cards' : 'Error',
|
|
71
|
+
content: { 'application/json': { schema: zod_1.z.toJSONSchema(schema) } },
|
|
72
|
+
},
|
|
73
|
+
])),
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
])),
|
|
77
|
+
};
|
|
78
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syra.fm/contracts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.json",
|
|
11
|
+
"test": "bun test src"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"zod": "^4.4.3"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "~5.9.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/README.md
DELETED