@portalshq/channel-registry 0.1.0 → 0.2.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 +31 -2
- package/dist/index.js +8 -2
- package/package.json +34 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
declare const channel: z.ZodObject<{
|
|
3
|
-
controlEndpoint: z.ZodString
|
|
3
|
+
controlEndpoint: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
4
4
|
queueTokenEnv: z.ZodString;
|
|
5
5
|
requiredEntities: z.ZodArray<z.ZodString>;
|
|
6
|
+
interactions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
6
7
|
youtube: z.ZodOptional<z.ZodObject<{
|
|
7
8
|
liveChatId: z.ZodString;
|
|
8
9
|
clientIdEnv: z.ZodString;
|
|
@@ -19,9 +20,10 @@ declare const channel: z.ZodObject<{
|
|
|
19
20
|
}, z.core.$strip>;
|
|
20
21
|
declare const registrySchema: z.ZodObject<{
|
|
21
22
|
channels: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
22
|
-
controlEndpoint: z.ZodString
|
|
23
|
+
controlEndpoint: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
23
24
|
queueTokenEnv: z.ZodString;
|
|
24
25
|
requiredEntities: z.ZodArray<z.ZodString>;
|
|
26
|
+
interactions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
25
27
|
youtube: z.ZodOptional<z.ZodObject<{
|
|
26
28
|
liveChatId: z.ZodString;
|
|
27
29
|
clientIdEnv: z.ZodString;
|
|
@@ -41,6 +43,33 @@ declare const registrySchema: z.ZodObject<{
|
|
|
41
43
|
}, z.core.$loose>>>;
|
|
42
44
|
entitiesFetchedAt: z.ZodOptional<z.ZodString>;
|
|
43
45
|
}, z.core.$strip>;
|
|
46
|
+
/** Validate without refreshing manifests or writing the registry. */
|
|
47
|
+
export declare function parseChannelRegistry(value: unknown): {
|
|
48
|
+
channels: Record<string, {
|
|
49
|
+
controlEndpoint: string;
|
|
50
|
+
queueTokenEnv: string;
|
|
51
|
+
requiredEntities: string[];
|
|
52
|
+
interactions?: Record<string, unknown> | undefined;
|
|
53
|
+
youtube?: {
|
|
54
|
+
liveChatId: string;
|
|
55
|
+
clientIdEnv: string;
|
|
56
|
+
clientSecretEnv: string;
|
|
57
|
+
refreshTokenEnv: string;
|
|
58
|
+
} | undefined;
|
|
59
|
+
twitch?: {
|
|
60
|
+
broadcasterUserId: string;
|
|
61
|
+
userId: string;
|
|
62
|
+
clientIdEnv: string;
|
|
63
|
+
clientSecretEnv: string;
|
|
64
|
+
refreshTokenEnv: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
}>;
|
|
67
|
+
entities: Record<string, {
|
|
68
|
+
[x: string]: unknown;
|
|
69
|
+
id: string;
|
|
70
|
+
}>;
|
|
71
|
+
entitiesFetchedAt?: string | undefined;
|
|
72
|
+
};
|
|
44
73
|
export type Channel = z.infer<typeof channel>;
|
|
45
74
|
export type EntityManifest = {
|
|
46
75
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,11 @@ import { z } from "zod";
|
|
|
4
4
|
const secretRef = z.string().regex(/^[A-Z][A-Z0-9_]*$/);
|
|
5
5
|
const entityUri = z.string().regex(/^px:\/\/[\w.-]+\/[\w.-]+\/[\w.-]+$/);
|
|
6
6
|
const channel = z.object({
|
|
7
|
-
controlEndpoint: z.string().url(),
|
|
7
|
+
controlEndpoint: z.union([z.string().url(), z.string().regex(/^\$\{[A-Z][A-Z0-9_]*\}$/)]),
|
|
8
8
|
queueTokenEnv: secretRef,
|
|
9
9
|
requiredEntities: z.array(entityUri).min(1),
|
|
10
|
+
// Capability-specific settings are validated by their owning package.
|
|
11
|
+
interactions: z.record(z.string(), z.unknown()).optional(),
|
|
10
12
|
youtube: z.object({ liveChatId: z.string().min(1), clientIdEnv: secretRef, clientSecretEnv: secretRef, refreshTokenEnv: secretRef }).optional(),
|
|
11
13
|
twitch: z.object({ broadcasterUserId: z.string().min(1), userId: z.string().min(1), clientIdEnv: secretRef, clientSecretEnv: secretRef, refreshTokenEnv: secretRef }).optional(),
|
|
12
14
|
});
|
|
@@ -15,6 +17,10 @@ const registrySchema = z.object({
|
|
|
15
17
|
entities: z.record(entityUri, z.object({ id: entityUri }).passthrough()).default({}),
|
|
16
18
|
entitiesFetchedAt: z.string().datetime().optional(),
|
|
17
19
|
});
|
|
20
|
+
/** Validate without refreshing manifests or writing the registry. */
|
|
21
|
+
export function parseChannelRegistry(value) {
|
|
22
|
+
return registrySchema.parse(value);
|
|
23
|
+
}
|
|
18
24
|
export function openChannelRegistry(options) {
|
|
19
25
|
let current;
|
|
20
26
|
function requireCurrent() {
|
|
@@ -35,7 +41,7 @@ export function openChannelRegistry(options) {
|
|
|
35
41
|
},
|
|
36
42
|
async refresh() {
|
|
37
43
|
const filePath = path.resolve(options.filePath);
|
|
38
|
-
const parsed =
|
|
44
|
+
const parsed = parseChannelRegistry(JSON.parse(await readFile(filePath, "utf8")));
|
|
39
45
|
const uris = [...new Set(Object.values(parsed.channels).flatMap((value) => value.requiredEntities))];
|
|
40
46
|
const manifests = await options.resolveManifests(uris);
|
|
41
47
|
if (manifests.length !== uris.length)
|
package/package.json
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portalshq/channel-registry",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"repository": {
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/portalshq/portals-cloud.git",
|
|
7
|
+
"directory": "packages/channel-registry"
|
|
8
|
+
},
|
|
5
9
|
"description": "Validated, PX-refreshed deployment-local channel registries.",
|
|
6
10
|
"type": "module",
|
|
7
11
|
"main": "dist/index.js",
|
|
8
12
|
"types": "dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
25
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"prepack": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"zod": "^4.3.6"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.0.0",
|
|
34
|
+
"typescript": "^5.6.3",
|
|
35
|
+
"vitest": "^3.2.7"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
}
|
|
15
41
|
}
|