@plitzi/sdk-shared 0.39.3 → 0.39.4

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 (54) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/clients/index.d.ts +59 -0
  3. package/dist/clients/index.mjs +38 -0
  4. package/dist/conditions/types.d.ts +1 -1
  5. package/dist/csrf/csrf.d.ts +36 -0
  6. package/dist/csrf/csrf.mjs +62 -0
  7. package/dist/csrf/index.d.ts +2 -0
  8. package/dist/csrf/index.mjs +1 -0
  9. package/dist/helpers/deepEqual/deepEqual.mjs +3 -2
  10. package/dist/helpers/lodash/cloneDeep.d.ts +3 -3
  11. package/dist/helpers/lodash/cloneDeep.mjs +24 -27
  12. package/dist/helpers/lodash/has.d.ts +2 -1
  13. package/dist/helpers/lodash/has.mjs +8 -8
  14. package/dist/helpers/lodash/index.d.ts +1 -1
  15. package/dist/helpers/lodash/omit.mjs +2 -2
  16. package/dist/helpers/twigWrapper/filters/arrays.mjs +43 -42
  17. package/dist/helpers/twigWrapper/filters/filters.mjs +3 -3
  18. package/dist/helpers/twigWrapper/filters/index.mjs +4 -4
  19. package/dist/helpers/twigWrapper/filters/misc.mjs +14 -13
  20. package/dist/helpers/twigWrapper/filters/objects.mjs +50 -49
  21. package/dist/helpers/twigWrapper/filters/strings.mjs +41 -40
  22. package/dist/helpers/twigWrapper/filters/types.d.ts +4 -0
  23. package/dist/helpers/twigWrapper/filters/types.mjs +2 -2
  24. package/dist/navigation/index.d.ts +1 -1
  25. package/dist/navigation/index.mjs +3 -3
  26. package/dist/navigation/routes.d.ts +2 -0
  27. package/dist/navigation/routes.mjs +2 -1
  28. package/dist/navigation/sitemap.d.ts +8 -0
  29. package/dist/navigation/sitemap.mjs +7 -4
  30. package/dist/react/index.d.ts +1 -1
  31. package/dist/refusals/index.d.ts +112 -0
  32. package/dist/refusals/index.mjs +94 -0
  33. package/dist/schema/aiCrawlers.d.ts +25 -0
  34. package/dist/schema/aiCrawlers.mjs +34 -0
  35. package/dist/schema/documentParts.d.ts +45 -0
  36. package/dist/schema/documentParts.mjs +73 -0
  37. package/dist/schema/index.d.ts +3 -0
  38. package/dist/schema/index.mjs +21 -18
  39. package/dist/schema/pageAccess.mjs +1 -1
  40. package/dist/schema/plitziMark.d.ts +9 -0
  41. package/dist/schema/plitziMark.mjs +3 -0
  42. package/dist/schema/schemaSettings.d.ts +1 -1
  43. package/dist/schema/schemaSettings.mjs +1 -1
  44. package/dist/schema/serverElements.d.ts +5 -0
  45. package/dist/store/runtimeStatePersist.mjs +2 -2
  46. package/dist/store/storeHooks.d.ts +33 -33
  47. package/dist/style/runtimeStyle.d.ts +5 -2
  48. package/dist/style/runtimeStyle.mjs +1 -1
  49. package/dist/types/ActionTypes.d.ts +2 -0
  50. package/dist/types/AuthTypes.d.ts +5 -0
  51. package/dist/types/SchemaTypes.d.ts +31 -4
  52. package/dist/types/StoreTypes.d.ts +5 -0
  53. package/eslint.config.mjs +123 -100
  54. package/package.json +1 -1
@@ -22,6 +22,9 @@ export declare const styleSheetHref: (hash: string) => string;
22
22
  export declare const styleSheetLinkable: (cache: string) => boolean;
