@anthusai/papyrus 5.9.0 → 5.11.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/amplify/data/resource.js +7 -3
- package/amplify/data/resource.ts +7 -3
- package/amplify/data/schema.js +2023 -1981
- package/amplify/data/schema.ts +50 -2
- package/amplify/site-backend-config.ts +7 -0
- package/amplify/site-backend.js +1 -1
- package/amplify/site-backend.ts +1 -1
- package/package.json +1 -1
- package/routes.manifest.json +1 -1
package/amplify/data/schema.ts
CHANGED
|
@@ -26,7 +26,27 @@ const modelWithoutSubscriptions = <Fields extends Parameters<typeof a.model>[0]>
|
|
|
26
26
|
a.model(fields).disableOperations(["subscriptions"]);
|
|
27
27
|
const realtimeModel = <Fields extends Parameters<typeof a.model>[0]>(fields: Fields) => a.model(fields);
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Model groups a site may leave out of its data API. CloudFormation creates at most 2,500 resources in one stack
|
|
31
|
+
* operation, nested stacks included, and the full model set exceeds that on a fresh create. A first deploy that
|
|
32
|
+
* excludes a group fits; a second deploy without the exclusion adds the models as an ordinary update.
|
|
33
|
+
*/
|
|
34
|
+
export const OPTIONAL_MODEL_GROUPS = {
|
|
35
|
+
editions: ["Edition", "EditionItem", "PublishedEdition", "PublishedEditionItem"],
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
export type OptionalModelGroup = keyof typeof OPTIONAL_MODEL_GROUPS;
|
|
39
|
+
|
|
40
|
+
export function assertKnownModelGroups(groups: readonly string[]): asserts groups is readonly OptionalModelGroup[] {
|
|
41
|
+
for (const group of groups) {
|
|
42
|
+
if (!(group in OPTIONAL_MODEL_GROUPS)) {
|
|
43
|
+
throw new Error(`Unknown model group "${group}"; known groups: ${Object.keys(OPTIONAL_MODEL_GROUPS).join(", ")}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function buildBaseDefinitions(includeEditions: boolean) {
|
|
49
|
+
const definitions = {
|
|
30
50
|
UserProfile: modelWithoutSubscriptions({
|
|
31
51
|
id: a.id().required(),
|
|
32
52
|
email: a.email(),
|
|
@@ -1799,7 +1819,7 @@ const baseDefinitions = {
|
|
|
1799
1819
|
updatedAt: a.datetime(),
|
|
1800
1820
|
tags: a.hasMany("ItemTag", "itemId"),
|
|
1801
1821
|
mediaAssets: a.hasMany("MediaAsset", "itemId"),
|
|
1802
|
-
editionItems: a.hasMany("EditionItem", "itemId"),
|
|
1822
|
+
...(includeEditions ? { editionItems: a.hasMany("EditionItem", "itemId") } : {}),
|
|
1803
1823
|
})
|
|
1804
1824
|
.secondaryIndexes((index) => [
|
|
1805
1825
|
index("lineageId").sortKeys(["versionNumber"]).queryField("listItemsByLineageAndVersion"),
|
|
@@ -2125,6 +2145,18 @@ const baseDefinitions = {
|
|
|
2125
2145
|
...editorialChecksSchemaDefinitions,
|
|
2126
2146
|
...monitoringViewSchemaDefinitions,
|
|
2127
2147
|
};
|
|
2148
|
+
if (!includeEditions) {
|
|
2149
|
+
const mutableDefinitions = definitions as Record<string, unknown>;
|
|
2150
|
+
for (const modelName of OPTIONAL_MODEL_GROUPS.editions) delete mutableDefinitions[modelName];
|
|
2151
|
+
}
|
|
2152
|
+
return definitions;
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
export function baseModelNames(excludedGroups: readonly OptionalModelGroup[] = []): string[] {
|
|
2156
|
+
return Object.keys(buildBaseDefinitions(!excludedGroups.includes("editions")));
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
const baseDefinitions = buildBaseDefinitions(true);
|
|
2128
2160
|
|
|
2129
2161
|
export const schema = a.schema(baseDefinitions).authorization((allow) => [
|
|
2130
2162
|
allow.resource(assignmentAction).to(["query", "mutate"]),
|
|
@@ -2150,4 +2182,20 @@ export function schemaWithPlugins(pluginDefinitions: Record<string, any>) {
|
|
|
2150
2182
|
]);
|
|
2151
2183
|
}
|
|
2152
2184
|
|
|
2185
|
+
/** The schema of a site that leaves optional model groups out of its first deploy. */
|
|
2186
|
+
export function schemaExcludingGroups(excludedGroups: readonly OptionalModelGroup[], pluginDefinitions: Record<string, any> = {}) {
|
|
2187
|
+
const definitions = buildBaseDefinitions(!excludedGroups.includes("editions")) as unknown as typeof baseDefinitions;
|
|
2188
|
+
const hasPlugins = Object.keys(pluginDefinitions).length > 0;
|
|
2189
|
+
return a.schema({ ...definitions, ...pluginDefinitions } as typeof baseDefinitions).authorization((allow) => [
|
|
2190
|
+
allow.resource(assignmentAction).to(["query", "mutate"]),
|
|
2191
|
+
allow.resource(categoryAction),
|
|
2192
|
+
allow.resource(contentActions),
|
|
2193
|
+
allow.resource(manageUserRole),
|
|
2194
|
+
allow.resource(modelAttachmentUpload),
|
|
2195
|
+
allow.resource(newsroomSummary),
|
|
2196
|
+
allow.resource(procedureAction),
|
|
2197
|
+
...(hasPlugins ? [] : [allow.resource(publicForms).to(["mutate"])]),
|
|
2198
|
+
]);
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2153
2201
|
export type Schema = ClientSchema<typeof schema>;
|
|
@@ -145,6 +145,13 @@ export type PapyrusSiteBackendConfig = {
|
|
|
145
145
|
* DependsOn ordering; no resource changes. Default 12; 0 turns it off.
|
|
146
146
|
*/
|
|
147
147
|
resolverWaveSize?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Optional model groups to leave out of the data API (see `OPTIONAL_MODEL_GROUPS`; today `editions`).
|
|
150
|
+
* CloudFormation allows 2,500 resources per stack operation, nested stacks included, and a fresh create of the full
|
|
151
|
+
* model set exceeds it. Deploy a new site once with a group excluded, then remove the exclusion and deploy again:
|
|
152
|
+
* the second deploy is an ordinary update that adds the models.
|
|
153
|
+
*/
|
|
154
|
+
excludeModelGroups?: string[];
|
|
148
155
|
/** Static reader app (Markus-static sites) that a publish rebuilds through IAM `amplify:StartJob`. */
|
|
149
156
|
reader?: { amplifyAppId: string; branchName?: string };
|
|
150
157
|
/** Lets the newsroom start the `staging` branch build of this CMS app. */
|
package/amplify/site-backend.js
CHANGED
|
@@ -97,7 +97,7 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
97
97
|
categoryAction,
|
|
98
98
|
contentActions,
|
|
99
99
|
editorialChecks,
|
|
100
|
-
data: defineSiteData(pluginDefinitions),
|
|
100
|
+
data: defineSiteData(pluginDefinitions, site.excludeModelGroups ?? []),
|
|
101
101
|
knowledgeQuery,
|
|
102
102
|
manageUserRole,
|
|
103
103
|
monitoringView,
|
package/amplify/site-backend.ts
CHANGED
|
@@ -118,7 +118,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
118
118
|
categoryAction,
|
|
119
119
|
contentActions,
|
|
120
120
|
editorialChecks,
|
|
121
|
-
data: defineSiteData(pluginDefinitions),
|
|
121
|
+
data: defineSiteData(pluginDefinitions, site.excludeModelGroups ?? []),
|
|
122
122
|
knowledgeQuery,
|
|
123
123
|
manageUserRole,
|
|
124
124
|
monitoringView,
|
package/package.json
CHANGED
package/routes.manifest.json
CHANGED