@plitzi/sdk-schema 0.38.16 → 0.38.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @plitzi/sdk-schema
2
2
 
3
+ ## 0.38.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 4f8dc37: ## Packages
8
+
9
+ - **A library package is imported by its root and its folders, never by a file** (`@plitzi/sdk-shared`, `sdk-schema`,
10
+ `sdk-style`, `sdk-elements`, `sdk-interactions`, `sdk-auth`, `sdk-dev-tools`, `sdk-event-bridge`, `sdk-navigation`,
11
+ `sdk-plugins`, `sdk-variables`): each `exports` is now `"."` and `"./*"`, the latter a folder's `index`.
12
+ `@plitzi/sdk-shared/helpers/isRecord` becomes `import { isRecord } from '@plitzi/sdk-shared/helpers'`, and a default
13
+ export by the name its folder gives it — almost always its file's (`import usePlitzi from '…/hooks/usePlitzi'` →
14
+ `import { usePlitzi } from '@plitzi/sdk-shared/hooks'`). A file-level specifier now fails with `ERR_MODULE_NOT_FOUND`.
15
+ New entries where a folder barrel would have brought more than was asked for: `@plitzi/sdk-shared/project` and
16
+ `@plitzi/sdk-shared/plugins/bundle` (Node only), `@plitzi/sdk-interactions/declarations` (the global callbacks and
17
+ utility specs, without React), and `@plitzi/sdk-elements/elements/declarations`, which now also carries the
18
+ declarations' attribute types and the constants they are checked with. `RuleGroup` is exported by `@plitzi/sdk-shared`
19
+ with the document types that use it. `plitzi upgrade migrations` names every such import in a project, with the folder to
20
+ import it from instead.
21
+ - **`@plitzi/sdk-shared`'s root exports the document types, and only them** (`@plitzi/sdk-shared`): what the package
22
+ does is imported from its folder — `formatDate` from `@plitzi/sdk-shared/helpers`, `ThemeProvider` from
23
+ `@plitzi/sdk-shared/theme`, a GraphQL operation's types from `@plitzi/sdk-shared/network/graphql` — so a module that
24
+ imports a type from the root no longer loads every area of the package.
25
+ - **What one package alone used lives in that package** (`@plitzi/sdk-shared`, `@plitzi/sdk-elements`): the data
26
+ source hooks moved from `@plitzi/sdk-shared/dataSource/hooks` to `@plitzi/sdk-elements/dataSource`
27
+ (`useRegisterSource`, `useResolvedVariables`), and the Apollo links the builder's client is built with into the
28
+ builder.
29
+ - **The builder's panels are an entry of their own** (`@plitzi/sdk-style`, `@plitzi/sdk-variables`,
30
+ `@plitzi/sdk-elements`): the style inspector, the advanced style editor and `BuilderStyleContextProvider` are imported
31
+ from `@plitzi/sdk-style/builder`; the variables' lists and forms from `@plitzi/sdk-variables/builder`; the elements'
32
+ settings panels (`defaultElementsSettings`) from `@plitzi/sdk-elements/builder`. Each package's root keeps what a page
33
+ and a server use — `generateCache` no longer loads the inspector, on a server 227 modules down to 21.
34
+
35
+ ## CLI
36
+ - **`plitzi upgrade`'s `renames` part is now `migrations`** (`@plitzi/cli`): what a version changed that a project's
37
+ own source must follow, one file per change in the CLI's `src/migrations/changes/` with the version it shipped in —
38
+ rewritten with `--write` when it has one right answer, said otherwise. The `--json` report carries `migrations` (each
39
+ with its `migration`, `since`, `file`, `line`, `what` and whether it was `written`) in place of `renames` and
40
+ `changes`. The changes of 0.38.0 (`canTemplate` → `canSnippet`, the `*Template` authoring names), 0.38.9 (a
41
+ `formControl` without `required` is optional) and 0.38.12 (`usePlitziServiceContext` → `usePlitzi`) are no longer
42
+ looked for: a project still on one of those versions makes them by hand.
43
+
44
+ - Updated dependencies [4f8dc37]
45
+ - @plitzi/sdk-shared@0.38.17
46
+ - @plitzi/sdk-style@0.38.17
47
+
3
48
  ## 0.38.16
