@plitzi/sdk-shared 0.38.24 → 0.39.0

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 (194) hide show
  1. package/CHANGELOG.md +146 -1
  2. package/dist/actions/functions.d.ts +22 -1
  3. package/dist/actions/functions.mjs +3 -3
  4. package/dist/actions/index.d.ts +1 -1
  5. package/dist/actions/index.mjs +7 -7
  6. package/dist/auth/failureChannel.mjs +1 -0
  7. package/dist/auth/index.d.ts +1 -1
  8. package/dist/auth/index.mjs +2 -2
  9. package/dist/auth/visitorRoles.d.ts +8 -0
  10. package/dist/auth/visitorRoles.mjs +5 -2
  11. package/dist/authoring/declare.d.ts +34 -1
  12. package/dist/authoring/elementCallbacks.d.ts +13 -0
  13. package/dist/authoring/elementCallbacks.mjs +11 -5
  14. package/dist/authoring/index.mjs +3 -3
  15. package/dist/authoring/paramSpec.d.ts +1 -0
  16. package/dist/dataSource/getBindingsDetails.d.ts +1 -1
  17. package/dist/dataSource/getBindingsDetails.mjs +1 -1
  18. package/dist/dataSource/globalSources.d.ts +1 -1
  19. package/dist/dataSource/index.d.ts +1 -2
  20. package/dist/dataSource/index.mjs +1 -1
  21. package/dist/dataSource/utility/arrayMap.mjs +1 -1
  22. package/dist/dataSource/utility/capitalize.mjs +1 -1
  23. package/dist/dataSource/utility/styleSelector.mjs +5 -3
  24. package/dist/dataSource/utility/styleVariant.mjs +17 -13
  25. package/dist/dataSource/variables/index.d.ts +2 -0
  26. package/dist/dataSource/variables/index.mjs +1 -0
  27. package/dist/dataSource/{resolveVariables.d.ts → variables/resolveVariables.d.ts} +1 -1
  28. package/dist/dataSource/{resolveVariables.mjs → variables/resolveVariables.mjs} +1 -1
  29. package/dist/devTools/chrome.d.ts +6 -0
  30. package/dist/devTools/chrome.mjs +2 -2
  31. package/dist/devTools/index.mjs +5 -5
  32. package/dist/devTools/sight/index.d.ts +1 -0
  33. package/dist/devTools/sight/index.mjs +1 -0
  34. package/dist/devTools/sight/sight.d.ts +28 -0
  35. package/dist/devTools/sight/sight.mjs +127 -0
  36. package/dist/devTools/utils/PlitziConsole.d.ts +14 -0
  37. package/dist/devTools/utils/PlitziConsole.mjs +20 -3
  38. package/dist/flags/flagsCookie.mjs +4 -4
  39. package/dist/flags/resolveFlags.d.ts +1 -1
  40. package/dist/helpers/index.mjs +19 -19
  41. package/dist/helpers/ruleEvaluator.d.ts +2 -0
  42. package/dist/helpers/ruleEvaluator.mjs +2 -2
  43. package/dist/helpers/scroll.d.ts +10 -0
  44. package/dist/helpers/scroll.mjs +2 -2
  45. package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +90 -88
  46. package/dist/helpers/twigWrapper/Evaluator/helpers.d.ts +6 -0
  47. package/dist/helpers/twigWrapper/Evaluator/helpers.mjs +11 -2
  48. package/dist/helpers/twigWrapper/filters/arrays.d.ts +2 -0
  49. package/dist/helpers/twigWrapper/filters/arrays.mjs +66 -0
  50. package/dist/helpers/twigWrapper/filters/catalog/index.d.ts +17 -0
  51. package/dist/helpers/twigWrapper/filters/catalog/index.mjs +351 -0
  52. package/dist/helpers/twigWrapper/filters/dateParts.d.ts +25 -0
  53. package/dist/helpers/twigWrapper/filters/dateParts.mjs +56 -0
  54. package/dist/helpers/twigWrapper/filters/dates.d.ts +2 -0
  55. package/dist/helpers/twigWrapper/filters/dates.mjs +97 -0
  56. package/dist/helpers/twigWrapper/filters/filters.d.ts +3 -13
  57. package/dist/helpers/twigWrapper/filters/filters.mjs +25 -483
  58. package/dist/helpers/twigWrapper/filters/hashing.d.ts +3 -0
  59. package/dist/helpers/twigWrapper/filters/hashing.mjs +101 -0
  60. package/dist/helpers/twigWrapper/filters/index.mjs +4 -1
  61. package/dist/helpers/twigWrapper/filters/misc.d.ts +5 -0
  62. package/dist/helpers/twigWrapper/filters/misc.mjs +52 -0
  63. package/dist/helpers/twigWrapper/filters/numbers.d.ts +2 -0
  64. package/dist/helpers/twigWrapper/filters/numbers.mjs +36 -0
  65. package/dist/helpers/twigWrapper/filters/objects.d.ts +3 -0
  66. package/dist/helpers/twigWrapper/filters/objects.mjs +61 -0
  67. package/dist/helpers/twigWrapper/filters/raw.d.ts +8 -0
  68. package/dist/helpers/twigWrapper/filters/raw.mjs +7 -0
  69. package/dist/helpers/twigWrapper/filters/strings.d.ts +7 -0
  70. package/dist/helpers/twigWrapper/filters/strings.mjs +79 -0
  71. package/dist/helpers/twigWrapper/filters/types.d.ts +5 -0
  72. package/dist/helpers/twigWrapper/filters/types.mjs +4 -0
  73. package/dist/helpers/twigWrapper/filters/values.d.ts +12 -0
  74. package/dist/helpers/twigWrapper/filters/values.mjs +17 -0
  75. package/dist/helpers/twigWrapper/inspectTemplate.d.ts +5 -0
  76. package/dist/helpers/twigWrapper/inspectTemplate.mjs +39 -20
  77. package/dist/helpers/utils.d.ts +4 -0
  78. package/dist/helpers/utils.mjs +3 -5
  79. package/dist/navigation/index.d.ts +2 -0
  80. package/dist/navigation/index.mjs +2 -1
  81. package/dist/navigation/sitemap.d.ts +16 -0
  82. package/dist/navigation/sitemap.mjs +25 -0
  83. package/dist/network/entitlements.d.ts +101 -0
  84. package/dist/network/entitlements.mjs +4 -0
  85. package/dist/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.d.ts +31 -0
  86. package/dist/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.mjs +13 -0
  87. package/dist/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.d.ts +5 -0
  88. package/dist/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.mjs +11 -0
  89. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.d.ts +1 -1
  90. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.mjs +1 -1
  91. package/dist/network/graphql/builder/Mutations/index.d.ts +5 -0
  92. package/dist/network/graphql/builder/Mutations/index.mjs +150 -146
  93. package/dist/network/graphql/builder/Queries/Space/SpaceTestsQuery.d.ts +40 -0
  94. package/dist/network/graphql/builder/Queries/Space/SpaceTestsQuery.mjs +24 -0
  95. package/dist/network/graphql/builder/Queries/index.d.ts +3 -0
  96. package/dist/network/graphql/builder/Queries/index.mjs +44 -42
  97. package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +3 -1
  98. package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
  99. package/dist/network/index.d.ts +1 -0
  100. package/dist/network/index.mjs +9 -8
  101. package/dist/network/spaceEvents.d.ts +20 -1
  102. package/dist/network/spaceEvents.mjs +12 -0
  103. package/dist/project/index.mjs +8 -5
  104. package/dist/project/layout/check.d.ts +22 -0
  105. package/dist/project/layout/check.mjs +60 -0
  106. package/dist/project/{layout.d.ts → layout/codes.d.ts} +3 -66
  107. package/dist/project/layout/codes.mjs +108 -0
  108. package/dist/project/layout/contents.d.ts +10 -0
  109. package/dist/project/layout/contents.mjs +31 -0
  110. package/dist/project/layout/files.d.ts +31 -0
  111. package/dist/project/layout/files.mjs +49 -0
  112. package/dist/project/layout/folders.d.ts +4 -0
  113. package/dist/project/layout/folders.mjs +69 -0
  114. package/dist/project/layout/index.d.ts +16 -0
  115. package/dist/project/layout/index.mjs +5 -0
  116. package/dist/project/layout/plugins.d.ts +46 -0
  117. package/dist/project/layout/plugins.mjs +99 -0
  118. package/dist/project/layout/vendor.d.ts +15 -0
  119. package/dist/project/layout/vendor.mjs +34 -0
  120. package/dist/project/pages/index.d.ts +8 -0
  121. package/dist/project/pages/index.mjs +14 -0
  122. package/dist/project/paths/index.d.ts +52 -4
  123. package/dist/project/paths/index.mjs +2 -2
  124. package/dist/project/root.d.ts +6 -0
  125. package/dist/project/root.mjs +11 -10
  126. package/dist/realtime/client.mjs +104 -91
  127. package/dist/realtime/presence.d.ts +2 -2
  128. package/dist/realtime/presence.mjs +27 -21
  129. package/dist/runs/index.d.ts +73 -0
  130. package/dist/runs/index.mjs +6 -0
  131. package/dist/runs/report.d.ts +56 -0
  132. package/dist/runs/report.mjs +17 -0
  133. package/dist/schema/index.d.ts +6 -0
  134. package/dist/schema/index.mjs +18 -12
  135. package/dist/schema/motion.d.ts +25 -0
  136. package/dist/schema/motion.mjs +47 -19
  137. package/dist/schema/pageAccess.d.ts +6 -0
  138. package/dist/schema/pageAccess.mjs +8 -3
  139. package/dist/schema/pageHead.d.ts +64 -0
  140. package/dist/schema/pageHead.mjs +68 -0
  141. package/dist/schema/providerAnswer.d.ts +17 -0
  142. package/dist/schema/providerAnswer.mjs +4 -0
  143. package/dist/schema/providerWhen.d.ts +36 -0
  144. package/dist/schema/providerWhen.mjs +58 -0
  145. package/dist/schema/schemaSettings.d.ts +14 -0
  146. package/dist/schema/schemaSettings.mjs +4 -0
  147. package/dist/schema/serverElements.d.ts +20 -1
  148. package/dist/schema/serverElements.mjs +41 -28
  149. package/dist/schema/serverInput.d.ts +34 -0
  150. package/dist/schema/serverInput.mjs +60 -0
  151. package/dist/schema/serverQuery.d.ts +47 -0
  152. package/dist/schema/serverQuery.mjs +70 -0
  153. package/dist/server/index.mjs +5 -5
  154. package/dist/server/rsc/refreshRsc.d.ts +6 -2
  155. package/dist/server/rsc/refreshRsc.mjs +75 -59
  156. package/dist/server/rsc/useRscSync.mjs +22 -18
  157. package/dist/source/export.d.ts +1 -1
  158. package/dist/state/runtimeStatePersist.mjs +25 -17
  159. package/dist/store/renderSettings.d.ts +2 -0
  160. package/dist/store/renderSettings.mjs +13 -5
  161. package/dist/store/storeHooks.d.ts +45 -45
  162. package/dist/style/index.mjs +16 -16
  163. package/dist/style/styleConstants.d.ts +12 -2
  164. package/dist/style/styleConstants.mjs +20 -0
  165. package/dist/style/styleStates.d.ts +5 -0
  166. package/dist/style/styleStates.mjs +21 -5
  167. package/dist/types/ActionTypes.d.ts +26 -3
  168. package/dist/types/AuthTypes.d.ts +19 -1
  169. package/dist/types/CommonTypes.d.ts +3 -2
  170. package/dist/types/ElementTypes.d.ts +1 -1
  171. package/dist/types/InteractionTypes.d.ts +10 -1
  172. package/dist/types/JobTypes.d.ts +2 -1
  173. package/dist/types/OAuthTypes.d.ts +246 -0
  174. package/dist/types/OAuthTypes.mjs +0 -0
  175. package/dist/types/PluginTypes.d.ts +2 -0
  176. package/dist/types/PreviewTypes.d.ts +71 -0
  177. package/dist/types/PreviewTypes.mjs +0 -0
  178. package/dist/types/RealtimeTypes.d.ts +11 -0
  179. package/dist/types/SchemaTypes.d.ts +56 -0
  180. package/dist/types/ServerAdapterTypes.d.ts +345 -0
  181. package/dist/types/ServerAdapterTypes.mjs +0 -0
  182. package/dist/types/ServerConfigTypes.d.ts +527 -0
  183. package/dist/types/ServerConfigTypes.mjs +0 -0
  184. package/dist/types/ServerLogTypes.d.ts +119 -0
  185. package/dist/types/ServerLogTypes.mjs +0 -0
  186. package/dist/types/ServerTypes.d.ts +30 -1215
  187. package/dist/types/StoreTypes.d.ts +39 -1
  188. package/dist/types/TestTypes.d.ts +249 -0
  189. package/dist/types/TestTypes.mjs +0 -0
  190. package/dist/types/index.d.ts +6 -0
  191. package/eslint.config.mjs +3 -1
  192. package/package.json +2 -2
  193. package/setupTests.ts +4 -3
  194. package/dist/project/layout.mjs +0 -394
