@plitzi/sdk-shared 0.39.3 → 0.39.6

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/clients/index.d.ts +60 -0
  3. package/dist/clients/index.mjs +47 -0
  4. package/dist/conditions/types.d.ts +1 -1
  5. package/dist/credentials/index.d.ts +4 -0
  6. package/dist/credentials/index.mjs +3 -0
  7. package/dist/credentials/kinds.d.ts +54 -0
  8. package/dist/credentials/kinds.mjs +326 -0
  9. package/dist/credentials/problems.d.ts +14 -0
  10. package/dist/credentials/problems.mjs +43 -0
  11. package/dist/csrf/csrf.d.ts +36 -0
  12. package/dist/csrf/csrf.mjs +62 -0
  13. package/dist/csrf/index.d.ts +2 -0
  14. package/dist/csrf/index.mjs +1 -0
  15. package/dist/helpers/deepEqual/deepEqual.mjs +3 -2
  16. package/dist/helpers/lodash/cloneDeep.d.ts +3 -3
  17. package/dist/helpers/lodash/cloneDeep.mjs +24 -27
  18. package/dist/helpers/lodash/has.d.ts +2 -1
  19. package/dist/helpers/lodash/has.mjs +8 -8
  20. package/dist/helpers/lodash/index.d.ts +1 -1
  21. package/dist/helpers/lodash/omit.mjs +2 -2
  22. package/dist/helpers/twigWrapper/charClass.mjs +21 -16
  23. package/dist/helpers/twigWrapper/filters/arrays.mjs +43 -42
  24. package/dist/helpers/twigWrapper/filters/filters.mjs +3 -3
  25. package/dist/helpers/twigWrapper/filters/index.mjs +4 -4
  26. package/dist/helpers/twigWrapper/filters/misc.mjs +14 -13
  27. package/dist/helpers/twigWrapper/filters/objects.mjs +50 -49
  28. package/dist/helpers/twigWrapper/filters/strings.mjs +41 -40
  29. package/dist/helpers/twigWrapper/filters/types.d.ts +4 -0
  30. package/dist/helpers/twigWrapper/filters/types.mjs +2 -2
  31. package/dist/hooks/index.d.ts +2 -1
  32. package/dist/hooks/index.mjs +3 -2
  33. package/dist/hooks/usePrePaint.d.ts +12 -0
  34. package/dist/hooks/usePrePaint.mjs +8 -0
  35. package/dist/navigation/index.d.ts +2 -1
  36. package/dist/navigation/index.mjs +4 -3
  37. package/dist/navigation/notFoundPages.d.ts +25 -0
  38. package/dist/navigation/notFoundPages.mjs +11 -0
  39. package/dist/navigation/routes.d.ts +2 -0
  40. package/dist/navigation/routes.mjs +2 -1
  41. package/dist/navigation/sitemap.d.ts +8 -0
  42. package/dist/navigation/sitemap.mjs +7 -4
  43. package/dist/network/graphql/builder/Mutations/Space/SpaceCancelDeployMutation.d.ts +7 -0
  44. package/dist/network/graphql/builder/Mutations/Space/SpaceCancelDeployMutation.mjs +3 -0
  45. package/dist/network/graphql/builder/Mutations/Space/SpaceCancelScheduledPublishMutation.d.ts +6 -0
  46. package/dist/network/graphql/builder/Mutations/Space/SpaceCancelScheduledPublishMutation.mjs +3 -0
  47. package/dist/network/graphql/builder/Mutations/Space/SpaceDeployMutation.d.ts +1 -1
  48. package/dist/network/graphql/builder/Mutations/Space/SpaceDeployMutation.mjs +1 -1
  49. package/dist/network/graphql/builder/Mutations/Space/SpaceRedeployMutation.d.ts +5 -0
  50. package/dist/network/graphql/builder/Mutations/Space/SpaceRedeployMutation.mjs +3 -0
  51. package/dist/network/graphql/builder/Mutations/Space/SpaceRollbackMutation.d.ts +5 -0
  52. package/dist/network/graphql/builder/Mutations/Space/SpaceRollbackMutation.mjs +3 -0
  53. package/dist/network/graphql/builder/Mutations/Space/SpaceSchedulePublishMutation.d.ts +5 -0
  54. package/dist/network/graphql/builder/Mutations/Space/SpaceSchedulePublishMutation.mjs +3 -0
  55. package/dist/network/graphql/builder/Mutations/Space/SpaceSetTargetMutation.d.ts +10 -0
  56. package/dist/network/graphql/builder/Mutations/Space/SpaceSetTargetMutation.mjs +3 -0
  57. package/dist/network/graphql/builder/Mutations/Space/SpaceTargetAutomationMutation.d.ts +11 -0
  58. package/dist/network/graphql/builder/Mutations/Space/SpaceTargetAutomationMutation.mjs +3 -0
  59. package/dist/network/graphql/builder/Mutations/index.d.ts +14 -0
  60. package/dist/network/graphql/builder/Mutations/index.mjs +88 -74
  61. package/dist/network/graphql/builder/Queries/Space/SpaceDeployDetailQuery.d.ts +7 -0
  62. package/dist/network/graphql/builder/Queries/Space/SpaceDeployDetailQuery.mjs +3 -0
  63. package/dist/network/graphql/builder/Queries/Space/SpacePublishCheckQuery.d.ts +7 -0
  64. package/dist/network/graphql/builder/Queries/Space/SpacePublishCheckQuery.mjs +3 -0
  65. package/dist/network/graphql/builder/Queries/Space/SpaceReleasesQuery.d.ts +7 -0
  66. package/dist/network/graphql/builder/Queries/Space/SpaceReleasesQuery.mjs +3 -0
  67. package/dist/network/graphql/builder/Queries/Space/SpaceScheduledPublishesQuery.d.ts +7 -0
  68. package/dist/network/graphql/builder/Queries/Space/SpaceScheduledPublishesQuery.mjs +3 -0
  69. package/dist/network/graphql/builder/Queries/Space/SpaceSnapshotsQuery.d.ts +7 -0
  70. package/dist/network/graphql/builder/Queries/Space/SpaceSnapshotsQuery.mjs +3 -0
  71. package/dist/network/graphql/builder/Queries/Space/SpaceTargetsQuery.d.ts +7 -0
  72. package/dist/network/graphql/builder/Queries/Space/SpaceTargetsQuery.mjs +3 -0
  73. package/dist/network/graphql/builder/Queries/Space/SpaceVersionChangesQuery.d.ts +7 -0
  74. package/dist/network/graphql/builder/Queries/Space/SpaceVersionChangesQuery.mjs +3 -0
  75. package/dist/network/graphql/builder/Queries/index.d.ts +14 -0
  76. package/dist/network/graphql/builder/Queries/index.mjs +38 -24
  77. package/dist/react/index.d.ts +1 -1
  78. package/dist/refusals/index.d.ts +112 -0
  79. package/dist/refusals/index.mjs +94 -0
  80. package/dist/schema/aiCrawlers.d.ts +25 -0
  81. package/dist/schema/aiCrawlers.mjs +34 -0
  82. package/dist/schema/documentParts.d.ts +45 -0
  83. package/dist/schema/documentParts.mjs +73 -0
  84. package/dist/schema/index.d.ts +3 -0
  85. package/dist/schema/index.mjs +21 -18
  86. package/dist/schema/pageAccess.d.ts +6 -0
  87. package/dist/schema/pageAccess.mjs +23 -23
  88. package/dist/schema/plitziMark.d.ts +9 -0
  89. package/dist/schema/plitziMark.mjs +3 -0
  90. package/dist/schema/schemaSettings.d.ts +1 -1
  91. package/dist/schema/schemaSettings.mjs +1 -1
  92. package/dist/schema/serverElements.d.ts +5 -0
  93. package/dist/store/runtimeStatePersist.mjs +10 -10
  94. package/dist/store/storeHooks.d.ts +45 -45
  95. package/dist/style/runtimeStyle.d.ts +5 -2
  96. package/dist/style/runtimeStyle.mjs +1 -1
  97. package/dist/types/ActionTypes.d.ts +2 -0
  98. package/dist/types/AuthTypes.d.ts +5 -0
  99. package/dist/types/SchemaTypes.d.ts +31 -4
  100. package/dist/types/ServerTypes.d.ts +6 -0
  101. package/dist/types/SpaceTypes.d.ts +277 -6
  102. package/dist/types/StoreTypes.d.ts +11 -0
  103. package/eslint.config.mjs +123 -100
  104. package/package.json +9 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.39.6