4
49
 
5
50
  ### Patch Changes
@@ -1,4 +1,5 @@
1
- import { Element, PageFolder, ReducerActionOrigin, Schema, SnippetStyle, SchemaFlag, SchemaVariable, DropPosition, SpaceComponent, SpaceComponentDeclaration } from '@plitzi/sdk-shared';
1
+ import { Element, PageFolder, Schema, SnippetStyle, SchemaFlag, SchemaVariable, DropPosition, SpaceComponent, SpaceComponentDeclaration } from '@plitzi/sdk-shared';
2
+ import { ReducerActionOrigin } from '@plitzi/sdk-shared/helpers';
2
3
  export declare const SchemaActions: {
3
4
  readonly SCHEMA_UPDATE: "SCHEMA_UPDATE";
4
5
  readonly SCHEMA_ADD_PAGE: "SCHEMA_ADD_PAGE";
@@ -1,8 +1,8 @@
1
1
  import { elementIdConflict as e, elementIdsFree as t, randomElementId as n, repointIds as r, takenIds as i, uniqueElementId as a } from "./elementId.mjs";
2
2
  import { descendants as o, parentChain as s } from "./elementTree.mjs";
3
- import { VARIABLE_REGEX as c } from "@plitzi/sdk-shared/schema/schemaConstants";
4
- import { EMPTY_STYLE_SCHEMA as l } from "@plitzi/sdk-shared/style/styleConstants";
5
- import u from "@plitzi/sdk-style/helpers/calculateInheriting";
3
+ import { VARIABLE_REGEX as c } from "@plitzi/sdk-shared/schema";
4
+ import { EMPTY_STYLE_SCHEMA as l } from "@plitzi/sdk-shared/style";
5
+ import { calculateInheriting as u } from "@plitzi/sdk-style/helpers";
6
6
  //#region src/helpers/FlatMap.ts
7
7
  var d = class {
8
8
  flat;
@@ -50,20 +50,14 @@ var e = /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/, t = (t) => e.test(t), n = (
50
50
  if (typeof r == "string") {
51
51
  let a = h(r, t);
52
52
  a !== r && (e[i] = a, n = !0);
53
- return;
54
- }
55
- n = g(r, t) || n;
53
+ } else n = g(r, t) || n;
56
54
  }), n;
57
55
  if (!e || typeof e != "object") return !1;
58
56
  let r = e;
59
- for (let [e, i] of Object.entries(r)) {
60
- if (typeof i == "string") {
61
- let a = h(i, t);
62
- a !== i && (r[e] = a, n = !0);
63
- continue;
64
- }
65
- n = g(i, t) || n;
66
- }
57
+ for (let [e, i] of Object.entries(r)) if (typeof i == "string") {
58
+ let a = h(i, t);
59
+ a !== i && (r[e] = a, n = !0);
60
+ } else n = g(i, t) || n;
67
61
  return n;