23
23
  /**
24
24
  * The stylesheet's text: the cache in the runtime layer, with the layers' order said first — the file may be the first
25
- * thing on the page to name them, and a plugin's stylesheet arriving later would otherwise take a layer above it.
25
+ * thing on the page to name them, and a plugin's stylesheet arriving later would otherwise take a layer above it — and
26
+ * the space's custom CSS after it, in the order the page drew them: the same on every page and for every visitor, it
27
+ * was most of what a page carried inline (44 KB of Plitzi's website's every page) and is kept by the browser with the
28
+ * rest. The page then carries the variables alone, which a request resolves.
26
29
  */
27
- export declare const styleSheetCss: (cache: string) => string;
30
+ export declare const styleSheetCss: (cache: string, customCss?: string) => string;
@@ -1,4 +1,4 @@
1
1
  import { PLUGIN_CSS_LAYER as e, RUNTIME_CSS_LAYER as t } from "./cssLayers.mjs";
2
2
  // src/style/runtimeStyle.ts
3
- var n = "plitzi-runtime-style", r = "plitzi-style", i = "/_plitzi/style/", a = (e) => `${i}${e}.css`, o = (e) => e !== "" && !e.includes("{{"), s = (n) => `@layer ${e}, ${t};@layer ${t}{${n}}`;
3
+ var n = "plitzi-runtime-style", r = "plitzi-style", i = "/_plitzi/style/", a = (e) => `${i}${e}.css`, o = (e) => e !== "" && !e.includes("{{"), s = (n, r = "") => `@layer ${e}, ${t};@layer ${t}{${r ? `${n}\n${r}` : n}}`;
4
4
  export { n as RUNTIME_STYLE_ID, r as STYLE_SHEET_ID, i as STYLE_SHEET_PATH, s as styleSheetCss, a as styleSheetHref, o as styleSheetLinkable };
