@spacefast/common 0.0.26 → 0.2.1
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/agents/connect-targets.d.ts +6 -146
- package/dist/agents/connect-targets.js +63 -295
- package/dist/agents/private-key-oauth.d.ts +31 -1
- package/dist/agents/private-key-oauth.js +124 -33
- package/dist/agents/registry/core.d.ts +292 -0
- package/dist/agents/registry/core.js +1388 -0
- package/dist/agents/registry/deeplink-probes.d.ts +23 -0
- package/dist/agents/registry/deeplink-probes.js +18 -0
- package/dist/agents/registry/node.d.ts +56 -0
- package/dist/agents/registry/node.js +339 -0
- package/dist/brand-assets-build.js +1 -2
- package/dist/brand-assets.js +4 -7
- package/dist/brand.d.ts +17 -0
- package/dist/brand.js +24 -4
- package/dist/config/domains.d.ts +55 -28
- package/dist/config/domains.js +85 -41
- package/dist/config/index.js +1 -2
- package/dist/contracts/abuse.js +9 -24
- package/dist/contracts/access-profiles.d.ts +86 -0
- package/dist/contracts/access-profiles.js +89 -0
- package/dist/contracts/access.d.ts +21 -27
- package/dist/contracts/access.js +33 -64
- package/dist/contracts/activity.d.ts +18 -1
- package/dist/contracts/activity.js +70 -26
- package/dist/contracts/analytics.js +8 -10
- package/dist/contracts/api-keys.d.ts +77 -52
- package/dist/contracts/api-keys.js +44 -24
- package/dist/contracts/application-journal.d.ts +216 -0
- package/dist/contracts/application-journal.js +167 -0
- package/dist/contracts/auth.d.ts +90 -17
- package/dist/contracts/auth.js +86 -17
- package/dist/contracts/beta.d.ts +9 -4
- package/dist/contracts/beta.js +20 -16
- package/dist/contracts/billing.js +7 -11
- package/dist/contracts/bootstrap.d.ts +791 -0
- package/dist/contracts/bootstrap.js +51 -0
- package/dist/contracts/builds.d.ts +186 -7
- package/dist/contracts/builds.js +75 -21
- package/dist/contracts/channels.d.ts +43 -0
- package/dist/contracts/channels.js +25 -9
- package/dist/contracts/cli.d.ts +7 -0
- package/dist/contracts/cli.js +6 -0
- package/dist/contracts/collab-public.d.ts +1 -1
- package/dist/contracts/collab-public.js +5 -8
- package/dist/contracts/comments.d.ts +45 -35
- package/dist/contracts/comments.js +107 -77
- package/dist/contracts/commerce.d.ts +165 -0
- package/dist/contracts/commerce.js +146 -0
- package/dist/contracts/common.d.ts +3 -3
- package/dist/contracts/common.js +18 -29
- package/dist/contracts/content-contract-verification.d.ts +521 -0
- package/dist/contracts/content-contract-verification.js +320 -0
- package/dist/contracts/content-platform-fixture.d.ts +1278 -0
- package/dist/contracts/content-platform-fixture.js +44 -0
- package/dist/contracts/content-program.d.ts +994 -0
- package/dist/contracts/content-program.js +658 -0
- package/dist/contracts/content-sync.d.ts +290 -0
- package/dist/contracts/content-sync.js +167 -0
- package/dist/contracts/content.d.ts +432 -0
- package/dist/contracts/content.js +303 -0
- package/dist/contracts/continuation.d.ts +17 -1
- package/dist/contracts/continuation.js +23 -23
- package/dist/contracts/countries.js +3 -4
- package/dist/contracts/crons.d.ts +17 -0
- package/dist/contracts/crons.js +33 -15
- package/dist/contracts/dashboard-prefs.d.ts +56 -0
- package/dist/contracts/dashboard-prefs.js +51 -0
- package/dist/contracts/device-auth.d.ts +234 -37
- package/dist/contracts/device-auth.js +267 -53
- package/dist/contracts/docs.d.ts +6 -10
- package/dist/contracts/docs.js +5 -13
- package/dist/contracts/domains.d.ts +499 -102
- package/dist/contracts/domains.js +169 -58
- package/dist/contracts/email-preferences.d.ts +3 -3
- package/dist/contracts/email-preferences.js +6 -7
- package/dist/contracts/enums.d.ts +26 -26
- package/dist/contracts/enums.js +61 -54
- package/dist/contracts/error-code-meta.d.ts +269 -7
- package/dist/contracts/error-code-meta.js +80 -5
- package/dist/contracts/error-codes.d.ts +5 -5
- package/dist/contracts/error-codes.js +78 -16
- package/dist/contracts/events.d.ts +100 -20
- package/dist/contracts/events.js +107 -20
- package/dist/contracts/execution.d.ts +47 -66
- package/dist/contracts/execution.js +51 -64
- package/dist/contracts/feature-lifecycle.d.ts +70 -14
- package/dist/contracts/feature-lifecycle.js +86 -15
- package/dist/contracts/features.d.ts +100 -37
- package/dist/contracts/features.js +21 -27
- package/dist/contracts/fixtures/content-platform-v1.json +1108 -0
- package/dist/contracts/frame-session.d.ts +192 -0
- package/dist/contracts/frame-session.js +164 -0
- package/dist/contracts/functions.d.ts +218 -211
- package/dist/contracts/functions.js +273 -260
- package/dist/contracts/grant-copy.d.ts +43 -0
- package/dist/contracts/grant-copy.js +44 -0
- package/dist/contracts/grants.d.ts +64 -56
- package/dist/contracts/grants.js +124 -23
- package/dist/contracts/ids.d.ts +4 -1
- package/dist/contracts/ids.js +4 -1
- package/dist/contracts/internal.d.ts +5 -4
- package/dist/contracts/internal.js +12 -3
- package/dist/contracts/mcp.d.ts +17 -0
- package/dist/contracts/mcp.js +23 -0
- package/dist/contracts/me.d.ts +6 -1
- package/dist/contracts/me.js +12 -6
- package/dist/contracts/notifications.d.ts +27 -29
- package/dist/contracts/notifications.js +9 -4
- package/dist/contracts/oauth-resources.d.ts +112 -10
- package/dist/contracts/oauth-resources.js +116 -11
- package/dist/contracts/oauth-scope-actions.d.ts +90 -0
- package/dist/contracts/oauth-scope-actions.js +126 -0
- package/dist/contracts/operations.d.ts +27 -4
- package/dist/contracts/operations.js +11 -5
- package/dist/contracts/pages.d.ts +29 -5
- package/dist/contracts/pages.js +22 -5
- package/dist/contracts/partner-notifications.d.ts +3 -0
- package/dist/contracts/partner-notifications.js +65 -0
- package/dist/contracts/{platform.d.ts → partner.d.ts} +29 -42
- package/dist/contracts/{platform.js → partner.js} +27 -40
- package/dist/contracts/plan-policy.d.ts +1 -1
- package/dist/contracts/principal-assertion.d.ts +43 -0
- package/dist/contracts/principal-assertion.js +67 -0
- package/dist/contracts/principals.d.ts +73 -0
- package/dist/contracts/principals.js +59 -0
- package/dist/contracts/privacy.d.ts +11 -0
- package/dist/contracts/privacy.js +17 -0
- package/dist/contracts/problem-document.js +3 -4
- package/dist/contracts/publish-archive.d.ts +116 -18
- package/dist/contracts/publish-archive.js +6 -3
- package/dist/contracts/push-new.d.ts +4 -4
- package/dist/contracts/quotas.js +3 -3
- package/dist/contracts/realtime.d.ts +52 -0
- package/dist/contracts/realtime.js +54 -0
- package/dist/contracts/repository-connections.d.ts +1 -1
- package/dist/contracts/repository-connections.js +6 -2
- package/dist/contracts/resources.d.ts +105 -14
- package/dist/contracts/resources.js +145 -21
- package/dist/contracts/route-inventory.d.ts +358 -0
- package/dist/contracts/route-inventory.js +141 -0
- package/dist/contracts/runtime-api.d.ts +112 -35
- package/dist/contracts/runtime-api.js +86 -66
- package/dist/contracts/runtime-app.d.ts +11 -21
- package/dist/contracts/runtime-app.js +39 -24
- package/dist/contracts/runtime-components.d.ts +143 -0
- package/dist/contracts/runtime-components.js +199 -0
- package/dist/contracts/runtime-db.d.ts +45 -19
- package/dist/contracts/runtime-db.js +85 -20
- package/dist/contracts/runtime-purge.js +3 -5
- package/dist/contracts/runtime-services.d.ts +43 -75
- package/dist/contracts/runtime-services.js +29 -49
- package/dist/contracts/runtime-storage.d.ts +14 -14
- package/dist/contracts/runtime-storage.js +28 -13
- package/dist/contracts/sf-config-v1.d.ts +14 -18
- package/dist/contracts/slugs.js +13 -4
- package/dist/contracts/space-config.d.ts +235 -28
- package/dist/contracts/space-config.js +246 -91
- package/dist/contracts/spaces.d.ts +360 -255
- package/dist/contracts/spaces.js +190 -122
- package/dist/contracts/superadmin-activity.d.ts +3 -43
- package/dist/contracts/superadmin-activity.js +6 -30
- package/dist/contracts/superadmin-emails.d.ts +1 -0
- package/dist/contracts/superadmin-emails.js +17 -1
- package/dist/contracts/superadmin-runtime.d.ts +199 -0
- package/dist/contracts/superadmin-runtime.js +141 -0
- package/dist/contracts/superadmin-search.d.ts +22 -2
- package/dist/contracts/superadmin-search.js +14 -6
- package/dist/contracts/superadmin-spaces.d.ts +435 -186
- package/dist/contracts/superadmin-spaces.js +131 -25
- package/dist/contracts/superadmin-teams.d.ts +3 -0
- package/dist/contracts/superadmin-teams.js +1 -2
- package/dist/contracts/superadmin-tenants.d.ts +627 -6
- package/dist/contracts/superadmin-tenants.js +32 -7
- package/dist/contracts/superadmin.d.ts +98 -16
- package/dist/contracts/superadmin.js +63 -10
- package/dist/contracts/tags.d.ts +85 -58
- package/dist/contracts/tags.js +44 -34
- package/dist/contracts/teams.d.ts +72 -9
- package/dist/contracts/teams.js +84 -25
- package/dist/contracts/tenants.d.ts +135 -0
- package/dist/contracts/tenants.js +120 -0
- package/dist/contracts/test-triggers.d.ts +70 -0
- package/dist/contracts/test-triggers.js +116 -0
- package/dist/contracts/theme-json.js +3 -8
- package/dist/contracts/transfers.d.ts +1 -0
- package/dist/contracts/transfers.js +1 -0
- package/dist/contracts/usage.d.ts +209 -0
- package/dist/contracts/usage.js +124 -12
- package/dist/contracts/variables.d.ts +2 -2
- package/dist/contracts/variables.js +9 -13
- package/dist/contracts/webhooks.d.ts +13 -5
- package/dist/contracts/webhooks.js +3 -1
- package/dist/contracts/zero.d.ts +57 -64
- package/dist/contracts/zero.js +68 -66
- package/dist/dashboard-paths/index.d.ts +24 -21
- package/dist/dashboard-paths/index.js +35 -47
- package/dist/dashboard-paths/route-reservations.generated.d.ts +2 -0
- package/dist/dashboard-paths/route-reservations.generated.js +36 -0
- package/dist/docs/agent-arrival.d.ts +92 -0
- package/dist/docs/agent-arrival.js +227 -0
- package/dist/docs/agent-output-policy.d.ts +6 -0
- package/dist/docs/agent-output-policy.js +22 -0
- package/dist/docs/agent-prose.d.ts +11 -17
- package/dist/docs/agent-prose.js +62 -37
- package/dist/docs/agent-setup.d.ts +72 -41
- package/dist/docs/agent-setup.js +336 -436
- package/dist/docs/catalog.d.ts +147 -89
- package/dist/docs/catalog.js +157 -42
- package/dist/docs/error-docs.d.ts +2098 -1
- package/dist/docs/error-docs.js +281 -16
- package/dist/docs/index-build.d.ts +0 -1
- package/dist/docs/index-build.js +2 -3
- package/dist/docs/page-context-prompt.d.ts +77 -0
- package/dist/docs/page-context-prompt.js +131 -0
- package/dist/docs/reference-urls.d.ts +46 -0
- package/dist/docs/reference-urls.js +79 -0
- package/dist/docs/search.d.ts +6 -8
- package/dist/docs/search.js +10 -13
- package/dist/docs/skill-distribution.d.ts +4 -1
- package/dist/docs/skill-distribution.js +10 -5
- package/dist/docs/skills.d.ts +117 -117
- package/dist/docs/skills.js +120 -72
- package/dist/docs/start-prompts.d.ts +45 -0
- package/dist/docs/start-prompts.js +62 -0
- package/dist/domain-exploration.js +9 -13
- package/dist/og-template.d.ts +56 -0
- package/dist/og-template.js +56 -0
- package/dist/slug-policy/index.js +5 -11
- package/dist/utils/browser-credential.d.ts +13 -6
- package/dist/utils/browser-credential.js +14 -7
- package/dist/utils/build-settings.d.ts +16 -0
- package/dist/utils/build-settings.js +63 -17
- package/dist/utils/canonical-json.d.ts +3 -5
- package/dist/utils/canonical-json.js +3 -5
- package/dist/utils/cast-transport.d.ts +5 -17
- package/dist/utils/cast-transport.js +6 -19
- package/dist/utils/claim-token.js +1 -2
- package/dist/utils/comment-avatars.js +4 -6
- package/dist/utils/concurrency.js +2 -3
- package/dist/utils/content-type.d.ts +7 -6
- package/dist/utils/content-type.js +73 -51
- package/dist/utils/credential-policy.d.ts +50 -6
- package/dist/utils/credential-policy.js +123 -57
- package/dist/utils/egress-policy.fixtures.json +1 -1
- package/dist/utils/generate-space-name.d.ts +3 -8
- package/dist/utils/generate-space-name.js +3 -8
- package/dist/utils/grants.d.ts +0 -1
- package/dist/utils/grants.js +4 -7
- package/dist/utils/gravatar.d.ts +2 -4
- package/dist/utils/gravatar.js +6 -12
- package/dist/utils/id-hints.js +14 -23
- package/dist/utils/idempotency.d.ts +3 -3
- package/dist/utils/idempotency.js +6 -7
- package/dist/utils/local-space-state.d.ts +15 -15
- package/dist/utils/local-space-state.js +34 -23
- package/dist/utils/oauth-signed-query.d.ts +3 -5
- package/dist/utils/oauth-signed-query.js +6 -9
- package/dist/utils/one-shot-replay.d.ts +3 -5
- package/dist/utils/one-shot-replay.js +3 -5
- package/dist/utils/page-colors.d.ts +4 -10
- package/dist/utils/page-colors.js +11 -35
- package/dist/utils/page-fonts.js +6 -11
- package/dist/utils/page-preview.d.ts +0 -1
- package/dist/utils/page-preview.js +0 -1
- package/dist/utils/pages.d.ts +22 -11
- package/dist/utils/pages.js +70 -30
- package/dist/utils/privacy-regions.d.ts +19 -0
- package/dist/utils/privacy-regions.js +91 -0
- package/dist/utils/publish-form-data.d.ts +4 -5
- package/dist/utils/publish-form-data.js +2 -3
- package/dist/utils/publish-policy.d.ts +10 -23
- package/dist/utils/publish-policy.js +63 -116
- package/dist/utils/query-client.d.ts +2 -0
- package/dist/utils/query-client.js +10 -1
- package/dist/utils/runtime-paths.d.ts +4 -4
- package/dist/utils/runtime-paths.js +6 -8
- package/dist/utils/runtime-upload.d.ts +4 -0
- package/dist/utils/runtime-upload.js +5 -0
- package/dist/utils/secure-local-file.d.ts +3 -3
- package/dist/utils/secure-local-file.js +18 -24
- package/dist/utils/space-config.d.ts +11 -14
- package/dist/utils/space-config.js +10 -16
- package/dist/utils/static-runtime-policy.d.ts +5 -8
- package/dist/utils/static-runtime-policy.generated.d.ts +16 -0
- package/dist/utils/static-runtime-policy.generated.js +70 -0
- package/dist/utils/static-runtime-policy.js +17 -84
- package/dist/utils/storage-policy.js +1 -2
- package/dist/utils/upload-session.js +8 -14
- package/dist/utils/version-path.js +11 -19
- package/dist/utils/wpcom-auth-redirects.d.ts +5 -14
- package/dist/utils/wpcom-auth-redirects.js +1 -4
- package/dist/vocabulary.d.ts +7 -7
- package/dist/vocabulary.js +30 -16
- package/package.json +14 -2
- package/dist/agents/client-registry.d.ts +0 -22
- package/dist/agents/client-registry.js +0 -41
- package/dist/docs/agent-handoff-document.d.ts +0 -15
- package/dist/docs/agent-handoff-document.js +0 -180
- package/dist/docs/agent-solutions.d.ts +0 -110
- package/dist/docs/agent-solutions.js +0 -183
- package/dist/utils/query-keys.d.ts +0 -84
- package/dist/utils/query-keys.js +0 -108
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { appRoutePathSchema, executionSha256Schema, httpMethodSchema } from "./execution.js";
|
|
3
|
+
import { grantCapabilitySchema } from "./grants.js";
|
|
4
|
+
export const CONTENT_PROGRAM_FORMAT = "spacefast.zero-wordpress";
|
|
5
|
+
export const CONTENT_PROGRAM_VERSION = 1;
|
|
6
|
+
export const contentProgramSha256Schema = executionSha256Schema.brand();
|
|
7
|
+
const stableIdSchema = z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.max(160)
|
|
11
|
+
.regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/);
|
|
12
|
+
export const contentResourceIdSchema = stableIdSchema.brand();
|
|
13
|
+
export const contentFieldIdSchema = stableIdSchema.brand();
|
|
14
|
+
export const contentTableIdSchema = stableIdSchema.brand();
|
|
15
|
+
export const contentAbilityIdSchema = stableIdSchema.brand();
|
|
16
|
+
export const contentSchemaIdSchema = stableIdSchema.brand();
|
|
17
|
+
export const contentComponentIdSchema = stableIdSchema.brand();
|
|
18
|
+
export const contentSyncBindingIdSchema = stableIdSchema.brand();
|
|
19
|
+
export const contentSyncSourcePathSchema = z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.max(1_000)
|
|
23
|
+
.refine((source) => !source.includes("\\") &&
|
|
24
|
+
Array.from(source).every((character) => {
|
|
25
|
+
const codePoint = character.codePointAt(0);
|
|
26
|
+
return codePoint !== undefined && codePoint >= 32 && codePoint !== 127;
|
|
27
|
+
}), "source paths cannot contain controls or backslashes")
|
|
28
|
+
.refine((source) => !source.startsWith("/") &&
|
|
29
|
+
source.split("/").every((segment) => segment !== "" && segment !== "." && segment !== ".."), "source paths must be normalized relative paths without traversal");
|
|
30
|
+
export const contentProgramJsonValueSchema = z.json();
|
|
31
|
+
export const contentResourceRefSchema = z
|
|
32
|
+
.string()
|
|
33
|
+
.regex(/^(?:content|table)\.[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/)
|
|
34
|
+
.brand();
|
|
35
|
+
export const contentSchemaRefSchema = z
|
|
36
|
+
.object({
|
|
37
|
+
id: contentSchemaIdSchema,
|
|
38
|
+
sha256: contentProgramSha256Schema,
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
export const contentSchemaDefinitionSchema = z
|
|
42
|
+
.object({
|
|
43
|
+
id: contentSchemaIdSchema,
|
|
44
|
+
sha256: contentProgramSha256Schema,
|
|
45
|
+
schema: contentProgramJsonValueSchema,
|
|
46
|
+
})
|
|
47
|
+
.strict();
|
|
48
|
+
const fieldValueSchema = z.discriminatedUnion("kind", [
|
|
49
|
+
z
|
|
50
|
+
.object({
|
|
51
|
+
kind: z.literal("text"),
|
|
52
|
+
multiline: z.boolean(),
|
|
53
|
+
maxLength: z.number().int().positive().nullable(),
|
|
54
|
+
})
|
|
55
|
+
.strict(),
|
|
56
|
+
z.object({ kind: z.literal("number") }).strict(),
|
|
57
|
+
z.object({ kind: z.literal("boolean") }).strict(),
|
|
58
|
+
z.object({ kind: z.literal("datetime") }).strict(),
|
|
59
|
+
z
|
|
60
|
+
.object({
|
|
61
|
+
kind: z.literal("blocks"),
|
|
62
|
+
allowed: z.union([z.literal("any"), z.array(contentComponentIdSchema).max(100)]),
|
|
63
|
+
})
|
|
64
|
+
.strict(),
|
|
65
|
+
z.object({ kind: z.literal("media"), multiple: z.boolean() }).strict(),
|
|
66
|
+
z
|
|
67
|
+
.object({
|
|
68
|
+
kind: z.literal("reference"),
|
|
69
|
+
target: contentResourceIdSchema,
|
|
70
|
+
multiple: z.boolean(),
|
|
71
|
+
})
|
|
72
|
+
.strict(),
|
|
73
|
+
z
|
|
74
|
+
.object({
|
|
75
|
+
kind: z.literal("enum"),
|
|
76
|
+
values: z.array(z.string().min(1).max(160)).min(1).max(100),
|
|
77
|
+
multiple: z.boolean(),
|
|
78
|
+
})
|
|
79
|
+
.strict(),
|
|
80
|
+
]);
|
|
81
|
+
export const contentProgramFieldSchema = z
|
|
82
|
+
.object({
|
|
83
|
+
id: contentFieldIdSchema,
|
|
84
|
+
name: stableIdSchema,
|
|
85
|
+
label: z.string().trim().min(1).max(160),
|
|
86
|
+
required: z.boolean(),
|
|
87
|
+
value: fieldValueSchema,
|
|
88
|
+
})
|
|
89
|
+
.strict();
|
|
90
|
+
export const wordpressContentResourceSchema = z
|
|
91
|
+
.object({
|
|
92
|
+
id: contentResourceIdSchema,
|
|
93
|
+
name: stableIdSchema,
|
|
94
|
+
label: z.string().trim().min(1).max(160),
|
|
95
|
+
kind: z.enum(["posts", "pages", "media", "collection"]),
|
|
96
|
+
fields: z.array(contentProgramFieldSchema).max(100),
|
|
97
|
+
publicRead: z.boolean(),
|
|
98
|
+
})
|
|
99
|
+
.strict();
|
|
100
|
+
export const wordpressProgramIrV1Schema = z
|
|
101
|
+
.object({
|
|
102
|
+
format: z.literal("spacefast.wordpress-program"),
|
|
103
|
+
version: z.literal(1),
|
|
104
|
+
resources: z.array(wordpressContentResourceSchema).min(3).max(53),
|
|
105
|
+
})
|
|
106
|
+
.strict()
|
|
107
|
+
.superRefine((wordpress, context) => {
|
|
108
|
+
const ids = new Set();
|
|
109
|
+
const kinds = new Map();
|
|
110
|
+
for (const [resourceIndex, resource] of wordpress.resources.entries()) {
|
|
111
|
+
if (ids.has(resource.id)) {
|
|
112
|
+
context.addIssue({
|
|
113
|
+
code: "custom",
|
|
114
|
+
path: ["resources", resourceIndex, "id"],
|
|
115
|
+
message: `duplicate content resource id ${resource.id}`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
ids.add(resource.id);
|
|
119
|
+
kinds.set(resource.kind, (kinds.get(resource.kind) ?? 0) + 1);
|
|
120
|
+
const fieldIds = new Set();
|
|
121
|
+
for (const [fieldIndex, field] of resource.fields.entries()) {
|
|
122
|
+
if (fieldIds.has(field.id)) {
|
|
123
|
+
context.addIssue({
|
|
124
|
+
code: "custom",
|
|
125
|
+
path: ["resources", resourceIndex, "fields", fieldIndex, "id"],
|
|
126
|
+
message: `duplicate field id ${field.id}`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
fieldIds.add(field.id);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for (const required of ["posts", "pages", "media"]) {
|
|
133
|
+
if (kinds.get(required) !== 1) {
|
|
134
|
+
context.addIssue({
|
|
135
|
+
code: "custom",
|
|
136
|
+
path: ["resources"],
|
|
137
|
+
message: `WordPress programs require exactly one native ${required} resource`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const native = wordpress.resources.find((resource) => resource.kind === required);
|
|
141
|
+
if (native && (native.id !== required || native.name !== required)) {
|
|
142
|
+
context.addIssue({
|
|
143
|
+
code: "custom",
|
|
144
|
+
path: ["resources"],
|
|
145
|
+
message: `the native ${required} resource must keep id and name ${required}`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (const [resourceIndex, resource] of wordpress.resources.entries()) {
|
|
150
|
+
for (const [fieldIndex, field] of resource.fields.entries()) {
|
|
151
|
+
if (field.value.kind === "reference" && !ids.has(field.value.target)) {
|
|
152
|
+
context.addIssue({
|
|
153
|
+
code: "custom",
|
|
154
|
+
path: ["resources", resourceIndex, "fields", fieldIndex, "value", "target"],
|
|
155
|
+
message: `unknown content resource ${field.value.target}`,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const tableColumnValueSchema = z.discriminatedUnion("kind", [
|
|
162
|
+
z
|
|
163
|
+
.object({ kind: z.literal("string"), maxLength: z.number().int().positive().nullable() })
|
|
164
|
+
.strict(),
|
|
165
|
+
z.object({ kind: z.literal("number") }).strict(),
|
|
166
|
+
z.object({ kind: z.literal("boolean") }).strict(),
|
|
167
|
+
z.object({ kind: z.literal("datetime") }).strict(),
|
|
168
|
+
z.object({ kind: z.literal("json") }).strict(),
|
|
169
|
+
]);
|
|
170
|
+
export const contentTableColumnSchema = z
|
|
171
|
+
.object({
|
|
172
|
+
id: contentFieldIdSchema,
|
|
173
|
+
name: stableIdSchema,
|
|
174
|
+
nullable: z.boolean(),
|
|
175
|
+
value: tableColumnValueSchema,
|
|
176
|
+
})
|
|
177
|
+
.strict();
|
|
178
|
+
export const contentTableIrV1Schema = z
|
|
179
|
+
.object({
|
|
180
|
+
id: contentTableIdSchema,
|
|
181
|
+
name: stableIdSchema,
|
|
182
|
+
columns: z.array(contentTableColumnSchema).max(100),
|
|
183
|
+
indexes: z
|
|
184
|
+
.array(z
|
|
185
|
+
.object({
|
|
186
|
+
id: stableIdSchema,
|
|
187
|
+
fields: z.array(contentFieldIdSchema).min(1).max(16),
|
|
188
|
+
unique: z.boolean(),
|
|
189
|
+
})
|
|
190
|
+
.strict())
|
|
191
|
+
.max(32),
|
|
192
|
+
})
|
|
193
|
+
.strict()
|
|
194
|
+
.superRefine((table, context) => {
|
|
195
|
+
const fieldIds = new Set(table.columns.map((column) => column.id));
|
|
196
|
+
const fieldNames = new Set();
|
|
197
|
+
for (const [columnPosition, column] of table.columns.entries()) {
|
|
198
|
+
if (fieldNames.has(column.name)) {
|
|
199
|
+
context.addIssue({
|
|
200
|
+
code: "custom",
|
|
201
|
+
path: ["columns", columnPosition, "name"],
|
|
202
|
+
message: `duplicate table column name ${column.name}`,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
fieldNames.add(column.name);
|
|
206
|
+
}
|
|
207
|
+
if (fieldIds.size !== table.columns.length) {
|
|
208
|
+
context.addIssue({
|
|
209
|
+
code: "custom",
|
|
210
|
+
path: ["columns"],
|
|
211
|
+
message: "table column ids must be unique",
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const indexIds = new Set();
|
|
215
|
+
for (const [indexPosition, index] of table.indexes.entries()) {
|
|
216
|
+
if (indexIds.has(index.id)) {
|
|
217
|
+
context.addIssue({
|
|
218
|
+
code: "custom",
|
|
219
|
+
path: ["indexes", indexPosition, "id"],
|
|
220
|
+
message: `duplicate table index id ${index.id}`,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
indexIds.add(index.id);
|
|
224
|
+
for (const [fieldPosition, field] of index.fields.entries()) {
|
|
225
|
+
if (!fieldIds.has(field)) {
|
|
226
|
+
context.addIssue({
|
|
227
|
+
code: "custom",
|
|
228
|
+
path: ["indexes", indexPosition, "fields", fieldPosition],
|
|
229
|
+
message: `table index references unknown field ${field}`,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
export const contentCacheProfileV1Schema = z.discriminatedUnion("kind", [
|
|
236
|
+
z.object({ kind: z.literal("none") }).strict(),
|
|
237
|
+
z
|
|
238
|
+
.object({
|
|
239
|
+
kind: z.literal("private"),
|
|
240
|
+
maxAgeSeconds: z.number().int().nonnegative().max(86_400),
|
|
241
|
+
})
|
|
242
|
+
.strict(),
|
|
243
|
+
z
|
|
244
|
+
.object({
|
|
245
|
+
kind: z.literal("public"),
|
|
246
|
+
maxAgeSeconds: z.number().int().nonnegative().max(86_400),
|
|
247
|
+
staleWhileRevalidateSeconds: z.number().int().nonnegative().max(604_800),
|
|
248
|
+
})
|
|
249
|
+
.strict(),
|
|
250
|
+
]);
|
|
251
|
+
const abilityRoutePathSchema = appRoutePathSchema({ subject: "Content program routes" });
|
|
252
|
+
export const contentAbilityRouteAdmissionV1Schema = z.enum(["authenticated", "public"]);
|
|
253
|
+
export const contentProgramRouteSchema = z
|
|
254
|
+
.object({
|
|
255
|
+
id: stableIdSchema,
|
|
256
|
+
method: httpMethodSchema,
|
|
257
|
+
path: abilityRoutePathSchema,
|
|
258
|
+
admission: contentAbilityRouteAdmissionV1Schema,
|
|
259
|
+
})
|
|
260
|
+
.strict();
|
|
261
|
+
const contentAbilityExposureSchema = z.discriminatedUnion("kind", [
|
|
262
|
+
z.object({ kind: z.literal("named"), named: z.literal(true) }).strict(),
|
|
263
|
+
z
|
|
264
|
+
.object({
|
|
265
|
+
kind: z.literal("routed"),
|
|
266
|
+
named: z.literal(true),
|
|
267
|
+
route: contentProgramRouteSchema,
|
|
268
|
+
})
|
|
269
|
+
.strict(),
|
|
270
|
+
]);
|
|
271
|
+
const abilityDescriptorFields = {
|
|
272
|
+
id: contentAbilityIdSchema,
|
|
273
|
+
input: contentSchemaRefSchema,
|
|
274
|
+
output: contentSchemaRefSchema,
|
|
275
|
+
permits: z.array(grantCapabilitySchema).max(5),
|
|
276
|
+
reads: z.array(contentResourceRefSchema).max(100),
|
|
277
|
+
writes: z.array(contentResourceRefSchema).max(100),
|
|
278
|
+
exposure: contentAbilityExposureSchema,
|
|
279
|
+
cache: contentCacheProfileV1Schema,
|
|
280
|
+
};
|
|
281
|
+
export const contentAbilityDescriptorV1Schema = z
|
|
282
|
+
.discriminatedUnion("kind", [
|
|
283
|
+
z
|
|
284
|
+
.object({ ...abilityDescriptorFields, kind: z.literal("query"), mode: z.literal("read") })
|
|
285
|
+
.strict(),
|
|
286
|
+
z
|
|
287
|
+
.object({ ...abilityDescriptorFields, kind: z.literal("mutation"), mode: z.literal("write") })
|
|
288
|
+
.strict(),
|
|
289
|
+
z
|
|
290
|
+
.object({
|
|
291
|
+
...abilityDescriptorFields,
|
|
292
|
+
kind: z.literal("endpoint"),
|
|
293
|
+
mode: z.enum(["read", "write"]),
|
|
294
|
+
})
|
|
295
|
+
.strict(),
|
|
296
|
+
])
|
|
297
|
+
.superRefine((ability, context) => {
|
|
298
|
+
if (new Set(ability.permits).size !== ability.permits.length) {
|
|
299
|
+
context.addIssue({ code: "custom", path: ["permits"], message: "permits must be unique" });
|
|
300
|
+
}
|
|
301
|
+
if (new Set(ability.reads).size !== ability.reads.length) {
|
|
302
|
+
context.addIssue({ code: "custom", path: ["reads"], message: "reads must be unique" });
|
|
303
|
+
}
|
|
304
|
+
if (new Set(ability.writes).size !== ability.writes.length) {
|
|
305
|
+
context.addIssue({ code: "custom", path: ["writes"], message: "writes must be unique" });
|
|
306
|
+
}
|
|
307
|
+
if (ability.mode === "read" && ability.writes.length > 0) {
|
|
308
|
+
context.addIssue({
|
|
309
|
+
code: "custom",
|
|
310
|
+
path: ["writes"],
|
|
311
|
+
message: "read abilities cannot declare writes",
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
if (ability.mode === "write" && ability.cache.kind !== "none") {
|
|
315
|
+
context.addIssue({
|
|
316
|
+
code: "custom",
|
|
317
|
+
path: ["cache"],
|
|
318
|
+
message: "write abilities cannot be cached",
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
if (ability.cache.kind === "public" && ability.permits.length > 0) {
|
|
322
|
+
context.addIssue({
|
|
323
|
+
code: "custom",
|
|
324
|
+
path: ["cache"],
|
|
325
|
+
message: "public caches cannot vary on a caller capability",
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
if (ability.cache.kind === "public" &&
|
|
329
|
+
ability.exposure.kind === "routed" &&
|
|
330
|
+
ability.exposure.route.admission === "authenticated") {
|
|
331
|
+
context.addIssue({
|
|
332
|
+
code: "custom",
|
|
333
|
+
path: ["cache"],
|
|
334
|
+
message: "authenticated routes cannot use a public cache",
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
if (ability.exposure.kind === "routed" &&
|
|
338
|
+
ability.exposure.route.admission === "public" &&
|
|
339
|
+
ability.permits.length > 0) {
|
|
340
|
+
context.addIssue({
|
|
341
|
+
code: "custom",
|
|
342
|
+
path: ["exposure", "route", "admission"],
|
|
343
|
+
message: "public route admission cannot require a caller capability",
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
if (ability.kind !== "endpoint" && ability.exposure.kind === "routed") {
|
|
347
|
+
context.addIssue({
|
|
348
|
+
code: "custom",
|
|
349
|
+
path: ["exposure"],
|
|
350
|
+
message: "only endpoints can expose an HTTP route",
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
const writableStores = new Set(ability.writes.map((resource) => resource.split(".", 1)[0]));
|
|
354
|
+
if (writableStores.size > 1) {
|
|
355
|
+
context.addIssue({
|
|
356
|
+
code: "custom",
|
|
357
|
+
path: ["writes"],
|
|
358
|
+
message: "an ability can write either WordPress content or Lakebed tables, not both",
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
export const contentAbilityDenialV1Schema = z.discriminatedUnion("reason", [
|
|
363
|
+
z
|
|
364
|
+
.object({
|
|
365
|
+
reason: z.literal("capability-missing"),
|
|
366
|
+
missing: z.array(grantCapabilitySchema).min(1).max(5),
|
|
367
|
+
})
|
|
368
|
+
.strict(),
|
|
369
|
+
z.object({ reason: z.literal("resource-denied"), resource: contentResourceRefSchema }).strict(),
|
|
370
|
+
z.object({ reason: z.literal("target-mismatch") }).strict(),
|
|
371
|
+
z
|
|
372
|
+
.object({
|
|
373
|
+
reason: z.literal("business-rule-denied"),
|
|
374
|
+
code: stableIdSchema,
|
|
375
|
+
detail: z.string().min(1).max(2_000),
|
|
376
|
+
})
|
|
377
|
+
.strict(),
|
|
378
|
+
]);
|
|
379
|
+
export const contentAbilityDecisionV1Schema = z.discriminatedUnion("decision", [
|
|
380
|
+
z
|
|
381
|
+
.object({
|
|
382
|
+
format: z.literal("spacefast.ability-decision"),
|
|
383
|
+
version: z.literal(1),
|
|
384
|
+
abilityId: contentAbilityIdSchema,
|
|
385
|
+
callId: stableIdSchema,
|
|
386
|
+
decision: z.literal("allowed"),
|
|
387
|
+
})
|
|
388
|
+
.strict(),
|
|
389
|
+
z
|
|
390
|
+
.object({
|
|
391
|
+
format: z.literal("spacefast.ability-decision"),
|
|
392
|
+
version: z.literal(1),
|
|
393
|
+
abilityId: contentAbilityIdSchema,
|
|
394
|
+
callId: stableIdSchema,
|
|
395
|
+
decision: z.literal("denied"),
|
|
396
|
+
denial: contentAbilityDenialV1Schema,
|
|
397
|
+
})
|
|
398
|
+
.strict(),
|
|
399
|
+
]);
|
|
400
|
+
export const contentAbilityReceiptV1Schema = z.discriminatedUnion("status", [
|
|
401
|
+
z
|
|
402
|
+
.object({
|
|
403
|
+
format: z.literal("spacefast.ability-receipt"),
|
|
404
|
+
version: z.literal(1),
|
|
405
|
+
abilityId: contentAbilityIdSchema,
|
|
406
|
+
callId: stableIdSchema,
|
|
407
|
+
status: z.literal("succeeded"),
|
|
408
|
+
output: contentProgramJsonValueSchema,
|
|
409
|
+
invalidates: z.array(contentAbilityIdSchema).max(500),
|
|
410
|
+
})
|
|
411
|
+
.strict(),
|
|
412
|
+
z
|
|
413
|
+
.object({
|
|
414
|
+
format: z.literal("spacefast.ability-receipt"),
|
|
415
|
+
version: z.literal(1),
|
|
416
|
+
abilityId: contentAbilityIdSchema,
|
|
417
|
+
callId: stableIdSchema,
|
|
418
|
+
status: z.literal("denied"),
|
|
419
|
+
denial: contentAbilityDenialV1Schema,
|
|
420
|
+
})
|
|
421
|
+
.strict(),
|
|
422
|
+
]);
|
|
423
|
+
export const contentClientPageIrV1Schema = z
|
|
424
|
+
.object({
|
|
425
|
+
id: stableIdSchema,
|
|
426
|
+
sourceKey: z.string().min(1).max(512),
|
|
427
|
+
path: abilityRoutePathSchema,
|
|
428
|
+
title: z.string().trim().min(1).max(500),
|
|
429
|
+
blockName: z.literal("zero/component"),
|
|
430
|
+
componentId: contentComponentIdSchema,
|
|
431
|
+
props: contentSchemaRefSchema,
|
|
432
|
+
})
|
|
433
|
+
.strict();
|
|
434
|
+
export const contentExecutableRefV1Schema = z
|
|
435
|
+
.object({
|
|
436
|
+
id: stableIdSchema,
|
|
437
|
+
runtime: z.enum(["php", "quickjs"]),
|
|
438
|
+
artifact: contentProgramSha256Schema,
|
|
439
|
+
export: z.string().min(1).max(256),
|
|
440
|
+
})
|
|
441
|
+
.strict();
|
|
442
|
+
export const contentSyncBindingV1Schema = z
|
|
443
|
+
.object({
|
|
444
|
+
id: contentSyncBindingIdSchema,
|
|
445
|
+
resourceId: contentResourceIdSchema,
|
|
446
|
+
fieldId: contentFieldIdSchema,
|
|
447
|
+
source: contentSyncSourcePathSchema,
|
|
448
|
+
slug: z.string().trim().min(1).max(200),
|
|
449
|
+
})
|
|
450
|
+
.strict();
|
|
451
|
+
export const contentProgramReleaseV1Schema = z
|
|
452
|
+
.object({
|
|
453
|
+
format: z.literal(CONTENT_PROGRAM_FORMAT),
|
|
454
|
+
version: z.literal(CONTENT_PROGRAM_VERSION),
|
|
455
|
+
revision: contentProgramSha256Schema,
|
|
456
|
+
schemas: z.array(contentSchemaDefinitionSchema).min(1).max(500),
|
|
457
|
+
wordpress: wordpressProgramIrV1Schema,
|
|
458
|
+
tables: z.array(contentTableIrV1Schema).max(100),
|
|
459
|
+
abilities: z.array(contentAbilityDescriptorV1Schema).max(500),
|
|
460
|
+
pages: z.array(contentClientPageIrV1Schema).max(10_000),
|
|
461
|
+
hooks: z.array(contentExecutableRefV1Schema).max(500),
|
|
462
|
+
syncBindings: z.array(contentSyncBindingV1Schema).max(10_000),
|
|
463
|
+
})
|
|
464
|
+
.strict()
|
|
465
|
+
.superRefine((program, context) => {
|
|
466
|
+
const schemas = new Map(program.schemas.map((schema) => [schema.id, schema.sha256]));
|
|
467
|
+
if (schemas.size !== program.schemas.length) {
|
|
468
|
+
context.addIssue({
|
|
469
|
+
code: "custom",
|
|
470
|
+
path: ["schemas"],
|
|
471
|
+
message: "program schema ids must be unique",
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
const resources = new Map(program.wordpress.resources.map((resource) => [resource.id, resource]));
|
|
475
|
+
const tables = new Set(program.tables.map((table) => table.id));
|
|
476
|
+
const ids = [
|
|
477
|
+
...program.wordpress.resources.map((resource) => resource.id),
|
|
478
|
+
...program.tables.map((table) => table.id),
|
|
479
|
+
...program.abilities.map((ability) => ability.id),
|
|
480
|
+
...program.pages.map((page) => page.id),
|
|
481
|
+
...program.hooks.map((hook) => hook.id),
|
|
482
|
+
...program.syncBindings.map((binding) => binding.id),
|
|
483
|
+
];
|
|
484
|
+
if (new Set(ids).size !== ids.length) {
|
|
485
|
+
context.addIssue({ code: "custom", message: "stable program ids must be globally unique" });
|
|
486
|
+
}
|
|
487
|
+
const verifySchemaRef = (ref, path) => {
|
|
488
|
+
if (schemas.get(ref.id) !== ref.sha256) {
|
|
489
|
+
context.addIssue({
|
|
490
|
+
code: "custom",
|
|
491
|
+
path,
|
|
492
|
+
message: `schema reference ${ref.id} does not match a program schema`,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
for (const [index, ability] of program.abilities.entries()) {
|
|
497
|
+
verifySchemaRef(ability.input, ["abilities", index, "input"]);
|
|
498
|
+
verifySchemaRef(ability.output, ["abilities", index, "output"]);
|
|
499
|
+
for (const [resourceIndex, resource] of [...ability.reads, ...ability.writes].entries()) {
|
|
500
|
+
const separator = resource.indexOf(".");
|
|
501
|
+
const kind = resource.slice(0, separator);
|
|
502
|
+
const id = resource.slice(separator + 1);
|
|
503
|
+
if ((kind === "content" && !resources.has(id)) || (kind === "table" && !tables.has(id))) {
|
|
504
|
+
context.addIssue({
|
|
505
|
+
code: "custom",
|
|
506
|
+
path: ["abilities", index, "reads", resourceIndex],
|
|
507
|
+
message: `ability references unknown resource ${resource}`,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (ability.cache.kind === "public") {
|
|
512
|
+
for (const [resourceIndex, resource] of ability.reads.entries()) {
|
|
513
|
+
const separator = resource.indexOf(".");
|
|
514
|
+
const kind = resource.slice(0, separator);
|
|
515
|
+
const id = resource.slice(separator + 1);
|
|
516
|
+
if (kind !== "content" || resources.get(id)?.publicRead !== true) {
|
|
517
|
+
context.addIssue({
|
|
518
|
+
code: "custom",
|
|
519
|
+
path: ["abilities", index, "reads", resourceIndex],
|
|
520
|
+
message: "public caches can read only statically public content resources",
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
for (const [index, page] of program.pages.entries()) {
|
|
527
|
+
verifySchemaRef(page.props, ["pages", index, "props"]);
|
|
528
|
+
}
|
|
529
|
+
for (const [index, binding] of program.syncBindings.entries()) {
|
|
530
|
+
const resource = resources.get(binding.resourceId);
|
|
531
|
+
const field = resource?.fields.find((candidate) => candidate.id === binding.fieldId);
|
|
532
|
+
if (!field) {
|
|
533
|
+
context.addIssue({
|
|
534
|
+
code: "custom",
|
|
535
|
+
path: ["syncBindings", index],
|
|
536
|
+
message: "sync binding must reference a field on its content resource",
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
else if (field.value.kind !== "blocks") {
|
|
540
|
+
context.addIssue({
|
|
541
|
+
code: "custom",
|
|
542
|
+
path: ["syncBindings", index, "fieldId"],
|
|
543
|
+
message: "Markdown sync bindings require a block field",
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
export const CONTENT_PROGRAM_ARTIFACT_FORMATS = {
|
|
549
|
+
program: CONTENT_PROGRAM_FORMAT,
|
|
550
|
+
executables: "spacefast.zero-executables",
|
|
551
|
+
sdk: "spacefast.sdk-descriptors",
|
|
552
|
+
routes: "spacefast.route-contributions",
|
|
553
|
+
requirements: "spacefast.program-requirements",
|
|
554
|
+
};
|
|
555
|
+
export function contentProgramArtifactRefSchema(format) {
|
|
556
|
+
return z
|
|
557
|
+
.object({
|
|
558
|
+
format: z.literal(format),
|
|
559
|
+
version: z.literal(1),
|
|
560
|
+
inputDigest: contentProgramSha256Schema,
|
|
561
|
+
sha256: contentProgramSha256Schema,
|
|
562
|
+
bytes: z.number().int().nonnegative(),
|
|
563
|
+
mediaType: z.literal("application/json"),
|
|
564
|
+
})
|
|
565
|
+
.strict();
|
|
566
|
+
}
|
|
567
|
+
export const compiledContentProgramV1Schema = z
|
|
568
|
+
.object({
|
|
569
|
+
format: z.literal("spacefast.compiled-program"),
|
|
570
|
+
version: z.literal(1),
|
|
571
|
+
program: contentProgramArtifactRefSchema(CONTENT_PROGRAM_ARTIFACT_FORMATS.program),
|
|
572
|
+
executables: contentProgramArtifactRefSchema(CONTENT_PROGRAM_ARTIFACT_FORMATS.executables),
|
|
573
|
+
sdk: contentProgramArtifactRefSchema(CONTENT_PROGRAM_ARTIFACT_FORMATS.sdk),
|
|
574
|
+
routes: contentProgramArtifactRefSchema(CONTENT_PROGRAM_ARTIFACT_FORMATS.routes),
|
|
575
|
+
requirements: contentProgramArtifactRefSchema(CONTENT_PROGRAM_ARTIFACT_FORMATS.requirements),
|
|
576
|
+
})
|
|
577
|
+
.strict();
|
|
578
|
+
export const contentExecutableSetV1Schema = z
|
|
579
|
+
.object({
|
|
580
|
+
format: z.literal(CONTENT_PROGRAM_ARTIFACT_FORMATS.executables),
|
|
581
|
+
version: z.literal(1),
|
|
582
|
+
inputDigest: contentProgramSha256Schema,
|
|
583
|
+
executables: z.array(contentExecutableRefV1Schema).max(500),
|
|
584
|
+
})
|
|
585
|
+
.strict();
|
|
586
|
+
const contentSdkOperationDescriptorV1Schema = z
|
|
587
|
+
.discriminatedUnion("kind", [
|
|
588
|
+
z
|
|
589
|
+
.object({
|
|
590
|
+
id: contentAbilityIdSchema,
|
|
591
|
+
kind: z.literal("query"),
|
|
592
|
+
mode: z.literal("read"),
|
|
593
|
+
input: contentSchemaRefSchema,
|
|
594
|
+
output: contentSchemaRefSchema,
|
|
595
|
+
cache: contentCacheProfileV1Schema,
|
|
596
|
+
invalidates: z.array(contentAbilityIdSchema),
|
|
597
|
+
})
|
|
598
|
+
.strict(),
|
|
599
|
+
z
|
|
600
|
+
.object({
|
|
601
|
+
id: contentAbilityIdSchema,
|
|
602
|
+
kind: z.literal("mutation"),
|
|
603
|
+
mode: z.literal("write"),
|
|
604
|
+
input: contentSchemaRefSchema,
|
|
605
|
+
output: contentSchemaRefSchema,
|
|
606
|
+
cache: z.object({ kind: z.literal("none") }).strict(),
|
|
607
|
+
invalidates: z.array(contentAbilityIdSchema),
|
|
608
|
+
})
|
|
609
|
+
.strict(),
|
|
610
|
+
z
|
|
611
|
+
.object({
|
|
612
|
+
id: contentAbilityIdSchema,
|
|
613
|
+
kind: z.literal("endpoint"),
|
|
614
|
+
mode: z.enum(["read", "write"]),
|
|
615
|
+
input: contentSchemaRefSchema,
|
|
616
|
+
output: contentSchemaRefSchema,
|
|
617
|
+
cache: contentCacheProfileV1Schema,
|
|
618
|
+
invalidates: z.array(contentAbilityIdSchema),
|
|
619
|
+
})
|
|
620
|
+
.strict(),
|
|
621
|
+
])
|
|
622
|
+
.superRefine((operation, context) => {
|
|
623
|
+
if (operation.mode === "write" && operation.cache.kind !== "none") {
|
|
624
|
+
context.addIssue({
|
|
625
|
+
code: "custom",
|
|
626
|
+
path: ["cache"],
|
|
627
|
+
message: "write SDK operations cannot be cached",
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
export const contentSdkDescriptorSetV1Schema = z
|
|
632
|
+
.object({
|
|
633
|
+
format: z.literal(CONTENT_PROGRAM_ARTIFACT_FORMATS.sdk),
|
|
634
|
+
version: z.literal(1),
|
|
635
|
+
inputDigest: contentProgramSha256Schema,
|
|
636
|
+
operations: z.array(contentSdkOperationDescriptorV1Schema),
|
|
637
|
+
sync: z.array(z
|
|
638
|
+
.object({
|
|
639
|
+
id: contentSyncBindingIdSchema,
|
|
640
|
+
resourceId: contentResourceIdSchema,
|
|
641
|
+
source: z.string().min(1).max(1_000),
|
|
642
|
+
})
|
|
643
|
+
.strict()),
|
|
644
|
+
})
|
|
645
|
+
.strict();
|
|
646
|
+
export const contentRouteContributionSetV1Schema = z
|
|
647
|
+
.object({
|
|
648
|
+
format: z.literal(CONTENT_PROGRAM_ARTIFACT_FORMATS.routes),
|
|
649
|
+
version: z.literal(1),
|
|
650
|
+
inputDigest: contentProgramSha256Schema,
|
|
651
|
+
routes: z.array(z
|
|
652
|
+
.object({
|
|
653
|
+
abilityId: contentAbilityIdSchema,
|
|
654
|
+
route: contentProgramRouteSchema,
|
|
655
|
+
})
|
|
656
|
+
.strict()),
|
|
657
|
+
})
|
|
658
|
+
.strict();
|