68
62
  }, _ = (e, t, n) => {
69
63
  let r = Object.entries(t).filter(([e, t]) => e !== t);
@@ -1,8 +1,7 @@
1
1
  import { remapCollidingIds as e } from "./elementId.mjs";
2
2
  import { documentIds as t } from "./components.mjs";
3
- import { isDisplayMode as n } from "@plitzi/sdk-shared/style/displayModes";
4
- import { sameSelector as r, selectorsOf as i } from "@plitzi/sdk-shared/style/snippetStyle";
5
- import a from "@plitzi/sdk-style/helpers/processSelector";
3
+ import { isDisplayMode as n, sameSelector as r, selectorsOf as i } from "@plitzi/sdk-shared/style";
4
+ import { processSelector as a } from "@plitzi/sdk-style/helpers";
6
5
  //#region src/helpers/fitSnippet.ts
7
6
  var o = (e, t) => {
8
7
  let n = 2;
@@ -1,6 +1,6 @@
1
1
  import { isValidElementId as e } from "./elementId.mjs";
2
2
  import { isInstance as t, propNameProblem as n } from "./components.mjs";
3
- import { findLayoutCycle as r } from "@plitzi/sdk-shared/schema/layoutChain";
3
+ import { findLayoutCycle as r } from "@plitzi/sdk-shared/schema";
4
4
  //#region src/helpers/schemaValidator.ts
5
5
  var i = /* @__PURE__ */ new Set([
6
6
  "UNRESOLVED_BINDING_SOURCE",
@@ -165,15 +165,7 @@ var i = /* @__PURE__ */ new Set([
165
165
  elementId: n
166
166
  }), e.add(n);
167
167
  let i = g(n);
168
- if (!i) {
169
- s.push({
170
- code: "INVALID_PAGE_REFERENCE",
171
- message: `Page ID "${n}" in pages array doesn't exist in flat`,
172
- elementId: n
173
- });
174
- return;
175
- }
176
- i.definition.type !== "page" && s.push({
168
+ i ? (i.definition.type !== "page" && s.push({
177
169
  code: "INVALID_PAGE_TYPE",
178
170
  message: `Element "${n}" in pages array has type "${i.definition.type}" instead of "page"`,
179
171
  elementId: n
@@ -181,7 +173,11 @@ var i = /* @__PURE__ */ new Set([
181
173
  code: "PAGE_ROOT_ID_MISMATCH",
182
174
  message: `Page "${n}" has rootId "${i.definition.rootId}" instead of its own ID`,
183
175
  elementId: n
184
- }), i.attributes?.default && t++;
176
+ }), i.attributes?.default && t++) : s.push({
177
+ code: "INVALID_PAGE_REFERENCE",
178
+ message: `Page ID "${n}" in pages array doesn't exist in flat`,
179
+ elementId: n
180
+ });
185
181
  }), t === 0 && u.length > 0 ? c.push({
186
182
  code: "NO_DEFAULT_PAGE",
187
183
  message: "No default page found in schema"
@@ -210,14 +206,7 @@ var i = /* @__PURE__ */ new Set([
210
206
  }, T = () => {
211
207
  let e = /* @__PURE__ */ new Set();
212
208
  d.forEach((t, n) => {
213
- if (!t.id) {
214
- s.push({
215
- code: "INVALID_FOLDER",
216
- message: `Page folder at index ${n} has no id`
217
- });
218
- return;
219
- }
220
- e.has(t.id) && s.push({
209
+ t.id ? (e.has(t.id) && s.push({
221
210
  code: "DUPLICATE_FOLDER",
222
211
  message: `Duplicate folder ID "${t.id}"`,
223
212
  elementId: t.id
@@ -226,7 +215,10 @@ var i = /* @__PURE__ */ new Set([
226
215
  message: `Folder "${t.id}" has non-existent parent "${t.parentId}"`,
227
216
  elementId: t.id,
228
217
  details: { parentId: t.parentId }
229
- }));
218
+ }))) : s.push({
219
+ code: "INVALID_FOLDER",
220
+ message: `Page folder at index ${n} has no id`
221
+ });
230
222
  });
231
223
  }, E = () => {
232
224
  let e = /* @__PURE__ */ new Set();
@@ -264,14 +256,7 @@ var i = /* @__PURE__ */ new Set([
264
256
  }, O = () => {
265
257
  let e = /* @__PURE__ */ new Set();
266
258
  f.forEach((t, n) => {
267
- if (!t.name) {
268
- s.push({
269
- code: "INVALID_VARIABLE",
270
- message: `Variable at index ${n} has no name`
271
- });
272
- return;
273
- }
274
- e.has(t.name) && s.push({
259
+ t.name ? (e.has(t.name) && s.push({
275
260
  code: "DUPLICATE_VARIABLE",
276
261
  message: `Duplicate variable name "${t.name}"`,
277
262
  details: { variableName: t.name }
@@ -279,6 +264,9 @@ var i = /* @__PURE__ */ new Set([
279
264
  code: "MISSING_VARIABLE_TYPE",
280
265
  message: `Variable "${t.name}" has no type`,
281
266
  details: { variableName: t.name }
267
+ })) : s.push({
268
+ code: "INVALID_VARIABLE",
269
+ message: `Variable at index ${n} has no name`
282
270
  });
283
271
  });
284
272
  }, k = () => {
@@ -376,20 +364,16 @@ var i = /* @__PURE__ */ new Set([
376
364
  let t = /* @__PURE__ */ new Set();
377
365
  Object.entries(e.definition.bindings).forEach(([n, r]) => {
378
366
  (r ?? []).forEach((r) => {
379
- if (!r.id) {
380
- s.push({
381
- code: "MISSING_BINDING_ID",
382
- message: `Element "${e.id}" has a ${n} binding to "${r.to}" with no id`,
383
- elementId: e.id
384
- });
385
- return;
386
- }
387
- t.has(r.id) && s.push({
367
+ r.id ? (t.has(r.id) && s.push({
388
368
  code: "DUPLICATE_BINDING_ID",
389
369
  message: `Element "${e.id}" has two bindings called "${r.id}"`,
390
370
  elementId: e.id,
391
371
  details: { bindingId: r.id }
392
- }), t.add(r.id);
372
+ }), t.add(r.id)) : s.push({
373
+ code: "MISSING_BINDING_ID",
374
+ message: `Element "${e.id}" has a ${n} binding to "${r.to}" with no id`,
375
+ elementId: e.id
376
+ });
393
377
  });
394
378
  });
395
379
  });
@@ -465,16 +449,12 @@ var i = /* @__PURE__ */ new Set([
465
449
  Object.values(n).forEach((r) => {
466
450
  if (!r || !t(r)) return;
467
451
  let i = r.attributes.referenceId, a = typeof i == "string" ? p[i] : void 0;
468
- if (!a || typeof i != "string") {
469
- s.push({
470
- code: "UNRESOLVED_COMPONENT",
471
- message: `Instance "${r.id}" places component "${String(i)}", which this space does not declare`,
472
- elementId: r.id,
473
- ...e ? { componentId: e } : {}
474
- });
475
- return;
476
- }
477
- e && d.set(e, (d.get(e) ?? /* @__PURE__ */ new Set()).add(i)), (r.definition.items ?? []).forEach((t) => {
452
+ !a || typeof i != "string" ? s.push({
453
+ code: "UNRESOLVED_COMPONENT",
454
+ message: `Instance "${r.id}" places component "${String(i)}", which this space does not declare`,
455
+ elementId: r.id,
456
+ ...e ? { componentId: e } : {}
457
+ }) : (e && d.set(e, (d.get(e) ?? /* @__PURE__ */ new Set()).add(i)), (r.definition.items ?? []).forEach((t) => {
478
458
  let o = n[t]?.attributes.slot ?? a.slots?.[0];
479
459
  (typeof o != "string" || !a.slots?.includes(o)) && s.push({
480
460
  code: "UNKNOWN_COMPONENT_SLOT",
@@ -482,7 +462,7 @@ var i = /* @__PURE__ */ new Set([
482
462
  elementId: t,
483
463
  ...e ? { componentId: e } : {}
484
464
  });
485
- });
465
+ }));
486
466
  });
487
467
  });
488
468
  let f = /* @__PURE__ */ new Set(), m = (e, t) => {
@@ -494,9 +474,7 @@ var i = /* @__PURE__ */ new Set([
494
474
  componentId: e,
495
475
  details: { cycle: n }
496
476
  }));
497
- return;
498
- }
499
- d.get(e)?.forEach((n) => m(n, [...t, e]));
477
+ } else d.get(e)?.forEach((n) => m(n, [...t, e]));
500
478
  };
501
479
  Object.keys(p).forEach((e) => m(e, []));
502
480
  };
package/dist/index.d.ts CHANGED
@@ -6,3 +6,13 @@ export * from './helpers/components';
6
6
  export * from './helpers/elementTree';
7
7
  export * from './helpers/schemaValidator';
8
8
  export { FlatMap, SchemaReducer };
9
+ export { slugifyElementId } from './helpers/elementId';
10
+ export { uniqueElementId } from './helpers/elementId';
11
+ export { isValidElementId } from './helpers/elementId';
12
+ export { positionalElementId } from './helpers/elementId';
13
+ export { elementIdConflict } from './helpers/elementId';
14
+ export { randomElementId } from './helpers/elementId';
15
+ export { default as fitSnippet } from './helpers/fitSnippet';
16
+ export { repointIds } from './helpers/elementId';
17
+ export { styleWithoutTag } from './helpers/styleWithoutTag';
18
+ export { rendersNoTag } from './helpers/styleWithoutTag';
package/dist/index.mjs CHANGED
@@ -1,6 +1,9 @@
1
- import { descendants as e, elementsByRoot as t, parentChain as n, renderContext as r, rootName as i } from "./helpers/elementTree.mjs";
2
- import a from "./helpers/FlatMap.mjs";
3
- import { RESERVED_PROP_NAMES as o, addComponent as s, componentNamed as c, detachInstance as l, documentIds as u, flatMapOf as d, instancesOf as f, isInstance as p, propNameProblem as m, removeComponent as h, renameElement as g, treeOf as _, treesOf as v, updateComponent as y } from "./helpers/components.mjs";
4
- import b, { SchemaActions as x } from "./SchemaReducer.mjs";
5
- import { REFERENCE_ERROR_CODES as S, assertSchemaValid as C, isIntegrityError as w, isSchemaValid as T, validateSchema as E } from "./helpers/schemaValidator.mjs";
6
- export { a as FlatMap, S as REFERENCE_ERROR_CODES, o as RESERVED_PROP_NAMES, x as SchemaActions, b as SchemaReducer, s as addComponent, C as assertSchemaValid, c as componentNamed, e as descendants, l as detachInstance, u as documentIds, t as elementsByRoot, d as flatMapOf, f as instancesOf, p as isInstance, w as isIntegrityError, T as isSchemaValid, n as parentChain, m as propNameProblem, h as removeComponent, g as renameElement, r as renderContext, i as rootName, _ as treeOf, v as treesOf, y as updateComponent, E as validateSchema };
1
+ import { elementIdConflict as e, isValidElementId as t, positionalElementId as n, randomElementId as r, repointIds as i, slugifyElementId as a, uniqueElementId as o } from "./helpers/elementId.mjs";
2
+ import { descendants as s, elementsByRoot as c, parentChain as l, renderContext as u, rootName as d } from "./helpers/elementTree.mjs";
3
+ import f from "./helpers/FlatMap.mjs";
4
+ import { RESERVED_PROP_NAMES as p, addComponent as m, componentNamed as h, detachInstance as g, documentIds as _, flatMapOf as v, instancesOf as y, isInstance as b, propNameProblem as x, removeComponent as S, renameElement as C, treeOf as w, treesOf as T, updateComponent as E } from "./helpers/components.mjs";
5
+ import D, { SchemaActions as O } from "./SchemaReducer.mjs";
6
+ import k from "./helpers/fitSnippet.mjs";
7
+ import { REFERENCE_ERROR_CODES as A, assertSchemaValid as j, isIntegrityError as M, isSchemaValid as N, validateSchema as P } from "./helpers/schemaValidator.mjs";
8
+ import { rendersNoTag as F, styleWithoutTag as I } from "./helpers/styleWithoutTag.mjs";
9
+ export { f as FlatMap, A as REFERENCE_ERROR_CODES, p as RESERVED_PROP_NAMES, O as SchemaActions, D as SchemaReducer, m as addComponent, j as assertSchemaValid, h as componentNamed, s as descendants, g as detachInstance, _ as documentIds, e as elementIdConflict, c as elementsByRoot, k as fitSnippet, v as flatMapOf, y as instancesOf, b as isInstance, M as isIntegrityError, N as isSchemaValid, t as isValidElementId, l as parentChain, n as positionalElementId, x as propNameProblem, r as randomElementId, S as removeComponent, C as renameElement, u as renderContext, F as rendersNoTag, i as repointIds, d as rootName, a as slugifyElementId, I as styleWithoutTag, w as treeOf, T as treesOf, o as uniqueElementId, E as updateComponent, P as validateSchema };
package/package.json CHANGED
@@ -1,50 +1,20 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-schema",
3
- "version": "0.38.16",
3
+ "version": "0.38.17",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "exports": {
9
9
  ".": {
10
+ "@plitzi/source": "./src/index.ts",
10
11
  "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.mjs"
12
13
  },
13
- "./SchemaReducer": {
14
- "types": "./dist/SchemaReducer.d.ts",
15
- "import": "./dist/SchemaReducer.mjs"
16
- },
17
- "./helpers/FlatMap": {
18
- "types": "./dist/helpers/FlatMap.d.ts",
19
- "import": "./dist/helpers/FlatMap.mjs"
20
- },
21
- "./helpers/components": {
22
- "types": "./dist/helpers/components.d.ts",
23
- "import": "./dist/helpers/components.mjs"
24
- },
25
- "./helpers/elementId": {
26
- "types": "./dist/helpers/elementId.d.ts",
27
- "import": "./dist/helpers/elementId.mjs"
28
- },
29
- "./helpers/elementTree": {
30
- "types": "./dist/helpers/elementTree.d.ts",
31
- "import": "./dist/helpers/elementTree.mjs"
32
- },
33
- "./helpers/fitSnippet": {
34
- "types": "./dist/helpers/fitSnippet.d.ts",
35
- "import": "./dist/helpers/fitSnippet.mjs"
36
- },
37
- "./helpers/schemaValidator": {
38
- "types": "./dist/helpers/schemaValidator.d.ts",
39
- "import": "./dist/helpers/schemaValidator.mjs"
40
- },
41
- "./helpers/styleWithoutTag": {
42
- "types": "./dist/helpers/styleWithoutTag.d.ts",
43
- "import": "./dist/helpers/styleWithoutTag.mjs"
44
- },
45
- "./index": {
46
- "types": "./dist/index.d.ts",
47
- "import": "./dist/index.mjs"
14
+ "./*": {
15
+ "@plitzi/source": "./src/*/index.ts",
16
+ "types": "./dist/*/index.d.ts",
17
+ "import": "./dist/*/index.mjs"
48
18
  }
49
19
  },
50
20
  "type": "module",
@@ -55,20 +25,20 @@
55
25
  "test": "vitest run",
56
26
  "test:watch": "vitest",
57
27
  "test:ui": "vitest --ui",
58
- "build:dev": "vite build --mode development --minify false && node ../sdk-shared/scripts/generate-exports.mjs",
28
+ "build:dev": "vite build --mode development --minify false",
59
29
  "build:dev-watch": "vite build --mode development --watch --minify false",
60
- "build:prod": "vite build && node ../sdk-shared/scripts/generate-exports.mjs"
30
+ "build:prod": "vite build"
61
31
  },
62
32
  "dependencies": {
63
33
  "@plitzi/plitzi-ui": "^1.6.33",
64
- "@plitzi/sdk-shared": "0.38.16",
65
- "@plitzi/sdk-style": "0.38.16",
34
+ "@plitzi/sdk-shared": "0.38.17",
35
+ "@plitzi/sdk-style": "0.38.17",
66
36
  "immer": "^11.1.21"
67
37
  },
68
38
  "devDependencies": {
69
39
  "eslint": "^9.39.5",
70
40
  "typescript": "^6.0.3",
71
- "vite": "^8.3.2",
72
- "vitest": "^5.0.3"
41
+ "vite": "^8.3.4",
42
+ "vitest": "^5.0.5"
73
43
  }
74
44
  }