@pylonsync/sdk 0.11.0 → 0.11.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/index.d.ts +39 -0
- package/package.json +1 -1
- package/src/index.ts +49 -0
- package/src/sdk.types.test.ts +33 -1
package/dist/index.d.ts
CHANGED
|
@@ -666,6 +666,17 @@ export interface AppManifest {
|
|
|
666
666
|
/** Self-hosted web fonts. Fetched + self-hosted at build; preload +
|
|
667
667
|
* `@font-face` auto-injected into the SSR `<head>`. */
|
|
668
668
|
fonts?: ManifestFont[];
|
|
669
|
+
/** Environment variables this app cannot run correctly without.
|
|
670
|
+
* `pylon deploy` refuses to ship when one is missing from the
|
|
671
|
+
* project's secrets. */
|
|
672
|
+
requiredEnv?: ManifestRequiredEnv[];
|
|
673
|
+
}
|
|
674
|
+
/** One environment variable the app declares it needs. */
|
|
675
|
+
export interface ManifestRequiredEnv {
|
|
676
|
+
name: string;
|
|
677
|
+
/** What breaks without it. Printed by `pylon deploy` when it is missing,
|
|
678
|
+
* so write the consequence, not the category. */
|
|
679
|
+
description: string;
|
|
669
680
|
}
|
|
670
681
|
/**
|
|
671
682
|
* Declare a recurring job. Runs the named function every time the cron
|
|
@@ -1084,12 +1095,40 @@ export declare function buildManifest(options: {
|
|
|
1084
1095
|
connections?: ManifestConnection[];
|
|
1085
1096
|
crons?: ManifestCron[];
|
|
1086
1097
|
fonts?: ManifestFont[];
|
|
1098
|
+
/** Environment variables this app cannot run correctly without. Declare
|
|
1099
|
+
* the ones whose absence is silent — a public origin baked into a script,
|
|
1100
|
+
* a webhook secret, an API base URL. `pylon deploy` checks them against
|
|
1101
|
+
* the project's secrets and refuses to ship when one is missing.
|
|
1102
|
+
*
|
|
1103
|
+
* ```ts
|
|
1104
|
+
* requiredEnv: [
|
|
1105
|
+
* requireEnv("SITE_URL", "this app's public origin; baked into /widget.js"),
|
|
1106
|
+
* ]
|
|
1107
|
+
* ```
|
|
1108
|
+
*/
|
|
1109
|
+
requiredEnv?: ManifestRequiredEnv[];
|
|
1087
1110
|
/** Set by `discoverFunctions()` (spread its result into this call).
|
|
1088
1111
|
* When true, the framework's AgentRun/AgentMessage entities and
|
|
1089
1112
|
* their owner-scoping policies are appended to the manifest —
|
|
1090
1113
|
* unless the app already declares entities with those names. */
|
|
1091
1114
|
hasAgents?: boolean;
|
|
1092
1115
|
}): AppManifest;
|
|
1116
|
+
/**
|
|
1117
|
+
* Declare an environment variable the app cannot run correctly without.
|
|
1118
|
+
*
|
|
1119
|
+
* This exists for the failures that are invisible. A missing database URL
|
|
1120
|
+
* crashes on the first query and someone notices in a minute; a missing
|
|
1121
|
+
* public origin gets baked into a script tag, served to a customer's
|
|
1122
|
+
* website, and nothing errors anywhere — the data just never arrives.
|
|
1123
|
+
*
|
|
1124
|
+
* `pylon deploy` reads these off the manifest, compares them against the
|
|
1125
|
+
* project's secrets, and refuses to ship when one is missing.
|
|
1126
|
+
*
|
|
1127
|
+
* Write the consequence in `description`, not the category: "the public
|
|
1128
|
+
* origin baked into /widget.js" tells the person reading the failure what
|
|
1129
|
+
* breaks, and "site URL" does not.
|
|
1130
|
+
*/
|
|
1131
|
+
export declare function requireEnv(name: string, description: string): ManifestRequiredEnv;
|
|
1093
1132
|
export { defineStudioConfig, defineStudioExtensions, type BrandConfig, type ThemeConfig, type ThemeAccent, type ThemeAppearance, type IconName, type SidebarConfig, type SidebarSection, type SidebarItem, type SidebarPageItem, type SidebarResourceItem, type SidebarLinkItem, type SidebarHeadingItem, type SidebarFooter, type SidebarFooterCard, type SidebarFooterCustom, type ResourceConfig, type ResourceListConfig, type ColumnConfig, type ColumnRenderer, type RendererKind, type RendererText, type RendererAvatar, type RendererBadge, type RendererDate, type RendererLink, type RendererBoolean, type RendererNumber, type RendererJson, type RendererCustom, type BulkAction, type RowAction, type PageConfig, type StudioConfig, type StudioCellRendererProps, type StudioPageProps, type StudioExtensions, } from "./studio";
|
|
1094
1133
|
/**
|
|
1095
1134
|
* Behavior — a function that mutates the entity definition before it's
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -854,6 +854,18 @@ export interface AppManifest {
|
|
|
854
854
|
/** Self-hosted web fonts. Fetched + self-hosted at build; preload +
|
|
855
855
|
* `@font-face` auto-injected into the SSR `<head>`. */
|
|
856
856
|
fonts?: ManifestFont[];
|
|
857
|
+
/** Environment variables this app cannot run correctly without.
|
|
858
|
+
* `pylon deploy` refuses to ship when one is missing from the
|
|
859
|
+
* project's secrets. */
|
|
860
|
+
requiredEnv?: ManifestRequiredEnv[];
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** One environment variable the app declares it needs. */
|
|
864
|
+
export interface ManifestRequiredEnv {
|
|
865
|
+
name: string;
|
|
866
|
+
/** What breaks without it. Printed by `pylon deploy` when it is missing,
|
|
867
|
+
* so write the consequence, not the category. */
|
|
868
|
+
description: string;
|
|
857
869
|
}
|
|
858
870
|
|
|
859
871
|
/**
|
|
@@ -2099,6 +2111,18 @@ export function buildManifest(options: {
|
|
|
2099
2111
|
connections?: ManifestConnection[];
|
|
2100
2112
|
crons?: ManifestCron[];
|
|
2101
2113
|
fonts?: ManifestFont[];
|
|
2114
|
+
/** Environment variables this app cannot run correctly without. Declare
|
|
2115
|
+
* the ones whose absence is silent — a public origin baked into a script,
|
|
2116
|
+
* a webhook secret, an API base URL. `pylon deploy` checks them against
|
|
2117
|
+
* the project's secrets and refuses to ship when one is missing.
|
|
2118
|
+
*
|
|
2119
|
+
* ```ts
|
|
2120
|
+
* requiredEnv: [
|
|
2121
|
+
* requireEnv("SITE_URL", "this app's public origin; baked into /widget.js"),
|
|
2122
|
+
* ]
|
|
2123
|
+
* ```
|
|
2124
|
+
*/
|
|
2125
|
+
requiredEnv?: ManifestRequiredEnv[];
|
|
2102
2126
|
/** Set by `discoverFunctions()` (spread its result into this call).
|
|
2103
2127
|
* When true, the framework's AgentRun/AgentMessage entities and
|
|
2104
2128
|
* their owner-scoping policies are appended to the manifest —
|
|
@@ -2179,9 +2203,34 @@ export function buildManifest(options: {
|
|
|
2179
2203
|
...(options.fonts && options.fonts.length > 0
|
|
2180
2204
|
? { fonts: options.fonts }
|
|
2181
2205
|
: {}),
|
|
2206
|
+
...(options.requiredEnv && options.requiredEnv.length > 0
|
|
2207
|
+
? { requiredEnv: options.requiredEnv }
|
|
2208
|
+
: {}),
|
|
2182
2209
|
};
|
|
2183
2210
|
}
|
|
2184
2211
|
|
|
2212
|
+
/**
|
|
2213
|
+
* Declare an environment variable the app cannot run correctly without.
|
|
2214
|
+
*
|
|
2215
|
+
* This exists for the failures that are invisible. A missing database URL
|
|
2216
|
+
* crashes on the first query and someone notices in a minute; a missing
|
|
2217
|
+
* public origin gets baked into a script tag, served to a customer's
|
|
2218
|
+
* website, and nothing errors anywhere — the data just never arrives.
|
|
2219
|
+
*
|
|
2220
|
+
* `pylon deploy` reads these off the manifest, compares them against the
|
|
2221
|
+
* project's secrets, and refuses to ship when one is missing.
|
|
2222
|
+
*
|
|
2223
|
+
* Write the consequence in `description`, not the category: "the public
|
|
2224
|
+
* origin baked into /widget.js" tells the person reading the failure what
|
|
2225
|
+
* breaks, and "site URL" does not.
|
|
2226
|
+
*/
|
|
2227
|
+
export function requireEnv(
|
|
2228
|
+
name: string,
|
|
2229
|
+
description: string,
|
|
2230
|
+
): ManifestRequiredEnv {
|
|
2231
|
+
return { name, description };
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2185
2234
|
// ---------------------------------------------------------------------------
|
|
2186
2235
|
// Studio configuration — re-exports
|
|
2187
2236
|
// ---------------------------------------------------------------------------
|
package/src/sdk.types.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { auth, buildManifest, entity, field } from "./index";
|
|
2
|
+
import { auth, buildManifest, entity, field, requireEnv } from "./index";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The shape callers actually hit.
|
|
@@ -109,3 +109,35 @@ describe("auth() account deletion hook", () => {
|
|
|
109
109
|
expect("on_delete_account" in auth({})).toBe(false);
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
|
+
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
// requiredEnv
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
test("requiredEnv only appears in the manifest when something is declared", () => {
|
|
118
|
+
const bare = buildManifest({
|
|
119
|
+
name: "app",
|
|
120
|
+
version: "1.0.0",
|
|
121
|
+
entities: [],
|
|
122
|
+
routes: [],
|
|
123
|
+
});
|
|
124
|
+
// An empty key in every manifest is noise the Rust side then has to ignore.
|
|
125
|
+
expect("requiredEnv" in bare).toBe(false);
|
|
126
|
+
|
|
127
|
+
const declared = buildManifest({
|
|
128
|
+
name: "app",
|
|
129
|
+
version: "1.0.0",
|
|
130
|
+
entities: [],
|
|
131
|
+
routes: [],
|
|
132
|
+
requiredEnv: [requireEnv("SITE_URL", "the public origin")],
|
|
133
|
+
});
|
|
134
|
+
expect(declared.requiredEnv).toEqual([
|
|
135
|
+
{ name: "SITE_URL", description: "the public origin" },
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("requireEnv keeps the description, because that is what the failure prints", () => {
|
|
140
|
+
const v = requireEnv("STRIPE_WEBHOOK_SECRET", "payments post here and are dropped without it");
|
|
141
|
+
expect(v.name).toBe("STRIPE_WEBHOOK_SECRET");
|
|
142
|
+
expect(v.description).toContain("dropped");
|
|
143
|
+
});
|