@@ -0,0 +1,351 @@
1
+ //#region src/helpers/twigWrapper/filters/catalog/index.ts
2
+ var e = {
3
+ raw: {
4
+ signature: "raw",
5
+ summary: "The value as it is, never serialised — what an attribute needing an object reads",
6
+ example: "{{ items|raw }}"
7
+ },
8
+ to_json: {
9
+ signature: "to_json",
10
+ summary: "The value as JSON: a string quoted, nothing as null",
11
+ example: "{{ settings|to_json }}"
12
+ },
13
+ json_encode: {
14
+ signature: "json_encode",
15
+ summary: "The same as to_json, by Twig’s name",
16
+ example: "{{ settings|json_encode }}"
17
+ },
18
+ object_as_json: {
19
+ signature: "object_as_json",
20
+ summary: "An object as JSON text; anything else as it is",
21
+ example: "{{ row|object_as_json }}"
22
+ },
23
+ default: {
24
+ signature: "default(fallback)",
25
+ summary: "The fallback when the value is undefined, null or an empty string",
26
+ example: "{{ user.name|default(\"Guest\") }}"
27
+ },
28
+ upper: {
29
+ signature: "upper",
30
+ summary: "A string in capitals",
31
+ example: "{{ \"hi\"|upper }} → HI"
32
+ },
33
+ lower: {
34
+ signature: "lower",
35
+ summary: "A string in lower case",
36
+ example: "{{ \"Hi\"|lower }} → hi"
37
+ },
38
+ trim: {
39
+ signature: "trim",
40
+ summary: "A string without the spaces around it",
41
+ example: "{{ \" hi \"|trim }} → hi"
42
+ },
43
+ capitalize: {
44
+ signature: "capitalize",
45
+ summary: "The first letter in capitals, the rest in lower case",
46
+ example: "{{ \"hELLO\"|capitalize }} → Hello"
47
+ },
48
+ title: {
49
+ signature: "title",
50
+ summary: "Every word’s first letter in capitals",
51
+ example: "{{ \"dog food\"|title }} → Dog Food"
52
+ },
53
+ camelize: {
54
+ signature: "camelize",
55
+ summary: "foo_bar and foo-bar as fooBar",
56
+ example: "{{ \"pet_name\"|camelize }} → petName"
57
+ },
58
+ kebab: {
59
+ signature: "kebab",
60
+ summary: "fooBar as foo-bar",
61
+ example: "{{ \"petName\"|kebab }} → pet-name"
62
+ },
63
+ snake: {
64
+ signature: "snake",
65
+ summary: "fooBar as foo_bar",
66
+ example: "{{ \"petName\"|snake }} → pet_name"
67
+ },
68
+ ltrim: {
69
+ signature: "ltrim",
70
+ summary: "A string without the spaces before it",
71
+ example: "{{ \" hi\"|ltrim }}"
72
+ },
73
+ rtrim: {
74
+ signature: "rtrim",
75
+ summary: "A string without the spaces after it",
76
+ example: "{{ \"hi \"|rtrim }}"
77
+ },
78
+ pad: {
79
+ signature: "pad(length, char?)",
80
+ summary: "A string padded on the left to a length, with spaces or char",
81
+ example: "{{ \"7\"|pad(3, \"0\") }} → 007"
82
+ },
83
+ padRight: {
84
+ signature: "padRight(length, char?)",
85
+ summary: "A string padded on the right to a length",
86
+ example: "{{ \"id\"|padRight(4, \".\") }} → id.."
87
+ },
88
+ number: {
89
+ signature: "number(decimals?)",
90
+ summary: "The first number in a string; a number with that many decimals, as text",
91
+ example: "{{ \"€12.50\"|number }} → 12.5"
92
+ },
93
+ replace: {
94
+ signature: "replace(search, replacement) | replace({ search: replacement, … })",
95
+ summary: "Every occurrence of search replaced — or of each key of a map by its value, in one pass",
96
+ example: "{{ phone|replace({\" \": \"\", \"-\": \"\"}) }}"
97
+ },
98
+ slice: {
99
+ signature: "slice(start, length?)",
100
+ summary: "Part of a string or a list, from start, length long",
101
+ example: "{{ items|slice(0, 5) }}"
102
+ },
103
+ split: {
104
+ signature: "split(separator)",
105
+ summary: "A string as a list, cut at the separator",
106
+ example: "{{ \"a,b\"|split(\",\") }}"
107
+ },
108
+ join: {
109
+ signature: "join(separator?)",
110
+ summary: "A list as one string",
111
+ example: "{{ tags|join(\", \") }}"
112
+ },
113
+ reverse: {
114
+ signature: "reverse",
115
+ summary: "A list, or a string, the other way round",
116
+ example: "{{ items|sort(e => e.date)|reverse }}"
117
+ },
118
+ length: {
119
+ signature: "length",
120
+ summary: "How many: characters, items, or an object’s keys",
121
+ example: "{{ pets|length }}"
122
+ },
123
+ first: {
124
+ signature: "first",
125
+ summary: "A list’s first item, or a string’s first character",
126
+ example: "{{ items|first }}"
127
+ },
128
+ last: {
129
+ signature: "last",
130
+ summary: "A list’s last item, or a string’s last character",
131
+ example: "{{ items|last }}"
132
+ },
133
+ contains: {
134
+ signature: "contains(needle)",
135
+ summary: "Whether a string holds the text, or a list the item",
136
+ example: "{{ tags|contains(\"vet\") }}"
137
+ },
138
+ startswith: {
139
+ signature: "startswith(prefix)",
140
+ summary: "Whether a string starts with the prefix",
141
+ example: "{{ path|startswith(\"/pets\") }}"
142
+ },
143
+ endswith: {
144
+ signature: "endswith(suffix)",
145
+ summary: "Whether a string ends with the suffix",
146
+ example: "{{ file|endswith(\".png\") }}"
147
+ },
148
+ number_format: {
149
+ signature: "number_format(decimals?, point?, thousands?)",
150
+ summary: "A number with decimals and separators",
151
+ example: "{{ 1234.5|number_format(2, \",\", \".\") }} → 1.234,50"
152
+ },
153
+ currency: {
154
+ signature: "currency(code, locale?, { trimZeros? })",
155
+ summary: "An amount as the locale writes it in that currency; en unless named, so server and browser agree",
156
+ example: "{{ total|currency(\"EUR\", \"en\") }} → €1,141.63"
157
+ },
158
+ percent: {
159
+ signature: "percent(decimals?, locale?)",
160
+ summary: "A share as a percentage",
161
+ example: "{{ 0.256|percent(1) }} → 25.6%"
162
+ },
163
+ sort: {
164
+ signature: "sort(key? | compare?)",
165
+ summary: "A list in order: by itself, by what the arrow takes of each item, or by a two-argument comparator",
166
+ example: "{{ expenses|sort(e => e.date) }}"
167
+ },
168
+ batch: {
169
+ signature: "batch(size)",
170
+ summary: "A list in groups of size",
171
+ example: "{{ items|batch(3) }}"
172
+ },
173
+ map: {
174
+ signature: "map(item => …)",
175
+ summary: "Each item turned into what the arrow makes of it",
176
+ example: "{{ pets|map(p => p.name) }}"
177
+ },
178
+ reduce: {
179
+ signature: "reduce((total, item) => …, initial)",
180
+ summary: "A list folded into one value",
181
+ example: "{{ expenses|reduce((sum, e) => sum + e.amount, 0) }}"
182
+ },
183
+ merge: {
184
+ signature: "merge(other)",
185
+ summary: "Two lists one after the other, or two objects in one",
186
+ example: "{{ a|merge(b) }}"
187
+ },
188
+ keys: {
189
+ signature: "keys",
190
+ summary: "An object’s keys, as a list",
191
+ example: "{{ totals|keys }}"
192
+ },
193
+ values: {
194
+ signature: "values",
195
+ summary: "An object’s values, as a list",
196
+ example: "{{ totals|values }}"
197
+ },
198
+ filter: {
199
+ signature: "filter(\"key\" | item => …)",
200
+ summary: "The items whose key is truthy, or the arrow keeps",
201
+ example: "{{ expenses|filter(e => e.category == \"vet\") }}"
202
+ },
203
+ column: {
204
+ signature: "column(key)",
205
+ summary: "Each object’s value at key, as a list",
206
+ example: "{{ pets|column(\"name\") }}"
207
+ },
208
+ url_encode: {
209
+ signature: "url_encode",
210
+ summary: "A string percent-encoded, an object as a query string",
211
+ example: "{{ query|url_encode }}"
212
+ },
213
+ nl2br: {
214
+ signature: "nl2br",
215
+ summary: "A <br> before every line break",
216
+ example: "{{ note|nl2br }}"
217
+ },
218
+ striptags: {
219
+ signature: "striptags(allowed?)",
220
+ summary: "A string without HTML tags, but those allowed",
221
+ example: "{{ html|striptags }}"
222
+ },
223
+ abs: {
224
+ signature: "abs",
225
+ summary: "A number without its sign",
226
+ example: "{{ -3|abs }} → 3"
227
+ },
228
+ round: {
229
+ signature: "round(precision?, \"common\" | \"ceil\" | \"floor\")",
230
+ summary: "A number rounded to precision decimals",
231
+ example: "{{ 2.456|round(1) }} → 2.5"
232
+ },
233
+ format: {
234
+ signature: "format(values…)",
235
+ summary: "sprintf: %s, %d, %f and %%, with PHP’s flags, width and precision",
236
+ example: "{{ \"%02d\"|format(5) }} → 05"
237
+ },
238
+ spaceless: {
239
+ signature: "spaceless",
240
+ summary: "HTML without the white space between its tags",
241
+ example: "{{ html|spaceless }}"
242
+ },
243
+ random: {
244
+ signature: "random",
245
+ summary: "One item of a list, or one character of a string, at random",
246
+ example: "{{ tips|random }}"
247
+ },
248
+ date: {
249
+ signature: "date(format, timeZone?)",
250
+ summary: "A date as format writes it — Y m d j n H G h g A a i s w N U l D F M; an epoch in seconds or milliseconds; with no zone named, the visitor’s local time once the page hydrates (the server’s before); \"now\" is the render’s moment; a bare YYYY-MM-DD is read in \"UTC\"",
251
+ example: "{{ expense.date|date(\"j M Y\", \"UTC\") }} · {{ message.at|date(\"H:i\") }} · {{ \"now\"|date(\"F Y\") }}"
252
+ },
253
+ ago: {
254
+ signature: "ago(locale?)",
255
+ summary: "Relative time: how long ago a moment was, or how far ahead, in words — \"4 minutes ago\", \"in 3 hours\", \"now\" — at the render’s moment, on the server and again in the browser",
256
+ example: "{{ played.endedAt|ago }} · {{ post.at|ago(\"es\") }}"
257
+ },
258
+ duration: {
259
+ signature: "duration",
260
+ summary: "A length in seconds as a clock writes it — 238 is \"3:58\", 3723 is \"1:02:03\"",
261
+ example: "{{ track.duration|duration }}"
262
+ },
263
+ base64_encode: {
264
+ signature: "base64_encode",
265
+ summary: "A string in base64, UTF-8 safe",
266
+ example: "{{ text|base64_encode }}"
267
+ },
268
+ base64_decode: {
269
+ signature: "base64_decode",
270
+ summary: "A base64 string decoded, UTF-8 safe",
271
+ example: "{{ encoded|base64_decode }}"
272
+ },
273
+ md5: {
274
+ signature: "md5",
275
+ summary: "A string’s MD5, in lower-case hex",
276
+ example: "{{ email|md5 }}"
277
+ },
278
+ without: {
279
+ signature: "without(key…)",
280
+ summary: "An object without those keys",
281
+ example: "{{ user|without(\"password\") }}"
282
+ },
283
+ only: {
284
+ signature: "only(key…)",
285
+ summary: "An object with only those keys",
286
+ example: "{{ user|only(\"id\", \"name\") }}"
287
+ },
288
+ find: {
289
+ signature: "find(item => … | \"key\", value)",
290
+ summary: "The first item the arrow keeps, or whose key is value",
291
+ example: "{{ pets|find(\"id\", expense.petId) }}"
292
+ },
293
+ pluck: {
294
+ signature: "pluck(key)",
295
+ summary: "Each object’s value at key, as a list",
296
+ example: "{{ expenses|pluck(\"amount\") }}"
297
+ },
298
+ unique: {
299
+ signature: "unique",
300
+ summary: "A list without repeats",
301
+ example: "{{ expenses|pluck(\"category\")|unique }}"
302
+ },
303
+ flatten: {
304
+ signature: "flatten",
305
+ summary: "A list of lists as one list, one level down",
306
+ example: "{{ groups|flatten }}"
307
+ },
308
+ sum: {
309
+ signature: "sum",
310
+ summary: "The numbers of a list added up — of a list of objects, pluck the field first",
311
+ example: "{{ expenses|pluck(\"amount\")|sum }}"
312
+ },
313
+ chunk: {
314
+ signature: "chunk(size)",
315
+ summary: "A list in pieces of size",
316
+ example: "{{ items|chunk(2) }}"
317
+ },
318
+ index_by: {
319
+ signature: "index_by(key)",
320
+ summary: "A list of objects as an object, keyed by key",
321
+ example: "{{ pets|index_by(\"id\") }}"
322
+ },
323
+ group_by: {
324
+ signature: "group_by(key)",
325
+ summary: "A list of objects grouped by their value at key",
326
+ example: "{{ expenses|group_by(\"category\") }}"
327
+ }
328
+ }, t = {
329
+ cycle: {
330
+ signature: "cycle(values, index)",
331
+ summary: "The value at index, going round the list: alternating classes, colours of a row",
332
+ example: "{{ cycle(['odd', 'even'], loop.index0) }}"
333
+ },
334
+ max: {
335
+ signature: "max(a, b, …) | max(list)",
336
+ summary: "The largest of the numbers given, or of a list",
337
+ example: "{{ max(carousel_row.count - 3, 0) }}"
338
+ },
339
+ min: {
340
+ signature: "min(a, b, …) | min(list)",
341
+ summary: "The smallest of the numbers given, or of a list",
342
+ example: "{{ min(state.page + 1, state.pages) }}"
343
+ },
344
+ range: {
345
+ signature: "range(end) | range(start, end, step?)",
346
+ summary: "The whole numbers from 0 (or start) to end, both included",
347
+ example: "{% for n in range(1, 5) %}{{ n }}{% endfor %}"
348
+ }
349
+ };
350
+ //#endregion
351
+ export { e as FILTER_DOCS, t as FUNCTION_DOCS };
@@ -0,0 +1,25 @@
1
+ type DateParts = {
2
+ year: number;
3
+ month: number;
4
+ day: number;
5
+ hours: number;
6
+ minutes: number;
7
+ seconds: number;
8
+ weekday: number;
9
+ };
10
+ /**
11
+ * What a `date` filter was handed, as a Date.
12
+ *
13
+ * An epoch in milliseconds is the shape every API here answers with (`nextRunAt`, `dueAt`), and it reaches a template
14
+ * as a number or — through an attribute — as a string of digits. `new Date("1790143200000")` is Invalid Date, so
15
+ * both are read as numbers first (`fromEpoch`, seconds too); anything else is left to the Date parser, ISO strings.
16
+ */
17
+ export declare const toDate: (value: unknown) => Date;
18
+ /**
19
+ * The calendar and clock parts of an instant, read in `timeZone` — or, with none, in the zone the code runs in.
20
+ *
21
+ * The zone is what a SERVER flow needs: its process runs in whatever zone the host was given, and "is it already
22
+ * past 21:00 at the restaurant" is a question about the restaurant's clock. `undefined` for a zone that does not exist.
23
+ */
24
+ export declare const dateParts: (date: Date, timeZone: string) => DateParts | undefined;
25
+ export {};
@@ -0,0 +1,56 @@
1
+ //#region src/helpers/twigWrapper/filters/dateParts.ts
2
+ var e = [
3
+ "Sun",
4
+ "Mon",
5
+ "Tue",
6
+ "Wed",
7
+ "Thu",
8
+ "Fri",
9
+ "Sat"
10
+ ], t = /* @__PURE__ */ new Map(), n = (e) => {
11
+ if (!t.has(e)) try {
12
+ t.set(e, new Intl.DateTimeFormat("en-US", {
13
+ timeZone: e,
14
+ hourCycle: "h23",
15
+ year: "numeric",
16
+ month: "numeric",
17
+ day: "numeric",
18
+ hour: "numeric",
19
+ minute: "numeric",
20
+ second: "numeric",
21
+ weekday: "short"
22
+ }));
23
+ } catch {
24
+ t.set(e, null);
25
+ }
26
+ return t.get(e) ?? null;
27
+ }, r = (e) => new Date(Math.abs(e) < 1e11 ? e * 1e3 : e), i = (e) => {
28
+ if (e instanceof Date) return e;
29
+ if (typeof e == "number") return r(e);
30
+ let t = String(e).trim();
31
+ return t === "now" ? /* @__PURE__ */ new Date() : /^-?\d+$/.test(t) ? r(Number(t)) : new Date(t);
32
+ }, a = (t, r) => {
33
+ if (!r) return {
34
+ year: t.getFullYear(),
35
+ month: t.getMonth() + 1,
36
+ day: t.getDate(),
37
+ hours: t.getHours(),
38
+ minutes: t.getMinutes(),
39
+ seconds: t.getSeconds(),
40
+ weekday: t.getDay()
41
+ };
42
+ let i = n(r);
43
+ if (!i) return;
44
+ let a = i.formatToParts(t), o = (e) => a.find((t) => t.type === e)?.value ?? "";
45
+ return {
46
+ year: Number(o("year")),
47
+ month: Number(o("month")),
48
+ day: Number(o("day")),
49
+ hours: Number(o("hour")),
50
+ minutes: Number(o("minute")),
51
+ seconds: Number(o("second")),
52
+ weekday: e.indexOf(o("weekday"))
53
+ };
54
+ };
55
+ //#endregion
56
+ export { a as dateParts, i as toDate };
@@ -0,0 +1,2 @@
1
+ import { TwigFilter } from './types';
2
+ export declare const dateFilters: Record<string, TwigFilter>;
@@ -0,0 +1,97 @@
1
+ import { numberOf as e, toStr as t } from "./values.mjs";
2
+ import { dateParts as n, toDate as r } from "./dateParts.mjs";
3
+ //#region src/helpers/twigWrapper/filters/dates.ts
4
+ var i = {
5
+ date: (e, i) => {
6
+ if (i.length === 0) return e;
7
+ let a = t(i[0]), o = r(e);
8
+ if (Number.isNaN(o.getTime())) return "";
9
+ let s = n(o, i.length > 1 ? t(i[1]) : "");
10
+ if (!s) return "";
11
+ let c = (e) => String(e).padStart(2, "0"), l = [
12
+ "January",
13
+ "February",
14
+ "March",
15
+ "April",
16
+ "May",
17
+ "June",
18
+ "July",
19
+ "August",
20
+ "September",
21
+ "October",
22
+ "November",
23
+ "December"
24
+ ], u = [
25
+ "Jan",
26
+ "Feb",
27
+ "Mar",
28
+ "Apr",
29
+ "May",
30
+ "Jun",
31
+ "Jul",
32
+ "Aug",
33
+ "Sep",
34
+ "Oct",
35
+ "Nov",
36
+ "Dec"
37
+ ], d = [
38
+ "Sunday",
39
+ "Monday",
40
+ "Tuesday",
41
+ "Wednesday",
42
+ "Thursday",
43
+ "Friday",
44
+ "Saturday"
45
+ ], f = {
46
+ Y: String(s.year),
47
+ y: c(s.year % 100),
48
+ m: c(s.month),
49
+ n: String(s.month),
50
+ d: c(s.day),
51
+ j: String(s.day),
52
+ H: c(s.hours),
53
+ G: String(s.hours),
54
+ h: c(s.hours % 12 || 12),
55
+ g: String(s.hours % 12 || 12),
56
+ A: s.hours < 12 ? "AM" : "PM",
57
+ a: s.hours < 12 ? "am" : "pm",
58
+ i: c(s.minutes),
59
+ s: c(s.seconds),
60
+ w: String(s.weekday),
61
+ N: String(s.weekday === 0 ? 7 : s.weekday),
62
+ U: String(Math.floor(o.getTime() / 1e3)),
63
+ l: d[s.weekday],
64
+ D: d[s.weekday].slice(0, 3),
65
+ F: l[s.month - 1],
66
+ M: u[s.month - 1]
67
+ }, p = "", m = !1;
68
+ for (let e of a) m ? (p += e, m = !1) : e === "\\" ? m = !0 : p += Object.prototype.hasOwnProperty.call(f, e) ? f[e] : e;
69
+ return p;
70
+ },
71
+ ago: (e, n) => {
72
+ let i = r(e);
73
+ if (Number.isNaN(i.getTime())) return "";
74
+ let a = Math.round((i.getTime() - Date.now()) / 1e3), [o, s] = [
75
+ ["year", 31536e3],
76
+ ["month", 2592e3],
77
+ ["week", 604800],
78
+ ["day", 86400],
79
+ ["hour", 3600],
80
+ ["minute", 60]
81
+ ].find(([, e]) => Math.abs(a) >= e) ?? ["second", 1], c = o === "second" ? Math.abs(a) < 10 ? 0 : a : Math.trunc(a / s);
82
+ for (let e of [n.length > 0 ? t(n[0]) : "en", "en"]) try {
83
+ return new Intl.RelativeTimeFormat(e, { numeric: "auto" }).format(c, o);
84
+ } catch {
85
+ continue;
86
+ }
87
+ return "";
88
+ },
89
+ duration: (t) => {
90
+ let n = e(t);
91
+ if (n === void 0 || n < 0) return "";
92
+ let r = Math.round(n), i = Math.floor(r / 3600), a = Math.floor(r % 3600 / 60), o = String(r % 60).padStart(2, "0");
93
+ return i > 0 ? `${String(i)}:${String(a).padStart(2, "0")}:${o}` : `${String(a)}:${o}`;
94
+ }
95
+ };
96
+ //#endregion
97
+ export { i as dateFilters };
@@ -1,14 +1,4 @@
1
- export type TwigFilter = (value: unknown, args: readonly unknown[]) => unknown;
2
- export declare const ARROW_PARAMS: unique symbol;
3
- export type ArrowCallback = ((...args: unknown[]) => unknown) & {
4
- [ARROW_PARAMS]?: number;
5
- };
6
- export type RawMarker = {
7
- readonly __raw: unknown;
8
- readonly __marker: typeof RAW_MARKER;
9
- };
10
- export declare const RAW_MARKER = "__PLITZI_RAW__";
11
- export declare const isRawMarker: (value: unknown) => value is RawMarker;
12
- export declare const wrapRaw: (value: unknown) => RawMarker;
13
- export declare const unwrapRaw: (value: unknown) => unknown;
1
+ import { TwigFilter } from './types';
2
+ export * from './raw';
3
+ export * from './types';
14
4
  export declare const filters: Record<string, TwigFilter>;