@platformos/platformos-check-common 0.0.8 → 0.0.9
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/README.md +4 -4
- package/dist/checks/graphql-variables/index.js +4 -0
- package/dist/checks/graphql-variables/index.js.map +1 -1
- package/dist/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.js +1 -1
- package/dist/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.js.map +1 -1
- package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.d.ts +19 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.js +79 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.js.map +1 -0
- package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.d.ts +3 -0
- package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.js +32 -0
- package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.js.map +1 -0
- package/dist/checks/liquid-html-syntax-error/index.js +21 -3
- package/dist/checks/liquid-html-syntax-error/index.js.map +1 -1
- package/dist/checks/matching-translations/index.js +103 -68
- package/dist/checks/matching-translations/index.js.map +1 -1
- package/dist/checks/undefined-object/index.js +6 -1
- package/dist/checks/undefined-object/index.js.map +1 -1
- package/dist/context-utils.d.ts +16 -0
- package/dist/context-utils.js +30 -1
- package/dist/context-utils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/liquid-doc/arguments.js +8 -1
- package/dist/liquid-doc/arguments.js.map +1 -1
- package/dist/liquid-doc/utils.d.ts +2 -2
- package/dist/liquid-doc/utils.js +10 -0
- package/dist/liquid-doc/utils.js.map +1 -1
- package/dist/path.d.ts +1 -1
- package/dist/path.js +12 -1
- package/dist/path.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/checks/duplicate-render-partial-arguments/index.spec.ts +12 -12
- package/src/checks/graphql-variables/index.spec.ts +95 -0
- package/src/checks/graphql-variables/index.ts +4 -0
- package/src/checks/img-width-and-height/index.ts +1 -1
- package/src/checks/invalid-hash-assign-target/index.spec.ts +26 -26
- package/src/checks/json-syntax-error/index.ts +1 -1
- package/src/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.ts +2 -2
- package/src/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.spec.ts +259 -0
- package/src/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.ts +89 -0
- package/src/checks/liquid-html-syntax-error/checks/UnknownTag.spec.ts +293 -0
- package/src/checks/liquid-html-syntax-error/checks/UnknownTag.ts +43 -0
- package/src/checks/liquid-html-syntax-error/index.ts +24 -3
- package/src/checks/matching-translations/index.spec.ts +114 -24
- package/src/checks/matching-translations/index.ts +102 -81
- package/src/checks/metadata-params/index.ts +1 -1
- package/src/checks/missing-partial/index.ts +6 -6
- package/src/checks/undefined-object/index.spec.ts +29 -2
- package/src/checks/undefined-object/index.ts +7 -1
- package/src/checks/unused-assign/index.ts +1 -1
- package/src/checks/valid-json/index.ts +1 -1
- package/src/checks/valid-render-partial-argument-types/index.spec.ts +13 -13
- package/src/context-utils.ts +42 -1
- package/src/disabled-checks/index.spec.ts +26 -61
- package/src/disabled-checks/index.ts +2 -4
- package/src/disabled-checks/test-checks.ts +4 -4
- package/src/ignore.spec.ts +4 -4
- package/src/index.ts +18 -0
- package/src/liquid-doc/arguments.ts +9 -3
- package/src/liquid-doc/liquidDoc.spec.ts +1 -1
- package/src/liquid-doc/utils.ts +13 -5
- package/src/path.ts +16 -1
- package/src/test/MockApp.ts +2 -2
- package/src/test/MockFileSystem.spec.ts +10 -11
- package/src/test/contain-offense.spec.ts +11 -3
- package/src/test/test-helper.ts +24 -28
- package/src/types.ts +8 -0
- package/src/visitor.spec.ts +2 -2
- package/src/types/schemas/index.ts +0 -3
- package/src/types/schemas/preset.ts +0 -52
- package/src/types/schemas/setting.ts +0 -320
- package/src/types/schemas/template.ts +0 -34
package/src/test/MockApp.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @example
|
|
3
3
|
* {
|
|
4
|
-
* '
|
|
4
|
+
* 'app/views/layouts/layout.liquid': `
|
|
5
5
|
* <html>
|
|
6
6
|
* {{ content_for_page }}
|
|
7
7
|
* </html>
|
|
8
8
|
* `,
|
|
9
|
-
* '
|
|
9
|
+
* 'app/views/partials/snip.liquid': `
|
|
10
10
|
* <b>'hello world'</b>
|
|
11
11
|
* `,
|
|
12
12
|
* }
|
|
@@ -7,20 +7,21 @@ describe('MockFileSystem', () => {
|
|
|
7
7
|
|
|
8
8
|
beforeEach(() => {
|
|
9
9
|
fs = new MockFileSystem({
|
|
10
|
-
'layout
|
|
11
|
-
'
|
|
10
|
+
'app/views/layouts/layout.liquid': 'layout.liquid content',
|
|
11
|
+
'app/views/layouts/password.liquid': 'password.liquid content',
|
|
12
12
|
'app/views/partials/product-card.liquid': 'product-card.liquid content',
|
|
13
13
|
'app/views/partials/product-variant.liquid': 'product-variant.liquid content',
|
|
14
|
-
'sections/section.liquid': 'section.liquid content',
|
|
15
14
|
'assets/js/foo.js': 'foo.js content',
|
|
16
15
|
'assets/js/bar.js': 'bar.js content',
|
|
17
|
-
'assets/
|
|
16
|
+
'assets/app.js': 'app.js content',
|
|
18
17
|
});
|
|
19
18
|
});
|
|
20
19
|
|
|
21
20
|
describe('readFile', () => {
|
|
22
21
|
it('returns the content of existing files', async () => {
|
|
23
|
-
expect(await fs.readFile('file:/layout
|
|
22
|
+
expect(await fs.readFile('file:/app/views/layouts/layout.liquid')).toBe(
|
|
23
|
+
'layout.liquid content',
|
|
24
|
+
);
|
|
24
25
|
expect(await fs.readFile('file:/assets/js/foo.js')).toBe('foo.js content');
|
|
25
26
|
});
|
|
26
27
|
|
|
@@ -31,10 +32,10 @@ describe('MockFileSystem', () => {
|
|
|
31
32
|
|
|
32
33
|
describe('readDirectory', () => {
|
|
33
34
|
it('returns the list of files in a leaf', async () => {
|
|
34
|
-
const result = await fs.readDirectory('file:/
|
|
35
|
+
const result = await fs.readDirectory('file:/app/views/layouts');
|
|
35
36
|
expect(result).to.eql([
|
|
36
|
-
['file:/layout
|
|
37
|
-
['file:/
|
|
37
|
+
['file:/app/views/layouts/layout.liquid', FileType.File],
|
|
38
|
+
['file:/app/views/layouts/password.liquid', FileType.File],
|
|
38
39
|
]);
|
|
39
40
|
});
|
|
40
41
|
|
|
@@ -42,16 +43,14 @@ describe('MockFileSystem', () => {
|
|
|
42
43
|
const result = await fs.readDirectory('file:/assets');
|
|
43
44
|
expect(result).to.eql([
|
|
44
45
|
['file:/assets/js', FileType.Directory],
|
|
45
|
-
['file:/assets/
|
|
46
|
+
['file:/assets/app.js', FileType.File],
|
|
46
47
|
]);
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
it('returns the list of files and directories at the root', async () => {
|
|
50
51
|
const result = await fs.readDirectory('file:/');
|
|
51
52
|
expect(result).to.eql([
|
|
52
|
-
['file:/layout', FileType.Directory],
|
|
53
53
|
['file:/app', FileType.Directory],
|
|
54
|
-
['file:/sections', FileType.Directory],
|
|
55
54
|
['file:/assets', FileType.Directory],
|
|
56
55
|
]);
|
|
57
56
|
});
|
|
@@ -7,7 +7,10 @@ const rootUri = 'file:///';
|
|
|
7
7
|
describe('Module: containOffense', () => {
|
|
8
8
|
const offenses: Offense[] = [
|
|
9
9
|
buildOffense(`The translation for 'hello.world' is missing`, 'locales/en.json'),
|
|
10
|
-
buildOffense(
|
|
10
|
+
buildOffense(
|
|
11
|
+
`'app/views/partials/missing.liquid' does not exist`,
|
|
12
|
+
'app/views/layouts/layout.liquid',
|
|
13
|
+
),
|
|
11
14
|
];
|
|
12
15
|
|
|
13
16
|
describe('with string assertions', () => {
|
|
@@ -29,12 +32,17 @@ describe('Module: containOffense', () => {
|
|
|
29
32
|
|
|
30
33
|
it(`should not contain the Offense when their messages match but absolute paths don't match`, () => {
|
|
31
34
|
expect(offenses).to.not.containOffense(
|
|
32
|
-
buildOffense(
|
|
35
|
+
buildOffense(
|
|
36
|
+
`The translation for 'hello.world' is missing`,
|
|
37
|
+
'app/views/layouts/password.liquid',
|
|
38
|
+
),
|
|
33
39
|
);
|
|
34
40
|
});
|
|
35
41
|
|
|
36
42
|
it(`should not contain the Offense when their absolute paths match but messages don't match`, () => {
|
|
37
|
-
expect(offenses).to.not.containOffense(
|
|
43
|
+
expect(offenses).to.not.containOffense(
|
|
44
|
+
buildOffense('!!!', 'app/views/layouts/layout.liquid'),
|
|
45
|
+
);
|
|
38
46
|
});
|
|
39
47
|
|
|
40
48
|
it(`should not contain the Offense when their absolute paths and messages don't match`, () => {
|
package/src/test/test-helper.ts
CHANGED
|
@@ -29,19 +29,19 @@ export { JSONCorrector, StringCorrector };
|
|
|
29
29
|
|
|
30
30
|
const rootUri = path.normalize('file:/');
|
|
31
31
|
|
|
32
|
-
export function getApp(
|
|
33
|
-
return Object.entries(
|
|
32
|
+
export function getApp(appDesc: MockApp): App {
|
|
33
|
+
return Object.entries(appDesc)
|
|
34
34
|
.map(([relativePath, source]) => toSourceCode(toUri(relativePath), source))
|
|
35
35
|
.filter((x): x is LiquidSourceCode | JSONSourceCode | YAMLSourceCode => x !== undefined);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export async function check(
|
|
39
|
-
|
|
39
|
+
appDesc: MockApp,
|
|
40
40
|
checks: CheckDefinition[] = recommended,
|
|
41
41
|
mockDependencies: Partial<Dependencies> = {},
|
|
42
42
|
checkSettings: ChecksSettings = {},
|
|
43
43
|
): Promise<Offense[]> {
|
|
44
|
-
const
|
|
44
|
+
const app = getApp(appDesc);
|
|
45
45
|
const config: Config = {
|
|
46
46
|
settings: { ...checkSettings },
|
|
47
47
|
checks,
|
|
@@ -52,9 +52,9 @@ export async function check(
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
const defaultMockDependencies: Dependencies = {
|
|
55
|
-
fs: new MockFileSystem({ '.platformos-check.yml': '', ...
|
|
55
|
+
fs: new MockFileSystem({ '.platformos-check.yml': '', ...appDesc }),
|
|
56
56
|
async getDocDefinition(relativePath) {
|
|
57
|
-
const file =
|
|
57
|
+
const file = app.find((file) => file.uri.endsWith(relativePath));
|
|
58
58
|
if (!file || !isLiquidHtmlNode(file.ast)) {
|
|
59
59
|
return undefined;
|
|
60
60
|
}
|
|
@@ -122,7 +122,7 @@ export async function check(
|
|
|
122
122
|
},
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
return coreCheck(
|
|
125
|
+
return coreCheck(app, config, { ...defaultMockDependencies, ...mockDependencies });
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export async function runLiquidCheck(
|
|
@@ -130,10 +130,10 @@ export async function runLiquidCheck(
|
|
|
130
130
|
sourceCode: string,
|
|
131
131
|
fileName: string = 'file.liquid',
|
|
132
132
|
mockDependencies: Partial<Dependencies> = {},
|
|
133
|
-
|
|
133
|
+
existingAppFiles?: MockApp,
|
|
134
134
|
): Promise<Offense[]> {
|
|
135
135
|
const offenses = await check(
|
|
136
|
-
{ ...
|
|
136
|
+
{ ...existingAppFiles, [fileName]: sourceCode },
|
|
137
137
|
[checkDef],
|
|
138
138
|
mockDependencies,
|
|
139
139
|
);
|
|
@@ -160,40 +160,37 @@ export async function runYAMLCheck(
|
|
|
160
160
|
return offenses.filter((offense) => offense.uri === path.join(rootUri, fileName));
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export async function autofix(
|
|
164
|
-
const
|
|
165
|
-
const fixed = { ...
|
|
163
|
+
export async function autofix(appDesc: MockApp, offenses: Offense[]) {
|
|
164
|
+
const app = getApp(appDesc);
|
|
165
|
+
const fixed = { ...appDesc };
|
|
166
166
|
|
|
167
167
|
const stringApplicator: FixApplicator = async (sourceCode, fixes) => {
|
|
168
168
|
fixed[asRelative(sourceCode.uri)] = applyFixToString(sourceCode.source, fixes);
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
await coreAutofix(
|
|
171
|
+
await coreAutofix(app, offenses, stringApplicator);
|
|
172
172
|
|
|
173
173
|
return fixed;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
export function applyFix(
|
|
177
|
-
themeDescOrSource: MockApp | string,
|
|
178
|
-
offense: Offense,
|
|
179
|
-
): string | undefined {
|
|
176
|
+
export function applyFix(appDescOrSource: MockApp | string, offense: Offense): string | undefined {
|
|
180
177
|
const source =
|
|
181
|
-
typeof
|
|
182
|
-
?
|
|
183
|
-
:
|
|
178
|
+
typeof appDescOrSource === 'string'
|
|
179
|
+
? appDescOrSource
|
|
180
|
+
: appDescOrSource[asRelative(offense.uri)];
|
|
184
181
|
const corrector = createCorrector(offense.type, source);
|
|
185
182
|
offense.fix?.(corrector as any);
|
|
186
183
|
return applyFixToString(source, corrector.fix);
|
|
187
184
|
}
|
|
188
185
|
|
|
189
186
|
export function applySuggestions(
|
|
190
|
-
|
|
187
|
+
appDescOrSource: MockApp | string,
|
|
191
188
|
offense: Offense,
|
|
192
189
|
): undefined | string[] {
|
|
193
190
|
const source =
|
|
194
|
-
typeof
|
|
195
|
-
?
|
|
196
|
-
:
|
|
191
|
+
typeof appDescOrSource === 'string'
|
|
192
|
+
? appDescOrSource
|
|
193
|
+
: appDescOrSource[asRelative(offense.uri)];
|
|
197
194
|
return offense.suggest?.map((suggestion) => {
|
|
198
195
|
const corrector = createCorrector(offense.type, source);
|
|
199
196
|
suggestion.fix(corrector as any);
|
|
@@ -201,12 +198,11 @@ export function applySuggestions(
|
|
|
201
198
|
});
|
|
202
199
|
}
|
|
203
200
|
|
|
204
|
-
export function highlightedOffenses(
|
|
205
|
-
const
|
|
206
|
-
typeof themeOrSource === 'string' ? { 'file.liquid': themeOrSource } : themeOrSource;
|
|
201
|
+
export function highlightedOffenses(appOrSource: MockApp | string, offenses: Offense[]) {
|
|
202
|
+
const app = typeof appOrSource === 'string' ? { 'file.liquid': appOrSource } : appOrSource;
|
|
207
203
|
return offenses.map((offense) => {
|
|
208
204
|
const relativePath = path.relative(offense.uri, rootUri);
|
|
209
|
-
const source =
|
|
205
|
+
const source = app[relativePath];
|
|
210
206
|
const {
|
|
211
207
|
start: { index: startIndex },
|
|
212
208
|
end: { index: endIndex },
|
package/src/types.ts
CHANGED
|
@@ -369,6 +369,14 @@ export interface AugmentedDependencies extends Dependencies {
|
|
|
369
369
|
fileSize: (uri: UriString) => Promise<number>;
|
|
370
370
|
getDefaultLocale: () => Promise<string>;
|
|
371
371
|
getDefaultTranslations(): Promise<Translations>;
|
|
372
|
+
/**
|
|
373
|
+
* Aggregates ALL translation files for `locale` within the given translations
|
|
374
|
+
* base directory (e.g. `file:///app/translations` or
|
|
375
|
+
* `file:///modules/common-styling/public/translations`).
|
|
376
|
+
*
|
|
377
|
+
* Covers both `{base}/{locale}.yml` and `{base}/{locale}/*.yml`.
|
|
378
|
+
*/
|
|
379
|
+
getTranslationsForBase(translationBaseUri: string, locale: string): Promise<Translations>;
|
|
372
380
|
}
|
|
373
381
|
|
|
374
382
|
type StaticContextProperties<T extends SourceCodeType> = T extends SourceCodeType
|
package/src/visitor.spec.ts
CHANGED
|
@@ -14,12 +14,12 @@ describe('Module: visitor', () => {
|
|
|
14
14
|
|
|
15
15
|
if (
|
|
16
16
|
typeof node.markup === 'string' ||
|
|
17
|
-
node.markup.
|
|
17
|
+
node.markup.partial.type === LiquidHtmlNodeTypes.VariableLookup
|
|
18
18
|
) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
return node.markup.
|
|
22
|
+
return node.markup.partial.value;
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Setting } from './setting';
|
|
2
|
-
|
|
3
|
-
export declare namespace Preset {
|
|
4
|
-
// Preset definitions
|
|
5
|
-
export type Preset =
|
|
6
|
-
| {
|
|
7
|
-
name: string;
|
|
8
|
-
settings?: Setting.Values;
|
|
9
|
-
blocks?: PresetBlockHash;
|
|
10
|
-
block_order?: string[];
|
|
11
|
-
}
|
|
12
|
-
| {
|
|
13
|
-
name: string;
|
|
14
|
-
settings?: Setting.Values;
|
|
15
|
-
blocks?: PresetBlockForArray[];
|
|
16
|
-
}
|
|
17
|
-
| { name: string; settings?: Setting.Values };
|
|
18
|
-
|
|
19
|
-
// Reuse the block preset types from ThemeBlock namespace
|
|
20
|
-
export type PresetBlockBase = {
|
|
21
|
-
type: string;
|
|
22
|
-
settings?: Setting.Values;
|
|
23
|
-
static?: boolean;
|
|
24
|
-
blocks?: PresetBlockHash | PresetBlockForArray[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type PresetBlockForHash = PresetBlockBase & {
|
|
28
|
-
block_order?: string[];
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type PresetBlockForArray = PresetBlockBase & {
|
|
32
|
-
id?: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// Hash format for blocks
|
|
36
|
-
export type PresetBlockHash = {
|
|
37
|
-
[id: string]: PresetBlockForHash;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/** Base type for presets */
|
|
41
|
-
export type BlockPresetBase = {
|
|
42
|
-
/** Refers to a block type. blocks/{type}.liquid */
|
|
43
|
-
type: string;
|
|
44
|
-
settings?: Setting.Values;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// prettier-ignore
|
|
48
|
-
export type Block = (
|
|
49
|
-
| PresetBlockForHash
|
|
50
|
-
| PresetBlockForArray
|
|
51
|
-
);
|
|
52
|
-
}
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
export declare namespace Setting {
|
|
2
|
-
/** Setting values are */
|
|
3
|
-
export type Values = Record<string, string | number | boolean | string[]>;
|
|
4
|
-
|
|
5
|
-
/** Union type of all setting types */
|
|
6
|
-
export type Any = InputSetting | SideBarSetting;
|
|
7
|
-
|
|
8
|
-
/** Settings used for display */
|
|
9
|
-
export type SideBarSetting = Header | Paragraph;
|
|
10
|
-
|
|
11
|
-
/** Settings with data */
|
|
12
|
-
export type InputSetting =
|
|
13
|
-
| Article
|
|
14
|
-
| Blog
|
|
15
|
-
| Collection
|
|
16
|
-
| Page
|
|
17
|
-
| Product
|
|
18
|
-
| CollectionList
|
|
19
|
-
| ProductList
|
|
20
|
-
| MetaobjectList
|
|
21
|
-
| Text
|
|
22
|
-
| Textarea
|
|
23
|
-
| Richtext
|
|
24
|
-
| InlineRichtext
|
|
25
|
-
| Html
|
|
26
|
-
| Url
|
|
27
|
-
| TextAlignment
|
|
28
|
-
| Number
|
|
29
|
-
| Range
|
|
30
|
-
| Checkbox
|
|
31
|
-
| Radio
|
|
32
|
-
| Select
|
|
33
|
-
| Color
|
|
34
|
-
| ColorBackground
|
|
35
|
-
| ColorScheme
|
|
36
|
-
| ColorSchemeGroup
|
|
37
|
-
| ImagePicker
|
|
38
|
-
| Video
|
|
39
|
-
| VideoUrl
|
|
40
|
-
| FontPicker
|
|
41
|
-
| LinkList
|
|
42
|
-
| Liquid
|
|
43
|
-
| Metaobject
|
|
44
|
-
| StyleLayoutPanel
|
|
45
|
-
| StyleSizePanel
|
|
46
|
-
| StyleSpacingPanel;
|
|
47
|
-
|
|
48
|
-
export enum Type {
|
|
49
|
-
// Resource Settings
|
|
50
|
-
Article = 'article',
|
|
51
|
-
Blog = 'blog',
|
|
52
|
-
Collection = 'collection',
|
|
53
|
-
Page = 'page',
|
|
54
|
-
Product = 'product',
|
|
55
|
-
|
|
56
|
-
// Resource List Settings
|
|
57
|
-
CollectionList = 'collection_list',
|
|
58
|
-
ProductList = 'product_list',
|
|
59
|
-
MetaobjectList = 'metaobject_list',
|
|
60
|
-
|
|
61
|
-
// Text Settings
|
|
62
|
-
Text = 'text',
|
|
63
|
-
Textarea = 'textarea',
|
|
64
|
-
Richtext = 'richtext',
|
|
65
|
-
InlineRichtext = 'inline_richtext',
|
|
66
|
-
Html = 'html',
|
|
67
|
-
Url = 'url',
|
|
68
|
-
TextAlignment = 'text_alignment',
|
|
69
|
-
|
|
70
|
-
// Number Settings
|
|
71
|
-
Number = 'number',
|
|
72
|
-
Range = 'range',
|
|
73
|
-
|
|
74
|
-
// Choice Settings
|
|
75
|
-
Checkbox = 'checkbox',
|
|
76
|
-
Radio = 'radio',
|
|
77
|
-
Select = 'select',
|
|
78
|
-
|
|
79
|
-
// Color Settings
|
|
80
|
-
Color = 'color',
|
|
81
|
-
ColorBackground = 'color_background',
|
|
82
|
-
ColorScheme = 'color_scheme',
|
|
83
|
-
ColorSchemeGroup = 'color_scheme_group',
|
|
84
|
-
|
|
85
|
-
// Media Settings
|
|
86
|
-
ImagePicker = 'image_picker',
|
|
87
|
-
Video = 'video',
|
|
88
|
-
VideoUrl = 'video_url',
|
|
89
|
-
|
|
90
|
-
// Special Settings
|
|
91
|
-
FontPicker = 'font_picker',
|
|
92
|
-
LinkList = 'link_list',
|
|
93
|
-
Liquid = 'liquid',
|
|
94
|
-
Metaobject = 'metaobject',
|
|
95
|
-
|
|
96
|
-
// Style Panel Settings
|
|
97
|
-
StyleLayoutPanel = 'style.layout_panel',
|
|
98
|
-
StyleSizePanel = 'style.size_panel',
|
|
99
|
-
StyleSpacingPanel = 'style.spacing_panel',
|
|
100
|
-
|
|
101
|
-
// Sidebar Settings
|
|
102
|
-
Header = 'header',
|
|
103
|
-
Paragraph = 'paragraph',
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Base Setting Interface
|
|
107
|
-
export interface Base<T extends Type> {
|
|
108
|
-
type: T;
|
|
109
|
-
id: string;
|
|
110
|
-
label?: string;
|
|
111
|
-
info?: string;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Sidebar Settings
|
|
115
|
-
export interface Header extends Base<Type.Header> {
|
|
116
|
-
content: string;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export interface Paragraph extends Base<Type.Paragraph> {
|
|
120
|
-
content: string;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Resource Settings
|
|
124
|
-
export interface Resource<T extends Type> extends Base<T> {
|
|
125
|
-
default?: string;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface Article extends Resource<Type.Article> {}
|
|
129
|
-
export interface Blog extends Resource<Type.Blog> {}
|
|
130
|
-
export interface Collection extends Resource<Type.Collection> {}
|
|
131
|
-
export interface Page extends Resource<Type.Page> {}
|
|
132
|
-
export interface Product extends Resource<Type.Product> {}
|
|
133
|
-
|
|
134
|
-
// Resource List Settings
|
|
135
|
-
export interface ResourceList<T extends Type> extends Base<T> {
|
|
136
|
-
limit?: number;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface CollectionList extends ResourceList<Type.CollectionList> {}
|
|
140
|
-
export interface ProductList extends ResourceList<Type.ProductList> {}
|
|
141
|
-
export interface MetaobjectList extends ResourceList<Type.MetaobjectList> {
|
|
142
|
-
metaobject_type: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Text Settings
|
|
146
|
-
export interface TextBase<T extends Type> extends Base<T> {
|
|
147
|
-
default?: string;
|
|
148
|
-
placeholder?: string;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface Text extends TextBase<Type.Text> {}
|
|
152
|
-
export interface Textarea extends TextBase<Type.Textarea> {}
|
|
153
|
-
export interface Richtext extends TextBase<Type.Richtext> {}
|
|
154
|
-
export interface InlineRichtext extends TextBase<Type.InlineRichtext> {}
|
|
155
|
-
export interface Html extends TextBase<Type.Html> {}
|
|
156
|
-
export interface Url extends TextBase<Type.Url> {}
|
|
157
|
-
|
|
158
|
-
export interface TextAlignment extends Base<Type.TextAlignment> {
|
|
159
|
-
default?: 'left' | 'center' | 'right' | 'justify';
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Number Settings
|
|
163
|
-
export interface NumberBase<T extends Type> extends Base<T> {
|
|
164
|
-
default?: number;
|
|
165
|
-
min?: number;
|
|
166
|
-
max?: number;
|
|
167
|
-
step?: number;
|
|
168
|
-
unit?: string;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export interface Number extends NumberBase<Type.Number> {}
|
|
172
|
-
export interface Range extends NumberBase<Type.Range> {}
|
|
173
|
-
|
|
174
|
-
// Choice Settings
|
|
175
|
-
export interface Checkbox extends Base<Type.Checkbox> {
|
|
176
|
-
default?: boolean;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface ChoiceOption {
|
|
180
|
-
value: string;
|
|
181
|
-
label: string;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export interface ChoiceBase<T extends Type> extends Base<T> {
|
|
185
|
-
options: ChoiceOption[];
|
|
186
|
-
default?: string;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export interface Radio extends ChoiceBase<Type.Radio> {}
|
|
190
|
-
export interface Select extends ChoiceBase<Type.Select> {}
|
|
191
|
-
|
|
192
|
-
// Color Settings
|
|
193
|
-
export interface ColorBase<T extends Type> extends Base<T> {
|
|
194
|
-
default?: string;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export interface Color extends ColorBase<Type.Color> {}
|
|
198
|
-
export interface ColorBackground extends ColorBase<Type.ColorBackground> {}
|
|
199
|
-
export interface ColorScheme extends Base<Type.ColorScheme> {
|
|
200
|
-
default?: string;
|
|
201
|
-
}
|
|
202
|
-
export interface ColorSchemeGroup extends Base<Type.ColorSchemeGroup> {}
|
|
203
|
-
|
|
204
|
-
// Media Settings
|
|
205
|
-
export interface ImagePicker extends Base<Type.ImagePicker> {
|
|
206
|
-
default?: string;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export interface Video extends Base<Type.Video> {
|
|
210
|
-
default?: string;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export interface VideoUrl extends Base<Type.VideoUrl> {
|
|
214
|
-
default?: string;
|
|
215
|
-
accept: Array<'youtube' | 'vimeo'>;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Special Settings
|
|
219
|
-
export interface FontPicker extends Base<Type.FontPicker> {
|
|
220
|
-
default?: string;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export interface LinkList extends Base<Type.LinkList> {
|
|
224
|
-
default?: string;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export interface Liquid extends Base<Type.Liquid> {
|
|
228
|
-
default?: string;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export interface Metaobject extends Base<Type.Metaobject> {
|
|
232
|
-
metaobject_type: string;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Style Panel Settings
|
|
236
|
-
export interface StyleLayoutPanel extends Base<Type.StyleLayoutPanel> {
|
|
237
|
-
default?: {
|
|
238
|
-
'flex-direction'?: 'row' | 'row-reverse' | 'column' | 'column-reverse';
|
|
239
|
-
'flex-wrap'?: 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
240
|
-
'justify-content'?:
|
|
241
|
-
| 'flex-start'
|
|
242
|
-
| 'flex-end'
|
|
243
|
-
| 'start'
|
|
244
|
-
| 'end'
|
|
245
|
-
| 'left'
|
|
246
|
-
| 'right'
|
|
247
|
-
| 'center'
|
|
248
|
-
| 'space-between'
|
|
249
|
-
| 'space-around'
|
|
250
|
-
| 'space-evenly';
|
|
251
|
-
'align-items'?:
|
|
252
|
-
| 'stretch'
|
|
253
|
-
| 'flex-start'
|
|
254
|
-
| 'start'
|
|
255
|
-
| 'self-start'
|
|
256
|
-
| 'flex-end'
|
|
257
|
-
| 'end'
|
|
258
|
-
| 'self-end'
|
|
259
|
-
| 'center'
|
|
260
|
-
| 'baseline';
|
|
261
|
-
'align-content'?:
|
|
262
|
-
| 'stretch'
|
|
263
|
-
| 'flex-start'
|
|
264
|
-
| 'start'
|
|
265
|
-
| 'flex-end'
|
|
266
|
-
| 'end'
|
|
267
|
-
| 'center'
|
|
268
|
-
| 'space-between'
|
|
269
|
-
| 'space-around'
|
|
270
|
-
| 'space-evenly';
|
|
271
|
-
gap?: string;
|
|
272
|
-
'row-gap'?: string;
|
|
273
|
-
'column-gap'?: string;
|
|
274
|
-
'@media (--mobile)'?: Partial<StyleLayoutPanel['default']>;
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export interface StyleSizePanel extends Base<Type.StyleSizePanel> {
|
|
279
|
-
default?: {
|
|
280
|
-
width?: string;
|
|
281
|
-
'min-width'?: string;
|
|
282
|
-
'max-width'?: string;
|
|
283
|
-
height?: string;
|
|
284
|
-
'min-height'?: string;
|
|
285
|
-
'max-height'?: string;
|
|
286
|
-
'flex-grow'?: string;
|
|
287
|
-
'flex-shrink'?: string;
|
|
288
|
-
'flex-basis'?: string;
|
|
289
|
-
'@media (--mobile)'?: Partial<StyleSizePanel['default']>;
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export interface StyleSpacingPanel extends Base<Type.StyleSpacingPanel> {
|
|
294
|
-
default?: {
|
|
295
|
-
padding?: string;
|
|
296
|
-
'padding-top'?: string;
|
|
297
|
-
'padding-right'?: string;
|
|
298
|
-
'padding-bottom'?: string;
|
|
299
|
-
'padding-left'?: string;
|
|
300
|
-
'padding-block'?: string;
|
|
301
|
-
'padding-block-start'?: string;
|
|
302
|
-
'padding-block-end'?: string;
|
|
303
|
-
'padding-inline'?: string;
|
|
304
|
-
'padding-inline-start'?: string;
|
|
305
|
-
'padding-inline-end'?: string;
|
|
306
|
-
margin?: string;
|
|
307
|
-
'margin-top'?: string;
|
|
308
|
-
'margin-right'?: string;
|
|
309
|
-
'margin-bottom'?: string;
|
|
310
|
-
'margin-left'?: string;
|
|
311
|
-
'margin-block'?: string;
|
|
312
|
-
'margin-block-start'?: string;
|
|
313
|
-
'margin-block-end'?: string;
|
|
314
|
-
'margin-inline'?: string;
|
|
315
|
-
'margin-inline-start'?: string;
|
|
316
|
-
'margin-inline-end'?: string;
|
|
317
|
-
'@media (--mobile)'?: Partial<StyleSpacingPanel['default']>;
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Setting } from './setting';
|
|
2
|
-
|
|
3
|
-
export namespace Template {
|
|
4
|
-
export interface Template {
|
|
5
|
-
layout?: string | false;
|
|
6
|
-
wrapper?: string;
|
|
7
|
-
sections: Record<string, Template.Section>;
|
|
8
|
-
order: string[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface Section {
|
|
12
|
-
type: string;
|
|
13
|
-
settings?: Setting.Values;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
blocks?: Record<string, Template.Block>;
|
|
16
|
-
block_order?: string[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface Block {
|
|
20
|
-
type: string;
|
|
21
|
-
settings?: Setting.Values;
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
blocks?: Record<string, Template.Block>;
|
|
24
|
-
block_order?: string[];
|
|
25
|
-
static?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface SectionGroup {
|
|
29
|
-
type: string;
|
|
30
|
-
name: string;
|
|
31
|
-
sections: Record<string, Template.Section>;
|
|
32
|
-
order: string[];
|
|
33
|
-
}
|
|
34
|
-
}
|