@platformos/platformos-check-common 0.0.11 → 0.0.12
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 +8 -0
- package/CLAUDE.md +150 -0
- package/dist/AugmentedPlatformOSDocset.js +1 -0
- package/dist/AugmentedPlatformOSDocset.js.map +1 -1
- package/dist/checks/deprecated-filter/index.js +15 -0
- package/dist/checks/deprecated-filter/index.js.map +1 -1
- package/dist/checks/duplicate-content-for-arguments/index.js +1 -1
- package/dist/checks/duplicate-content-for-arguments/index.js.map +1 -1
- package/dist/checks/graphql/index.d.ts +1 -0
- package/dist/checks/graphql/index.js +20 -7
- package/dist/checks/graphql/index.js.map +1 -1
- package/dist/checks/invalid-hash-assign-target/index.js +4 -3
- package/dist/checks/invalid-hash-assign-target/index.js.map +1 -1
- package/dist/checks/missing-content-for-arguments/index.js +1 -1
- package/dist/checks/missing-content-for-arguments/index.js.map +1 -1
- package/dist/checks/pagination-size/index.js +1 -1
- package/dist/checks/pagination-size/index.js.map +1 -1
- package/dist/checks/undefined-object/index.js +14 -13
- package/dist/checks/undefined-object/index.js.map +1 -1
- package/dist/checks/unknown-property/index.js +75 -10
- package/dist/checks/unknown-property/index.js.map +1 -1
- package/dist/checks/unknown-property/property-shape.js +14 -1
- package/dist/checks/unknown-property/property-shape.js.map +1 -1
- package/dist/checks/unrecognized-content-for-arguments/index.js +1 -1
- package/dist/checks/unrecognized-content-for-arguments/index.js.map +1 -1
- package/dist/checks/unused-assign/index.js +23 -1
- package/dist/checks/unused-assign/index.js.map +1 -1
- package/dist/checks/valid-content-for-argument-types/index.js +1 -1
- package/dist/checks/valid-content-for-argument-types/index.js.map +1 -1
- package/dist/checks/variable-name/index.js +4 -0
- package/dist/checks/variable-name/index.js.map +1 -1
- package/dist/doc-generator/DocBlockGenerator.d.ts +16 -0
- package/dist/doc-generator/DocBlockGenerator.js +464 -0
- package/dist/doc-generator/DocBlockGenerator.js.map +1 -0
- package/dist/doc-generator/index.d.ts +1 -0
- package/dist/doc-generator/index.js +6 -0
- package/dist/doc-generator/index.js.map +1 -0
- package/dist/frontmatter/index.d.ts +59 -0
- package/dist/frontmatter/index.js +301 -0
- package/dist/frontmatter/index.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/liquid-doc/arguments.js +5 -0
- package/dist/liquid-doc/arguments.js.map +1 -1
- package/dist/path.d.ts +1 -1
- package/dist/path.js +3 -1
- package/dist/path.js.map +1 -1
- package/dist/to-schema.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/block.js.map +1 -1
- package/package.json +2 -2
- package/src/AugmentedPlatformOSDocset.ts +1 -0
- package/src/checks/deprecated-filter/index.spec.ts +41 -1
- package/src/checks/deprecated-filter/index.ts +17 -0
- package/src/checks/graphql/index.spec.ts +173 -0
- package/src/checks/graphql/index.ts +21 -10
- package/src/checks/invalid-hash-assign-target/index.spec.ts +26 -0
- package/src/checks/invalid-hash-assign-target/index.ts +6 -4
- package/src/checks/undefined-object/index.spec.ts +123 -19
- package/src/checks/undefined-object/index.ts +16 -18
- package/src/checks/unknown-property/index.spec.ts +133 -0
- package/src/checks/unknown-property/index.ts +84 -10
- package/src/checks/unknown-property/property-shape.ts +15 -1
- package/src/checks/unused-assign/index.spec.ts +74 -0
- package/src/checks/unused-assign/index.ts +26 -1
- package/src/checks/variable-name/index.spec.ts +9 -0
- package/src/checks/variable-name/index.ts +5 -0
- package/src/frontmatter/index.ts +344 -0
- package/src/index.ts +3 -0
- package/src/liquid-doc/arguments.ts +3 -0
- package/src/path.ts +2 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frontmatter schema definitions for platformOS Liquid file types.
|
|
3
|
+
*
|
|
4
|
+
* Each Liquid file type in platformOS has a YAML frontmatter section at the
|
|
5
|
+
* top of the file that configures server-side behaviour. The schema for each
|
|
6
|
+
* type is different — Pages have slug/layout, Emails have to/from/subject, etc.
|
|
7
|
+
*
|
|
8
|
+
* This module provides:
|
|
9
|
+
* - FrontmatterFieldSchema — type definition for a single field
|
|
10
|
+
* - FrontmatterSchema — type definition for a complete schema
|
|
11
|
+
* - FRONTMATTER_SCHEMAS — per-type schemas keyed by PlatformOSFileType
|
|
12
|
+
* - getFrontmatterSchema() — convenience lookup that returns undefined for
|
|
13
|
+
* types without a frontmatter schema
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { PlatformOSFileType } from '@platformos/platformos-common';
|
|
17
|
+
|
|
18
|
+
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
export type FrontmatterFieldType = 'string' | 'boolean' | 'integer' | 'number' | 'array' | 'object';
|
|
21
|
+
|
|
22
|
+
export interface FrontmatterFieldSchema {
|
|
23
|
+
/** The expected YAML type(s) for this field's value. */
|
|
24
|
+
type: FrontmatterFieldType | FrontmatterFieldType[];
|
|
25
|
+
/** Whether this field must be present. */
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/** Human-readable description of this field. */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** Whether this field name is deprecated in favour of a newer one. */
|
|
30
|
+
deprecated?: boolean;
|
|
31
|
+
/** Message shown when this deprecated field is used. */
|
|
32
|
+
deprecatedMessage?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface FrontmatterSchema {
|
|
36
|
+
/** Human-readable name of the file type, used in diagnostics. */
|
|
37
|
+
name: string;
|
|
38
|
+
/**
|
|
39
|
+
* Known frontmatter fields.
|
|
40
|
+
* Checks can use this to surface unknown keys or missing required keys.
|
|
41
|
+
*/
|
|
42
|
+
fields: Record<string, FrontmatterFieldSchema>;
|
|
43
|
+
/**
|
|
44
|
+
* Whether fields not listed in `fields` are allowed without a warning.
|
|
45
|
+
* Defaults to true — schemas are additive and may not be exhaustive.
|
|
46
|
+
*/
|
|
47
|
+
allowAdditionalFields?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ─── Schemas ──────────────────────────────────────────────────────────────────
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Per-type frontmatter schemas.
|
|
54
|
+
*
|
|
55
|
+
* Only Liquid file types are present here — GraphQL, YAML, and Asset types
|
|
56
|
+
* do not use frontmatter.
|
|
57
|
+
*
|
|
58
|
+
* Field lists are based on real-world usage in platformOS apps. Set
|
|
59
|
+
* `allowAdditionalFields: true` (the default) everywhere so that apps using
|
|
60
|
+
* custom/undocumented keys don't get false-positive warnings until the schemas
|
|
61
|
+
* are finalised.
|
|
62
|
+
*/
|
|
63
|
+
export const FRONTMATTER_SCHEMAS: Partial<Record<PlatformOSFileType, FrontmatterSchema>> = {
|
|
64
|
+
// ── Page ─────────────────────────────────────────────────────────────────────
|
|
65
|
+
[PlatformOSFileType.Page]: {
|
|
66
|
+
name: 'Page',
|
|
67
|
+
fields: {
|
|
68
|
+
slug: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: 'URL slug for this page. Supports dynamic segments (e.g. users/:id).',
|
|
71
|
+
},
|
|
72
|
+
layout: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
description: 'Layout template to wrap this page (path relative to app root, no extension).',
|
|
75
|
+
},
|
|
76
|
+
layout_name: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'Alias for layout.',
|
|
79
|
+
deprecated: true,
|
|
80
|
+
deprecatedMessage: 'Use `layout` instead of `layout_name`.',
|
|
81
|
+
},
|
|
82
|
+
method: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'HTTP method this page responds to (get, post, put, patch, delete).',
|
|
85
|
+
},
|
|
86
|
+
authorization_policies: {
|
|
87
|
+
type: 'array',
|
|
88
|
+
description: 'List of authorization policy names that must pass before rendering.',
|
|
89
|
+
},
|
|
90
|
+
response_headers: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
description: 'Liquid template that renders a JSON object of HTTP response headers.',
|
|
93
|
+
},
|
|
94
|
+
metadata: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
description: 'Arbitrary metadata object (e.g. SEO title/description, robots directives).',
|
|
97
|
+
},
|
|
98
|
+
max_deep_level: {
|
|
99
|
+
type: 'integer',
|
|
100
|
+
description: 'Maximum number of dynamic URL segments to capture.',
|
|
101
|
+
},
|
|
102
|
+
searchable: {
|
|
103
|
+
type: 'boolean',
|
|
104
|
+
description: 'Whether this page is included in platformOS search indexes.',
|
|
105
|
+
},
|
|
106
|
+
format: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
description: 'Response format (html, json, xml, csv, …). Often encoded in the filename.',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
allowAdditionalFields: true,
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
// ── Layout ───────────────────────────────────────────────────────────────────
|
|
115
|
+
[PlatformOSFileType.Layout]: {
|
|
116
|
+
name: 'Layout',
|
|
117
|
+
fields: {
|
|
118
|
+
name: {
|
|
119
|
+
type: 'string',
|
|
120
|
+
description: 'Identifier used to reference this layout from pages.',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
allowAdditionalFields: true,
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
// ── Partial ──────────────────────────────────────────────────────────────────
|
|
127
|
+
[PlatformOSFileType.Partial]: {
|
|
128
|
+
name: 'Partial',
|
|
129
|
+
fields: {
|
|
130
|
+
metadata: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
description:
|
|
133
|
+
'Partial metadata. `metadata.params` declares accepted parameters; `metadata.name` is a human-readable label for the style guide.',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
allowAdditionalFields: true,
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// ── AuthorizationPolicy ──────────────────────────────────────────────────────
|
|
140
|
+
[PlatformOSFileType.Authorization]: {
|
|
141
|
+
name: 'AuthorizationPolicy',
|
|
142
|
+
fields: {
|
|
143
|
+
name: {
|
|
144
|
+
type: 'string',
|
|
145
|
+
required: true,
|
|
146
|
+
description: 'Unique identifier for this authorization policy.',
|
|
147
|
+
},
|
|
148
|
+
redirect_to: {
|
|
149
|
+
type: 'string',
|
|
150
|
+
description: 'URL to redirect the user to when the policy fails.',
|
|
151
|
+
},
|
|
152
|
+
flash_alert: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
description: 'Flash alert message shown after a failed authorization redirect.',
|
|
155
|
+
},
|
|
156
|
+
flash_notice: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: 'Flash notice message shown after a failed authorization redirect.',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
allowAdditionalFields: true,
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
// ── Email ────────────────────────────────────────────────────────────────────
|
|
165
|
+
[PlatformOSFileType.Email]: {
|
|
166
|
+
name: 'Email',
|
|
167
|
+
fields: {
|
|
168
|
+
to: {
|
|
169
|
+
type: 'string',
|
|
170
|
+
required: true,
|
|
171
|
+
description: 'Recipient email address (may use Liquid).',
|
|
172
|
+
},
|
|
173
|
+
from: {
|
|
174
|
+
type: 'string',
|
|
175
|
+
description: 'Sender email address.',
|
|
176
|
+
},
|
|
177
|
+
reply_to: {
|
|
178
|
+
type: 'string',
|
|
179
|
+
description: 'Reply-to email address.',
|
|
180
|
+
},
|
|
181
|
+
cc: {
|
|
182
|
+
type: 'string',
|
|
183
|
+
description: 'Carbon-copy recipients.',
|
|
184
|
+
},
|
|
185
|
+
bcc: {
|
|
186
|
+
type: 'string',
|
|
187
|
+
description: 'Blind carbon-copy recipients.',
|
|
188
|
+
},
|
|
189
|
+
subject: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
required: true,
|
|
192
|
+
description: 'Email subject line (may use Liquid).',
|
|
193
|
+
},
|
|
194
|
+
layout_path: {
|
|
195
|
+
type: 'string',
|
|
196
|
+
description: 'Layout partial to wrap the email body.',
|
|
197
|
+
},
|
|
198
|
+
delay: {
|
|
199
|
+
type: 'integer',
|
|
200
|
+
description: 'Seconds to delay delivery after being triggered.',
|
|
201
|
+
},
|
|
202
|
+
enabled: {
|
|
203
|
+
type: 'boolean',
|
|
204
|
+
description: 'When false, this email is never sent. Defaults to true.',
|
|
205
|
+
},
|
|
206
|
+
trigger_condition: {
|
|
207
|
+
type: ['boolean', 'string'],
|
|
208
|
+
description:
|
|
209
|
+
'Liquid expression or boolean; email is only sent when this evaluates to true.',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
allowAdditionalFields: true,
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
// ── ApiCall ──────────────────────────────────────────────────────────────────
|
|
216
|
+
[PlatformOSFileType.ApiCall]: {
|
|
217
|
+
name: 'ApiCall',
|
|
218
|
+
fields: {
|
|
219
|
+
to: {
|
|
220
|
+
type: 'string',
|
|
221
|
+
required: true,
|
|
222
|
+
description: 'Target URL for the HTTP request (may use Liquid).',
|
|
223
|
+
},
|
|
224
|
+
request_type: {
|
|
225
|
+
type: 'string',
|
|
226
|
+
required: true,
|
|
227
|
+
description: 'HTTP method: GET, POST, PUT, PATCH, or DELETE.',
|
|
228
|
+
},
|
|
229
|
+
request_headers: {
|
|
230
|
+
type: 'string',
|
|
231
|
+
description: 'Liquid template rendering a JSON object of request headers.',
|
|
232
|
+
},
|
|
233
|
+
headers: {
|
|
234
|
+
type: 'string',
|
|
235
|
+
description: 'Alias for request_headers.',
|
|
236
|
+
deprecated: true,
|
|
237
|
+
deprecatedMessage: 'Use `request_headers` instead of `headers`.',
|
|
238
|
+
},
|
|
239
|
+
callback: {
|
|
240
|
+
type: 'string',
|
|
241
|
+
description: 'Liquid template executed after the HTTP response is received.',
|
|
242
|
+
},
|
|
243
|
+
delay: {
|
|
244
|
+
type: 'integer',
|
|
245
|
+
description: 'Seconds to delay the request after being triggered.',
|
|
246
|
+
},
|
|
247
|
+
enabled: {
|
|
248
|
+
type: 'boolean',
|
|
249
|
+
description: 'When false, this API call is never executed. Defaults to true.',
|
|
250
|
+
},
|
|
251
|
+
trigger_condition: {
|
|
252
|
+
type: ['boolean', 'string'],
|
|
253
|
+
description: 'Liquid expression or boolean; call is only made when this evaluates to true.',
|
|
254
|
+
},
|
|
255
|
+
format: {
|
|
256
|
+
type: 'string',
|
|
257
|
+
description: 'Request body encoding format (http, json, …).',
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
allowAdditionalFields: true,
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
// ── Sms ──────────────────────────────────────────────────────────────────────
|
|
264
|
+
[PlatformOSFileType.Sms]: {
|
|
265
|
+
name: 'SMS',
|
|
266
|
+
fields: {
|
|
267
|
+
to: {
|
|
268
|
+
type: 'string',
|
|
269
|
+
required: true,
|
|
270
|
+
description: 'Recipient phone number in E.164 format (may use Liquid).',
|
|
271
|
+
},
|
|
272
|
+
delay: {
|
|
273
|
+
type: 'integer',
|
|
274
|
+
description: 'Seconds to delay sending after being triggered.',
|
|
275
|
+
},
|
|
276
|
+
enabled: {
|
|
277
|
+
type: 'boolean',
|
|
278
|
+
description: 'When false, this SMS is never sent. Defaults to true.',
|
|
279
|
+
},
|
|
280
|
+
trigger_condition: {
|
|
281
|
+
type: ['boolean', 'string'],
|
|
282
|
+
description: 'Liquid expression or boolean; SMS is only sent when this evaluates to true.',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
allowAdditionalFields: true,
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
// ── Migration ────────────────────────────────────────────────────────────────
|
|
289
|
+
[PlatformOSFileType.Migration]: {
|
|
290
|
+
name: 'Migration',
|
|
291
|
+
fields: {},
|
|
292
|
+
allowAdditionalFields: true,
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
// ── FormConfiguration ────────────────────────────────────────────────────────
|
|
296
|
+
[PlatformOSFileType.FormConfiguration]: {
|
|
297
|
+
name: 'FormConfiguration',
|
|
298
|
+
fields: {
|
|
299
|
+
name: {
|
|
300
|
+
type: 'string',
|
|
301
|
+
required: true,
|
|
302
|
+
description: 'Unique identifier for this form, used in include_form / function calls.',
|
|
303
|
+
},
|
|
304
|
+
resource: {
|
|
305
|
+
type: ['string', 'object'],
|
|
306
|
+
description: 'Model or resource type this form operates on.',
|
|
307
|
+
},
|
|
308
|
+
resource_owner: {
|
|
309
|
+
type: 'string',
|
|
310
|
+
description: 'Who owns the resource being created/updated.',
|
|
311
|
+
},
|
|
312
|
+
fields: {
|
|
313
|
+
type: 'object',
|
|
314
|
+
description: 'Field definitions — what data this form accepts and validates.',
|
|
315
|
+
},
|
|
316
|
+
redirect_to: {
|
|
317
|
+
type: 'string',
|
|
318
|
+
description: 'URL to redirect to after a successful form submission.',
|
|
319
|
+
},
|
|
320
|
+
flash_notice: {
|
|
321
|
+
type: 'string',
|
|
322
|
+
description: 'Flash notice message shown after a successful submission.',
|
|
323
|
+
},
|
|
324
|
+
flash_alert: {
|
|
325
|
+
type: 'string',
|
|
326
|
+
description: 'Flash alert message shown after a failed submission.',
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
allowAdditionalFields: true,
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// ─── Lookup helper ────────────────────────────────────────────────────────────
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Returns the frontmatter schema for a given file type, or undefined if no
|
|
337
|
+
* schema is defined for that type (e.g. GraphQL, YAML, Asset types).
|
|
338
|
+
*/
|
|
339
|
+
export function getFrontmatterSchema(
|
|
340
|
+
fileType: PlatformOSFileType | undefined,
|
|
341
|
+
): FrontmatterSchema | undefined {
|
|
342
|
+
if (fileType === undefined) return undefined;
|
|
343
|
+
return FRONTMATTER_SCHEMAS[fileType];
|
|
344
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -56,6 +56,8 @@ export {
|
|
|
56
56
|
isApiCall,
|
|
57
57
|
isAuthorization,
|
|
58
58
|
isEmail,
|
|
59
|
+
isFormConfiguration,
|
|
60
|
+
isKnownGraphQLFile,
|
|
59
61
|
isKnownLiquidFile,
|
|
60
62
|
isLayout,
|
|
61
63
|
isMigration,
|
|
@@ -64,6 +66,7 @@ export {
|
|
|
64
66
|
isSms,
|
|
65
67
|
PlatformOSFileType,
|
|
66
68
|
} from '@platformos/platformos-common';
|
|
69
|
+
export * from './frontmatter';
|
|
67
70
|
export * from './json';
|
|
68
71
|
export * from './JSONValidator';
|
|
69
72
|
export * as path from './path';
|
|
@@ -129,6 +129,8 @@ export function findTypeMismatchParams(
|
|
|
129
129
|
}
|
|
130
130
|
} else if (arg.value.type === NodeTypes.VariableLookup) {
|
|
131
131
|
continue;
|
|
132
|
+
} else if (arg.value.type === NodeTypes.NamedArgument) {
|
|
133
|
+
continue;
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
const liquidDocParamDef = liquidDocParameters.get(arg.name);
|
|
@@ -159,6 +161,7 @@ export function reportTypeMismatches(
|
|
|
159
161
|
for (const arg of typeMismatchArgs) {
|
|
160
162
|
const paramDef = liquidDocParameters.get(arg.name);
|
|
161
163
|
if (!paramDef || !paramDef.type) continue;
|
|
164
|
+
if (arg.value.type === NodeTypes.NamedArgument) continue;
|
|
162
165
|
|
|
163
166
|
const expectedType = paramDef.type.toLowerCase();
|
|
164
167
|
const actualType = inferArgumentType(arg.value);
|