4
+
5
+ No changes in this release.
6
+
7
+ ## 0.39.5
8
+
9
+ ### Patch Changes
10
+
11
+ - 4427674: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
12
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
13
+
14
+ ## 0.39.4
15
+
16
+ ### Patch Changes
17
+
18
+ - 35415a1: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
19
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
20
+
3
21
  ## 0.39.3
4
22
 
5
23
  No changes in this release.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * A client of the platform and its version — the CLI and the builder say theirs on every request, and the platform
3
+ * judges it against the oldest it takes. Older than that is refused with the step that upgrades it; older than the
4
+ * platform but not too old is answered, and told what is current, which the client says once. Released together, every
5
+ * `@plitzi/*` package has the platform's version, so a client's version is compared with the platform's own.
6
+ */
7
+ /** What a client sends: `<surface>/<version>` — `cli/0.39.3`. */
8
+ export declare const CLIENT_HEADER = "x-plitzi-client";
9
+ /** What the platform answers a client older than itself with: its own version. */
10
+ export declare const CURRENT_HEADER = "x-plitzi-current";
11
+ /** `sdkServer` is a server of a customer's own running `@plitzi/sdk-server` and asking Plitzi for its space. */
12
+ export declare const CLIENT_SURFACES: readonly ["cli", "builder", "sdkServer"];
13
+ export type ClientSurface = (typeof CLIENT_SURFACES)[number];
14
+ /** The step that brings each surface up to the platform. */
15
+ export declare const CLIENT_UPGRADE: Record<ClientSurface, string>;
16
+ export declare const clientHeaderValue: (surface: ClientSurface, version: string) => string;
17
+ /** The client a request names, or nothing when it names none this platform knows — a browser, a script, a page. */
18
+ export declare const clientOf: (header: string | undefined) => {
19
+ surface: ClientSurface;
20
+ version: string;
21
+ } | undefined;
22
+ /**
23
+ * The oldest client a platform of `current` takes when its deployment names none: the minor before its own, from its
24
+ * first patch. A client one minor behind still works; two behind is refused.
25
+ */
26
+ export declare const oldestByDefault: (current: string) => string;
27
+ export type ClientVerdict =
28
+ /** No client of the platform's, or one as new as it: answered as any request is. */
29
+ {
30
+ kind: 'current';
31
+ }
32
+ /** Older than the platform, not older than it takes: answered, and told what is current. */
33
+ | {
34
+ kind: 'behind';
35
+ surface: ClientSurface;
36
+ version: string;
37
+ current: string;
38
+ }
39
+ /** Older than the oldest the platform takes: refused, with the step that upgrades it. */
40
+ | {
41
+ kind: 'refused';
42
+ surface: ClientSurface;
43
+ version: string;
44
+ oldest: string;
45
+ current: string;
46
+ };
47
+ /**
48
+ * A client judged against the platform: `current` is the platform's version, `oldest` the oldest of each surface it
49
+ * takes. A patch behind is current — patches change no contract.
50
+ */
51
+ export declare const judgeClient: (header: string | undefined, platform: {
52
+ current: string;
53
+ oldest: Record<ClientSurface, string>;
54
+ }) => ClientVerdict;
55
+ /** What a refused client is told: what it is, what the platform takes, and the step. */
56
+ export declare const outdatedText: (verdict: Extract<ClientVerdict, {
57
+ kind: "refused";
58
+ }>) => string;
59
+ /** What a client behind is told, once. */
60
+ export declare const behindText: (surface: ClientSurface, version: string, current: string) => string;
@@ -0,0 +1,47 @@
1
+ // src/clients/index.ts
2
+ var e = "x-plitzi-client", t = "x-plitzi-current", n = [
3
+ "cli",
4
+ "builder",
5
+ "sdkServer"
6
+ ], r = {
7
+ cli: "in a project, plitzi upgrade packages (the CLI is one of them); elsewhere, npx @plitzi/cli@latest",
8
+ builder: "reload the builder: it loads the platform’s own",
9
+ sdkServer: "update @plitzi/sdk-server, build the server again (plitzi build --ssr) and deploy it"
10
+ }, i = {
11
+ cli: "CLI",
12
+ builder: "builder",
13
+ sdkServer: "server"
14
+ }, a = (e) => {
15
+ let t = /^(\d+)\.(\d+)\.(\d+)/.exec(e.trim());
16
+ return t ? [
17
+ Number(t[1]),
18
+ Number(t[2]),
19
+ Number(t[3])
20
+ ] : void 0;
21
+ }, o = (e, t) => e[0] - t[0] || e[1] - t[1] || e[2] - t[2], s = (e) => n.some((t) => t === e), c = (e, t) => `${e}/${t}`, l = (e) => {
22
+ let [t = "", n = ""] = (e ?? "").split("/");
23
+ return s(t) && a(n) ? {
24
+ surface: t,
25
+ version: n
26
+ } : void 0;
27
+ }, u = (e) => {
28
+ let t = a(e);
29
+ if (!t) return e;
30
+ let [n, r] = t;
31
+ return r > 0 ? `${String(n)}.${String(r - 1)}.0` : `${String(n)}.0.0`;
32
+ }, d = (e, t) => {
33
+ let n = l(e), r = n && a(n.version), i = a(t.current);
34
+ if (!n || !r || !i) return { kind: "current" };
35
+ let s = a(t.oldest[n.surface]);
36
+ return s && o(r, s) < 0 ? {
37
+ kind: "refused",
38
+ ...n,
39
+ oldest: t.oldest[n.surface],
40
+ current: t.current
41
+ } : r[0] < i[0] || r[0] === i[0] && r[1] < i[1] ? {
42
+ kind: "behind",
43
+ ...n,
44
+ current: t.current
45
+ } : { kind: "current" };
46
+ }, f = (e) => `This ${i[e.surface]} is ${e.version}, and the platform (${e.current}) takes ${e.oldest} and later: ${r[e.surface]}.`, p = (e, t, n) => `Plitzi ${n} is out, and this ${i[e]} is ${t}: ${r[e]}.`;
47
+ export { e as CLIENT_HEADER, n as CLIENT_SURFACES, r as CLIENT_UPGRADE, t as CURRENT_HEADER, p as behindText, c as clientHeaderValue, l as clientOf, d as judgeClient, u as oldestByDefault, f as outdatedText };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * A condition as Plitzi stores it — a flag's rules, an interaction's `when`, a binding's condition: the schema's own
3
- * format, so sdk-shared defines it (RFC 0032, D13). plitzi-ui's QueryBuilder edits the same shape with prop types of its
3
+ * format, so sdk-shared defines it (docs/en/server-packages.md, D13). plitzi-ui's QueryBuilder edits the same shape with prop types of its
4
4
  * own, and a type test in the builder, where the two meet, holds them assignable both ways.
