@platformos/platformos-common 0.0.12 → 0.0.16
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 +27 -0
- package/dist/documents-locator/DocumentsLocator.d.ts +13 -2
- package/dist/documents-locator/DocumentsLocator.js +49 -13
- package/dist/documents-locator/DocumentsLocator.js.map +1 -1
- package/dist/frontmatter.d.ts +75 -0
- package/dist/frontmatter.js +487 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/path-utils.d.ts +34 -0
- package/dist/path-utils.js +40 -0
- package/dist/path-utils.js.map +1 -1
- package/dist/route-table/RouteTable.d.ts +26 -0
- package/dist/route-table/RouteTable.js +18 -1
- package/dist/route-table/RouteTable.js.map +1 -1
- package/dist/route-table/index.d.ts +1 -1
- package/dist/route-table/index.js +2 -1
- package/dist/route-table/index.js.map +1 -1
- package/dist/translation-provider/TranslationProvider.d.ts +10 -1
- package/dist/translation-provider/TranslationProvider.js +32 -8
- package/dist/translation-provider/TranslationProvider.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/documents-locator/DocumentsLocator.spec.ts +68 -0
- package/src/documents-locator/DocumentsLocator.ts +62 -20
- package/src/frontmatter.ts +533 -0
- package/src/index.ts +1 -0
- package/src/path-utils.ts +55 -0
- package/src/route-table/RouteTable.ts +19 -2
- package/src/route-table/index.ts +1 -1
- package/src/translation-provider/TranslationProvider.ts +37 -15
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Frontmatter schema definitions for platformOS Liquid file types.
|
|
4
|
+
*
|
|
5
|
+
* Each Liquid file type in platformOS has a YAML frontmatter section at the
|
|
6
|
+
* top of the file that configures server-side behaviour. The schema for each
|
|
7
|
+
* type is different — Pages have slug/layout, Emails have to/from/subject, etc.
|
|
8
|
+
*
|
|
9
|
+
* This module provides:
|
|
10
|
+
* - FrontmatterFieldSchema — type definition for a single field
|
|
11
|
+
* - FrontmatterSchema — type definition for a complete schema
|
|
12
|
+
* - FRONTMATTER_SCHEMAS — per-type schemas keyed by PlatformOSFileType
|
|
13
|
+
* - getFrontmatterSchema() — convenience lookup that returns undefined for
|
|
14
|
+
* types without a frontmatter schema
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FRONTMATTER_ASSOCIATION_DIRS = exports.FRONTMATTER_SCHEMAS = void 0;
|
|
18
|
+
exports.getFrontmatterSchema = getFrontmatterSchema;
|
|
19
|
+
exports.containsLiquid = containsLiquid;
|
|
20
|
+
const path_utils_1 = require("./path-utils");
|
|
21
|
+
// ─── Schemas ──────────────────────────────────────────────────────────────────
|
|
22
|
+
/**
|
|
23
|
+
* Per-type frontmatter schemas.
|
|
24
|
+
*
|
|
25
|
+
* Only Liquid file types are present here — GraphQL, YAML, and Asset types
|
|
26
|
+
* do not use frontmatter.
|
|
27
|
+
*
|
|
28
|
+
* Field lists are derived from the server-side converter files in
|
|
29
|
+
* app/services/app_builder/converters/. Enum constraints mirror server validations.
|
|
30
|
+
* Unknown keys always produce a warning; file types with arbitrary frontmatter
|
|
31
|
+
* (e.g. Migration) are omitted so no validation runs for them.
|
|
32
|
+
*/
|
|
33
|
+
exports.FRONTMATTER_SCHEMAS = {
|
|
34
|
+
// ── Page ─────────────────────────────────────────────────────────────────────
|
|
35
|
+
[path_utils_1.PlatformOSFileType.Page]: {
|
|
36
|
+
name: 'Page',
|
|
37
|
+
fields: {
|
|
38
|
+
slug: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'URL slug for this page. Supports dynamic segments (e.g. users/:id).',
|
|
41
|
+
},
|
|
42
|
+
layout: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'Layout template to wrap this page (path relative to app root, no extension).',
|
|
45
|
+
},
|
|
46
|
+
layout_name: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'Alias for layout.',
|
|
49
|
+
deprecated: true,
|
|
50
|
+
deprecatedMessage: 'Use `layout` instead of `layout_name`.',
|
|
51
|
+
},
|
|
52
|
+
method: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'HTTP method this page responds to.',
|
|
55
|
+
enumValues: ['delete', 'get', 'patch', 'post', 'put', 'options'],
|
|
56
|
+
},
|
|
57
|
+
redirect_to: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'URL to redirect to.',
|
|
60
|
+
},
|
|
61
|
+
redirect_url: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'Alias for redirect_to.',
|
|
64
|
+
deprecated: true,
|
|
65
|
+
deprecatedMessage: 'Use `redirect_to` instead of `redirect_url`.',
|
|
66
|
+
},
|
|
67
|
+
redirect_code: {
|
|
68
|
+
type: 'integer',
|
|
69
|
+
description: 'HTTP redirect status code.',
|
|
70
|
+
enumValues: [301, 302, 307],
|
|
71
|
+
},
|
|
72
|
+
authorization_policies: {
|
|
73
|
+
type: 'array',
|
|
74
|
+
description: 'List of authorization policy names that must pass before rendering.',
|
|
75
|
+
},
|
|
76
|
+
response_headers: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'Liquid template that renders a JSON object of HTTP response headers.',
|
|
79
|
+
},
|
|
80
|
+
metadata: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
description: 'Arbitrary metadata object (e.g. SEO title/description, robots directives).',
|
|
83
|
+
},
|
|
84
|
+
max_deep_level: {
|
|
85
|
+
type: 'integer',
|
|
86
|
+
description: 'Maximum number of dynamic URL segments to capture.',
|
|
87
|
+
},
|
|
88
|
+
searchable: {
|
|
89
|
+
type: 'boolean',
|
|
90
|
+
description: 'Whether this page is included in platformOS search indexes.',
|
|
91
|
+
},
|
|
92
|
+
format: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'Response format (html, json, xml, csv, …). Often encoded in the filename.',
|
|
95
|
+
},
|
|
96
|
+
default_layout: {
|
|
97
|
+
type: 'boolean',
|
|
98
|
+
description: 'Use the instance default layout.',
|
|
99
|
+
},
|
|
100
|
+
handler: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
description: 'Template handler type.',
|
|
103
|
+
},
|
|
104
|
+
converter: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
description: 'Content converter, e.g. `markdown`.',
|
|
107
|
+
},
|
|
108
|
+
dynamic_cache: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
description: 'Dynamic cache settings: { key, layout, expire }.',
|
|
111
|
+
},
|
|
112
|
+
static_cache: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
description: 'Static cache settings: { expire }.',
|
|
115
|
+
},
|
|
116
|
+
cache_for: {
|
|
117
|
+
type: 'integer',
|
|
118
|
+
description: 'Static cache expiration in seconds.',
|
|
119
|
+
},
|
|
120
|
+
subdomain: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
description: 'Subdomain routing.',
|
|
123
|
+
},
|
|
124
|
+
require_verified_user: {
|
|
125
|
+
type: 'boolean',
|
|
126
|
+
},
|
|
127
|
+
admin_page: {
|
|
128
|
+
type: 'boolean',
|
|
129
|
+
},
|
|
130
|
+
enable_profiler: {
|
|
131
|
+
type: 'boolean',
|
|
132
|
+
},
|
|
133
|
+
metadata_title: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'SEO <title> shorthand (alias for metadata.title).',
|
|
136
|
+
},
|
|
137
|
+
metadata_meta_description: {
|
|
138
|
+
type: 'string',
|
|
139
|
+
description: 'SEO meta description shorthand (alias for metadata.meta_description).',
|
|
140
|
+
},
|
|
141
|
+
metadata_canonical_url: {
|
|
142
|
+
type: 'string',
|
|
143
|
+
description: 'Canonical URL shorthand (alias for metadata.canonical_url).',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
// ── Layout ───────────────────────────────────────────────────────────────────
|
|
148
|
+
// liquid_view_converter.rb: primary_key derived from physical_file_path; no `name` property.
|
|
149
|
+
[path_utils_1.PlatformOSFileType.Layout]: {
|
|
150
|
+
name: 'Layout',
|
|
151
|
+
fields: {
|
|
152
|
+
converter: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
description: 'Content converter, e.g. `markdown`.',
|
|
155
|
+
},
|
|
156
|
+
metadata: {
|
|
157
|
+
type: 'object',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
// ── Partial ──────────────────────────────────────────────────────────────────
|
|
162
|
+
[path_utils_1.PlatformOSFileType.Partial]: {
|
|
163
|
+
name: 'Partial',
|
|
164
|
+
fields: {
|
|
165
|
+
metadata: {
|
|
166
|
+
type: 'object',
|
|
167
|
+
description: 'Partial metadata. `metadata.params` declares accepted parameters; `metadata.name` is a human-readable label for the style guide.',
|
|
168
|
+
},
|
|
169
|
+
converter: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
description: 'Content converter, e.g. `markdown`.',
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
// ── AuthorizationPolicy ──────────────────────────────────────────────────────
|
|
176
|
+
// authorization_policy_converter.rb: name, content, flash_alert, redirect_to, http_status, metadata.
|
|
177
|
+
// Note: only flash_alert is supported — flash_notice is NOT a valid property here.
|
|
178
|
+
[path_utils_1.PlatformOSFileType.Authorization]: {
|
|
179
|
+
name: 'AuthorizationPolicy',
|
|
180
|
+
fields: {
|
|
181
|
+
name: {
|
|
182
|
+
type: 'string',
|
|
183
|
+
description: 'Unique identifier for this authorization policy.',
|
|
184
|
+
},
|
|
185
|
+
redirect_to: {
|
|
186
|
+
type: 'string',
|
|
187
|
+
description: 'URL to redirect the user to when the policy fails.',
|
|
188
|
+
},
|
|
189
|
+
flash_alert: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
description: 'Flash alert message shown after a failed authorization redirect.',
|
|
192
|
+
},
|
|
193
|
+
http_status: {
|
|
194
|
+
type: 'integer',
|
|
195
|
+
description: 'HTTP status code returned on policy failure.',
|
|
196
|
+
enumValues: [403, 404],
|
|
197
|
+
},
|
|
198
|
+
metadata: {
|
|
199
|
+
type: 'object',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
// ── Email ────────────────────────────────────────────────────────────────────
|
|
204
|
+
[path_utils_1.PlatformOSFileType.Email]: {
|
|
205
|
+
name: 'Email',
|
|
206
|
+
fields: {
|
|
207
|
+
name: {
|
|
208
|
+
type: 'string',
|
|
209
|
+
description: 'Unique identifier for this email notification.',
|
|
210
|
+
},
|
|
211
|
+
to: {
|
|
212
|
+
type: 'string',
|
|
213
|
+
description: 'Recipient email address (may use Liquid).',
|
|
214
|
+
},
|
|
215
|
+
from: {
|
|
216
|
+
type: 'string',
|
|
217
|
+
description: 'Sender email address.',
|
|
218
|
+
},
|
|
219
|
+
reply_to: {
|
|
220
|
+
type: 'string',
|
|
221
|
+
description: 'Reply-to email address.',
|
|
222
|
+
},
|
|
223
|
+
cc: {
|
|
224
|
+
type: 'string',
|
|
225
|
+
description: 'Carbon-copy recipients.',
|
|
226
|
+
},
|
|
227
|
+
bcc: {
|
|
228
|
+
type: 'string',
|
|
229
|
+
description: 'Blind carbon-copy recipients.',
|
|
230
|
+
},
|
|
231
|
+
subject: {
|
|
232
|
+
type: 'string',
|
|
233
|
+
description: 'Email subject line (may use Liquid).',
|
|
234
|
+
},
|
|
235
|
+
layout: {
|
|
236
|
+
type: 'string',
|
|
237
|
+
description: 'Layout partial to wrap the email body.',
|
|
238
|
+
},
|
|
239
|
+
layout_path: {
|
|
240
|
+
type: 'string',
|
|
241
|
+
description: 'Alias for layout.',
|
|
242
|
+
deprecated: true,
|
|
243
|
+
deprecatedMessage: 'Use `layout` instead of `layout_path`.',
|
|
244
|
+
},
|
|
245
|
+
delay: {
|
|
246
|
+
type: 'integer',
|
|
247
|
+
description: 'Seconds to delay delivery after being triggered.',
|
|
248
|
+
},
|
|
249
|
+
enabled: {
|
|
250
|
+
type: 'boolean',
|
|
251
|
+
description: 'When false, this email is never sent. Defaults to true.',
|
|
252
|
+
},
|
|
253
|
+
trigger_condition: {
|
|
254
|
+
type: ['boolean', 'string'],
|
|
255
|
+
description: 'Liquid expression or boolean; email is only sent when this evaluates to true.',
|
|
256
|
+
},
|
|
257
|
+
locale: {
|
|
258
|
+
type: 'string',
|
|
259
|
+
description: 'Locale for the email.',
|
|
260
|
+
},
|
|
261
|
+
forced: {
|
|
262
|
+
type: 'boolean',
|
|
263
|
+
},
|
|
264
|
+
attachments: {
|
|
265
|
+
type: 'string',
|
|
266
|
+
},
|
|
267
|
+
unique_args: {
|
|
268
|
+
type: 'object',
|
|
269
|
+
description: 'Extra key/value pairs passed to the email delivery provider.',
|
|
270
|
+
},
|
|
271
|
+
metadata: {
|
|
272
|
+
type: 'object',
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
// ── ApiCall ──────────────────────────────────────────────────────────────────
|
|
277
|
+
[path_utils_1.PlatformOSFileType.ApiCall]: {
|
|
278
|
+
name: 'ApiCall',
|
|
279
|
+
fields: {
|
|
280
|
+
name: {
|
|
281
|
+
type: 'string',
|
|
282
|
+
description: 'Unique identifier for this API call notification.',
|
|
283
|
+
},
|
|
284
|
+
to: {
|
|
285
|
+
type: 'string',
|
|
286
|
+
description: 'Target URL for the HTTP request (may use Liquid).',
|
|
287
|
+
},
|
|
288
|
+
request_type: {
|
|
289
|
+
type: 'string',
|
|
290
|
+
description: 'HTTP method: GET, POST, PUT, PATCH, or DELETE.',
|
|
291
|
+
enumValues: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
|
292
|
+
},
|
|
293
|
+
request_headers: {
|
|
294
|
+
type: 'string',
|
|
295
|
+
description: 'Liquid template rendering a JSON object of request headers.',
|
|
296
|
+
},
|
|
297
|
+
headers: {
|
|
298
|
+
type: 'string',
|
|
299
|
+
description: 'Alias for request_headers.',
|
|
300
|
+
deprecated: true,
|
|
301
|
+
deprecatedMessage: 'Use `request_headers` instead of `headers`.',
|
|
302
|
+
},
|
|
303
|
+
callback: {
|
|
304
|
+
type: 'string',
|
|
305
|
+
description: 'Liquid template executed after the HTTP response is received.',
|
|
306
|
+
},
|
|
307
|
+
delay: {
|
|
308
|
+
type: 'integer',
|
|
309
|
+
description: 'Seconds to delay the request after being triggered.',
|
|
310
|
+
},
|
|
311
|
+
enabled: {
|
|
312
|
+
type: 'boolean',
|
|
313
|
+
description: 'When false, this API call is never executed. Defaults to true.',
|
|
314
|
+
},
|
|
315
|
+
trigger_condition: {
|
|
316
|
+
type: ['boolean', 'string'],
|
|
317
|
+
description: 'Liquid expression or boolean; call is only made when this evaluates to true.',
|
|
318
|
+
},
|
|
319
|
+
format: {
|
|
320
|
+
type: 'string',
|
|
321
|
+
description: 'Request body encoding format (http, json, …).',
|
|
322
|
+
},
|
|
323
|
+
locale: {
|
|
324
|
+
type: 'string',
|
|
325
|
+
},
|
|
326
|
+
metadata: {
|
|
327
|
+
type: 'object',
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
// ── Sms ──────────────────────────────────────────────────────────────────────
|
|
332
|
+
[path_utils_1.PlatformOSFileType.Sms]: {
|
|
333
|
+
name: 'SMS',
|
|
334
|
+
fields: {
|
|
335
|
+
name: {
|
|
336
|
+
type: 'string',
|
|
337
|
+
description: 'Unique identifier for this SMS notification.',
|
|
338
|
+
},
|
|
339
|
+
to: {
|
|
340
|
+
type: 'string',
|
|
341
|
+
description: 'Recipient phone number in E.164 format (may use Liquid).',
|
|
342
|
+
},
|
|
343
|
+
content: {
|
|
344
|
+
type: 'string',
|
|
345
|
+
description: 'SMS body (may use Liquid).',
|
|
346
|
+
},
|
|
347
|
+
delay: {
|
|
348
|
+
type: 'integer',
|
|
349
|
+
description: 'Seconds to delay sending after being triggered.',
|
|
350
|
+
},
|
|
351
|
+
enabled: {
|
|
352
|
+
type: 'boolean',
|
|
353
|
+
description: 'When false, this SMS is never sent. Defaults to true.',
|
|
354
|
+
},
|
|
355
|
+
trigger_condition: {
|
|
356
|
+
type: ['boolean', 'string'],
|
|
357
|
+
description: 'Liquid expression or boolean; SMS is only sent when this evaluates to true.',
|
|
358
|
+
},
|
|
359
|
+
locale: {
|
|
360
|
+
type: 'string',
|
|
361
|
+
},
|
|
362
|
+
metadata: {
|
|
363
|
+
type: 'object',
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
// ── FormConfiguration ────────────────────────────────────────────────────────
|
|
368
|
+
[path_utils_1.PlatformOSFileType.FormConfiguration]: {
|
|
369
|
+
name: 'FormConfiguration',
|
|
370
|
+
fields: {
|
|
371
|
+
name: {
|
|
372
|
+
type: 'string',
|
|
373
|
+
description: 'Unique identifier for this form, used in include_form / function calls.',
|
|
374
|
+
},
|
|
375
|
+
resource: {
|
|
376
|
+
type: ['string', 'object'],
|
|
377
|
+
description: 'Model or resource type this form operates on.',
|
|
378
|
+
},
|
|
379
|
+
resource_owner: {
|
|
380
|
+
type: 'string',
|
|
381
|
+
description: 'Who owns the resource being created/updated.',
|
|
382
|
+
},
|
|
383
|
+
fields: {
|
|
384
|
+
type: 'object',
|
|
385
|
+
description: 'Field definitions — what data this form accepts and validates.',
|
|
386
|
+
},
|
|
387
|
+
configuration: {
|
|
388
|
+
type: 'object',
|
|
389
|
+
description: 'Alias for fields.',
|
|
390
|
+
},
|
|
391
|
+
redirect_to: {
|
|
392
|
+
type: 'string',
|
|
393
|
+
description: 'URL to redirect to after a successful form submission.',
|
|
394
|
+
},
|
|
395
|
+
return_to: {
|
|
396
|
+
type: 'string',
|
|
397
|
+
description: 'Alias for redirect_to.',
|
|
398
|
+
deprecated: true,
|
|
399
|
+
deprecatedMessage: 'Use `redirect_to` instead of `return_to`.',
|
|
400
|
+
},
|
|
401
|
+
flash_notice: {
|
|
402
|
+
type: 'string',
|
|
403
|
+
description: 'Flash notice message shown after a successful submission.',
|
|
404
|
+
},
|
|
405
|
+
flash_alert: {
|
|
406
|
+
type: 'string',
|
|
407
|
+
description: 'Flash alert message shown after a failed submission.',
|
|
408
|
+
},
|
|
409
|
+
spam_protection: {
|
|
410
|
+
type: 'string',
|
|
411
|
+
description: 'Spam protection mechanism to use.',
|
|
412
|
+
enumValues: ['recaptcha', 'recaptcha_v2', 'recaptcha_v3', 'hcaptcha'],
|
|
413
|
+
},
|
|
414
|
+
request_allowed: {
|
|
415
|
+
type: 'boolean',
|
|
416
|
+
description: 'Whether the request is allowed. Default: true.',
|
|
417
|
+
},
|
|
418
|
+
live_reindex: {
|
|
419
|
+
type: 'boolean',
|
|
420
|
+
},
|
|
421
|
+
default_payload: {
|
|
422
|
+
type: ['string', 'object'],
|
|
423
|
+
},
|
|
424
|
+
callback_actions: {
|
|
425
|
+
type: 'string',
|
|
426
|
+
description: 'Liquid template with GraphQL mutations to run after submission.',
|
|
427
|
+
},
|
|
428
|
+
async_callback_actions: {
|
|
429
|
+
type: 'object',
|
|
430
|
+
description: 'Async callback settings: { content, delay, max_attempts, priority }.',
|
|
431
|
+
},
|
|
432
|
+
email_notifications: {
|
|
433
|
+
type: 'array',
|
|
434
|
+
description: 'Email notification names to trigger after successful form submission.',
|
|
435
|
+
},
|
|
436
|
+
sms_notifications: {
|
|
437
|
+
type: 'array',
|
|
438
|
+
description: 'SMS notification names to trigger after successful form submission.',
|
|
439
|
+
},
|
|
440
|
+
api_call_notifications: {
|
|
441
|
+
type: 'array',
|
|
442
|
+
description: 'API call notification names to trigger after successful form submission.',
|
|
443
|
+
},
|
|
444
|
+
response_headers: {
|
|
445
|
+
type: ['string', 'object'],
|
|
446
|
+
},
|
|
447
|
+
metadata: {
|
|
448
|
+
type: 'object',
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
};
|
|
453
|
+
// ─── Lookup helper ────────────────────────────────────────────────────────────
|
|
454
|
+
/**
|
|
455
|
+
* Returns the frontmatter schema for a given file type, or undefined if no
|
|
456
|
+
* schema is defined for that type (e.g. GraphQL, YAML, Asset types).
|
|
457
|
+
*/
|
|
458
|
+
function getFrontmatterSchema(fileType) {
|
|
459
|
+
if (fileType === undefined)
|
|
460
|
+
return undefined;
|
|
461
|
+
return exports.FRONTMATTER_SCHEMAS[fileType];
|
|
462
|
+
}
|
|
463
|
+
// ─── Frontmatter association directories ──────────────────────────────────────
|
|
464
|
+
/**
|
|
465
|
+
* Maps frontmatter list-field names to their canonical app-relative directory.
|
|
466
|
+
*
|
|
467
|
+
* Derived from FILE_TYPE_DIRS[type][0] so it always stays in sync with the
|
|
468
|
+
* single source of truth in path-utils.ts.
|
|
469
|
+
*
|
|
470
|
+
* Used by both the ValidFrontmatter check (file-existence validation) and the
|
|
471
|
+
* FrontmatterDefinitionProvider (go-to-definition) to resolve association paths.
|
|
472
|
+
*/
|
|
473
|
+
exports.FRONTMATTER_ASSOCIATION_DIRS = {
|
|
474
|
+
authorization_policies: path_utils_1.FILE_TYPE_DIRS[path_utils_1.PlatformOSFileType.Authorization][0],
|
|
475
|
+
email_notifications: path_utils_1.FILE_TYPE_DIRS[path_utils_1.PlatformOSFileType.Email][0],
|
|
476
|
+
sms_notifications: path_utils_1.FILE_TYPE_DIRS[path_utils_1.PlatformOSFileType.Sms][0],
|
|
477
|
+
api_call_notifications: path_utils_1.FILE_TYPE_DIRS[path_utils_1.PlatformOSFileType.ApiCall][0],
|
|
478
|
+
};
|
|
479
|
+
// ─── Liquid expression detection ──────────────────────────────────────────────
|
|
480
|
+
/**
|
|
481
|
+
* Returns true if the value contains a Liquid output tag (`{{`) or tag (`{%`).
|
|
482
|
+
* Used to skip static validation of dynamic frontmatter values.
|
|
483
|
+
*/
|
|
484
|
+
function containsLiquid(value) {
|
|
485
|
+
return value.includes('{{') || value.includes('{%');
|
|
486
|
+
}
|
|
487
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":";AAAA;;;;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;IAC5E,sBAAsB,EAAE,2BAAc,CAAC,+BAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC3E,mBAAmB,EAAE,2BAAc,CAAC,+BAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChE,iBAAiB,EAAE,2BAAc,CAAC,+BAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5D,sBAAsB,EAAE,2BAAc,CAAC,+BAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;CACtE,CAAC;AAEF,iFAAiF;AAEjF;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,4 +19,5 @@ __exportStar(require("./translation-provider/TranslationProvider"), exports);
|
|
|
19
19
|
__exportStar(require("./route-table"), exports);
|
|
20
20
|
__exportStar(require("./AbstractFileSystem"), exports);
|
|
21
21
|
__exportStar(require("./path-utils"), exports);
|
|
22
|
+
__exportStar(require("./frontmatter"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uEAAqD;AACrD,6EAA2D;AAC3D,gDAA8B;AAC9B,uDAAqC;AACrC,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uEAAqD;AACrD,6EAA2D;AAC3D,gDAA8B;AAC9B,uDAAqC;AACrC,+CAA6B;AAC7B,gDAA8B"}
|
package/dist/path-utils.d.ts
CHANGED
|
@@ -122,6 +122,16 @@ export declare function getModulePaths(type: PlatformOSFileType, moduleName: str
|
|
|
122
122
|
* templates, build artifacts) return false and are excluded from linting.
|
|
123
123
|
*/
|
|
124
124
|
export declare function isKnownLiquidFile(uri: UriString): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Returns true if the URI has a `.liquid` extension but does not match any
|
|
127
|
+
* recognized platformOS directory. Useful for detecting misplaced files that
|
|
128
|
+
* the server will silently ignore.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* isUnclassifiedLiquidFile('file:///project/scripts/helper.liquid') // → true
|
|
132
|
+
* isUnclassifiedLiquidFile('file:///project/app/views/pages/home.liquid') // → false (Page)
|
|
133
|
+
*/
|
|
134
|
+
export declare function isUnclassifiedLiquidFile(uri: UriString): boolean;
|
|
125
135
|
/**
|
|
126
136
|
* Returns true if the URI belongs to a recognized platformOS GraphQL directory
|
|
127
137
|
* and should be linted. Files outside known directories (e.g. generator
|
|
@@ -137,3 +147,27 @@ export declare function isApiCall(uri: UriString): boolean;
|
|
|
137
147
|
export declare function isSms(uri: UriString): boolean;
|
|
138
148
|
export declare function isMigration(uri: UriString): boolean;
|
|
139
149
|
export declare function isFormConfiguration(uri: UriString): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Result of parsing a `modules/{name}/...` prefix from a path or key.
|
|
152
|
+
* Used by DocumentsLocator and TranslationProvider to route lookups to the
|
|
153
|
+
* correct module directory.
|
|
154
|
+
*/
|
|
155
|
+
export type ModulePrefix = {
|
|
156
|
+
isModule: false;
|
|
157
|
+
key: string;
|
|
158
|
+
} | {
|
|
159
|
+
isModule: true;
|
|
160
|
+
moduleName: string;
|
|
161
|
+
key: string;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Parse a `modules/{name}/{rest}` prefix from a path or translation key.
|
|
165
|
+
* Returns the module name and the remaining key, or marks it as non-module.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* parseModulePrefix('modules/community/components/card') // → { isModule: true, moduleName: 'community', key: 'components/card' }
|
|
169
|
+
* parseModulePrefix('modules/community/hello.world') // → { isModule: true, moduleName: 'community', key: 'hello.world' }
|
|
170
|
+
* parseModulePrefix('app/views/partials/card') // → { isModule: false, key: 'app/views/partials/card' }
|
|
171
|
+
* parseModulePrefix('modules/community') // → { isModule: false, key: 'modules/community' } (no key segment)
|
|
172
|
+
*/
|
|
173
|
+
export declare function parseModulePrefix(path: string): ModulePrefix;
|
package/dist/path-utils.js
CHANGED
|
@@ -25,6 +25,7 @@ exports.getFileType = getFileType;
|
|
|
25
25
|
exports.getAppPaths = getAppPaths;
|
|
26
26
|
exports.getModulePaths = getModulePaths;
|
|
27
27
|
exports.isKnownLiquidFile = isKnownLiquidFile;
|
|
28
|
+
exports.isUnclassifiedLiquidFile = isUnclassifiedLiquidFile;
|
|
28
29
|
exports.isKnownGraphQLFile = isKnownGraphQLFile;
|
|
29
30
|
exports.isPartial = isPartial;
|
|
30
31
|
exports.isPage = isPage;
|
|
@@ -35,6 +36,7 @@ exports.isApiCall = isApiCall;
|
|
|
35
36
|
exports.isSms = isSms;
|
|
36
37
|
exports.isMigration = isMigration;
|
|
37
38
|
exports.isFormConfiguration = isFormConfiguration;
|
|
39
|
+
exports.parseModulePrefix = parseModulePrefix;
|
|
38
40
|
/**
|
|
39
41
|
* File types that exist in a platformOS app, each corresponding to a server-side
|
|
40
42
|
* converter that processes the file on deploy.
|
|
@@ -221,6 +223,18 @@ function isKnownLiquidFile(uri) {
|
|
|
221
223
|
const type = getFileType(uri);
|
|
222
224
|
return type !== undefined && LIQUID_FILE_TYPES.has(type);
|
|
223
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Returns true if the URI has a `.liquid` extension but does not match any
|
|
228
|
+
* recognized platformOS directory. Useful for detecting misplaced files that
|
|
229
|
+
* the server will silently ignore.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* isUnclassifiedLiquidFile('file:///project/scripts/helper.liquid') // → true
|
|
233
|
+
* isUnclassifiedLiquidFile('file:///project/app/views/pages/home.liquid') // → false (Page)
|
|
234
|
+
*/
|
|
235
|
+
function isUnclassifiedLiquidFile(uri) {
|
|
236
|
+
return uri.endsWith('.liquid') && getFileType(uri) === undefined;
|
|
237
|
+
}
|
|
224
238
|
/**
|
|
225
239
|
* Returns true if the URI belongs to a recognized platformOS GraphQL directory
|
|
226
240
|
* and should be linted. Files outside known directories (e.g. generator
|
|
@@ -256,4 +270,30 @@ function isMigration(uri) {
|
|
|
256
270
|
function isFormConfiguration(uri) {
|
|
257
271
|
return getFileType(uri) === PlatformOSFileType.FormConfiguration;
|
|
258
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Parse a `modules/{name}/{rest}` prefix from a path or translation key.
|
|
275
|
+
* Returns the module name and the remaining key, or marks it as non-module.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* parseModulePrefix('modules/community/components/card') // → { isModule: true, moduleName: 'community', key: 'components/card' }
|
|
279
|
+
* parseModulePrefix('modules/community/hello.world') // → { isModule: true, moduleName: 'community', key: 'hello.world' }
|
|
280
|
+
* parseModulePrefix('app/views/partials/card') // → { isModule: false, key: 'app/views/partials/card' }
|
|
281
|
+
* parseModulePrefix('modules/community') // → { isModule: false, key: 'modules/community' } (no key segment)
|
|
282
|
+
*/
|
|
283
|
+
function parseModulePrefix(path) {
|
|
284
|
+
if (!path.startsWith('modules/')) {
|
|
285
|
+
return { isModule: false, key: path };
|
|
286
|
+
}
|
|
287
|
+
const withoutPrefix = path.slice('modules/'.length);
|
|
288
|
+
const slashIdx = withoutPrefix.indexOf('/');
|
|
289
|
+
if (slashIdx === -1) {
|
|
290
|
+
// Just "modules/name" with no key segment
|
|
291
|
+
return { isModule: false, key: path };
|
|
292
|
+
}
|
|
293
|
+
const moduleName = withoutPrefix.slice(0, slashIdx);
|
|
294
|
+
const key = withoutPrefix.slice(slashIdx + 1);
|
|
295
|
+
// moduleName must be non-empty to be a valid module prefix.
|
|
296
|
+
// key may be empty (e.g. 'modules/users/') — that means "all files in the module".
|
|
297
|
+
return moduleName ? { isModule: true, moduleName, key } : { isModule: false, key: path };
|
|
298
|
+
}
|
|
259
299
|
//# sourceMappingURL=path-utils.js.map
|
package/dist/path-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAsJH,kCAKC;AAUD,kCAEC;AAiBD,wCAOC;AAOD,8CAGC;AAOD,gDAEC;AAED,8BAEC;AAED,wBAEC;AAED,4BAEC;AAED,0CAEC;AAED,0BAEC;AAED,8BAEC;AAED,sBAEC;AAED,kCAEC;AAED,kDAEC;
|
|
1
|
+
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAsJH,kCAKC;AAUD,kCAEC;AAiBD,wCAOC;AAOD,8CAGC;AAWD,4DAEC;AAOD,gDAEC;AAED,8BAEC;AAED,wBAEC;AAED,4BAEC;AAED,0CAEC;AAED,0BAEC;AAED,8BAEC;AAED,sBAEC;AAED,kCAEC;AAED,kDAEC;AAuBD,8CAmBC;AAzSD;;;;;;;;GAQG;AACH,IAAY,kBAsCX;AAtCD,WAAY,kBAAkB;IAC5B,+EAA+E;IAC/E,6CAA6C;IAC7C,mCAAa,CAAA;IACb,qDAAqD;IACrD,uCAAiB,CAAA;IACjB,+DAA+D;IAC/D,yCAAmB,CAAA;IACnB,6DAA6D;IAC7D,qDAA+B,CAAA;IAC/B,iFAAiF;IACjF,qCAAe,CAAA;IACf,yFAAyF;IACzF,yCAAmB,CAAA;IACnB,4EAA4E;IAC5E,iCAAW,CAAA;IACX,uCAAuC;IACvC,6CAAuB,CAAA;IACvB,kEAAkE;IAClE,6DAAuC,CAAA;IAEvC,+EAA+E;IAC/E,iFAAiF;IACjF,yDAAmC,CAAA;IACnC,4GAA4G;IA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