@panneau/protocol 5.0.0-alpha.3 → 5.0.0-alpha.31
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/dist/addresses.d.ts +23 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +52 -0
- package/dist/addresses.js.map +1 -0
- package/dist/compound.d.ts +20 -0
- package/dist/compound.d.ts.map +1 -0
- package/dist/compound.js +27 -0
- package/dist/compound.js.map +1 -0
- package/dist/conditions.d.ts +1 -1
- package/dist/conformance/index.d.ts +6 -0
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +801 -11
- package/dist/conformance/index.js.map +1 -1
- package/dist/constants.d.ts +108 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +181 -3
- package/dist/constants.js.map +1 -1
- package/dist/context.d.ts +15 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +34 -0
- package/dist/context.js.map +1 -0
- package/dist/currencies.d.ts +22 -0
- package/dist/currencies.d.ts.map +1 -0
- package/dist/currencies.js +231 -0
- package/dist/currencies.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +19 -8
- package/dist/libraries.d.ts +33 -0
- package/dist/libraries.d.ts.map +1 -0
- package/dist/libraries.js +59 -0
- package/dist/libraries.js.map +1 -0
- package/dist/links.d.ts +38 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +65 -0
- package/dist/links.js.map +1 -0
- package/dist/lint.d.ts +4 -3
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +168 -7
- package/dist/lint.js.map +1 -1
- package/dist/mock/auth.d.ts +71 -0
- package/dist/mock/auth.d.ts.map +1 -0
- package/dist/mock/auth.js +346 -0
- package/dist/mock/auth.js.map +1 -0
- package/dist/mock/example.d.ts +3 -2
- package/dist/mock/example.d.ts.map +1 -1
- package/dist/mock/example.js +241 -144
- package/dist/mock/example.js.map +1 -1
- package/dist/mock/index.d.ts +79 -7
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +603 -38
- package/dist/mock/index.js.map +1 -1
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +392 -144
- package/dist/openapi.js.map +1 -1
- package/dist/problem.d.ts +1 -1
- package/dist/query.d.ts +18 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +34 -8
- package/dist/query.js.map +1 -1
- package/dist/resourceTypes.d.ts +39 -0
- package/dist/resourceTypes.d.ts.map +1 -0
- package/dist/resourceTypes.js +34 -0
- package/dist/resourceTypes.js.map +1 -0
- package/dist/rules.d.ts +18 -5
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +233 -15
- package/dist/rules.js.map +1 -1
- package/dist/runtime/index.d.ts +20 -10
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +13 -3
- package/dist/schemas/action.d.ts +118 -10
- package/dist/schemas/action.d.ts.map +1 -1
- package/dist/schemas/action.js +20 -3
- package/dist/schemas/action.js.map +1 -1
- package/dist/schemas/api.d.ts +334 -42
- package/dist/schemas/api.d.ts.map +1 -1
- package/dist/schemas/api.js +194 -34
- package/dist/schemas/api.js.map +1 -1
- package/dist/schemas/boot.d.ts +25 -1
- package/dist/schemas/boot.d.ts.map +1 -1
- package/dist/schemas/boot.js +2 -1
- package/dist/schemas/boot.js.map +1 -1
- package/dist/schemas/common.d.ts +1 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/common.js +2 -1
- package/dist/schemas/common.js.map +1 -1
- package/dist/schemas/definition.d.ts +341 -28
- package/dist/schemas/definition.d.ts.map +1 -1
- package/dist/schemas/definition.js +65 -19
- package/dist/schemas/definition.js.map +1 -1
- package/dist/schemas/field.d.ts +357 -2
- package/dist/schemas/field.d.ts.map +1 -1
- package/dist/schemas/field.js +160 -20
- package/dist/schemas/field.js.map +1 -1
- package/dist/schemas/index.d.ts +1429 -80
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +60 -10
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/jsonRules.d.ts +83 -0
- package/dist/schemas/jsonRules.d.ts.map +1 -0
- package/dist/schemas/jsonRules.js +46 -0
- package/dist/schemas/jsonRules.js.map +1 -0
- package/dist/schemas/layout.d.ts +2 -1
- package/dist/schemas/layout.d.ts.map +1 -1
- package/dist/schemas/layout.js +2 -1
- package/dist/schemas/layout.js.map +1 -1
- package/dist/schemas/list.d.ts +23 -2
- package/dist/schemas/list.d.ts.map +1 -1
- package/dist/schemas/list.js +15 -6
- package/dist/schemas/list.js.map +1 -1
- package/dist/schemas/resource.d.ts +263 -17
- package/dist/schemas/resource.d.ts.map +1 -1
- package/dist/schemas/resource.js +19 -4
- package/dist/schemas/resource.js.map +1 -1
- package/dist/schemas/theme.d.ts +4 -0
- package/dist/schemas/theme.d.ts.map +1 -1
- package/dist/schemas/theme.js +1 -0
- package/dist/schemas/theme.js.map +1 -1
- package/dist/schemas/widget.d.ts +109 -0
- package/dist/schemas/widget.d.ts.map +1 -0
- package/dist/schemas/widget.js +74 -0
- package/dist/schemas/widget.js.map +1 -0
- package/dist/search.d.ts +51 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +53 -0
- package/dist/search.js.map +1 -0
- package/dist/themes.d.ts +1 -1
- package/dist/transforms.d.ts +17 -0
- package/dist/transforms.d.ts.map +1 -0
- package/dist/transforms.js +34 -0
- package/dist/transforms.js.map +1 -0
- package/dist/validate.d.ts +5 -3
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +36 -2
- package/dist/validate.js.map +1 -1
- package/dist/values.d.ts +5 -1
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +16 -2
- package/dist/values.js.map +1 -1
- package/dist/widgets.d.ts +42 -0
- package/dist/widgets.d.ts.map +1 -0
- package/dist/widgets.js +130 -0
- package/dist/widgets.js.map +1 -0
- package/package.json +6 -3
- package/schema/boot.schema.json +713 -20
- package/schema/definition.schema.json +710 -20
- package/schema/openapi.json +5656 -2229
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type AddressPart } from './constants.js';
|
|
2
|
+
import type { Field } from './schemas/field.js';
|
|
3
|
+
/** The countries whose postal codes the `postalCode` rule checks: Canada and the United States. */
|
|
4
|
+
export declare const POSTAL_CODE_COUNTRIES: readonly string[];
|
|
5
|
+
/**
|
|
6
|
+
* A postal code in the format of its country: `H2X 1Y4` for Canada (`h2x1y4`), `12345-6789` for
|
|
7
|
+
* the United States (`123456789`). Elsewhere, or when it doesn't read as one of its country, the
|
|
8
|
+
* code in capitals, its spaces collapsed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizePostalCode(code: string, country?: string | null): string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a postal code is one of its country, once normalized. Postal codes of countries whose
|
|
13
|
+
* format Panneau doesn't check (`POSTAL_CODE_COUNTRIES`), or without a country, pass.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isPostalCode(code: string, country?: string | null): boolean;
|
|
16
|
+
/** Whether a value is one of the parts of an address. */
|
|
17
|
+
export declare function isAddressPart(value: unknown): value is AddressPart;
|
|
18
|
+
/**
|
|
19
|
+
* The parts a filled address of a field must have: those of `settings.required`, or `street`,
|
|
20
|
+
* `city` and `country`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAddressRequiredParts(field: Pick<Field, 'settings'>): AddressPart[];
|
|
23
|
+
//# sourceMappingURL=addresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../src/addresses.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,WAAW,EAAkC,MAAM,aAAa,CAAC;AAC9F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAS7C,mGAAmG;AACnG,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAyB,CAAC;AAO7E;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAiBjF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAI3E;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,WAAW,EAAE,CAKrF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ADDRESS_PARTS, DEFAULT_ADDRESS_REQUIRED_PARTS } from "./constants.js";
|
|
2
|
+
//#region src/addresses.ts
|
|
3
|
+
/** The formats of normalized postal codes, for the countries whose postal codes are checked. */
|
|
4
|
+
var FORMATS = {
|
|
5
|
+
CA: /^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z] \d[ABCEGHJ-NPRSTV-Z]\d$/,
|
|
6
|
+
US: /^\d{5}(-\d{4})?$/
|
|
7
|
+
};
|
|
8
|
+
/** The countries whose postal codes the `postalCode` rule checks: Canada and the United States. */
|
|
9
|
+
var POSTAL_CODE_COUNTRIES = Object.keys(FORMATS);
|
|
10
|
+
/** Capitals, with the spaces trimmed and collapsed: the postal codes of other countries. */
|
|
11
|
+
function normalizeText(code) {
|
|
12
|
+
return code.trim().replace(/\s+/g, " ").toUpperCase();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A postal code in the format of its country: `H2X 1Y4` for Canada (`h2x1y4`), `12345-6789` for
|
|
16
|
+
* the United States (`123456789`). Elsewhere, or when it doesn't read as one of its country, the
|
|
17
|
+
* code in capitals, its spaces collapsed.
|
|
18
|
+
*/
|
|
19
|
+
function normalizePostalCode(code, country) {
|
|
20
|
+
const compact = code.replace(/[\s-]+/g, "").toUpperCase();
|
|
21
|
+
switch (country?.toUpperCase()) {
|
|
22
|
+
case "CA": return /^[A-Z]\d[A-Z]\d[A-Z]\d$/.test(compact) ? `${compact.slice(0, 3)} ${compact.slice(3)}` : normalizeText(code);
|
|
23
|
+
case "US":
|
|
24
|
+
if (/^\d{5}$/.test(compact)) return compact;
|
|
25
|
+
return /^\d{9}$/.test(compact) ? `${compact.slice(0, 5)}-${compact.slice(5)}` : normalizeText(code);
|
|
26
|
+
default: return normalizeText(code);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether a postal code is one of its country, once normalized. Postal codes of countries whose
|
|
31
|
+
* format Panneau doesn't check (`POSTAL_CODE_COUNTRIES`), or without a country, pass.
|
|
32
|
+
*/
|
|
33
|
+
function isPostalCode(code, country) {
|
|
34
|
+
const format = country !== void 0 && country !== null ? FORMATS[country.toUpperCase()] : void 0;
|
|
35
|
+
return format === void 0 || format.test(normalizePostalCode(code, country));
|
|
36
|
+
}
|
|
37
|
+
/** Whether a value is one of the parts of an address. */
|
|
38
|
+
function isAddressPart(value) {
|
|
39
|
+
return typeof value === "string" && ADDRESS_PARTS.includes(value);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The parts a filled address of a field must have: those of `settings.required`, or `street`,
|
|
43
|
+
* `city` and `country`.
|
|
44
|
+
*/
|
|
45
|
+
function getAddressRequiredParts(field) {
|
|
46
|
+
const setting = field.settings?.required;
|
|
47
|
+
return Array.isArray(setting) ? setting.filter(isAddressPart) : [...DEFAULT_ADDRESS_REQUIRED_PARTS];
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { POSTAL_CODE_COUNTRIES, getAddressRequiredParts, isAddressPart, isPostalCode, normalizePostalCode };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=addresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addresses.js","names":[],"sources":["../src/addresses.ts"],"sourcesContent":["// Addresses (decision 0054): their required parts, and postal codes by country, which clients and\n// backends normalize, and whose formats the `postalCode` rule checks. This module doesn't import\n// zod.\nimport { ADDRESS_PARTS, type AddressPart, DEFAULT_ADDRESS_REQUIRED_PARTS } from './constants';\nimport type { Field } from './schemas/field';\n\n/** The formats of normalized postal codes, for the countries whose postal codes are checked. */\nconst FORMATS: Readonly<Record<string, RegExp>> = {\n // Letters that Canada Post doesn't use (D, F, I, O, Q, U, and W or Z first) are refused\n CA: /^[ABCEGHJ-NPRSTVXY]\\d[ABCEGHJ-NPRSTV-Z] \\d[ABCEGHJ-NPRSTV-Z]\\d$/,\n US: /^\\d{5}(-\\d{4})?$/,\n};\n\n/** The countries whose postal codes the `postalCode` rule checks: Canada and the United States. */\nexport const POSTAL_CODE_COUNTRIES: readonly string[] = Object.keys(FORMATS);\n\n/** Capitals, with the spaces trimmed and collapsed: the postal codes of other countries. */\nfunction normalizeText(code: string): string {\n return code.trim().replace(/\\s+/g, ' ').toUpperCase();\n}\n\n/**\n * A postal code in the format of its country: `H2X 1Y4` for Canada (`h2x1y4`), `12345-6789` for\n * the United States (`123456789`). Elsewhere, or when it doesn't read as one of its country, the\n * code in capitals, its spaces collapsed.\n */\nexport function normalizePostalCode(code: string, country?: string | null): string {\n const compact = code.replace(/[\\s-]+/g, '').toUpperCase();\n switch (country?.toUpperCase()) {\n case 'CA':\n return /^[A-Z]\\d[A-Z]\\d[A-Z]\\d$/.test(compact)\n ? `${compact.slice(0, 3)} ${compact.slice(3)}`\n : normalizeText(code);\n case 'US':\n if (/^\\d{5}$/.test(compact)) {\n return compact;\n }\n return /^\\d{9}$/.test(compact)\n ? `${compact.slice(0, 5)}-${compact.slice(5)}`\n : normalizeText(code);\n default:\n return normalizeText(code);\n }\n}\n\n/**\n * Whether a postal code is one of its country, once normalized. Postal codes of countries whose\n * format Panneau doesn't check (`POSTAL_CODE_COUNTRIES`), or without a country, pass.\n */\nexport function isPostalCode(code: string, country?: string | null): boolean {\n const format =\n country !== undefined && country !== null ? FORMATS[country.toUpperCase()] : undefined;\n return format === undefined || format.test(normalizePostalCode(code, country));\n}\n\n/** Whether a value is one of the parts of an address. */\nexport function isAddressPart(value: unknown): value is AddressPart {\n return typeof value === 'string' && (ADDRESS_PARTS as readonly string[]).includes(value);\n}\n\n/**\n * The parts a filled address of a field must have: those of `settings.required`, or `street`,\n * `city` and `country`.\n */\nexport function getAddressRequiredParts(field: Pick<Field, 'settings'>): AddressPart[] {\n const setting = field.settings?.required;\n return Array.isArray(setting)\n ? setting.filter(isAddressPart)\n : [...DEFAULT_ADDRESS_REQUIRED_PARTS];\n}\n"],"mappings":";;;AAOA,IAAM,UAA4C;CAE9C,IAAI;CACJ,IAAI;AACR;;AAGA,IAAa,wBAA2C,OAAO,KAAK,OAAO;;AAG3E,SAAS,cAAc,MAAsB;CACzC,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAQ,GAAG,CAAC,CAAC,YAAY;AACxD;;;;;;AAOA,SAAgB,oBAAoB,MAAc,SAAiC;CAC/E,MAAM,UAAU,KAAK,QAAQ,WAAW,EAAE,CAAC,CAAC,YAAY;CACxD,QAAQ,SAAS,YAAY,GAA7B;EACI,KAAK,MACD,OAAO,0BAA0B,KAAK,OAAO,IACvC,GAAG,QAAQ,MAAM,GAAG,CAAC,EAAE,GAAG,QAAQ,MAAM,CAAC,MACzC,cAAc,IAAI;EAC5B,KAAK;GACD,IAAI,UAAU,KAAK,OAAO,GACtB,OAAO;GAEX,OAAO,UAAU,KAAK,OAAO,IACvB,GAAG,QAAQ,MAAM,GAAG,CAAC,EAAE,GAAG,QAAQ,MAAM,CAAC,MACzC,cAAc,IAAI;EAC5B,SACI,OAAO,cAAc,IAAI;CACjC;AACJ;;;;;AAMA,SAAgB,aAAa,MAAc,SAAkC;CACzE,MAAM,SACF,YAAY,KAAA,KAAa,YAAY,OAAO,QAAQ,QAAQ,YAAY,KAAK,KAAA;CACjF,OAAO,WAAW,KAAA,KAAa,OAAO,KAAK,oBAAoB,MAAM,OAAO,CAAC;AACjF;;AAGA,SAAgB,cAAc,OAAsC;CAChE,OAAO,OAAO,UAAU,YAAa,cAAoC,SAAS,KAAK;AAC3F;;;;;AAMA,SAAgB,wBAAwB,OAA+C;CACnF,MAAM,UAAU,MAAM,UAAU;CAChC,OAAO,MAAM,QAAQ,OAAO,IACtB,QAAQ,OAAO,aAAa,IAC5B,CAAC,GAAG,8BAA8B;AAC5C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Field } from './schemas/field.js';
|
|
2
|
+
/**
|
|
3
|
+
* The shape of a value made of nested fields: an object of its `fields` (`group`), or a list of
|
|
4
|
+
* them (`repeater`).
|
|
5
|
+
*/
|
|
6
|
+
export type NestedShape = 'group' | 'repeater';
|
|
7
|
+
/** Whether a field type is built in. */
|
|
8
|
+
export declare function isBuiltInFieldType(type: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a field is a compound field (decision 0065): a type that isn't built in, provided by a
|
|
11
|
+
* plugin, that carries its sub-fields in `fields`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isCompoundField(field: Pick<Field, 'type' | 'fields'>): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The shape of a field's value when it is made of nested fields: `group` and `repeater` fields,
|
|
16
|
+
* and compound fields, an object of their `fields`, or a list of them with `multiple`
|
|
17
|
+
* (decision 0065). Other fields return `null`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNestedShape(field: Pick<Field, 'type' | 'fields' | 'multiple'>): NestedShape | null;
|
|
20
|
+
//# sourceMappingURL=compound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compound.d.ts","sourceRoot":"","sources":["../src/compound.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;AAE/C,wCAAwC;AACxC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,OAAO,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC,GACnD,WAAW,GAAG,IAAI,CAQpB"}
|
package/dist/compound.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BUILT_IN_FIELD_TYPES } from "./constants.js";
|
|
2
|
+
//#region src/compound.ts
|
|
3
|
+
/** Whether a field type is built in. */
|
|
4
|
+
function isBuiltInFieldType(type) {
|
|
5
|
+
return BUILT_IN_FIELD_TYPES.includes(type);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Whether a field is a compound field (decision 0065): a type that isn't built in, provided by a
|
|
9
|
+
* plugin, that carries its sub-fields in `fields`.
|
|
10
|
+
*/
|
|
11
|
+
function isCompoundField(field) {
|
|
12
|
+
return field.fields !== void 0 && !isBuiltInFieldType(field.type);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The shape of a field's value when it is made of nested fields: `group` and `repeater` fields,
|
|
16
|
+
* and compound fields, an object of their `fields`, or a list of them with `multiple`
|
|
17
|
+
* (decision 0065). Other fields return `null`.
|
|
18
|
+
*/
|
|
19
|
+
function getNestedShape(field) {
|
|
20
|
+
if (field.type === "group" || field.type === "repeater") return field.type;
|
|
21
|
+
if (isCompoundField(field)) return field.multiple === true ? "repeater" : "group";
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getNestedShape, isBuiltInFieldType, isCompoundField };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=compound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compound.js","names":[],"sources":["../src/compound.ts"],"sourcesContent":["// Fields made of other fields: `group`, `repeater`, and the compound fields of plugins\n// (decision 0065). This module doesn't import zod.\nimport { BUILT_IN_FIELD_TYPES } from './constants';\nimport type { Field } from './schemas/field';\n\n/**\n * The shape of a value made of nested fields: an object of its `fields` (`group`), or a list of\n * them (`repeater`).\n */\nexport type NestedShape = 'group' | 'repeater';\n\n/** Whether a field type is built in. */\nexport function isBuiltInFieldType(type: string): boolean {\n return (BUILT_IN_FIELD_TYPES as readonly string[]).includes(type);\n}\n\n/**\n * Whether a field is a compound field (decision 0065): a type that isn't built in, provided by a\n * plugin, that carries its sub-fields in `fields`.\n */\nexport function isCompoundField(field: Pick<Field, 'type' | 'fields'>): boolean {\n return field.fields !== undefined && !isBuiltInFieldType(field.type);\n}\n\n/**\n * The shape of a field's value when it is made of nested fields: `group` and `repeater` fields,\n * and compound fields, an object of their `fields`, or a list of them with `multiple`\n * (decision 0065). Other fields return `null`.\n */\nexport function getNestedShape(\n field: Pick<Field, 'type' | 'fields' | 'multiple'>,\n): NestedShape | null {\n if (field.type === 'group' || field.type === 'repeater') {\n return field.type;\n }\n if (isCompoundField(field)) {\n return field.multiple === true ? 'repeater' : 'group';\n }\n return null;\n}\n"],"mappings":";;;AAYA,SAAgB,mBAAmB,MAAuB;CACtD,OAAQ,qBAA2C,SAAS,IAAI;AACpE;;;;;AAMA,SAAgB,gBAAgB,OAAgD;CAC5E,OAAO,MAAM,WAAW,KAAA,KAAa,CAAC,mBAAmB,MAAM,IAAI;AACvE;;;;;;AAOA,SAAgB,eACZ,OACkB;CAClB,IAAI,MAAM,SAAS,WAAW,MAAM,SAAS,YACzC,OAAO,MAAM;CAEjB,IAAI,gBAAgB,KAAK,GACrB,OAAO,MAAM,aAAa,OAAO,aAAa;CAElD,OAAO;AACX"}
|
package/dist/conditions.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ export interface ConformanceOptions {
|
|
|
7
7
|
init?: RequestInit;
|
|
8
8
|
/** Resource to test. Defaults to the first resource of the definition. */
|
|
9
9
|
resource?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Values of the context (decision 0045), sent in `Panneau-Context` with every request: for a
|
|
12
|
+
* backend whose resources need a value of a required param. The checks of the context use
|
|
13
|
+
* them too, and the first choice of each param without one.
|
|
14
|
+
*/
|
|
15
|
+
context?: Record<string, string>;
|
|
10
16
|
/**
|
|
11
17
|
* Enables the checks that write data, on the tested resource. Use a test database: these
|
|
12
18
|
* checks create, update and delete an item.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conformance/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conformance/index.ts"],"names":[],"mappings":"AAgCA,MAAM,WAAW,kBAAkB;IAC/B,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,wEAAwE;IACxE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE;QACL,mCAAmC;QACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,kCAAkC;QAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,2FAA2F;QAC3F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACL;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,iBAAiB,CAAC;IAC1B,qDAAqD;IACrD,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAsFD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA2rD5F;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAU9D"}
|