5
5
  */
6
6
  export type RuleValue = Date | string | number | boolean | undefined | null | object;
@@ -0,0 +1,4 @@
1
+ export { CREDENTIAL_GROUPS, CREDENTIAL_KINDS, isCredentialProvider, isDeployCredentialKind } from './kinds';
2
+ export type { CredentialField, CredentialGroup, CredentialKind, DeployCredentialKind } from './kinds';
3
+ export { credentialData, credentialProblems } from './problems';
4
+ export type { CredentialProblem } from './problems';
@@ -0,0 +1,3 @@
1
+ import { CREDENTIAL_GROUPS as e, CREDENTIAL_KINDS as t, isCredentialProvider as n, isDeployCredentialKind as r } from "./kinds.mjs";
2
+ import { credentialData as i, credentialProblems as a } from "./problems.mjs";
3
+ export { e as CREDENTIAL_GROUPS, t as CREDENTIAL_KINDS, i as credentialData, a as credentialProblems, n as isCredentialProvider, r as isDeployCredentialKind };
@@ -0,0 +1,54 @@
1
+ import { SpaceCredentialProvider } from '../types';
2
+ /**
3
+ * Every kind of credential a space keeps, as one list: what it signs in to, where its provider issues one and with
4
+ * what permissions, and its fields — the builder's form draws it, its list labels each credential by it, and the server
5
+ * judges a saved one against it (`credentialProblems`). A new kind is a value of `SpaceCredentialProvider` and its entry
6
+ * here.
7
+ */
8
+ export type CredentialGroup = 'api' | 'storage' | 'deploy' | 'email' | 'access';
9
+ export type CredentialField = {
10
+ key: string;
11
+ label: string;
12
+ required: boolean;
13
+ /** Typed as a password: never shown back, never trimmed. */
14
+ secret?: boolean;
15
+ example?: string;
16
+ /** What to write, said under the field. */
17
+ hint?: string;
18
+ /** What a new credential starts with. */
19
+ initial?: string;
20
+ /** The values it takes, when it is a choice. */
21
+ choices?: readonly {
22
+ value: string;
23
+ label: string;
24
+ }[];
25
+ /** The shape its provider issues it in: a value of another shape is refused as it is saved, naming the shape. */
26
+ format?: {
27
+ pattern: RegExp;
28
+ expected: string;
29
+ };
30
+ };
31
+ export type CredentialKind = {
32
+ label: string;
33
+ /** Font Awesome classes. */
34
+ icon: string;
35
+ group: CredentialGroup;
36
+ /** What it signs in to, in one sentence. */
37
+ purpose: string;
38
+ /** Where its provider issues one, and what it must be allowed — in the provider's own words for its screens. */
39
+ obtain?: {
40
+ url?: string;
41
+ steps: readonly string[];
42
+ };
43
+ /** Its fields; none for an open one, whose keys are its author's (a connector's `{{credential.<key>}}`). */
44
+ fields: readonly CredentialField[];
45
+ };
46
+ export declare const CREDENTIAL_GROUPS: readonly {
47
+ id: CredentialGroup;
48
+ label: string;
49
+ }[];
50
+ export declare const CREDENTIAL_KINDS: Readonly<Record<SpaceCredentialProvider, CredentialKind>>;
51
+ export declare const isCredentialProvider: (value: unknown) => value is SpaceCredentialProvider;
52
+ export type DeployCredentialKind = 'github' | 'cloudflare' | 'netlify' | 'vercel' | 'ftp';
53
+ /** A kind only deploy targets sign in with (an AWS key or an R2 pair also opens a CDN, so they are storage's). */
54
+ export declare const isDeployCredentialKind: (value: unknown) => value is DeployCredentialKind;
@@ -0,0 +1,326 @@
1
+ // src/credentials/kinds.ts
2
+ var e = [
3
+ {
4
+ id: "api",
5
+ label: "APIs and content"
6
+ },
7
+ {
8
+ id: "storage",
9
+ label: "Storage"
10
+ },
11
+ {
12
+ id: "deploy",
13
+ label: "Deploys"
14
+ },
15
+ {
16
+ id: "email",
17
+ label: "Email"
18
+ },
19
+ {
20
+ id: "access",
21
+ label: "Site access"
22
+ }
23
+ ], t = "Copy both values as soon as they are shown: the secret is shown only once.", n = {
24
+ custom: {
25
+ label: "API, CMS or secret",
26
+ icon: "fa-solid fa-plug",
27
+ group: "api",
28
+ purpose: "Named values of yours: the token a connector signs in to an API or a CMS with, or the secret a webhook is signed by.",
29
+ obtain: { steps: ["Create a token in the API’s or the CMS’s settings (Strapi: Settings → API Tokens; Contentful: Settings → API keys).", "Give it only what the connector does: read, or read and write."] },
30
+ fields: []
31
+ },
32
+ s3: {
33
+ label: "AWS",
34
+ icon: "fa-brands fa-aws",
35
+ group: "storage",
36
+ purpose: "An AWS access key: opens an S3 bucket of the space’s CDN, and deploys to S3, CloudFront or Amplify.",
37
+ obtain: {
38
+ url: "https://console.aws.amazon.com/iam/home#/users",
39
+ steps: [
40
+ "In IAM, open a user meant for Plitzi (or create one) → Security credentials → Create access key.",
41
+ "Allow it the bucket only: s3:ListBucket, s3:GetObject, s3:PutObject and s3:DeleteObject — plus cloudfront:UpdateDistribution and cloudfront:CreateInvalidation for CloudFront, or the app’s Amplify deployments.",
42
+ t
43
+ ]
44
+ },
45
+ fields: [{
46
+ key: "accessKeyId",
47
+ label: "Access Key ID",
48
+ required: !0,
49
+ example: "AKIAIOSFODNN7EXAMPLE",
50
+ format: {
51
+ pattern: /^[A-Z0-9]{16,128}$/u,
52
+ expected: "16 to 128 upper-case letters and digits"
53
+ }
54
+ }, {
55
+ key: "secretAccessKey",
56
+ label: "Secret Access Key",
57
+ required: !0,
58
+ secret: !0,
59
+ format: {
60
+ pattern: /^[A-Za-z0-9/+=]{40}$/u,
61
+ expected: "40 characters"
62
+ }
63
+ }]
64
+ },
65
+ r2: {
66
+ label: "Cloudflare R2",
67
+ icon: "fa-brands fa-cloudflare",
68
+ group: "storage",
69
+ purpose: "An R2 API token’s key pair: opens a bucket of the space’s CDN, and deploys to R2.",
70
+ obtain: {
71
+ url: "https://dash.cloudflare.com/?to=/:account/r2/api-tokens",
72
+ steps: [
73
+ "In R2 → Manage API tokens → Create API token.",
74
+ "Object Read & Write, applied to the bucket alone.",
75
+ `${t} Use the S3 client’s pair, not the token value.`
76
+ ]
77
+ },
78
+ fields: [{
79
+ key: "accessKeyId",
80
+ label: "Access Key ID",
81
+ required: !0,
82
+ format: {
83
+ pattern: /^[0-9a-f]{32}$/u,
84
+ expected: "32 hexadecimal characters"
85
+ }
86
+ }, {
87
+ key: "secretAccessKey",
88
+ label: "Secret Access Key",
89
+ required: !0,
90
+ secret: !0,
91
+ format: {
92
+ pattern: /^[0-9a-f]{64}$/u,
93
+ expected: "64 hexadecimal characters"
94
+ }
95
+ }]
96
+ },
97
+ github: {
98
+ label: "GitHub",
99
+ icon: "fa-brands fa-github",
100
+ group: "deploy",
101
+ purpose: "Commits the site to a repository’s branch that GitHub Pages serves.",
102
+ obtain: {
103
+ url: "https://github.com/settings/personal-access-tokens/new",
104
+ steps: [
105
+ "Create a fine-grained personal access token.",
106
+ "Repository access: only the site’s repository.",
107
+ "Permissions: Contents — Read and write."
108
+ ]
109
+ },
110
+ fields: [{
111
+ key: "token",
112
+ label: "Token",
113
+ required: !0,
114
+ secret: !0,
115
+ example: "github_pat_…"
116
+ }]
117
+ },
118
+ cloudflare: {
119
+ label: "Cloudflare Pages",
120
+ icon: "fa-brands fa-cloudflare",
121
+ group: "deploy",
122
+ purpose: "Deploys the site to a Cloudflare Pages project.",
123
+ obtain: {
124
+ url: "https://dash.cloudflare.com/profile/api-tokens",
125
+ steps: [
126
+ "Create Token → Create Custom Token.",
127
+ "Permissions: Account → Cloudflare Pages → Edit, for the project’s account.",
128
+ "The account ID is on the account’s home page, under API in the right-hand column."
129
+ ]
130
+ },
131
+ fields: [{
132
+ key: "apiToken",
133
+ label: "API token",
134
+ required: !0,
135
+ secret: !0
136
+ }, {
137
+ key: "accountId",
138
+ label: "Account ID",
139
+ required: !0,
140
+ example: "023e105f4ecef8ad9ca31a8372d0c353",
141
+ format: {
142
+ pattern: /^[0-9a-f]{32}$/u,
143
+ expected: "32 hexadecimal characters"
144
+ }
145
+ }]
146
+ },
147
+ netlify: {
148
+ label: "Netlify",
149
+ icon: "fa-solid fa-diamond",
150
+ group: "deploy",
151
+ purpose: "Deploys the site to a Netlify site.",
152
+ obtain: {
153
+ url: "https://app.netlify.com/user/applications#personal-access-tokens",
154
+ steps: ["New access token, with an expiry you will renew.", "It reaches every site its account can: use an account meant for deploys when you can."]
155
+ },
156
+ fields: [{
157
+ key: "token",
158
+ label: "Personal access token",
159
+ required: !0,
160
+ secret: !0,
161
+ example: "nfp_…"
162
+ }]
163
+ },
164
+ vercel: {
165
+ label: "Vercel",
166
+ icon: "fa-solid fa-caret-up",
167
+ group: "deploy",
168
+ purpose: "Deploys the site to a Vercel project as its production deployment.",
169
+ obtain: {
170
+ url: "https://vercel.com/account/settings/tokens",
171
+ steps: ["Create a token.", "Scope: the team the project belongs to — not Full Account."]
172
+ },
173
+ fields: [{
174
+ key: "token",
175
+ label: "Token",
176
+ required: !0,
177
+ secret: !0
178
+ }]
179
+ },
180
+ ftp: {
181
+ label: "FTP",
182
+ icon: "fa-solid fa-server",
183
+ group: "deploy",
184
+ purpose: "Uploads the site to a host over FTP — over TLS unless the host has none.",
185
+ obtain: { steps: ["Your host’s control panel lists its FTP accounts (cPanel: Files → FTP Accounts).", "Use an account whose home is the site’s folder, so it reaches nothing else."] },
186
+ fields: [
187
+ {
188
+ key: "host",
189
+ label: "Host",
190
+ required: !0,
191
+ example: "ftp.example.com"
192
+ },
193
+ {
194
+ key: "port",
195
+ label: "Port",
196
+ required: !1,
197
+ example: "21",
198
+ format: {
199
+ pattern: /^\d{1,5}$/u,
200
+ expected: "a port number"
201
+ }
202
+ },
203
+ {
204
+ key: "user",
205
+ label: "User",
206
+ required: !0
207
+ },
208
+ {
209
+ key: "password",
210
+ label: "Password",
211
+ required: !0,
212
+ secret: !0
213
+ },
214
+ {
215
+ key: "secure",
216
+ label: "Security",
217
+ required: !1,
218
+ initial: "explicit",
219
+ choices: [
220
+ {
221
+ value: "explicit",
222
+ label: "TLS when connected (AUTH TLS, port 21)"
223
+ },
224
+ {
225
+ value: "implicit",
226
+ label: "TLS from the start (port 990)"
227
+ },
228
+ {
229
+ value: "none",
230
+ label: "None — the password travels in the clear"
231
+ }
232
+ ]
233
+ }
234
+ ]
235
+ },
236
+ smtp: {
237
+ label: "SMTP (email)",
238
+ icon: "fa-solid fa-envelope",
239
+ group: "email",
240
+ purpose: "The mail server a flow’s Send email step sends through.",
241
+ obtain: { steps: ["Your email provider’s SMTP settings: Postmark, SendGrid, Amazon SES, Resend, or your own server.", "Gmail and Outlook need an app password, never the account’s own."] },
242
+ fields: [
243
+ {
244
+ key: "host",
245
+ label: "Host",
246
+ required: !0,
247
+ example: "smtp.example.com"
248
+ },
249
+ {
250
+ key: "port",
251
+ label: "Port",
252
+ required: !0,
253
+ example: "587",
254
+ initial: "587"
255
+ },
256
+ {
257
+ key: "security",
258
+ label: "Security",
259
+ required: !0,
260
+ initial: "starttls",
261
+ choices: [
262
+ {
263
+ value: "starttls",
264
+ label: "STARTTLS (usually 587)"
265
+ },
266
+ {
267
+ value: "tls",
268
+ label: "TLS (usually 465)"
269
+ },
270
+ {
271
+ value: "none",
272
+ label: "None"
273
+ }
274
+ ]
275
+ },
276
+ {
277
+ key: "username",
278
+ label: "User",
279
+ required: !1
280
+ },
281
+ {
282
+ key: "password",
283
+ label: "Password",
284
+ required: !1,
285
+ secret: !0
286
+ },
287
+ {
288
+ key: "fromEmail",
289
+ label: "Send as (email)",
290
+ required: !0,
291
+ example: "hello@example.com"
292
+ },
293
+ {
294
+ key: "fromName",
295
+ label: "Send as (name)",
296
+ required: !1,
297
+ example: "Acme"
298
+ }
299
+ ]
300
+ },
301
+ ssr: {
302
+ label: "Site password",
303
+ icon: "fa-solid fa-lock",
304
+ group: "access",
305
+ purpose: "Asks a domain’s visitors for a password before it shows them a page.",
306
+ fields: [{
307
+ key: "user",
308
+ label: "User",
309
+ required: !0,
310
+ format: {
311
+ pattern: /^.{2,20}$/u,
312
+ expected: "2 to 20 characters"
313
+ }
314
+ }, {
315
+ key: "pass",
316
+ label: "Password",
317
+ required: !0,
318
+ secret: !0,
319
+ format: {
320
+ pattern: /^.{2,50}$/u,
321
+ expected: "2 to 50 characters"
322
+ }
323
+ }]
324
+ }
325
+ }, r = (e) => typeof e == "string" && Object.hasOwn(n, e), i = (e) => r(e) && n[e].group === "deploy";
326
+ export { e as CREDENTIAL_GROUPS, n as CREDENTIAL_KINDS, r as isCredentialProvider, i as isDeployCredentialKind };
@@ -0,0 +1,14 @@
1
+ import { SpaceCredentialProvider } from '../types';
2
+ /** What is wrong with one field of a credential, said by the field's label — or `''` for the credential as a whole. */
3
+ export type CredentialProblem = {
4
+ key: string;
5
+ message: string;
6
+ };
7
+ /**
8
+ * What keeps a credential from being used, field by field — nothing when it is whole: the one judgement the builder's
9
+ * form shows beside each field and the server refuses a save with. A field with a problem of its own is said once;
10
+ * what a kind checks beyond its fields (an SMTP server, by the rule `email.send` applies) is said for the rest.
11
+ */
12
+ export declare const credentialProblems: (provider: SpaceCredentialProvider, data: Record<string, unknown>) => CredentialProblem[];
13
+ /** A credential's values as they are kept: the fields it asks, text trimmed (a secret as typed), empty ones left out. */
14
+ export declare const credentialData: (provider: SpaceCredentialProvider, values: Record<string, string>) => Record<string, string>;
@@ -0,0 +1,43 @@
1
+ import { CREDENTIAL_KINDS as e } from "./kinds.mjs";
2
+ import { readSmtpCredential as t } from "../actions/smtp.mjs";
3
+ // src/credentials/problems.ts
4
+ var n = (e) => e.split(".").length === 3 && e.length > 100, r = (e, t) => {
5
+ let r = typeof t == "string" ? e.secret ? t : t.trim() : typeof t == "number" ? String(t) : "";
6
+ if (!r) return e.required ? `${e.label} is required` : void 0;
7
+ if (e.choices && !e.choices.some((e) => e.value === r)) return `${e.label} is one of ${e.choices.map((e) => e.value).join(", ")}`;
8
+ if (e.format && !e.format.pattern.test(r)) {
9
+ let t = n(r) ? "a signed token, not a key" : `${String(r.length)} characters`;
10
+ return `${e.label} is ${e.format.expected}; this one is ${t}`;
11
+ }
12
+ }, i = (n, i) => {
13
+ let a = e[n];
14
+ if (a.fields.length === 0) {
15
+ let e = Object.entries(i);
16
+ return e.length === 0 ? [{
17
+ key: "",
18
+ message: "It holds at least one value, under the name its connector reads it by"
19
+ }] : e.flatMap(([e, t]) => typeof t == "string" && t !== "" ? [] : [{
20
+ key: e,
21
+ message: `${e} has no value`
22
+ }]);
23
+ }
24
+ let o = a.fields.flatMap((e) => {
25
+ let t = r(e, i[e.key]);
26
+ return t ? [{
27
+ key: e.key,
28
+ message: t
29
+ }] : [];
30
+ });
31
+ if (n === "smtp") {
32
+ let e = new Set(o.map((e) => e.key));
33
+ o.push(...t(i).problems.filter((t) => !e.has(t.key)));
34
+ }
35
+ return o;
36
+ }, a = (t, n) => {
37
+ let r = e[t];
38
+ return r.fields.length === 0 ? Object.fromEntries(Object.entries(n).flatMap(([e, t]) => e.trim() ? [[e.trim(), t]] : [])) : Object.fromEntries(r.fields.flatMap((e) => {
39
+ let t = n[e.key] ?? "", r = e.secret ? t : t.trim();
40
+ return r ? [[e.key, r]] : [];
41
+ }));
42
+ };
43
+ export { a as credentialData, i as credentialProblems };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The CSRF token, from the page's side: echoed on every write a page sends with the visitor's session cookie to an API
3
+ * that asks for one (the kernel's `createCsrf`), and renewed when it has run out.
4
+ *
5
+ * The page is told which APIs ask for it, the cookie it is kept in and where a new one is handed out, by the page
6
+ * server (`<meta name="plitzi-csrf">`, from the deployment's `rsc.visitorCredentials`). A meta tag rather than state:
7
+ * every copy of this module reads the same one — the SDK's, the builder's bundle, a plugin's. Sent to those APIs alone:
8
+ * the token is bound to the session, and a request to anywhere else never carries it.
9
+ */
10
+ /** The header the token is echoed in. */
11
+ export declare const CSRF_HEADER_NAME = "x-csrf-token";
12
+ /** The field a `<form>` may carry it in instead. */
13
+ export declare const CSRF_FIELD_NAME = "_csrf";
14
+ /** The suffix of its cookie's name, after the session cookie's: `plitzi_auth` → `plitzi_auth_csrf`. */
15
+ export declare const CSRF_COOKIE_SUFFIX = "_csrf";
16
+ /** The meta tag the page server writes what the page needs to know in. */
17
+ export declare const CSRF_HINT_META = "plitzi-csrf";
18
+ /** What a refusal for the token says, in the kernel's words: a reason a new token answers. */
19
+ export declare const CSRF_RENEWABLE: readonly ["missing", "malformed", "expired", "mismatch"];
20
+ /** What the page is told: the APIs that ask for the token, each with the cookie it keeps it in, and where a new one is
21
+ * handed out on each. */
22
+ export type CsrfHint = {
23
+ apis: {
24
+ origin: string;
25
+ cookie: string;
26
+ }[];
27
+ path: string;
28
+ };
29
+ /** The hint the page carries, or none: a page no API asks a token of, or one drawn without a server. */
30
+ export declare const readCsrfHint: (doc?: Pick<Document, "querySelector">) => CsrfHint | undefined;
31
+ /**
32
+ * `fetch`, echoing the CSRF token on a write sent with the session cookie to an API that asks for one — and, refused
33
+ * for the token (it ran out, the session changed), asking for a new one and sending the write once more. Any other
34
+ * request is sent as it is.
35
+ */
36
+ export declare const csrfFetch: (input: string | URL, init?: RequestInit, fetchImpl?: typeof fetch) => Promise<Response>;