@@ -375,6 +375,8 @@ export type ActionRejectRecord = {
375
375
  */
376
376
  export type ActionRunRecord = {
377
377
  runId: string;
378
+ /** The W3C trace the run was part of (`sdk-kernel/trace`): every line it logged, on every process, names it. */
379
+ traceId?: string;
378
380
  actionId: string;
379
381
  spaceId: number;
380
382
  environment: Environment;
@@ -103,6 +103,11 @@ export type AuthContextValue = {
103
103
  * chose to leave, and sent back to it they were only ever sent to sign in again.
104
104
  */
105
105
  signedOutHere?: boolean;
106
+ /**
107
+ * The visitor changed their session on this page — signed in, signed out, or did either in another tab — rather than
108
+ * arriving with it. What the page was sent for its first visitor may not be what it would send them now.
109
+ */
110
+ sessionChangedHere?: boolean;
106
111
  user?: {
107
112
  details?: {
108
113
  id: number;
@@ -4,6 +4,7 @@ import { SnippetStyle } from './SnippetTypes';
4
4
  import { SpaceTests } from './TestTypes';
5
5
  import { BuiltinParam } from '../authoring/paramSpec';
6
6
  import { RuleGroup } from '../conditions/types';
7
+ import { AiCrawlerKind } from '../schema/aiCrawlers';
7
8
  import { ElementMotion } from '../schema/motion';
8
9
  /** The `when` guard a binding, a flag rule and a sub-value are written with: part of the document, so exported with it. */
9
10
  export type { RuleGroup };
@@ -261,11 +262,25 @@ export type Schema = {
261
262
  */
262
263
  robotsTxt?: string;
263
264
  /**
264
- * Keeps the crawlers that gather pages to train AI models (`AI_CRAWLERS`: GPTBot, ClaudeBot, Google-Extended…) out of
265
- * the whole site: `/robots.txt` says `Disallow: /` to each, after whatever `robotsTxt` says. Search engines keep
266
- * reading it. Left out, nobody is kept out.
265
+ * The site's `/.well-known/security.txt` (RFC 9116), as a researcher who found a flaw reads it: where to write
266
+ * (`Contact:`), until when the text holds (`Expires:`), and anything else the RFC names. Left out, the address answers
267
+ * 404 — a site that says nothing is not given words it did not write.
267
268
  */
268
- blockAiCrawlers?: boolean;
269
+ securityTxt?: string;
270
+ /**
271
+ * The space's `/llms.txt` (llmstxt.org), as an assistant reads it to find its way around: the site's name, what it
272
+ * is, and a link to each page with what it is for. Left out, the server writes one from the pages the sitemap lists
273
+ * — each page's SEO title and description. A space that keeps `assistants` out (`blockAiCrawlers`) answers 404:
274
+ * an index for them would invite what the site refuses.
275
+ */
276
+ llmsTxt?: string;
277
+ /**
278
+ * The kinds of AI crawler kept out of the whole site, each its owner's to decide (`AI_CRAWLERS`): `training` (GPTBot,
279
+ * ClaudeBot, Google-Extended…), `assistants` fetching a page for a person (ChatGPT-User, Claude-User…) and AI
280
+ * `search` indexes (OAI-SearchBot, PerplexityBot…). `/robots.txt` says `Disallow: /` to each agent of each kind named,
281
+ * after whatever `robotsTxt` says. Search engines keep reading it. Left out, nobody is kept out.
282
+ */
283
+ blockAiCrawlers?: AiCrawlerKind[];
269
284
  /**
270
285
  * A move from page to page drawn as one view becoming the next (the browser's view transitions): the pages cross-fade,
271
286
  * and an element named the same on both by CSS — `view-transition-name: fighter-portrait` — moves from where it was
@@ -283,6 +298,11 @@ export type Schema = {
283
298
  * yours" there, as on any page. Left out, the platform's few words. A page with an `access` of its own cannot be it.
284
299
  */
285
300
  withheldPage?: string;
301
+ /**
302
+ * Sends the whole space with every page instead of in parts — the page's own elements and its layouts', the rest
303
+ * fetched as a link to it is followed. For a space whose pages read each other's elements at run time.
304
+ */
305
+ wholeDocument?: boolean;
286
306
  /** The language its pages are written in, as a language tag (`en`, `es-MX`): `<html lang>` and `og:locale`. */
287
307
  language?: string;
288
308
  /** The tab's icon: a file of the site (`/favicon.svg`) or an address (`https://…`). Left out, Plitzi's. */
@@ -378,6 +398,13 @@ export type Schema = {
378
398
  pages: Element['id'][];
379
399
  pageFolders: PageFolder[];
380
400
  components: Record<SpaceComponent['id'], SpaceComponent>;
401
+ /**
402
+ * Only in a document a page server sends in parts (`splitSchema`): the roots — pages and layouts — whose elements are
403
+ * not in `flat` yet, each by the name of the part that holds them, fetched before a page that needs it is drawn; `''`
404
+ * for one this visitor is not sent, which only the server can draw. Absent, the document is whole: the SDK alone, the
405
+ * builder, the MCP and a static deploy never see it.
406
+ */
407
+ parts?: Record<string, string>;
381
408
  };
382
409
  export type SchemaContextValue = {
383
410
  definition?: {
@@ -121,6 +121,11 @@ export type CommonState = {
121
121
  href: string;
122
122
  currentPageId: string;
123
123
  navigate: (url: string, how?: NavigateHow) => void;
124
+ /**
125
+ * Gets ready what following a link to `url` will need — the parts of the space its page is drawn from, when the
126
+ * space is sent in parts — so the navigation does not wait for them. Nothing when there is nothing to get.
127
+ */
128
+ prefetch?: (url: string) => void;
124
129
  /**
125
130
  * Where a navigation is going while it waits for the destination's server data — `''` when none is. A link to a
126
131
  * page resolved on the server asks for that page's data before it goes, and the page on screen stays until then:
package/eslint.config.mjs CHANGED
@@ -9,106 +9,129 @@ import storybook from 'eslint-plugin-storybook';
9
9
  import importEslint from 'eslint-plugin-import';
10
10
  import { globalIgnores } from 'eslint/config';
11
11
 
12
- export default tsEslint.config({
13
- extends: [js.configs.recommended, ...tsEslint.configs.strictTypeChecked, globalIgnores(['**/*.js'])],
14
- files: ['**/*.{ts,tsx}'],
15
- ignores: ['node_modules', 'node_modules/*', './node_modules/**', '**/node_modules/**', 'dist', 'coverage', '.yarn/*'],
16
- languageOptions: {
17
- ecmaVersion: 2023,
18
- globals: globals.browser,
19
- parserOptions: {
20
- projectService: {
21
- allowDefaultProject: ['.storybook/*.ts', '.storybook/*.tsx'],
22
- defaultProject: './tsconfig.json'
23
- },
24
- tsconfigRootDir: import.meta.dirname
25
- }
26
- },
27
- plugins: {
28
- import: importEslint,
29
- 'react-hooks': reactHooks,
30
- 'react-refresh': reactRefresh,
31
- react,
32
- prettier,
33
- jsxRuntime: react.configs.flat['jsx-runtime'],
34
- storybook
35
- },
36
- rules: {
37
- ...reactHooks.configs.recommended.rules,
38
- // One rule evaluator for every reader: sdk-shared's (`@plitzi/sdk-shared/conditions`). plitzi-ui keeps a copy of its
39
- // own, which Plitzi never reads, so the builder's preview and the server cannot decide a condition two ways.
40
- '@typescript-eslint/no-restricted-imports': [
41
- 'error',
42
- {
43
- paths: [
44
- {
45
- name: '@plitzi/plitzi-ui/QueryBuilder/evaluator',
46
- message: 'Evaluate a condition with `evaluateRuleGroup` from `@plitzi/sdk-shared/conditions`.'
47
- },
48
- {
49
- name: '@plitzi/plitzi-ui/QueryBuilder',
50
- importNames: ['QueryBuilderEvaluator'],
51
- message: 'Evaluate a condition with `evaluateRuleGroup` from `@plitzi/sdk-shared/conditions`.'
52
- },
53
- {
54
- name: '@plitzi/plitzi-ui/QueryBuilder/helpers',
55
- importNames: ['QueryBuilderEvaluator'],
56
- message: 'Evaluate a condition with `evaluateRuleGroup` from `@plitzi/sdk-shared/conditions`.'
57
- }
58
- ]
59
- }
12
+ export default tsEslint.config(
13
+ {
14
+ extends: [js.configs.recommended, ...tsEslint.configs.strictTypeChecked, globalIgnores(['**/*.js'])],
15
+ files: ['**/*.{ts,tsx}'],
16
+ ignores: [
17
+ 'node_modules',
18
+ 'node_modules/*',
19
+ './node_modules/**',
20
+ '**/node_modules/**',
21
+ 'dist',
22
+ 'coverage',
23
+ '.yarn/*'
60
24
  ],
61
- 'no-useless-assignment': 'off',
62
- '@typescript-eslint/no-deprecated': 'off',
63
- '@typescript-eslint/no-useless-default-assignment': 'off',
64
- '@typescript-eslint/consistent-type-imports': [
65
- 'warn',
66
- {
67
- disallowTypeAnnotations: false,
68
- fixStyle: 'separate-type-imports',
69
- prefer: 'type-imports'
25
+ languageOptions: {
26
+ ecmaVersion: 2023,
27
+ globals: globals.browser,
28
+ parserOptions: {
29
+ projectService: {
30
+ allowDefaultProject: ['.storybook/*.ts', '.storybook/*.tsx'],
31
+ defaultProject: './tsconfig.json'
32
+ },
33
+ tsconfigRootDir: import.meta.dirname
70
34
  }
71
- ],
72
- '@typescript-eslint/no-unnecessary-type-arguments': 'off',
73
- '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { attributes: false, arguments: false } }],
74
- '@typescript-eslint/no-confusing-void-expression': 'off', // ['error', { ignoreArrowShorthand: true, ignoreVoidOperator: true }],
75
- 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
76
- 'no-var': 'error',
77
- // A file is read whole — by a person, and by an agent before it changes it: past this, it is split by what changes
78
- // together. A project's own files are held to the same idea by `plitzi lint` (`file-too-long`, `MAX_LINES`).
79
- 'max-lines': ['error', { max: 600, skipBlankLines: true, skipComments: true }],
80
- curly: 'error',
81
- // indent: ['warn', 2],
82
- 'linebreak-style': ['error', 'unix'],
83
- 'prefer-const': ['error', { destructuring: 'any', ignoreReadBeforeAssign: false }],
84
- // semi: ['warn', 'never'],
85
- 'react/jsx-key': ['warn', { checkFragmentShorthand: true }],
86
- 'react-hooks/refs': 'off', // @todo: review later
87
- 'react-hooks/immutability': 'off', // @todo: review later
88
- 'react-hooks/set-state-in-effect': 'off', // @todo: review later
89
- 'react-hooks/preserve-manual-memoization': 'off', // @todo: review later
90
- // sdk-elements' memos that the page server, which draws once, makes as values (`Element/hooks/drawnMemo.ts`).
91
- 'react-hooks/exhaustive-deps': ['warn', { additionalHooks: '(useDrawnMemo|useDrawnCallback)' }],
92
- 'prettier/prettier': ['warn', { trailingComma: 'none' }],
93
- '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],
94
- // Destructuring a key out so the rest carries everything else is how a field is dropped from an object here.
95
- '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
96
- 'import/order': [
97
- 'error',
98
- {
99
- groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'type'],
100
- pathGroups: [
101
- { pattern: '@plitzi/+(sdk-*|nexus)/**', group: 'internal' },
102
- { pattern: '@plitzi/+(sdk-*|nexus)', group: 'internal' }
103
- // { pattern: '@icons/**', group: 'internal' },
104
- // { pattern: '@components/**', group: 'internal' },
105
- // { pattern: '@hooks/**', group: 'internal' },
106
- // { pattern: '@/**', group: 'internal' } // , position: 'before'
107
- ],
108
- pathGroupsExcludedImportTypes: ['type'],
109
- alphabetize: { order: 'asc', caseInsensitive: true },
110
- 'newlines-between': 'always'
111
- }
112
- ]
35
+ },
36
+ plugins: {
37
+ import: importEslint,
38
+ 'react-hooks': reactHooks,
39
+ 'react-refresh': reactRefresh,
40
+ react,
41
+ prettier,
42
+ jsxRuntime: react.configs.flat['jsx-runtime'],
43
+ storybook
44
+ },
45
+ rules: {
46
+ ...reactHooks.configs.recommended.rules,
47
+ // One rule evaluator for every reader: sdk-shared's (`@plitzi/sdk-shared/conditions`). plitzi-ui keeps a copy of its
48
+ // own, which Plitzi never reads, so the builder's preview and the server cannot decide a condition two ways.
49
+ '@typescript-eslint/no-restricted-imports': [
50
+ 'error',
51
+ {
52
+ paths: [
53
+ {
54
+ name: '@plitzi/plitzi-ui/QueryBuilder/evaluator',
55
+ message: 'Evaluate a condition with `evaluateRuleGroup` from `@plitzi/sdk-shared/conditions`.'
56
+ },
57
+ {
58
+ name: '@plitzi/plitzi-ui/QueryBuilder',
59
+ importNames: ['QueryBuilderEvaluator'],
60
+ message: 'Evaluate a condition with `evaluateRuleGroup` from `@plitzi/sdk-shared/conditions`.'
61
+ },
62
+ {
63
+ name: '@plitzi/plitzi-ui/QueryBuilder/helpers',
64
+ importNames: ['QueryBuilderEvaluator'],
65
+ message: 'Evaluate a condition with `evaluateRuleGroup` from `@plitzi/sdk-shared/conditions`.'
66
+ }
67
+ ]
68
+ }
69
+ ],
70
+ 'no-useless-assignment': 'off',
71
+ '@typescript-eslint/no-deprecated': 'off',
72
+ '@typescript-eslint/no-useless-default-assignment': 'off',
73
+ '@typescript-eslint/consistent-type-imports': [
74
+ 'warn',
75
+ {
76
+ disallowTypeAnnotations: false,
77
+ fixStyle: 'separate-type-imports',
78
+ prefer: 'type-imports'
79
+ }
80
+ ],
81
+ '@typescript-eslint/no-unnecessary-type-arguments': 'off',
82
+ '@typescript-eslint/no-misused-promises': [
83
+ 'error',
84
+ { checksVoidReturn: { attributes: false, arguments: false } }
85
+ ],
86
+ '@typescript-eslint/no-confusing-void-expression': 'off', // ['error', { ignoreArrowShorthand: true, ignoreVoidOperator: true }],
87
+ 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
88
+ 'no-var': 'error',
89
+ // A file is read whole — by a person, and by an agent before it changes it: past this, it is split by what changes
90
+ // together. A project's own files are held to the same idea by `plitzi lint` (`file-too-long`, `MAX_LINES`).
91
+ 'max-lines': ['error', { max: 600, skipBlankLines: true, skipComments: true }],
92
+ curly: 'error',
93
+ // indent: ['warn', 2],
94
+ 'linebreak-style': ['error', 'unix'],
95
+ 'prefer-const': ['error', { destructuring: 'any', ignoreReadBeforeAssign: false }],
96
+ // semi: ['warn', 'never'],
97
+ 'react/jsx-key': ['warn', { checkFragmentShorthand: true }],
98
+ 'react-hooks/refs': 'off', // @todo: review later
99
+ 'react-hooks/immutability': 'off', // @todo: review later
100
+ 'react-hooks/set-state-in-effect': 'off', // @todo: review later
101
+ 'react-hooks/preserve-manual-memoization': 'off', // @todo: review later
102
+ // sdk-elements' memos that the page server, which draws once, makes as values (`Element/hooks/drawnMemo.ts`).
103
+ 'react-hooks/exhaustive-deps': ['warn', { additionalHooks: '(useDrawnMemo|useDrawnCallback)' }],
104
+ 'prettier/prettier': ['warn', { trailingComma: 'none' }],
105
+ '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],
106
+ // Destructuring a key out so the rest carries everything else is how a field is dropped from an object here.
107
+ '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
108
+ 'import/order': [
109
+ 'error',
110
+ {
111
+ groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'type'],
112
+ pathGroups: [
113
+ { pattern: '@plitzi/+(sdk-*|nexus)/**', group: 'internal' },
114
+ { pattern: '@plitzi/+(sdk-*|nexus)', group: 'internal' }
115
+ // { pattern: '@icons/**', group: 'internal' },
116
+ // { pattern: '@components/**', group: 'internal' },
117
+ // { pattern: '@hooks/**', group: 'internal' },
118
+ // { pattern: '@/**', group: 'internal' } // , position: 'before'
119
+ ],
120
+ pathGroupsExcludedImportTypes: ['type'],
121
+ alphabetize: { order: 'asc', caseInsensitive: true },
122
+ 'newlines-between': 'always'
123
+ }
124
+ ]
125
+ }
126
+ },
127
+ /**
128
+ * Where a file exports more than components on purpose, and Fast Refresh reloads it whole: an element's file exports
129
+ * its component and what declares it (its definition, its settings), read together by the registry; a model's form
130
+ * exports the form and its schema; an entry point and an MCP app's view export what their bundle is. Said here once,
131
+ * per folder, instead of a comment in each file.
132
+ */
133
+ {
134
+ files: ['src/index.tsx', 'src/**/elements/**/*.tsx', 'src/**/[mM]odels/**/*.tsx', 'src/**/apps/*/view/index.tsx'],
135
+ rules: { 'react-refresh/only-export-components': 'off' }
113
136
  }
114
- });
137
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-shared",
3
- "version": "0.39.3",
3
+ "version": "0.39.4",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",