@plitzi/sdk-shared 0.38.16 → 0.38.18

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 (125) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/dist/actions/cron.mjs +5 -9
  3. package/dist/actions/validateDocument.mjs +24 -50
  4. package/dist/connectors/validateManifest.mjs +28 -73
  5. package/dist/dataSource/helpers/index.mjs +1 -2
  6. package/dist/dataSource/index.d.ts +1 -1
  7. package/dist/dataSource/index.mjs +6 -8
  8. package/dist/dataSource/utility/dateConverter.mjs +1 -1
  9. package/dist/dataSource/utility/index.d.ts +1 -0
  10. package/dist/dataSource/utility/index.mjs +16 -15
  11. package/dist/{helpers → dates}/formatDate.mjs +1 -1
  12. package/dist/dates/index.d.ts +6 -0
  13. package/dist/dates/index.mjs +3 -0
  14. package/dist/{helpers → dates}/isDate.mjs +1 -1
  15. package/dist/devTools/index.d.ts +1 -3
  16. package/dist/devTools/index.mjs +5 -6
  17. package/dist/devTools/{DevToolsContext.d.ts → react/DevToolsContext.d.ts} +1 -1
  18. package/dist/devTools/{DevToolsContext.mjs → react/DevToolsContext.mjs} +1 -1
  19. package/dist/devTools/react/index.d.ts +3 -0
  20. package/dist/devTools/react/index.mjs +1 -0
  21. package/dist/devTools/utils/PlitziConsole.mjs +8 -12
  22. package/dist/elements/index.mjs +1 -2
  23. package/dist/flags/flagsCookie.mjs +4 -4
  24. package/dist/flags/index.mjs +2 -2
  25. package/dist/flags/react/index.d.ts +3 -0
  26. package/dist/flags/react/index.mjs +1 -0
  27. package/dist/flags/{useFlagResolution.d.ts → react/useFlagResolution.d.ts} +2 -4
  28. package/dist/flags/react/useFlagResolution.mjs +35 -0
  29. package/dist/flags/resolveFlags.d.ts +3 -1
  30. package/dist/flags/resolveFlags.mjs +16 -8
  31. package/dist/helpers/index.d.ts +8 -2
  32. package/dist/helpers/index.mjs +19 -13
  33. package/dist/helpers/keys.mjs +4 -8
  34. package/dist/helpers/twigWrapper/Evaluator/index.mjs +1 -2
  35. package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +12 -26
  36. package/dist/helpers/twigWrapper/Parser/index.mjs +1 -2
  37. package/dist/helpers/twigWrapper/TemplateCache/index.mjs +1 -2
  38. package/dist/helpers/twigWrapper/charClass.mjs +2 -6
  39. package/dist/helpers/twigWrapper/filters/index.mjs +1 -2
  40. package/dist/helpers/twigWrapper/templateRoots.mjs +3 -8
  41. package/dist/hooks/useNetwork.mjs +1 -4
  42. package/dist/index.d.ts +5 -19
  43. package/dist/index.mjs +3 -99
  44. package/dist/network/graphql/builder/Mutations/index.d.ts +1 -0
  45. package/dist/network/graphql/builder/Mutations/index.mjs +148 -148
  46. package/dist/network/graphql/builder/Queries/index.mjs +4 -4
  47. package/dist/network/index.mjs +8 -8
  48. package/dist/plugins/{bundle.mjs → bundle/bundle.mjs} +1 -1
  49. package/dist/plugins/bundle/index.d.ts +2 -0
  50. package/dist/plugins/bundle/index.mjs +1 -0
  51. package/dist/plugins/index.d.ts +1 -0
  52. package/dist/plugins/index.mjs +1 -0
  53. package/dist/plugins/{PluginsContext.d.ts → react/PluginsContext.d.ts} +1 -1
  54. package/dist/plugins/{PluginsContext.mjs → react/PluginsContext.mjs} +1 -1
  55. package/dist/plugins/react/index.d.ts +3 -0
  56. package/dist/plugins/react/index.mjs +1 -0
  57. package/dist/project/index.d.ts +8 -0
  58. package/dist/project/index.mjs +5 -0
  59. package/dist/project/layout.mjs +5 -5
  60. package/dist/project/{paths.d.ts → paths/index.d.ts} +8 -1
  61. package/dist/project/paths/index.mjs +4 -0
  62. package/dist/project/root.mjs +1 -1
  63. package/dist/queries/queryCache.mjs +1 -7
  64. package/dist/realtime/client.mjs +3 -12
  65. package/dist/schema/index.d.ts +5 -3
  66. package/dist/schema/index.mjs +11 -7
  67. package/dist/schema/{SchemaContext.d.ts → react/SchemaContext.d.ts} +1 -1
  68. package/dist/schema/{SchemaContext.mjs → react/SchemaContext.mjs} +1 -1
  69. package/dist/schema/react/index.d.ts +3 -0
  70. package/dist/schema/react/index.mjs +1 -0
  71. package/dist/server/actions/useActionsSync.mjs +1 -1
  72. package/dist/server/actions/useImagesSync.mjs +1 -1
  73. package/dist/server/actions/useRealtimeSync.mjs +1 -1
  74. package/dist/server/index.d.ts +3 -0
  75. package/dist/server/index.mjs +7 -4
  76. package/dist/server/rsc/refreshRsc.mjs +11 -11
  77. package/dist/server/rsc/useRscSync.mjs +1 -1
  78. package/dist/server/usePluginRoute.mjs +1 -1
  79. package/dist/state/runtimeStatePersist.mjs +9 -15
  80. package/dist/store/index.d.ts +1 -193
  81. package/dist/store/index.mjs +6 -9
  82. package/dist/store/renderSettings.mjs +1 -1
  83. package/dist/store/storeHooks.d.ts +193 -0
  84. package/dist/store/storeHooks.mjs +5 -0
  85. package/dist/store/tracing/tracingCollector.mjs +1 -5
  86. package/dist/style/fonts.mjs +17 -25
  87. package/dist/style/index.d.ts +2 -0
  88. package/dist/style/index.mjs +17 -15
  89. package/dist/style/react/index.d.ts +5 -0
  90. package/dist/style/react/index.mjs +3 -0
  91. package/dist/style/{useDisplayMode.d.ts → react/useDisplayMode.d.ts} +1 -1
  92. package/dist/style/{useDisplayMode.mjs → react/useDisplayMode.mjs} +2 -2
  93. package/dist/style/{useElementSize.mjs → react/useElementSize.mjs} +1 -1
  94. package/dist/style/stylePseudos.mjs +2 -5
  95. package/dist/style/styleTarget.mjs +6 -6
  96. package/dist/theme/ThemeProvider.mjs +2 -2
  97. package/dist/theme/cookie/index.d.ts +1 -0
  98. package/dist/theme/cookie/index.mjs +1 -0
  99. package/dist/theme/{themeCookie.d.ts → cookie/themeCookie.d.ts} +1 -1
  100. package/dist/theme/{themeCookie.mjs → cookie/themeCookie.mjs} +2 -2
  101. package/dist/theme/index.d.ts +2 -1
  102. package/dist/theme/index.mjs +5 -5
  103. package/dist/types/SchemaTypes.d.ts +2 -1
  104. package/dist/types/ServerTypes.d.ts +27 -11
  105. package/dist/websockets/index.mjs +1 -2
  106. package/package.json +21 -1607
  107. package/vite.config.ts +20 -4
  108. package/dist/auth/authFailureLink.d.ts +0 -9
  109. package/dist/auth/authFailureLink.mjs +0 -20
  110. package/dist/dataSource/hooks/index.d.ts +0 -4
  111. package/dist/dataSource/hooks/index.mjs +0 -3
  112. package/dist/dataSource/hooks/useRegisterSource.d.ts +0 -9
  113. package/dist/dataSource/hooks/useRegisterSource.mjs +0 -40
  114. package/dist/dataSource/hooks/useResolvedVariables.d.ts +0 -12
  115. package/dist/dataSource/hooks/useResolvedVariables.mjs +0 -28
  116. package/dist/flags/useFlagResolution.mjs +0 -43
  117. package/dist/helpers/stripTypename.d.ts +0 -15
  118. package/dist/helpers/stripTypename.mjs +0 -41
  119. package/dist/project/paths.mjs +0 -4
  120. package/dist/server/rsc/projectData.d.ts +0 -6
  121. package/dist/server/rsc/projectData.mjs +0 -4
  122. /package/dist/{helpers → dates}/formatDate.d.ts +0 -0
  123. /package/dist/{helpers → dates}/isDate.d.ts +0 -0
  124. /package/dist/plugins/{bundle.d.ts → bundle/bundle.d.ts} +0 -0
  125. /package/dist/style/{useElementSize.d.ts → react/useElementSize.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,112 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.38.18
4
+
5
+ ### Patch Changes
6
+
7
+ - b3023c9: ## Security
8
+
9
+ - **A page of the same site on another origin is no longer this server's own** (`@plitzi/sdk-server`): the guard
10
+ against writes another page caused (`crossSiteWrites`, the sign-in's login-CSRF check and `createOriginGuardMiddleware`)
11
+ trusted `Sec-Fetch-Site: same-site` — and a site has no port and spans every sub-domain, so another port of the host
12
+ (where `createAuthoringHost` serves pages an agent wrote) or a sibling sub-domain (every space of a platform on one
13
+ domain) could write as if it were the server's own page. Now only `same-origin` (and `none`, a typed URL) is; `same-site`
14
+ is refused 403 `reason: 'foreign'` unless its origin is named (`crossSiteWrites.origins`, `identity.platformOrigins`),
15
+ and the `Origin` fallback compares host and port. In production an app and its spaces are already on different sites,
16
+ so a deployment that works there needs nothing; one that relied on a sibling sub-domain locally names it.
17
+ `createAuthoringHost`'s docs now say to serve on a host of its own — a cookie belongs to a host whatever its port.
18
+
19
+ ## Server
20
+ - **An open page takes a new version of its space where it stands** (`@plitzi/sdk-server`, `@plitzi/plitzi-sdk`):
21
+ `server.updatePages(documents, { draft? })` hands the pages showing that space — or that draft — its new documents,
22
+ and each swaps them in place, its state, scroll and focus kept (`replaceSpace` on what the SDK's `render` returns;
23
+ `false`, and the page loads again, for a page with elements the server draws). The development loop of a project uses
24
+ it: a save to the space no longer reloads the open page. `createAuthoringHost`'s `put` over an id that pages show
25
+ hands them the new version and answers how many took it (`updated`), so a page an agent keeps improving is seen to
26
+ grow instead of reloading — no second iframe needed.
27
+ - **`devReload` is `livePages`** (`@plitzi/sdk-server`): the channel the open pages listen on now carries the space,
28
+ not only "load again", and a host that is not developing uses it too. Its address is `/__plitzi/live`; a draft's page
29
+ listens for its own changes alone (`?__pt=`). A plugin swapped where it is drawn stays a development server's
30
+ (`devMode`). `plitzi upgrade migrations --write` renames the option in a project's code (`livePagesOption`).
31
+
32
+ ## Packages
33
+ - **`@plitzi/sdk-server` starts in half the time** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`): importing it took
34
+ ~310 ms, ~200 of them `date-fns` — 108 modules nothing on the server uses, brought by `@plitzi/sdk-shared/helpers` —
35
+ and loaded the browser's hooks and contexts of every folder of `@plitzi/sdk-shared` it read, `@plitzi/nexus/react`
36
+ with them. Now ~150 ms (`@plitzi/sdk-shared` 139 → 113 modules, `@plitzi/nexus` 53 → 31). What moved, each
37
+ rewritten by `plitzi upgrade migrations --write` (`movedExports`):
38
+ - the dates — `formatDate`, `formatDateUTC`, `formatFromNow`, `formatUTCToLocal`, `getDurationMs`, `isDate`,
39
+ `isValidFormat`, `parseDate`, `toUnixSeconds`, `SupportedLocale` — from `@plitzi/sdk-shared/helpers` to
40
+ `@plitzi/sdk-shared/dates`;
41
+ - React's bindings to an entry of their own beside each area, as `@plitzi/nexus/react` is: `useDisplayMode`,
42
+ `useElementSize` → `@plitzi/sdk-shared/style/react`; `SchemaContext` → `schema/react`; `PluginsContext` →
43
+ `plugins/react`; `DevToolsContext` → `devTools/react`; `useFlagResolution` → `flags/react` (`flagUserFrom` stays
44
+ in `flags`);
45
+ - `PROJECT_DATA_PREFIX` from `@plitzi/sdk-shared/server` to `@plitzi/sdk-shared/project/paths` — the project's
46
+ layout names, an entry a browser imports too (`@plitzi/sdk-shared/project` stays Node only and re-exports them).
47
+ The theme cookie's helpers (`themeFromCookies`…) are also `@plitzi/sdk-shared/theme/cookie`, still exported by
48
+ `@plitzi/sdk-shared/theme`.
49
+
50
+ `yarn check:server-footprint` (in CI after the build) holds what the server's root loads, package by package — Plitzi's
51
+ and every other — to a budget: a heavy library or a folder of hooks coming back fails with what came in.
52
+
53
+ ## CLI
54
+ - **`plitzi upgrade migrations --write` writes a file import's new home when it has one** (`@plitzi/cli`): the
55
+ `folderImports` migration of 0.38.17 named every import of a package's FILE and wrote none. It now reads the installed
56
+ declarations with the project's own TypeScript and rewrites each `import` / `export … from` whose every name the folder
57
+ exports under one name — `import usePlitzi from '@plitzi/sdk-shared/hooks/usePlitzi'` →
58
+ `import { usePlitzi } from '@plitzi/sdk-shared/hooks'`, `type` modifiers and aliases kept. What has no one answer is
59
+ said with why (a namespace import, an `import()` or mock, a name the folder does not export, a project with no
60
+ TypeScript). The report says which places `--write` writes (`writable` in `--json`) instead of calling every one
61
+ "yours to change"; a migration now gives each place its own `edit` in place of a whole-file `rewrite`
62
+ (`docs/en/releases.md`).
63
+ - **`plitzi doctor` says an import of a path the installed package does not export** (`@plitzi/cli`):
64
+ `import-not-exported`, an error, at the importing file — what Node otherwise reports at start as an
65
+ `ERR_MODULE_NOT_FOUND` into the package's `dist`, which reads as a broken install rather than a changed API. For a
66
+ `@plitzi` package the fix names `plitzi upgrade migrations --write`; for any other, its `exports`. Asked only of a
67
+ package that is installed.
68
+
69
+ ## 0.38.17
70
+
71
+ ### Patch Changes
72
+
73
+ - 4f8dc37: ## Packages
74
+
75
+ - **A library package is imported by its root and its folders, never by a file** (`@plitzi/sdk-shared`, `sdk-schema`,
76
+ `sdk-style`, `sdk-elements`, `sdk-interactions`, `sdk-auth`, `sdk-dev-tools`, `sdk-event-bridge`, `sdk-navigation`,
77
+ `sdk-plugins`, `sdk-variables`): each `exports` is now `"."` and `"./*"`, the latter a folder's `index`.
78
+ `@plitzi/sdk-shared/helpers/isRecord` becomes `import { isRecord } from '@plitzi/sdk-shared/helpers'`, and a default
79
+ export by the name its folder gives it — almost always its file's (`import usePlitzi from '…/hooks/usePlitzi'` →
80
+ `import { usePlitzi } from '@plitzi/sdk-shared/hooks'`). A file-level specifier now fails with `ERR_MODULE_NOT_FOUND`.
81
+ New entries where a folder barrel would have brought more than was asked for: `@plitzi/sdk-shared/project` and
82
+ `@plitzi/sdk-shared/plugins/bundle` (Node only), `@plitzi/sdk-interactions/declarations` (the global callbacks and
83
+ utility specs, without React), and `@plitzi/sdk-elements/elements/declarations`, which now also carries the
84
+ declarations' attribute types and the constants they are checked with. `RuleGroup` is exported by `@plitzi/sdk-shared`
85
+ with the document types that use it. `plitzi upgrade migrations` names every such import in a project, with the folder to
86
+ import it from instead.
87
+ - **`@plitzi/sdk-shared`'s root exports the document types, and only them** (`@plitzi/sdk-shared`): what the package
88
+ does is imported from its folder — `formatDate` from `@plitzi/sdk-shared/helpers`, `ThemeProvider` from
89
+ `@plitzi/sdk-shared/theme`, a GraphQL operation's types from `@plitzi/sdk-shared/network/graphql` — so a module that
90
+ imports a type from the root no longer loads every area of the package.
91
+ - **What one package alone used lives in that package** (`@plitzi/sdk-shared`, `@plitzi/sdk-elements`): the data
92
+ source hooks moved from `@plitzi/sdk-shared/dataSource/hooks` to `@plitzi/sdk-elements/dataSource`
93
+ (`useRegisterSource`, `useResolvedVariables`), and the Apollo links the builder's client is built with into the
94
+ builder.
95
+ - **The builder's panels are an entry of their own** (`@plitzi/sdk-style`, `@plitzi/sdk-variables`,
96
+ `@plitzi/sdk-elements`): the style inspector, the advanced style editor and `BuilderStyleContextProvider` are imported
97
+ from `@plitzi/sdk-style/builder`; the variables' lists and forms from `@plitzi/sdk-variables/builder`; the elements'
98
+ settings panels (`defaultElementsSettings`) from `@plitzi/sdk-elements/builder`. Each package's root keeps what a page
99
+ and a server use — `generateCache` no longer loads the inspector, on a server 227 modules down to 21.
100
+
101
+ ## CLI
102
+ - **`plitzi upgrade`'s `renames` part is now `migrations`** (`@plitzi/cli`): what a version changed that a project's
103
+ own source must follow, one file per change in the CLI's `src/migrations/changes/` with the version it shipped in —
104
+ rewritten with `--write` when it has one right answer, said otherwise. The `--json` report carries `migrations` (each
105
+ with its `migration`, `since`, `file`, `line`, `what` and whether it was `written`) in place of `renames` and
106
+ `changes`. The changes of 0.38.0 (`canTemplate` → `canSnippet`, the `*Template` authoring names), 0.38.9 (a
107
+ `formControl` without `required` is optional) and 0.38.12 (`usePlitziServiceContext` → `usePlitzi`) are no longer
108
+ looked for: a project still on one of those versions makes them by hand.
109
+
3
110
  ## 0.38.16
4
111
 
5
112
  ### Patch Changes
@@ -79,16 +79,12 @@ var e = [
79
79
  for (let e = o; e <= c;) {
80
80
  let t = new Date(e), n = a(t);
81
81
  if (!n) return;
82
- if (!s(i, n)) {
83
- e += (1440 - n.hour * 60 - n.minute) * d;
84
- continue;
82
+ if (!s(i, n)) e += (1440 - n.hour * 60 - n.minute) * d;
83
+ else if (!p.has(n.hour)) e += (60 - n.minute) * d;
84
+ else {
85
+ if (u.has(n.minute)) return t;
86
+ e += d;
85
87
  }
86
- if (!p.has(n.hour)) {
87
- e += (60 - n.minute) * d;
88
- continue;
89
- }
90
- if (u.has(n.minute)) return t;
91
- e += d;
92
88
  }
93
89
  }, m = (e, t, n, r, i = 1e3) => {
94
90
  let a = 0, o = new Date(t.getTime() + d);
@@ -38,29 +38,19 @@ var s = [
38
38
  return;
39
39
  }
40
40
  }, h = (e, t, n) => {
41
- if (e !== void 0) {
42
- if (!r(e)) {
43
- n.push({
44
- path: t,
45
- message: "must be an object of field definitions"
46
- });
47
- return;
48
- }
49
- Object.entries(e).forEach(([e, i]) => {
50
- if (!r(i) || !p(i.type)) {
51
- n.push({
52
- path: `${t}.${e}`,
53
- message: "must declare a type"
54
- });
55
- return;
56
- }
57
- s.includes(i.type) || n.push({
58
- path: `${t}.${e}.type`,
59
- message: `unknown field type "${i.type}"`,
60
- hint: `one of ${s.join(", ")}`
61
- });
41
+ e !== void 0 && (r(e) ? Object.entries(e).forEach(([e, i]) => {
42
+ !r(i) || !p(i.type) ? n.push({
43
+ path: `${t}.${e}`,
44
+ message: "must declare a type"
45
+ }) : s.includes(i.type) || n.push({
46
+ path: `${t}.${e}.type`,
47
+ message: `unknown field type "${i.type}"`,
48
+ hint: `one of ${s.join(", ")}`
62
49
  });
63
- }
50
+ }) : n.push({
51
+ path: t,
52
+ message: "must be an object of field definitions"
53
+ }));
64
54
  }, g = (n, s, d, f) => {
65
55
  let g = `nodes.${n}`, _ = s.action;
66
56
  if (!p(_) || !l.includes(_)) {
@@ -164,36 +154,20 @@ var s = [
164
154
  });
165
155
  }), o.forEach(([t, n]) => {
166
156
  let o = `nodes.${t}`;
167
- if (!r(n)) {
168
- i.push({
169
- path: o,
170
- message: "must be an object"
171
- });
172
- return;
173
- }
174
- if (n.type === "trigger") {
175
- g(t, n, i, a);
176
- return;
177
- }
178
- if (n.type !== "task") {
179
- i.push({
180
- path: `${o}.type`,
181
- message: `"${String(n.type)}" steps run in the browser and cannot run on the server`,
182
- hint: "a server action is made of task steps"
183
- });
184
- return;
185
- }
186
- if (!p(n.action) || !f.test(n.action)) {
187
- i.push({
188
- path: `${o}.action`,
189
- message: "must name a task as <namespace>.<action>",
190
- hint: "for example flow.output or http.request"
191
- });
192
- return;
193
- }
194
- p(n.afterNode) && !Object.hasOwn(e, n.afterNode) && i.push({
157
+ r(n) ? n.type === "trigger" ? g(t, n, i, a) : n.type === "task" ? !p(n.action) || !f.test(n.action) ? i.push({
158
+ path: `${o}.action`,
159
+ message: "must name a task as <namespace>.<action>",
160
+ hint: "for example flow.output or http.request"
161
+ }) : p(n.afterNode) && !Object.hasOwn(e, n.afterNode) && i.push({
195
162
  path: `${o}.afterNode`,
196
163
  message: `points at "${n.afterNode}", which is not a step here`
164
+ }) : i.push({
165
+ path: `${o}.type`,
166
+ message: `"${String(n.type)}" steps run in the browser and cannot run on the server`,
167
+ hint: "a server action is made of task steps"
168
+ }) : i.push({
169
+ path: o,
170
+ message: "must be an object"
197
171
  });
198
172
  }), o.forEach(([e]) => {
199
173
  d.has(e) && i.push({
@@ -35,50 +35,30 @@ var i = [
35
35
  });
36
36
  }, p = (t, n, r, i) => {
37
37
  if (n !== void 0) {
38
- if (!e(n)) {
39
- d(t, r, "Must be an object of string values", "Each entry is one name and its templated value");
40
- return;
41
- }
42
- for (let [e, a] of Object.entries(n)) {
43
- if (typeof a != "string") {
44
- d(t, `${r}.${e}`, "Must be a string", "Values are Twig templates the server renders per request");
45
- continue;
46
- }
47
- t.templates.push({
38
+ if (!e(n)) d(t, r, "Must be an object of string values", "Each entry is one name and its templated value");
39
+ else {
40
+ for (let [e, a] of Object.entries(n)) typeof a == "string" ? t.templates.push({
48
41
  path: `${r}.${e}`,
49
42
  value: a,
50
43
  scope: i
51
- });
44
+ }) : d(t, `${r}.${e}`, "Must be a string", "Values are Twig templates the server renders per request");
45
+ return n;
52
46
  }
53
- return n;
54
47
  }
55
48
  }, m = (e, t, r, i) => {
56
- if (t === void 0) {
57
- i && d(e, r, "A write endpoint must declare its method", `One of ${n.join(", ")}`);
58
- return;
59
- }
60
- if (typeof t != "string" || !n.includes(t)) {
61
- d(e, r, `"${c(t)}" is not an HTTP method`, `One of ${n.join(", ")}`);
62
- return;
63
- }
64
- return t;
49
+ if (t === void 0) i && d(e, r, "A write endpoint must declare its method", `One of ${n.join(", ")}`);
50
+ else if (typeof t != "string" || !n.includes(t)) d(e, r, `"${c(t)}" is not an HTTP method`, `One of ${n.join(", ")}`);
51
+ else return t;
65
52
  }, h = (e, t, n, r) => {
66
- if (!s(t.path)) {
67
- d(e, `${n}.path`, "An endpoint needs a path", "It is appended to baseUrl, e.g. \"/api/{{resource}}\"");
68
- return;
69
- }
70
- e.templates.push({
53
+ s(t.path) ? e.templates.push({
71
54
  path: `${n}.path`,
72
55
  value: t.path,
73
56
  scope: r
74
- });
57
+ }) : d(e, `${n}.path`, "An endpoint needs a path", "It is appended to baseUrl, e.g. \"/api/{{resource}}\"");
75
58
  }, g = (e, t, n) => {
76
59
  if (t !== void 0) {
77
- if (typeof t != "string" || !i.includes(t)) {
78
- d(e, n, `"${c(t)}" is not a paging style`, `One of ${i.join(", ")}`);
79
- return;
80
- }
81
- return t;
60
+ if (typeof t != "string" || !i.includes(t)) d(e, n, `"${c(t)}" is not a paging style`, `One of ${i.join(", ")}`);
61
+ else return t;
82
62
  }
83
63
  }, _ = (n, r, i, a) => {
84
64
  let o = `endpoints.read.${r}`;
@@ -103,60 +83,35 @@ var i = [
103
83
  v !== void 0 && !_.includes(v) && f(n, `${o}.query`, `"${r}" pages by ${u} but never uses ${v}, so every page resolves to the first one`, `Put ${v} in the query (or the path) this endpoint sends`);
104
84
  }, v = (t, n, r) => {
105
85
  let i = `endpoints.write.${n}`;
106
- if (!e(r)) {
107
- d(t, i, "A write endpoint must be an object", "It declares at least a method and a path");
108
- return;
109
- }
110
- h(t, r, i, "write"), m(t, r.method, `${i}.method`, !0), p(t, r.query, `${i}.query`, "write"), p(t, r.headers, `${i}.headers`, "write"), r.bodyPath !== void 0 && typeof r.bodyPath != "string" && d(t, `${i}.bodyPath`, "Must be a string", "It names where to nest the values, e.g. \"data\"");
86
+ e(r) ? (h(t, r, i, "write"), m(t, r.method, `${i}.method`, !0), p(t, r.query, `${i}.query`, "write"), p(t, r.headers, `${i}.headers`, "write"), r.bodyPath !== void 0 && typeof r.bodyPath != "string" && d(t, `${i}.bodyPath`, "Must be a string", "It names where to nest the values, e.g. \"data\"")) : d(t, i, "A write endpoint must be an object", "It declares at least a method and a path");
111
87
  }, y = (t, n, r) => {
112
- if (!e(n)) {
113
- d(t, "endpoints", "A connector must declare its endpoints", "At least one read endpoint, usually \"list\"");
114
- return;
115
- }
116
- if (!e(n.read) || Object.keys(n.read).length === 0) d(t, "endpoints.read", "A connector needs at least one read endpoint", "Name it \"list\" — that is the one a provider element addresses when it names none");
117
- else for (let [e, i] of Object.entries(n.read)) _(t, e, i, r);
118
- if (n.write !== void 0) {
119
- if (!e(n.write)) {
120
- d(t, "endpoints.write", "Must be an object of endpoints keyed by name", "Omit it for a read-only connector");
121
- return;
88
+ if (!e(n)) d(t, "endpoints", "A connector must declare its endpoints", "At least one read endpoint, usually \"list\"");
89
+ else {
90
+ if (!e(n.read) || Object.keys(n.read).length === 0) d(t, "endpoints.read", "A connector needs at least one read endpoint", "Name it \"list\" — that is the one a provider element addresses when it names none");
91
+ else for (let [e, i] of Object.entries(n.read)) _(t, e, i, r);
92
+ if (n.write !== void 0) {
93
+ if (!e(n.write)) d(t, "endpoints.write", "Must be an object of endpoints keyed by name", "Omit it for a read-only connector");
94
+ else for (let [e, r] of Object.entries(n.write)) v(t, e, r);
122
95
  }
123
- for (let [e, r] of Object.entries(n.write)) v(t, e, r);
124
96
  }
125
97
  }, b = (t, n) => {
126
- if (n !== void 0) {
127
- if (!e(n)) {
128
- d(t, "auth", "Must be an object", "Shape: { in, name, value }");
129
- return;
130
- }
131
- if (n.in !== "header" && n.in !== "query" && d(t, "auth.in", "Auth travels in a header or a query parameter", "One of header, query"), s(n.name) || d(t, "auth.name", "Auth needs the name it is sent under", "e.g. \"Authorization\" for a bearer token"), typeof n.value != "string") {
132
- d(t, "auth.value", "Must be a string", "A template, e.g. \"Bearer {{credential.token}}\"");
133
- return;
134
- }
135
- t.templates.push({
136
- path: "auth.value",
137
- value: n.value,
138
- scope: "request"
139
- });
140
- }
98
+ n !== void 0 && (e(n) ? (n.in !== "header" && n.in !== "query" && d(t, "auth.in", "Auth travels in a header or a query parameter", "One of header, query"), s(n.name) || d(t, "auth.name", "Auth needs the name it is sent under", "e.g. \"Authorization\" for a bearer token"), typeof n.value == "string" ? t.templates.push({
99
+ path: "auth.value",
100
+ value: n.value,
101
+ scope: "request"
102
+ }) : d(t, "auth.value", "Must be a string", "A template, e.g. \"Bearer {{credential.token}}\"")) : d(t, "auth", "Must be an object", "Shape: { in, name, value }"));
141
103
  }, x = (e, t) => {
142
104
  let n = p(e, t, "operators", "filter");
143
105
  if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && !r.includes("=") && d(e, `operators.${t}`, `Operator "${t}" renders no "key=value" pair, so a filter using it is dropped`, "Write the full query entry, e.g. \"filters[{{field}}][$eq]={{value}}\"");
144
106
  }, S = (t, n) => {
145
107
  if (n !== void 0) {
146
- if (!e(n)) {
147
- d(t, "fields", "Must be an object of field name → type", `Types: ${a.join(", ")}`);
148
- return;
149
- }
150
- for (let [e, r] of Object.entries(n)) (typeof r != "string" || !a.includes(r)) && d(t, `fields.${e}`, `"${c(r)}" is not a field type`, `One of ${a.join(", ")}`);
108
+ if (!e(n)) d(t, "fields", "Must be an object of field name → type", `Types: ${a.join(", ")}`);
109
+ else for (let [e, r] of Object.entries(n)) (typeof r != "string" || !a.includes(r)) && d(t, `fields.${e}`, `"${c(r)}" is not a field type`, `One of ${a.join(", ")}`);
151
110
  }
152
111
  }, C = (e, t) => {
153
112
  let n = !1;
154
113
  for (let t of e.templates) for (let i of l(t.value)) i.startsWith("credential.") && (n = !0), u(i, t.scope) || f(e, t.path, `{{${i}}} is not a value the engine binds here, so it renders empty`, `Tokens available in this position: ${r.filter((e) => e.scopes.includes(t.scope)).map((e) => e.value).join(", ")}`);
155
- if (n && !s(t)) {
156
- f(e, "credential", "This manifest reads {{credential.…}} but names no credential, so every request goes unauthenticated", "The connector still saves. Ask the space owner to create the credential and attach it — the secret is never part of the manifest.");
157
- return;
158
- }
159
- !n && s(t) && f(e, "credential", "A credential is attached but no template reads {{credential.…}}, so it is never sent", "Reference it where the provider expects it, e.g. auth.value = \"Bearer {{credential.token}}\"");
114
+ n && !s(t) ? f(e, "credential", "This manifest reads {{credential.…}} but names no credential, so every request goes unauthenticated", "The connector still saves. Ask the space owner to create the credential and attach it — the secret is never part of the manifest.") : !n && s(t) && f(e, "credential", "A credential is attached but no template reads {{credential.…}}, so it is never sent", "Reference it where the provider expects it, e.g. auth.value = \"Bearer {{credential.token}}\"");
160
115
  }, w = (t) => {
161
116
  let n = {
162
117
  errors: [],
@@ -1,2 +1 @@
1
- import e from "./getSourceName.mjs";
2
- export { e as getSourceName };
1
+ export { default as getSourceName } from "./getSourceName.mjs";
@@ -1,4 +1,3 @@
1
- export * from './hooks';
2
1
  export * from './helpers';
3
2
  export { evaluateComputed, liveSources } from './computed';
4
3
  export { GLOBAL_SOURCES, COMPUTED_GLOBALS } from './globalSources';
@@ -7,3 +6,4 @@ export { default as getBindingsDetails } from './getBindingsDetails';
7
6
  export { default as resolveVariables } from './resolveVariables';
8
7
  export type { VariableScope } from './resolveVariables';
9
8
  export { default as utility, utilityOptions } from './utility';
9
+ export * from './globalSources';
@@ -1,9 +1,7 @@
1
- import { COMPUTED_GLOBALS as e, GLOBAL_SOURCES as t } from "./globalSources.mjs";
2
- import { evaluateComputed as n, liveSources as r } from "./computed.mjs";
3
- import i, { utilityOptions as a } from "./utility/index.mjs";
4
- import o from "./getBindingsDetails.mjs";
5
- import s from "./helpers/getSourceName.mjs";
6
- import c from "./hooks/useRegisterSource.mjs";
1
+ import { COMPUTED_GLOBALS as e, GLOBAL_SOURCES as t, GLOBAL_SOURCE_FIELDS as n } from "./globalSources.mjs";
2
+ import { evaluateComputed as r, liveSources as i } from "./computed.mjs";
3
+ import a, { utilityOptions as o } from "./utility/index.mjs";
4
+ import s from "./getBindingsDetails.mjs";
5
+ import c from "./helpers/getSourceName.mjs";
7
6
  import l from "./resolveVariables.mjs";
8
- import u from "./hooks/useResolvedVariables.mjs";
9
- export { e as COMPUTED_GLOBALS, t as GLOBAL_SOURCES, n as evaluateComputed, o as getBindingsDetails, s as getSourceName, r as liveSources, l as resolveVariables, c as useRegisterSource, u as useResolvedVariables, i as utility, a as utilityOptions };
7
+ export { e as COMPUTED_GLOBALS, t as GLOBAL_SOURCES, n as GLOBAL_SOURCE_FIELDS, r as evaluateComputed, s as getBindingsDetails, c as getSourceName, i as liveSources, l as resolveVariables, a as utility, o as utilityOptions };
@@ -1,4 +1,4 @@
1
- import { formatDate as e, formatDateUTC as t, formatFromNow as n, parseDate as r } from "../../helpers/formatDate.mjs";
1
+ import { formatDate as e, formatDateUTC as t, formatFromNow as n, parseDate as r } from "../../dates/formatDate.mjs";
2
2
  var i = {
3
3
  action: "dateConverter",
4
4
  title: "Date Converter",
@@ -5,3 +5,4 @@ export declare const utilityOptions: {
5
5
  value: string;
6
6
  }[];
7
7
  export default utilities;
8
+ export * from './truthiness';
@@ -1,26 +1,27 @@
1
1
  import e from "./arrayMap.mjs";
2
2
  import t from "./capitalize.mjs";
3
3
  import n from "./dateConverter.mjs";
4
- import r from "./not.mjs";
5
- import i from "./staticValue.mjs";
6
- import a from "./stringToArray.mjs";
7
- import o from "./styleSelector.mjs";
8
- import s from "./styleVariant.mjs";
9
- import c from "./twigTemplate.mjs";
4
+ import { isTrue as r } from "./truthiness.mjs";
5
+ import i from "./not.mjs";
6
+ import a from "./staticValue.mjs";
7
+ import o from "./stringToArray.mjs";
8
+ import s from "./styleSelector.mjs";
9
+ import c from "./styleVariant.mjs";
10
+ import l from "./twigTemplate.mjs";
10
11
  //#region src/dataSource/utility/index.ts
11
- var l = {
12
- twigTemplate: c,
12
+ var u = {
13
+ twigTemplate: l,
13
14
  dateConverter: n,
14
- staticValue: i,
15
+ staticValue: a,
15
16
  capitalize: t,
16
17
  arrayMap: e,
17
- stringToArray: a,
18
- not: r,
19
- styleSelector: o,
20
- styleVariant: s
21
- }, u = Object.values(l).map(({ title: e, action: t }) => ({
18
+ stringToArray: o,
19
+ not: i,
20
+ styleSelector: s,
21
+ styleVariant: c
22
+ }, d = Object.values(u).map(({ title: e, action: t }) => ({
22
23
  label: e,
23
24
  value: t
24
25
  }));
25
26
  //#endregion
26
- export { l as default, u as utilityOptions };
27
+ export { u as default, r as isTrue, d as utilityOptions };
@@ -6,7 +6,7 @@ import { enUS as i } from "date-fns/locale/en-US";
6
6
  import { es as a } from "date-fns/locale/es";
7
7
  import { pt as o } from "date-fns/locale/pt";
8
8
  import { parseISO as s } from "date-fns/parseISO";
9
- //#region src/helpers/formatDate.ts
9
+ //#region src/dates/formatDate.ts
10
10
  var c = {
11
11
  en: i,
12
12
  es: a,
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Dates as a page shows them — formatted, parsed, relative to now — in the locales a space speaks. Apart from `helpers`
3
+ * because date-fns is heavy to load (a hundred modules), and only what shows a date should pay for it.
4
+ */
5
+ export * from './formatDate';
6
+ export * from './isDate';
@@ -0,0 +1,3 @@
1
+ import { formatDate as e, formatDateUTC as t, formatFromNow as n, formatUTCToLocal as r, getDurationMs as i, isValidFormat as a, parseDate as o, toUnixSeconds as s } from "./formatDate.mjs";
2
+ import { isDate as c } from "./isDate.mjs";
3
+ export { e as formatDate, t as formatDateUTC, n as formatFromNow, r as formatUTCToLocal, i as getDurationMs, c as isDate, a as isValidFormat, o as parseDate, s as toUnixSeconds };
@@ -1,7 +1,7 @@
1
1
  import { format as e } from "date-fns/format";
2
2
  import { isValid as t } from "date-fns/isValid";
3
3
  import { parse as n } from "date-fns/parse";
4
- //#region src/helpers/isDate.ts
4
+ //#region src/dates/isDate.ts
5
5
  function r(r, i) {
6
6
  if (typeof r != "string") return !1;
7
7
  try {
@@ -1,10 +1,8 @@
1
1
  import { default as debugCookieName } from './debugCookie';
2
- import { default as DevToolsContext } from './DevToolsContext';
3
2
  import { default as isInteractionFlow } from './interactionLog';
4
3
  import { default as PlitziConsole } from './utils/PlitziConsole';
5
4
  export * from './chrome';
6
5
  export * from './debugCookie';
7
- export * from './DevToolsContext';
8
6
  export * from './interactionLog';
9
7
  export * from './utils/PlitziConsole';
10
- export { PlitziConsole, DevToolsContext, debugCookieName, isInteractionFlow };
8
+ export { PlitziConsole, debugCookieName, isInteractionFlow };
@@ -1,6 +1,5 @@
1
- import e from "./DevToolsContext.mjs";
2
- import { DEV_TOOLS_ATTRIBUTE as t, HIDE_DEV_TOOLS_CSS as n } from "./chrome.mjs";
3
- import { debugCookieName as r } from "./debugCookie.mjs";
4
- import i from "./interactionLog.mjs";
5
- import a, { createStoreDevToolsLogger as o, pConsole as s } from "./utils/PlitziConsole.mjs";
6
- export { t as DEV_TOOLS_ATTRIBUTE, e as DevToolsContext, n as HIDE_DEV_TOOLS_CSS, a as PlitziConsole, o as createStoreDevToolsLogger, r as debugCookieName, i as isInteractionFlow, s as pConsole };
1
+ import { DEV_TOOLS_ATTRIBUTE as e, HIDE_DEV_TOOLS_CSS as t } from "./chrome.mjs";
2
+ import { debugCookieName as n } from "./debugCookie.mjs";
3
+ import r from "./interactionLog.mjs";
4
+ import i, { createStoreDevToolsLogger as a, pConsole as o } from "./utils/PlitziConsole.mjs";
5
+ export { e as DEV_TOOLS_ATTRIBUTE, t as HIDE_DEV_TOOLS_CSS, i as PlitziConsole, a as createStoreDevToolsLogger, n as debugCookieName, r as isInteractionFlow, o as pConsole };
@@ -1,4 +1,4 @@
1
- import { Log, ProviderCallback } from '../types';
1
+ import { Log, ProviderCallback } from '../../types';
2
2
  import { Dispatch, SetStateAction } from 'react';
3
3
  export type DevToolsContextValue = {
4
4
  providers: Record<string, ProviderCallback>;
@@ -1,4 +1,4 @@
1
- import { sharedContext as e } from "../helpers/sharedContext.mjs";
1
+ import { sharedContext as e } from "../../helpers/sharedContext.mjs";
2
2
  var t = e("DevToolsContext", {
3
3
  logs: [],
4
4
  providers: {}
@@ -0,0 +1,3 @@
1
+ /** devTools's React bindings — apart from `@plitzi/sdk-shared/devTools`, which a server imports without React's hooks and contexts. */
2
+ export { default as DevToolsContext } from './DevToolsContext';
3
+ export * from './DevToolsContext';
@@ -0,0 +1 @@
1
+ export { default as DevToolsContext } from "./DevToolsContext.mjs";
@@ -56,17 +56,7 @@ var e = (e, t = 2) => String(e).padStart(t, "0"), t = (t) => `${e(t.getHours())}
56
56
  this.#r.push(n), this.#r.length > this.recentLimit && this.#r.shift();
57
57
  for (let e of this.#n) e(n);
58
58
  }
59
- if (!this.callbackInternal) {
60
- this.pendingLogs.push({
61
- logType: e,
62
- category: t,
63
- message: r,
64
- params: i,
65
- time: a
66
- }), this.pendingLogs.length > this.pendingLimit && this.pendingLogs.shift();
67
- return;
68
- }
69
- this.listening ? this.logsListened.push({
59
+ this.callbackInternal ? (this.listening ? this.logsListened.push({
70
60
  logType: e,
71
61
  category: t,
72
62
  message: r,
@@ -78,7 +68,13 @@ var e = (e, t = 2) => String(e).padStart(t, "0"), t = (t) => `${e(t.getHours())}
78
68
  message: r,
79
69
  params: i,
80
70
  time: a
81
- }), this.#a()), this.logsListened.length > this.logsListenedLimit && this.logsListened.shift();
71
+ }), this.#a()), this.logsListened.length > this.logsListenedLimit && this.logsListened.shift()) : (this.pendingLogs.push({
72
+ logType: e,
73
+ category: t,
74
+ message: r,
75
+ params: i,
76
+ time: a
77
+ }), this.pendingLogs.length > this.pendingLimit && this.pendingLogs.shift());
82
78
  }
83
79
  #a() {
84
80
  this.#t || (this.#t = !0, queueMicrotask(() => {
@@ -1,2 +1 @@
1
- import e from "./ComponentContext.mjs";
2
- export { e as ComponentContext };
1
+ export { default as ComponentContext } from "./ComponentContext.mjs";
@@ -1,16 +1,16 @@
1
- import { cookieFromHeader as e } from "../helpers/cookies.mjs";
2
- import { isFlagName as t } from "./schemaFlag.mjs";
1
+ import { isFlagName as e } from "./schemaFlag.mjs";
2
+ import { cookieFromHeader as t } from "../helpers/cookies.mjs";
3
3
  //#region src/flags/flagsCookie.ts
4
4
  var n = (e) => {
5
5
  let t = e?.split(":")[1];
6
6
  return t ? `plitzi_flags_${t}` : "plitzi_flags";
7
- }, r = (e) => e ? Object.fromEntries(e.split(",").map((e) => e.split(":")).filter(([e, n]) => t(e) && (n === "1" || n === "0")).map(([e, t]) => [e, t === "1"])) : {}, i = (e) => Object.entries(e).filter(([e]) => t(e)).map(([e, t]) => `${e}:${t ? "1" : "0"}`).join(","), a = (e, t, n) => {
7
+ }, r = (t) => t ? Object.fromEntries(t.split(",").map((e) => e.split(":")).filter(([t, n]) => e(t) && (n === "1" || n === "0")).map(([e, t]) => [e, t === "1"])) : {}, i = (t) => Object.entries(t).filter(([t]) => e(t)).map(([e, t]) => `${e}:${t ? "1" : "0"}`).join(","), a = (e, t, n) => {
8
8
  let { [t]: r, ...i } = e;
9
9
  return n === void 0 ? i : {
10
10
  ...i,
11
11
  [t]: n
12
12
  };
13
- }, o = (t, i) => r(e(t, n(i))), s = (e, t) => {
13
+ }, o = (e, i) => r(t(e, n(i))), s = (e, t) => {
14
14
  let r = n(e), a = i(t);
15
15
  try {
16
16
  document.cookie = a ? `${r}=${encodeURIComponent(a)};path=/;SameSite=Lax` : `${r}=;path=/;max-age=0;SameSite=Lax`;
@@ -1,4 +1,4 @@
1
1
  import { FLAG_GATE_PATTERN as e, FLAG_NAME_PATTERN as t, isFlagName as n, isSchemaFlag as r } from "./schemaFlag.mjs";
2
2
  import { flagsCookieName as i, forcedFlagsFromCookies as a, parseFlagList as o, serializeFlagList as s, withForcedFlag as c, writeForcedFlags as l } from "./flagsCookie.mjs";
3
- import { FLAG_LAYERS as u, flagUserFromSSR as d, flagValues as f, hasConditions as p, passesFlagGate as m, resolveFlags as h, undeclaredFlagOverrides as g } from "./resolveFlags.mjs";
4
- export { e as FLAG_GATE_PATTERN, u as FLAG_LAYERS, t as FLAG_NAME_PATTERN, d as flagUserFromSSR, f as flagValues, i as flagsCookieName, a as forcedFlagsFromCookies, p as hasConditions, n as isFlagName, r as isSchemaFlag, o as parseFlagList, m as passesFlagGate, h as resolveFlags, s as serializeFlagList, g as undeclaredFlagOverrides, c as withForcedFlag, l as writeForcedFlags };
3
+ import { FLAG_LAYERS as u, flagUserFrom as d, flagUserFromSSR as f, flagValues as p, hasConditions as m, passesFlagGate as h, resolveFlags as g, undeclaredFlagOverrides as _ } from "./resolveFlags.mjs";
4
+ export { e as FLAG_GATE_PATTERN, u as FLAG_LAYERS, t as FLAG_NAME_PATTERN, d as flagUserFrom, f as flagUserFromSSR, p as flagValues, i as flagsCookieName, a as forcedFlagsFromCookies, m as hasConditions, n as isFlagName, r as isSchemaFlag, o as parseFlagList, h as passesFlagGate, g as resolveFlags, s as serializeFlagList, _ as undeclaredFlagOverrides, c as withForcedFlag, l as writeForcedFlags };
@@ -0,0 +1,3 @@
1
+ /** flags's React bindings — apart from `@plitzi/sdk-shared/flags`, which a server imports without React's hooks and contexts. */
2
+ export { default as useFlagResolution } from './useFlagResolution';
3
+ export * from './useFlagResolution';
@@ -0,0 +1 @@
1
+ export { default as useFlagResolution } from "./useFlagResolution.mjs";