@spacefast/common 0.2.1 → 0.4.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/marketplace-prompts.d.ts +1 -0
- package/dist/agents/marketplace-prompts.js +6 -0
- package/dist/agents/registry/core.d.ts +4 -12
- package/dist/agents/registry/core.js +7 -28
- package/dist/config/domains.d.ts +10 -8
- package/dist/config/domains.js +4 -7
- package/dist/contracts/access-core.d.ts +135 -0
- package/dist/contracts/access-core.js +242 -0
- package/dist/contracts/access-profiles.d.ts +8 -8
- package/dist/contracts/access-profiles.js +8 -8
- package/dist/contracts/access.d.ts +14 -103
- package/dist/contracts/access.js +10 -210
- package/dist/contracts/activity.d.ts +54 -55
- package/dist/contracts/activity.js +38 -9
- package/dist/contracts/api-keys.d.ts +69 -26
- package/dist/contracts/api-keys.js +29 -2
- package/dist/contracts/application-journal.d.ts +197 -4
- package/dist/contracts/application-journal.js +97 -16
- package/dist/contracts/auth.d.ts +20 -0
- package/dist/contracts/auth.js +18 -0
- package/dist/contracts/beta.d.ts +13 -0
- package/dist/contracts/beta.js +28 -0
- package/dist/contracts/billing.d.ts +2 -2
- package/dist/contracts/bootstrap.d.ts +23 -6
- package/dist/contracts/builds.d.ts +24 -4
- package/dist/contracts/builds.js +16 -4
- package/dist/contracts/channels.d.ts +43 -0
- package/dist/contracts/channels.js +22 -6
- package/dist/contracts/comments.d.ts +49 -0
- package/dist/contracts/comments.js +61 -2
- package/dist/contracts/commerce.d.ts +19 -13
- package/dist/contracts/connector-access.d.ts +28 -0
- package/dist/contracts/connector-access.js +31 -0
- package/dist/contracts/connectors.d.ts +2382 -0
- package/dist/contracts/connectors.js +941 -0
- package/dist/contracts/content-contract-verification.d.ts +112 -58
- package/dist/contracts/content-contract-verification.js +42 -54
- package/dist/contracts/content-model-emit.d.ts +97 -0
- package/dist/contracts/content-model-emit.js +306 -0
- package/dist/contracts/content-model-sdk.d.ts +101 -0
- package/dist/contracts/content-model-sdk.js +232 -0
- package/dist/contracts/{content-program.d.ts → content-model.d.ts} +338 -82
- package/dist/contracts/{content-program.js → content-model.js} +291 -63
- package/dist/contracts/content-platform-fixture.d.ts +380 -110
- package/dist/contracts/content-platform-fixture.js +8 -8
- package/dist/contracts/content-sync.d.ts +197 -74
- package/dist/contracts/content-sync.js +98 -37
- package/dist/contracts/content.d.ts +30 -422
- package/dist/contracts/content.js +34 -294
- package/dist/contracts/dashboard-prefs.d.ts +10 -3
- package/dist/contracts/dashboard-prefs.js +6 -3
- package/dist/contracts/data-location.d.ts +9 -0
- package/dist/contracts/data-location.js +7 -0
- package/dist/contracts/deployment-comparison.d.ts +67 -0
- package/dist/contracts/deployment-comparison.js +68 -0
- package/dist/contracts/device-auth.d.ts +55 -11
- package/dist/contracts/domains.d.ts +40 -16
- package/dist/contracts/domains.js +23 -0
- package/dist/contracts/enums.d.ts +1 -10
- package/dist/contracts/enums.js +0 -15
- package/dist/contracts/error-code-meta.d.ts +388 -20
- package/dist/contracts/error-code-meta.js +201 -5
- package/dist/contracts/error-codes.d.ts +17 -4
- package/dist/contracts/error-codes.js +109 -10
- package/dist/contracts/events.d.ts +5 -0
- package/dist/contracts/events.js +12 -3
- package/dist/contracts/execution.d.ts +5 -1
- package/dist/contracts/execution.js +4 -0
- package/dist/contracts/feature-lifecycle.d.ts +53 -20
- package/dist/contracts/feature-lifecycle.js +65 -23
- package/dist/contracts/features.d.ts +57 -31
- package/dist/contracts/features.js +0 -1
- package/dist/contracts/feedback.d.ts +124 -0
- package/dist/contracts/feedback.js +64 -0
- package/dist/contracts/fixtures/content-model-sdk-v1.generated.d.ts +129 -0
- package/dist/contracts/fixtures/content-model-sdk-v1.generated.js +48 -0
- package/dist/contracts/fixtures/content-platform-v1.json +101 -49
- package/dist/contracts/frame-session.d.ts +60 -10
- package/dist/contracts/frame-session.js +52 -12
- package/dist/contracts/functions.d.ts +28 -2
- package/dist/contracts/functions.js +25 -2
- package/dist/contracts/grant-copy.d.ts +2 -0
- package/dist/contracts/grant-copy.js +2 -0
- package/dist/contracts/grants-core.d.ts +95 -0
- package/dist/contracts/grants-core.js +435 -0
- package/dist/contracts/grants.d.ts +13 -84
- package/dist/contracts/grants.js +21 -369
- package/dist/contracts/ids-core.d.ts +11 -0
- package/dist/contracts/ids-core.js +14 -0
- package/dist/contracts/ids.d.ts +7 -4
- package/dist/contracts/ids.js +12 -4
- package/dist/contracts/internal.d.ts +18 -0
- package/dist/contracts/internal.js +19 -0
- package/dist/contracts/mcp.d.ts +8 -18
- package/dist/contracts/mcp.js +2 -23
- package/dist/contracts/notifications.d.ts +4 -1
- package/dist/contracts/notifications.js +1 -0
- package/dist/contracts/oauth-resources.d.ts +55 -9
- package/dist/contracts/oauth-resources.js +64 -1
- package/dist/contracts/oauth-scope-actions.d.ts +27 -3
- package/dist/contracts/oauth-scope-actions.js +18 -8
- package/dist/contracts/operations.d.ts +1 -1
- package/dist/contracts/partner-account.d.ts +629 -0
- package/dist/contracts/partner-account.js +18 -0
- package/dist/contracts/principal-assertion.d.ts +74 -1
- package/dist/contracts/principal-assertion.js +67 -3
- package/dist/contracts/publish-archive.d.ts +22 -1
- package/dist/contracts/push-new.d.ts +3 -3
- package/dist/contracts/push-new.js +1 -1
- package/dist/contracts/quotas.js +2 -1
- package/dist/contracts/repository-connections.d.ts +10 -6
- package/dist/contracts/repository-connections.js +15 -0
- package/dist/contracts/resources.d.ts +6 -5
- package/dist/contracts/resources.js +7 -0
- package/dist/contracts/route-inventory.d.ts +74 -19
- package/dist/contracts/route-inventory.js +20 -6
- package/dist/contracts/runtime-api.d.ts +415 -4
- package/dist/contracts/runtime-api.js +60 -15
- package/dist/contracts/runtime-app.d.ts +6 -1
- package/dist/contracts/runtime-components.d.ts +646 -18
- package/dist/contracts/runtime-components.js +304 -188
- package/dist/contracts/runtime-services.d.ts +15 -0
- package/dist/contracts/runtime-services.js +25 -0
- package/dist/contracts/runtime-storage.d.ts +32 -0
- package/dist/contracts/runtime-storage.js +37 -0
- package/dist/contracts/source-workspaces.d.ts +511 -0
- package/dist/contracts/source-workspaces.js +276 -0
- package/dist/contracts/space-config-spacefast.d.ts +394 -0
- package/dist/contracts/space-config-spacefast.js +70 -0
- package/dist/contracts/space-config.d.ts +177 -90
- package/dist/contracts/space-config.js +77 -92
- package/dist/contracts/spaces.d.ts +132 -24
- package/dist/contracts/spaces.js +77 -13
- package/dist/contracts/superadmin-connectors.d.ts +371 -0
- package/dist/contracts/superadmin-connectors.js +61 -0
- package/dist/contracts/superadmin-emails.d.ts +1 -1
- package/dist/contracts/superadmin-emails.js +1 -1
- package/dist/contracts/superadmin-entities.d.ts +105 -0
- package/dist/contracts/superadmin-entities.js +64 -0
- package/dist/contracts/superadmin-runtime.d.ts +35 -116
- package/dist/contracts/superadmin-runtime.js +13 -69
- package/dist/contracts/superadmin-search.d.ts +12 -14
- package/dist/contracts/superadmin-search.js +2 -2
- package/dist/contracts/superadmin-spaces.d.ts +15 -72
- package/dist/contracts/superadmin-spaces.js +2 -7
- package/dist/contracts/superadmin-teams.d.ts +12 -0
- package/dist/contracts/superadmin-teams.js +7 -1
- package/dist/contracts/superadmin-tenants.d.ts +44 -16
- package/dist/contracts/superadmin.d.ts +2 -2
- package/dist/contracts/tags.d.ts +12 -12
- package/dist/contracts/teams.d.ts +29 -1
- package/dist/contracts/teams.js +24 -2
- package/dist/contracts/tenants.d.ts +98 -0
- package/dist/contracts/tenants.js +20 -0
- package/dist/contracts/transfers.d.ts +92 -0
- package/dist/contracts/transfers.js +37 -0
- package/dist/contracts/usage.d.ts +9 -1
- package/dist/contracts/usage.js +2 -0
- package/dist/contracts/visual-review.d.ts +448 -0
- package/dist/contracts/visual-review.js +156 -0
- package/dist/contracts/wordpress-php-toolkit.json +9 -0
- package/dist/contracts/work-mode.d.ts +24 -0
- package/dist/contracts/work-mode.js +17 -0
- package/dist/contracts/wp-cli.d.ts +66 -0
- package/dist/contracts/wp-cli.js +68 -0
- package/dist/contracts/zero-catalog.d.ts +29 -0
- package/dist/contracts/zero-catalog.js +55 -0
- package/dist/contracts/zero-platform-abilities.generated.d.ts +31 -0
- package/dist/contracts/zero-platform-abilities.generated.js +373 -0
- package/dist/contracts/zero-spacefast.d.ts +444 -0
- package/dist/contracts/zero-spacefast.js +149 -0
- package/dist/contracts/zero-types.d.ts +47 -0
- package/dist/contracts/zero-types.js +263 -0
- package/dist/contracts/zero.d.ts +781 -14
- package/dist/contracts/zero.js +204 -10
- package/dist/dashboard-paths/index.d.ts +2 -2
- package/dist/dashboard-paths/route-reservations.generated.d.ts +2 -2
- package/dist/dashboard-paths/route-reservations.generated.js +5 -0
- package/dist/docs/agent-prose.d.ts +1 -1
- package/dist/docs/agent-prose.js +15 -18
- package/dist/docs/agent-setup.d.ts +1 -1
- package/dist/docs/agent-setup.js +5 -13
- package/dist/docs/catalog.d.ts +64 -28
- package/dist/docs/catalog.js +155 -28
- package/dist/docs/error-docs.d.ts +365 -17
- package/dist/docs/error-docs.js +369 -21
- package/dist/docs/reference-urls.js +1 -1
- package/dist/docs/skills.d.ts +84 -84
- package/dist/docs/skills.js +66 -47
- package/dist/docs/start-prompts.d.ts +14 -0
- package/dist/docs/start-prompts.js +20 -0
- package/dist/utils/account-labels.d.ts +7 -0
- package/dist/utils/account-labels.js +15 -0
- package/dist/utils/auth.d.ts +1 -0
- package/dist/utils/auth.js +1 -0
- package/dist/utils/credential-policy.d.ts +22 -1
- package/dist/utils/credential-policy.js +55 -6
- package/dist/utils/local-space-state.d.ts +7 -0
- package/dist/utils/local-space-state.js +7 -0
- package/dist/utils/logger.d.ts +34 -0
- package/dist/utils/logger.js +144 -0
- package/dist/utils/page-routes.d.ts +9 -0
- package/dist/utils/page-routes.js +82 -0
- package/dist/utils/pages.d.ts +2 -0
- package/dist/utils/pages.js +7 -0
- package/dist/utils/publish-form-data.d.ts +2 -0
- package/dist/utils/publish-form-data.js +2 -0
- package/dist/utils/publish-policy-spacefast.d.ts +13 -0
- package/dist/utils/publish-policy-spacefast.js +117 -0
- package/dist/utils/publish-policy.d.ts +22 -16
- package/dist/utils/publish-policy.fixtures.json +15 -0
- package/dist/utils/publish-policy.js +62 -139
- package/dist/utils/query-client.js +9 -1
- package/dist/utils/runtime-upload.d.ts +4 -0
- package/dist/utils/runtime-upload.js +5 -0
- package/dist/utils/space-config.d.ts +2 -3
- package/dist/utils/space-config.js +1 -1
- package/dist/utils/uploaded-source.d.ts +4 -0
- package/dist/utils/uploaded-source.js +12 -0
- package/dist/visual-review.d.ts +4 -0
- package/dist/visual-review.js +208 -0
- package/dist/vocabulary.d.ts +38 -0
- package/dist/vocabulary.js +55 -0
- package/package.json +7 -2
- package/dist/agents/registry/deeplink-probes.d.ts +0 -23
- package/dist/agents/registry/deeplink-probes.js +0 -18
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Bounds on the Space-scoped bearer a control-plane caller mints for an agent.
|
|
4
|
+
*
|
|
5
|
+
* Short enough that a leaked bearer expires before it is worth passing around,
|
|
6
|
+
* long enough for one agent session's worth of REST calls. The default is what
|
|
7
|
+
* `sf zero` asks for when nobody chose.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SPACE_ZERO_TOKEN_MIN_TTL_SECONDS = 60;
|
|
10
|
+
export declare const SPACE_ZERO_TOKEN_MAX_TTL_SECONDS = 3600;
|
|
11
|
+
export declare const SPACE_ZERO_TOKEN_DEFAULT_TTL_SECONDS = 900;
|
|
12
|
+
export declare const spaceZeroTokenRequestSchema: z.ZodObject<{
|
|
13
|
+
credentialId: z.ZodTemplateLiteral<`mch_${string}`>;
|
|
14
|
+
ttlSeconds: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export type SpaceZeroTokenRequest = z.infer<typeof spaceZeroTokenRequestSchema>;
|
|
17
|
+
export declare const spaceZeroTokenSchema: z.ZodObject<{
|
|
18
|
+
token: z.ZodString;
|
|
19
|
+
expiresAt: z.ZodString;
|
|
20
|
+
host: z.ZodString;
|
|
21
|
+
endpoint: z.ZodString;
|
|
22
|
+
credentialId: z.ZodTemplateLiteral<`mch_${string}`>;
|
|
23
|
+
capabilities: z.ZodArray<z.ZodEnum<{
|
|
24
|
+
"page.view": "page.view";
|
|
25
|
+
"comments.read": "comments.read";
|
|
26
|
+
"comments.write": "comments.write";
|
|
27
|
+
"content.publish": "content.publish";
|
|
28
|
+
"access.manage": "access.manage";
|
|
29
|
+
}>>;
|
|
30
|
+
role: z.ZodNullable<z.ZodEnum<{
|
|
31
|
+
editor: "editor";
|
|
32
|
+
subscriber: "subscriber";
|
|
33
|
+
administrator: "administrator";
|
|
34
|
+
}>>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
export type SpaceZeroToken = z.infer<typeof spaceZeroTokenSchema>;
|
|
37
|
+
/**
|
|
38
|
+
* What a caller must hold to reach an Ability.
|
|
39
|
+
*
|
|
40
|
+
* The two Ability origins authorize in two different vocabularies, and
|
|
41
|
+
* flattening them would say something false. A content-model Ability names
|
|
42
|
+
* Spacefast Grant capabilities, which the runtime checks against the
|
|
43
|
+
* capabilities this request's Grant carries. A platform Ability names one
|
|
44
|
+
* WordPress capability and lets WordPress decide, through the role
|
|
45
|
+
* content-principals.php projects from that same Grant. Same origin story, two
|
|
46
|
+
* different words — so the row says which one it is rather than pretending
|
|
47
|
+
* `upload_files` and a Grant capability are the same kind of thing.
|
|
48
|
+
*/
|
|
49
|
+
export declare const spaceZeroAbilityRequirementSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<"grant">;
|
|
51
|
+
capabilities: z.ZodArray<z.ZodString>;
|
|
52
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
53
|
+
kind: z.ZodLiteral<"wordpress">;
|
|
54
|
+
capability: z.ZodString;
|
|
55
|
+
}, z.core.$strict>], "kind">;
|
|
56
|
+
export type SpaceZeroAbilityRequirement = z.infer<typeof spaceZeroAbilityRequirementSchema>;
|
|
57
|
+
/**
|
|
58
|
+
* One Ability a Space publishes, across every set it publishes one from.
|
|
59
|
+
*
|
|
60
|
+
* Two origins answer here and the row is deliberately uniform over both.
|
|
61
|
+
* Content-model Abilities are compiled at publish and bound to the version, so
|
|
62
|
+
* the live version is the authority and a rollback moves them with it. The
|
|
63
|
+
* `zero-wp-users` and `zero-storage` sets are registered by the runtime
|
|
64
|
+
* engine's own PHP; the control plane reads them from a mirror generated out of
|
|
65
|
+
* those same registrations (scripts/emit-zero-abilities.php), so enumerating
|
|
66
|
+
* them here is not a second source of truth — it is the first one, projected.
|
|
67
|
+
*
|
|
68
|
+
* Schemas are resolved, not referenced. A content-model Ability's schemas live
|
|
69
|
+
* in the release's schema table behind a pointer; a platform Ability's are
|
|
70
|
+
* inline in PHP. The catalog resolves the pointer so every row describes itself
|
|
71
|
+
* the same way and one consumer can generate types from all of them.
|
|
72
|
+
*/
|
|
73
|
+
export declare const spaceZeroAbilitySchema: z.ZodObject<{
|
|
74
|
+
name: z.ZodString;
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
category: z.ZodString;
|
|
77
|
+
mode: z.ZodEnum<{
|
|
78
|
+
read: "read";
|
|
79
|
+
write: "write";
|
|
80
|
+
}>;
|
|
81
|
+
requires: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
82
|
+
kind: z.ZodLiteral<"grant">;
|
|
83
|
+
capabilities: z.ZodArray<z.ZodString>;
|
|
84
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
85
|
+
kind: z.ZodLiteral<"wordpress">;
|
|
86
|
+
capability: z.ZodString;
|
|
87
|
+
}, z.core.$strict>], "kind">;
|
|
88
|
+
inputSchema: z.ZodNullable<z.ZodType<import("./content-model.js").ContentModelJsonValue, unknown, z.core.$ZodTypeInternals<import("./content-model.js").ContentModelJsonValue, unknown>>>;
|
|
89
|
+
outputSchema: z.ZodNullable<z.ZodType<import("./content-model.js").ContentModelJsonValue, unknown, z.core.$ZodTypeInternals<import("./content-model.js").ContentModelJsonValue, unknown>>>;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
export type SpaceZeroAbility = z.infer<typeof spaceZeroAbilitySchema>;
|
|
92
|
+
/**
|
|
93
|
+
* The content model the Space's live version publishes, whole.
|
|
94
|
+
*
|
|
95
|
+
* `listSpaceZeroAbilities` answers what an agent can call; this answers what
|
|
96
|
+
* the shapes are, in the form a type generator needs — the compiled release
|
|
97
|
+
* itself, schema table and all. The two are deliberately separate reads: the
|
|
98
|
+
* catalog is what a person or agent browses, and this is a build input that
|
|
99
|
+
* only a toolchain asks for.
|
|
100
|
+
*
|
|
101
|
+
* `versionId` is what the answer came from, so a generated artifact can name
|
|
102
|
+
* its source and a `--check` can say what moved. A Space with no live version,
|
|
103
|
+
* or a live version that declares no content model, answers with nulls rather
|
|
104
|
+
* than a 404: having no content model is an ordinary state, not a missing
|
|
105
|
+
* resource.
|
|
106
|
+
*/
|
|
107
|
+
export declare const spaceZeroContentModelSchema: z.ZodObject<{
|
|
108
|
+
versionId: z.ZodNullable<z.ZodString>;
|
|
109
|
+
model: z.ZodNullable<z.ZodObject<{
|
|
110
|
+
format: z.ZodLiteral<"spacefast.zero-wordpress">;
|
|
111
|
+
version: z.ZodLiteral<1>;
|
|
112
|
+
revision: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
113
|
+
schemas: z.ZodArray<z.ZodObject<{
|
|
114
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSchemaId", "out">;
|
|
115
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
116
|
+
schema: z.ZodType<import("./content-model.js").ContentModelJsonValue, unknown, z.core.$ZodTypeInternals<import("./content-model.js").ContentModelJsonValue, unknown>>;
|
|
117
|
+
}, z.core.$strict>>;
|
|
118
|
+
wordpress: z.ZodObject<{
|
|
119
|
+
format: z.ZodLiteral<"spacefast.wordpress-content-model">;
|
|
120
|
+
version: z.ZodLiteral<1>;
|
|
121
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
122
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentResourceId", "out">;
|
|
123
|
+
name: z.ZodString;
|
|
124
|
+
label: z.ZodString;
|
|
125
|
+
kind: z.ZodEnum<{
|
|
126
|
+
media: "media";
|
|
127
|
+
collection: "collection";
|
|
128
|
+
posts: "posts";
|
|
129
|
+
pages: "pages";
|
|
130
|
+
}>;
|
|
131
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
132
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentFieldId", "out">;
|
|
133
|
+
name: z.ZodString;
|
|
134
|
+
label: z.ZodString;
|
|
135
|
+
required: z.ZodBoolean;
|
|
136
|
+
value: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
137
|
+
kind: z.ZodLiteral<"text">;
|
|
138
|
+
multiline: z.ZodBoolean;
|
|
139
|
+
maxLength: z.ZodNullable<z.ZodNumber>;
|
|
140
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
+
kind: z.ZodLiteral<"number">;
|
|
142
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
143
|
+
kind: z.ZodLiteral<"boolean">;
|
|
144
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
145
|
+
kind: z.ZodLiteral<"datetime">;
|
|
146
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
147
|
+
kind: z.ZodLiteral<"blocks">;
|
|
148
|
+
allowed: z.ZodUnion<readonly [z.ZodLiteral<"any">, z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentComponentId", "out">>]>;
|
|
149
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
150
|
+
kind: z.ZodLiteral<"media">;
|
|
151
|
+
multiple: z.ZodBoolean;
|
|
152
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
153
|
+
kind: z.ZodLiteral<"reference">;
|
|
154
|
+
target: z.core.$ZodBranded<z.ZodString, "ContentResourceId", "out">;
|
|
155
|
+
multiple: z.ZodBoolean;
|
|
156
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
157
|
+
kind: z.ZodLiteral<"enum">;
|
|
158
|
+
values: z.ZodArray<z.ZodString>;
|
|
159
|
+
multiple: z.ZodBoolean;
|
|
160
|
+
}, z.core.$strict>], "kind">;
|
|
161
|
+
}, z.core.$strict>>;
|
|
162
|
+
publicRead: z.ZodBoolean;
|
|
163
|
+
}, z.core.$strict>>;
|
|
164
|
+
}, z.core.$strict>;
|
|
165
|
+
tables: z.ZodArray<z.ZodObject<{
|
|
166
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentTableId", "out">;
|
|
167
|
+
name: z.ZodString;
|
|
168
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
169
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentFieldId", "out">;
|
|
170
|
+
name: z.ZodString;
|
|
171
|
+
nullable: z.ZodBoolean;
|
|
172
|
+
value: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
173
|
+
kind: z.ZodLiteral<"string">;
|
|
174
|
+
maxLength: z.ZodNullable<z.ZodNumber>;
|
|
175
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
176
|
+
kind: z.ZodLiteral<"number">;
|
|
177
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
178
|
+
kind: z.ZodLiteral<"boolean">;
|
|
179
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
180
|
+
kind: z.ZodLiteral<"datetime">;
|
|
181
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
182
|
+
kind: z.ZodLiteral<"json">;
|
|
183
|
+
}, z.core.$strict>], "kind">;
|
|
184
|
+
}, z.core.$strict>>;
|
|
185
|
+
indexes: z.ZodArray<z.ZodObject<{
|
|
186
|
+
id: z.ZodString;
|
|
187
|
+
fields: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentFieldId", "out">>;
|
|
188
|
+
unique: z.ZodBoolean;
|
|
189
|
+
}, z.core.$strict>>;
|
|
190
|
+
}, z.core.$strict>>;
|
|
191
|
+
abilities: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
192
|
+
kind: z.ZodLiteral<"query">;
|
|
193
|
+
mode: z.ZodLiteral<"read">;
|
|
194
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentAbilityId", "out">;
|
|
195
|
+
input: z.ZodObject<{
|
|
196
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSchemaId", "out">;
|
|
197
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
198
|
+
}, z.core.$strict>;
|
|
199
|
+
output: z.ZodObject<{
|
|
200
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSchemaId", "out">;
|
|
201
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
202
|
+
}, z.core.$strict>;
|
|
203
|
+
permits: z.ZodArray<z.ZodEnum<{
|
|
204
|
+
"page.view": "page.view";
|
|
205
|
+
"comments.read": "comments.read";
|
|
206
|
+
"comments.write": "comments.write";
|
|
207
|
+
"content.publish": "content.publish";
|
|
208
|
+
"access.manage": "access.manage";
|
|
209
|
+
}>>;
|
|
210
|
+
reads: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentResourceRef", "out">>;
|
|
211
|
+
writes: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentResourceRef", "out">>;
|
|
212
|
+
exposure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
213
|
+
kind: z.ZodLiteral<"named">;
|
|
214
|
+
named: z.ZodLiteral<true>;
|
|
215
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
216
|
+
kind: z.ZodLiteral<"routed">;
|
|
217
|
+
named: z.ZodLiteral<true>;
|
|
218
|
+
route: z.ZodObject<{
|
|
219
|
+
id: z.ZodString;
|
|
220
|
+
method: z.ZodEnum<{
|
|
221
|
+
POST: "POST";
|
|
222
|
+
PUT: "PUT";
|
|
223
|
+
GET: "GET";
|
|
224
|
+
HEAD: "HEAD";
|
|
225
|
+
PATCH: "PATCH";
|
|
226
|
+
DELETE: "DELETE";
|
|
227
|
+
OPTIONS: "OPTIONS";
|
|
228
|
+
}>;
|
|
229
|
+
path: z.ZodString;
|
|
230
|
+
admission: z.ZodEnum<{
|
|
231
|
+
public: "public";
|
|
232
|
+
authenticated: "authenticated";
|
|
233
|
+
}>;
|
|
234
|
+
}, z.core.$strict>;
|
|
235
|
+
}, z.core.$strict>], "kind">;
|
|
236
|
+
cache: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
237
|
+
kind: z.ZodLiteral<"none">;
|
|
238
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
239
|
+
kind: z.ZodLiteral<"private">;
|
|
240
|
+
maxAgeSeconds: z.ZodNumber;
|
|
241
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
242
|
+
kind: z.ZodLiteral<"public">;
|
|
243
|
+
maxAgeSeconds: z.ZodNumber;
|
|
244
|
+
staleWhileRevalidateSeconds: z.ZodNumber;
|
|
245
|
+
}, z.core.$strict>], "kind">;
|
|
246
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
247
|
+
kind: z.ZodLiteral<"mutation">;
|
|
248
|
+
mode: z.ZodLiteral<"write">;
|
|
249
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentAbilityId", "out">;
|
|
250
|
+
input: z.ZodObject<{
|
|
251
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSchemaId", "out">;
|
|
252
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
253
|
+
}, z.core.$strict>;
|
|
254
|
+
output: z.ZodObject<{
|
|
255
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSchemaId", "out">;
|
|
256
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
257
|
+
}, z.core.$strict>;
|
|
258
|
+
permits: z.ZodArray<z.ZodEnum<{
|
|
259
|
+
"page.view": "page.view";
|
|
260
|
+
"comments.read": "comments.read";
|
|
261
|
+
"comments.write": "comments.write";
|
|
262
|
+
"content.publish": "content.publish";
|
|
263
|
+
"access.manage": "access.manage";
|
|
264
|
+
}>>;
|
|
265
|
+
reads: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentResourceRef", "out">>;
|
|
266
|
+
writes: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentResourceRef", "out">>;
|
|
267
|
+
exposure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
268
|
+
kind: z.ZodLiteral<"named">;
|
|
269
|
+
named: z.ZodLiteral<true>;
|
|
270
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
271
|
+
kind: z.ZodLiteral<"routed">;
|
|
272
|
+
named: z.ZodLiteral<true>;
|
|
273
|
+
route: z.ZodObject<{
|
|
274
|
+
id: z.ZodString;
|
|
275
|
+
method: z.ZodEnum<{
|
|
276
|
+
POST: "POST";
|
|
277
|
+
PUT: "PUT";
|
|
278
|
+
GET: "GET";
|
|
279
|
+
HEAD: "HEAD";
|
|
280
|
+
PATCH: "PATCH";
|
|
281
|
+
DELETE: "DELETE";
|
|
282
|
+
OPTIONS: "OPTIONS";
|
|
283
|
+
}>;
|
|
284
|
+
path: z.ZodString;
|
|
285
|
+
admission: z.ZodEnum<{
|
|
286
|
+
public: "public";
|
|
287
|
+
authenticated: "authenticated";
|
|
288
|
+
}>;
|
|
289
|
+
}, z.core.$strict>;
|
|
290
|
+
}, z.core.$strict>], "kind">;
|
|
291
|
+
cache: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
292
|
+
kind: z.ZodLiteral<"none">;
|
|
293
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
294
|
+
kind: z.ZodLiteral<"private">;
|
|
295
|
+
maxAgeSeconds: z.ZodNumber;
|
|
296
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
297
|
+
kind: z.ZodLiteral<"public">;
|
|
298
|
+
maxAgeSeconds: z.ZodNumber;
|
|
299
|
+
staleWhileRevalidateSeconds: z.ZodNumber;
|
|
300
|
+
}, z.core.$strict>], "kind">;
|
|
301
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
302
|
+
kind: z.ZodLiteral<"endpoint">;
|
|
303
|
+
mode: z.ZodEnum<{
|
|
304
|
+
read: "read";
|
|
305
|
+
write: "write";
|
|
306
|
+
}>;
|
|
307
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentAbilityId", "out">;
|
|
308
|
+
input: z.ZodObject<{
|
|
309
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSchemaId", "out">;
|
|
310
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
311
|
+
}, z.core.$strict>;
|
|
312
|
+
output: z.ZodObject<{
|
|
313
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSchemaId", "out">;
|
|
314
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
315
|
+
}, z.core.$strict>;
|
|
316
|
+
permits: z.ZodArray<z.ZodEnum<{
|
|
317
|
+
"page.view": "page.view";
|
|
318
|
+
"comments.read": "comments.read";
|
|
319
|
+
"comments.write": "comments.write";
|
|
320
|
+
"content.publish": "content.publish";
|
|
321
|
+
"access.manage": "access.manage";
|
|
322
|
+
}>>;
|
|
323
|
+
reads: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentResourceRef", "out">>;
|
|
324
|
+
writes: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentResourceRef", "out">>;
|
|
325
|
+
exposure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
326
|
+
kind: z.ZodLiteral<"named">;
|
|
327
|
+
named: z.ZodLiteral<true>;
|
|
328
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
329
|
+
kind: z.ZodLiteral<"routed">;
|
|
330
|
+
named: z.ZodLiteral<true>;
|
|
331
|
+
route: z.ZodObject<{
|
|
332
|
+
id: z.ZodString;
|
|
333
|
+
method: z.ZodEnum<{
|
|
334
|
+
POST: "POST";
|
|
335
|
+
PUT: "PUT";
|
|
336
|
+
GET: "GET";
|
|
337
|
+
HEAD: "HEAD";
|
|
338
|
+
PATCH: "PATCH";
|
|
339
|
+
DELETE: "DELETE";
|
|
340
|
+
OPTIONS: "OPTIONS";
|
|
341
|
+
}>;
|
|
342
|
+
path: z.ZodString;
|
|
343
|
+
admission: z.ZodEnum<{
|
|
344
|
+
public: "public";
|
|
345
|
+
authenticated: "authenticated";
|
|
346
|
+
}>;
|
|
347
|
+
}, z.core.$strict>;
|
|
348
|
+
}, z.core.$strict>], "kind">;
|
|
349
|
+
cache: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
350
|
+
kind: z.ZodLiteral<"none">;
|
|
351
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
352
|
+
kind: z.ZodLiteral<"private">;
|
|
353
|
+
maxAgeSeconds: z.ZodNumber;
|
|
354
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
355
|
+
kind: z.ZodLiteral<"public">;
|
|
356
|
+
maxAgeSeconds: z.ZodNumber;
|
|
357
|
+
staleWhileRevalidateSeconds: z.ZodNumber;
|
|
358
|
+
}, z.core.$strict>], "kind">;
|
|
359
|
+
}, z.core.$strict>], "kind">>;
|
|
360
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
361
|
+
id: z.ZodString;
|
|
362
|
+
sourceKey: z.ZodString;
|
|
363
|
+
path: z.ZodString;
|
|
364
|
+
title: z.ZodString;
|
|
365
|
+
blockName: z.ZodLiteral<"zero/component">;
|
|
366
|
+
componentId: z.core.$ZodBranded<z.ZodString, "ContentComponentId", "out">;
|
|
367
|
+
props: z.ZodObject<{
|
|
368
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSchemaId", "out">;
|
|
369
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
370
|
+
}, z.core.$strict>;
|
|
371
|
+
}, z.core.$strict>>;
|
|
372
|
+
hooks: z.ZodArray<z.ZodObject<{
|
|
373
|
+
id: z.ZodString;
|
|
374
|
+
runtime: z.ZodEnum<{
|
|
375
|
+
php: "php";
|
|
376
|
+
quickjs: "quickjs";
|
|
377
|
+
}>;
|
|
378
|
+
artifact: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
379
|
+
export: z.ZodString;
|
|
380
|
+
}, z.core.$strict>>;
|
|
381
|
+
syncBindings: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
382
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentSyncBindingId", "out">;
|
|
383
|
+
resourceId: z.core.$ZodBranded<z.ZodString, "ContentResourceId", "out">;
|
|
384
|
+
fieldId: z.core.$ZodBranded<z.ZodString, "ContentFieldId", "out">;
|
|
385
|
+
source: z.ZodString;
|
|
386
|
+
publicPath: z.ZodOptional<z.ZodString>;
|
|
387
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
388
|
+
md: "md";
|
|
389
|
+
html: "html";
|
|
390
|
+
tsx: "tsx";
|
|
391
|
+
}>>;
|
|
392
|
+
compiled: z.ZodOptional<z.ZodObject<{
|
|
393
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
394
|
+
}, z.core.$strict>>;
|
|
395
|
+
documentSeed: z.ZodOptional<z.ZodObject<{
|
|
396
|
+
text: z.ZodString;
|
|
397
|
+
sha256: z.core.$ZodBranded<z.ZodString, "ContentModelSha256", "out">;
|
|
398
|
+
}, z.core.$strict>>;
|
|
399
|
+
slug: z.ZodString;
|
|
400
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
401
|
+
format: "md" | "html" | "tsx";
|
|
402
|
+
id: string & z.core.$brand<"ContentSyncBindingId">;
|
|
403
|
+
resourceId: string & z.core.$brand<"ContentResourceId">;
|
|
404
|
+
fieldId: string & z.core.$brand<"ContentFieldId">;
|
|
405
|
+
source: string;
|
|
406
|
+
slug: string;
|
|
407
|
+
publicPath?: string | undefined;
|
|
408
|
+
compiled?: {
|
|
409
|
+
sha256: string & z.core.$brand<"ContentModelSha256">;
|
|
410
|
+
} | undefined;
|
|
411
|
+
documentSeed?: {
|
|
412
|
+
text: string;
|
|
413
|
+
sha256: string & z.core.$brand<"ContentModelSha256">;
|
|
414
|
+
} | undefined;
|
|
415
|
+
}, {
|
|
416
|
+
id: string & z.core.$brand<"ContentSyncBindingId">;
|
|
417
|
+
resourceId: string & z.core.$brand<"ContentResourceId">;
|
|
418
|
+
fieldId: string & z.core.$brand<"ContentFieldId">;
|
|
419
|
+
source: string;
|
|
420
|
+
slug: string;
|
|
421
|
+
publicPath?: string | undefined;
|
|
422
|
+
format?: "md" | "html" | "tsx" | undefined;
|
|
423
|
+
compiled?: {
|
|
424
|
+
sha256: string & z.core.$brand<"ContentModelSha256">;
|
|
425
|
+
} | undefined;
|
|
426
|
+
documentSeed?: {
|
|
427
|
+
text: string;
|
|
428
|
+
sha256: string & z.core.$brand<"ContentModelSha256">;
|
|
429
|
+
} | undefined;
|
|
430
|
+
}>>>;
|
|
431
|
+
materializations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
432
|
+
resourceId: z.core.$ZodBranded<z.ZodString, "ContentResourceId", "out">;
|
|
433
|
+
fieldId: z.core.$ZodBranded<z.ZodString, "ContentFieldId", "out">;
|
|
434
|
+
directory: z.ZodString;
|
|
435
|
+
suffix: z.ZodString;
|
|
436
|
+
format: z.ZodEnum<{
|
|
437
|
+
md: "md";
|
|
438
|
+
html: "html";
|
|
439
|
+
tsx: "tsx";
|
|
440
|
+
}>;
|
|
441
|
+
}, z.core.$strict>>>;
|
|
442
|
+
}, z.core.$strict>>;
|
|
443
|
+
}, z.core.$strict>;
|
|
444
|
+
export type SpaceZeroContentModel = z.infer<typeof spaceZeroContentModelSchema>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { contentModelJsonValueSchema, contentModelReleaseV1Schema } from "./content-model.js";
|
|
3
|
+
import { grantCapabilitySchema } from "./grants-core.js";
|
|
4
|
+
import { registeredIdSchema } from "./ids.js";
|
|
5
|
+
import { wordpressPrincipalRoleSchema } from "./principal-assertion.js";
|
|
6
|
+
// Spacefast's Zero surface: the control-plane API a Space's Zero capsule is
|
|
7
|
+
// reached THROUGH — agent bearers minted against a Space's machine credential,
|
|
8
|
+
// the Ability catalog a Space publishes, the content model a live version
|
|
9
|
+
// carries. Every shape here names a host resource (a Space, a credential, a
|
|
10
|
+
// Grant), which is why it is not part of the framework contract in `./zero.js`.
|
|
11
|
+
/**
|
|
12
|
+
* Bounds on the Space-scoped bearer a control-plane caller mints for an agent.
|
|
13
|
+
*
|
|
14
|
+
* Short enough that a leaked bearer expires before it is worth passing around,
|
|
15
|
+
* long enough for one agent session's worth of REST calls. The default is what
|
|
16
|
+
* `sf zero` asks for when nobody chose.
|
|
17
|
+
*/
|
|
18
|
+
export const SPACE_ZERO_TOKEN_MIN_TTL_SECONDS = 60;
|
|
19
|
+
export const SPACE_ZERO_TOKEN_MAX_TTL_SECONDS = 3_600;
|
|
20
|
+
export const SPACE_ZERO_TOKEN_DEFAULT_TTL_SECONDS = 900;
|
|
21
|
+
export const spaceZeroTokenRequestSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
credentialId: registeredIdSchema("mch").describe("A live machine credential of this Space. Its canonical scoped Grant is the authority the Space's own runtime re-derives the WordPress role from."),
|
|
24
|
+
ttlSeconds: z
|
|
25
|
+
.number()
|
|
26
|
+
.int()
|
|
27
|
+
.min(SPACE_ZERO_TOKEN_MIN_TTL_SECONDS)
|
|
28
|
+
.max(SPACE_ZERO_TOKEN_MAX_TTL_SECONDS)
|
|
29
|
+
.default(SPACE_ZERO_TOKEN_DEFAULT_TTL_SECONDS)
|
|
30
|
+
.describe("How long the bearer stays valid, in seconds."),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
export const spaceZeroTokenSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
token: z
|
|
36
|
+
.string()
|
|
37
|
+
.min(1)
|
|
38
|
+
.describe("Send as `X-SF-Authorization: Bearer <token>` to the Space's own REST surface — the plain Authorization header belongs to the customer's application and passes through untouched."),
|
|
39
|
+
expiresAt: z.string().datetime(),
|
|
40
|
+
host: z.string().min(1).describe("The serving host this bearer is bound to."),
|
|
41
|
+
endpoint: z.string().url().describe("The Space's WordPress REST root."),
|
|
42
|
+
credentialId: registeredIdSchema("mch"),
|
|
43
|
+
/**
|
|
44
|
+
* The named credential's Grant capabilities, which is what the serving
|
|
45
|
+
* Space re-derives its answer from. Re-derivation is per request and
|
|
46
|
+
* against the requested path, so a credential scoped away from a path
|
|
47
|
+
* answers there with less than this — never with more.
|
|
48
|
+
*/
|
|
49
|
+
capabilities: z.array(grantCapabilitySchema),
|
|
50
|
+
role: wordpressPrincipalRoleSchema
|
|
51
|
+
.nullable()
|
|
52
|
+
.describe("The WordPress role those capabilities project to, or null when the request would reach WordPress as nobody."),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
/**
|
|
56
|
+
* What a caller must hold to reach an Ability.
|
|
57
|
+
*
|
|
58
|
+
* The two Ability origins authorize in two different vocabularies, and
|
|
59
|
+
* flattening them would say something false. A content-model Ability names
|
|
60
|
+
* Spacefast Grant capabilities, which the runtime checks against the
|
|
61
|
+
* capabilities this request's Grant carries. A platform Ability names one
|
|
62
|
+
* WordPress capability and lets WordPress decide, through the role
|
|
63
|
+
* content-principals.php projects from that same Grant. Same origin story, two
|
|
64
|
+
* different words — so the row says which one it is rather than pretending
|
|
65
|
+
* `upload_files` and a Grant capability are the same kind of thing.
|
|
66
|
+
*/
|
|
67
|
+
export const spaceZeroAbilityRequirementSchema = z.discriminatedUnion("kind", [
|
|
68
|
+
z
|
|
69
|
+
.object({
|
|
70
|
+
kind: z.literal("grant"),
|
|
71
|
+
capabilities: z
|
|
72
|
+
.array(z.string().min(1))
|
|
73
|
+
.describe("Grant capabilities the caller must hold, all of them."),
|
|
74
|
+
})
|
|
75
|
+
.strict(),
|
|
76
|
+
z
|
|
77
|
+
.object({
|
|
78
|
+
kind: z.literal("wordpress"),
|
|
79
|
+
capability: z
|
|
80
|
+
.string()
|
|
81
|
+
.min(1)
|
|
82
|
+
.describe("The WordPress capability the Ability's permission callback asks for."),
|
|
83
|
+
})
|
|
84
|
+
.strict(),
|
|
85
|
+
]);
|
|
86
|
+
/**
|
|
87
|
+
* One Ability a Space publishes, across every set it publishes one from.
|
|
88
|
+
*
|
|
89
|
+
* Two origins answer here and the row is deliberately uniform over both.
|
|
90
|
+
* Content-model Abilities are compiled at publish and bound to the version, so
|
|
91
|
+
* the live version is the authority and a rollback moves them with it. The
|
|
92
|
+
* `zero-wp-users` and `zero-storage` sets are registered by the runtime
|
|
93
|
+
* engine's own PHP; the control plane reads them from a mirror generated out of
|
|
94
|
+
* those same registrations (scripts/emit-zero-abilities.php), so enumerating
|
|
95
|
+
* them here is not a second source of truth — it is the first one, projected.
|
|
96
|
+
*
|
|
97
|
+
* Schemas are resolved, not referenced. A content-model Ability's schemas live
|
|
98
|
+
* in the release's schema table behind a pointer; a platform Ability's are
|
|
99
|
+
* inline in PHP. The catalog resolves the pointer so every row describes itself
|
|
100
|
+
* the same way and one consumer can generate types from all of them.
|
|
101
|
+
*/
|
|
102
|
+
export const spaceZeroAbilitySchema = z
|
|
103
|
+
.object({
|
|
104
|
+
name: z.string().min(1).describe("The name WordPress publishes the Ability under."),
|
|
105
|
+
id: z
|
|
106
|
+
.string()
|
|
107
|
+
.min(1)
|
|
108
|
+
.describe("The Ability's product id, before the Abilities API's flattening — `content.projects.list` for `zero/content-projects-list`."),
|
|
109
|
+
// Every ability set lists here as the catalog widens (users, storage,
|
|
110
|
+
// future features) — a literal would refuse rows the runtime legitimately
|
|
111
|
+
// serves.
|
|
112
|
+
category: z.string().min(1),
|
|
113
|
+
mode: z.enum(["read", "write"]),
|
|
114
|
+
requires: spaceZeroAbilityRequirementSchema,
|
|
115
|
+
inputSchema: contentModelJsonValueSchema
|
|
116
|
+
.nullable()
|
|
117
|
+
.describe("JSON Schema for the Ability's input, or null when it declares none."),
|
|
118
|
+
outputSchema: contentModelJsonValueSchema
|
|
119
|
+
.nullable()
|
|
120
|
+
.describe("JSON Schema for the Ability's output, or null when it declares none."),
|
|
121
|
+
})
|
|
122
|
+
.strict();
|
|
123
|
+
/**
|
|
124
|
+
* The content model the Space's live version publishes, whole.
|
|
125
|
+
*
|
|
126
|
+
* `listSpaceZeroAbilities` answers what an agent can call; this answers what
|
|
127
|
+
* the shapes are, in the form a type generator needs — the compiled release
|
|
128
|
+
* itself, schema table and all. The two are deliberately separate reads: the
|
|
129
|
+
* catalog is what a person or agent browses, and this is a build input that
|
|
130
|
+
* only a toolchain asks for.
|
|
131
|
+
*
|
|
132
|
+
* `versionId` is what the answer came from, so a generated artifact can name
|
|
133
|
+
* its source and a `--check` can say what moved. A Space with no live version,
|
|
134
|
+
* or a live version that declares no content model, answers with nulls rather
|
|
135
|
+
* than a 404: having no content model is an ordinary state, not a missing
|
|
136
|
+
* resource.
|
|
137
|
+
*/
|
|
138
|
+
export const spaceZeroContentModelSchema = z
|
|
139
|
+
.object({
|
|
140
|
+
versionId: z
|
|
141
|
+
.string()
|
|
142
|
+
.min(1)
|
|
143
|
+
.nullable()
|
|
144
|
+
.describe("The live version this content model came from, or null when there is none."),
|
|
145
|
+
model: contentModelReleaseV1Schema
|
|
146
|
+
.nullable()
|
|
147
|
+
.describe("The compiled content model release, or null when the live version declares none."),
|
|
148
|
+
})
|
|
149
|
+
.strict();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module `sf zero types` writes into a Zero project.
|
|
3
|
+
*
|
|
4
|
+
* Three things a project's types depend on live in the platform rather than in
|
|
5
|
+
* the project's own source, and each one is only knowable by asking: the
|
|
6
|
+
* content model the live version compiled, the Ability catalog that version
|
|
7
|
+
* publishes alongside the engine's own sets, and the database schema the broker
|
|
8
|
+
* validates against. A capsule author can read all three from the dashboard and
|
|
9
|
+
* retype them by hand; this prints them instead.
|
|
10
|
+
*
|
|
11
|
+
* The output is self-contained on purpose — no imports, because it lands in
|
|
12
|
+
* someone else's project where a dependency on `@spacefast/common` would be an
|
|
13
|
+
* imposition. That is the same rule `contentModelSdkModule` follows, and its
|
|
14
|
+
* output is embedded here verbatim rather than re-derived: it already prints
|
|
15
|
+
* exactly the content-model half of this file.
|
|
16
|
+
*/
|
|
17
|
+
import type { ContentModelReleaseV1 } from "./content-model.js";
|
|
18
|
+
import type { SpaceZeroAbility } from "./zero-spacefast.js";
|
|
19
|
+
import type { ZeroTable } from "./zero.js";
|
|
20
|
+
/** Everything a pull read, and where it read it from. */
|
|
21
|
+
export type ZeroTypesSource = Readonly<{
|
|
22
|
+
/**
|
|
23
|
+
* The Space the types describe, or null for a local capsule compile.
|
|
24
|
+
*
|
|
25
|
+
* A project with no Space yet still has a content model and a database
|
|
26
|
+
* schema — its own, compiled locally — and the generated module is the same
|
|
27
|
+
* shape either way. What changes is what the header can honestly claim about
|
|
28
|
+
* where the types came from.
|
|
29
|
+
*/
|
|
30
|
+
space: Readonly<{
|
|
31
|
+
id: string;
|
|
32
|
+
slug: string;
|
|
33
|
+
}> | null;
|
|
34
|
+
/** The live version the content model and catalog came from, when there is one. */
|
|
35
|
+
versionId: string | null;
|
|
36
|
+
abilities: readonly SpaceZeroAbility[];
|
|
37
|
+
contentModel: ContentModelReleaseV1 | null;
|
|
38
|
+
tables: readonly ZeroTable[];
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Prints the whole `zero-types` module.
|
|
42
|
+
*
|
|
43
|
+
* Section order follows what a reader reaches for: the content model first
|
|
44
|
+
* because it is what most capsules are written against, then the Ability
|
|
45
|
+
* catalog that says what may be called and by whom, then the database rows.
|
|
46
|
+
*/
|
|
47
|
+
export declare function zeroTypesModule(source: ZeroTypesSource): string;
|