@tryghost/metafield-types 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +7 -4
- package/build/identity.d.ts +47 -25
- package/build/identity.d.ts.map +1 -1
- package/build/identity.js +52 -29
- package/build/identity.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/structure.d.ts +1 -1
- package/build/structure.d.ts.map +1 -1
- package/build/structure.js +1 -1
- package/build/structure.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @tryghost/metafield-types
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Changed `./identity` to name a field through types that only a check produces, and renamed the parts helper.
|
|
8
|
+
|
|
9
|
+
- `IdentityTextSchema` reads an identity such as `custom.shipping_address.country` into its namespace, key and parts, and writes one back. `z.safeDecode(IdentityTextSchema, text)` replaces `parseIdentity`, and `z.encode(IdentityTextSchema, identity)` replaces `formatIdentity`.
|
|
10
|
+
- `IdentitySchema` checks an identity whose segments arrive apart, such as a route's namespace and key. Reading a whole field's identity can leave `parts` out; what it reads always has them.
|
|
11
|
+
- `NamespaceSchema`, `KeySchema` and `PartSchema` check one segment each and produce the `Namespace`, `Key` and `Part` types. They replace `IDENTITY_SEGMENT`.
|
|
12
|
+
- `Identity` is the decoded shape, with `parts` in place of `partPath`. `FieldIdentity` and `FieldIdentityString` are removed.
|
|
13
|
+
- `CUSTOM_NAMESPACE` is a `Namespace` rather than the literal `'custom'`.
|
|
14
|
+
- `./identity` now loads `zod/mini`.
|
|
15
|
+
- `subFieldsOf` is renamed `partsOf`.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Corrected the description of CUSTOM_NAMESPACE: every field now records its namespace, so the constant only matters to code that speaks for the publisher's own fields.
|
|
20
|
+
|
|
3
21
|
## 0.1.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -15,12 +15,15 @@ npm install @tryghost/metafield-types
|
|
|
15
15
|
type of value each part holds. It depends on nothing.
|
|
16
16
|
- `@tryghost/metafield-types/countries`: the two-letter country codes a country
|
|
17
17
|
part accepts. It depends on nothing.
|
|
18
|
-
- `@tryghost/metafield-types/identity`: how a field is named
|
|
19
|
-
|
|
18
|
+
- `@tryghost/metafield-types/identity`: how a field is named everywhere: its
|
|
19
|
+
namespace, its key, the parts of a record value, and the identity they make
|
|
20
|
+
together (`custom.shipping_address.country`). Each is a type that only its
|
|
21
|
+
check produces. It loads `zod/mini`, a small fraction of zod's size, so a
|
|
22
|
+
browser app can check identities without paying for the rest.
|
|
20
23
|
- `@tryghost/metafield-types`: the structure above, plus the rules that validate
|
|
21
24
|
a value of each type. These are built on [zod](https://zod.dev), and only this
|
|
22
|
-
entry point loads it, so an integration that only draws inputs can use
|
|
23
|
-
|
|
25
|
+
entry point loads all of it, so an integration that only draws inputs can use
|
|
26
|
+
`./structure` and `./countries` without loading zod at all.
|
|
24
27
|
|
|
25
28
|
## Compatibility
|
|
26
29
|
|
package/build/identity.d.ts
CHANGED
|
@@ -1,36 +1,58 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
1
2
|
/**
|
|
2
|
-
* How a
|
|
3
|
-
*
|
|
3
|
+
* How a metafield is named, in the words every surface uses for it, and the checks that
|
|
4
|
+
* produce each word.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* - A **namespace** is who declared the field: `custom` for the fields a site's own staff
|
|
7
|
+
* define, and an app's own name for the fields it declares.
|
|
8
|
+
* - A **key** names the field within its namespace.
|
|
9
|
+
* - A **part** names one attribute of a record type's value, such as an address's
|
|
10
|
+
* `country`. A record inside a record takes a part for each level.
|
|
11
|
+
* - An **identity** is the namespace, the key and any parts, in that order, joined by dots:
|
|
12
|
+
* `custom.company` names a field, and `custom.shipping_address.country` one part of its
|
|
13
|
+
* value.
|
|
9
14
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
15
|
+
* Every one of them is a segment, and every segment follows the same rule: lowercase
|
|
16
|
+
* letters, digits and underscores. Filters, CSV columns, email replacement strings and
|
|
17
|
+
* themes all accept those and disagree about everything else. No segment can contain the
|
|
18
|
+
* dot, so an identity splits back into its segments by position.
|
|
19
|
+
*
|
|
20
|
+
* `metafields` is the qualifier, not part of an identity: it names the container, and each
|
|
21
|
+
* context writes it once, as the payload key, the route prefix, the CSV column prefix or the
|
|
22
|
+
* filter relation.
|
|
13
23
|
*/
|
|
14
24
|
export declare const QUALIFIER = "metafields";
|
|
15
25
|
export declare const SEPARATOR = ".";
|
|
26
|
+
export declare const NamespaceSchema: z.core.$ZodBranded<z.ZodMiniString<string>, "Namespace", "out">;
|
|
27
|
+
export type Namespace = z.infer<typeof NamespaceSchema>;
|
|
28
|
+
export declare const KeySchema: z.core.$ZodBranded<z.ZodMiniString<string>, "Key", "out">;
|
|
29
|
+
export type Key = z.infer<typeof KeySchema>;
|
|
30
|
+
export declare const PartSchema: z.core.$ZodBranded<z.ZodMiniString<string>, "Part", "out">;
|
|
31
|
+
export type Part = z.infer<typeof PartSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* An identity's segments, each checked. A field's own identity has no parts, so reading one
|
|
34
|
+
* whose segments arrive apart, such as a route's namespace and key, can leave `parts` out.
|
|
35
|
+
* What it reads always has them.
|
|
36
|
+
*/
|
|
37
|
+
export declare const IdentitySchema: z.ZodMiniObject<{
|
|
38
|
+
namespace: z.core.$ZodBranded<z.ZodMiniString<string>, "Namespace", "out">;
|
|
39
|
+
key: z.core.$ZodBranded<z.ZodMiniString<string>, "Key", "out">;
|
|
40
|
+
parts: z.ZodMiniDefault<z.ZodMiniArray<z.core.$ZodBranded<z.ZodMiniString<string>, "Part", "out">>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type Identity = z.output<typeof IdentitySchema>;
|
|
43
|
+
/** An identity read from its text, checking every segment, and written back to it. */
|
|
44
|
+
export declare const IdentityTextSchema: z.ZodMiniCodec<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
45
|
+
namespace: z.core.$ZodBranded<z.ZodMiniString<string>, "Namespace", "out">;
|
|
46
|
+
key: z.core.$ZodBranded<z.ZodMiniString<string>, "Key", "out">;
|
|
47
|
+
parts: z.ZodMiniDefault<z.ZodMiniArray<z.core.$ZodBranded<z.ZodMiniString<string>, "Part", "out">>>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
16
49
|
/**
|
|
17
50
|
* The namespace holding the fields a site's own staff define.
|
|
18
51
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* namespace, not an error.
|
|
52
|
+
* Every field records its namespace, so reading and writing fields never needs this. It
|
|
53
|
+
* is for code that speaks only for the publisher's fields: who may define fields where,
|
|
54
|
+
* and the surfaces that name a publisher's field by key alone. Another namespace is not
|
|
55
|
+
* an error for not being this one: a namespace nobody has declared fields in is empty.
|
|
24
56
|
*/
|
|
25
|
-
export declare const CUSTOM_NAMESPACE
|
|
26
|
-
export declare const IDENTITY_SEGMENT: RegExp;
|
|
27
|
-
/** A formatted identity — `namespace.key`, or `namespace.key.partPath` for one part. */
|
|
28
|
-
export type FieldIdentityString = string;
|
|
29
|
-
export interface FieldIdentity {
|
|
30
|
-
namespace: string;
|
|
31
|
-
key: string;
|
|
32
|
-
partPath: string | null;
|
|
33
|
-
}
|
|
34
|
-
export declare function formatIdentity({ namespace, key, partPath }: FieldIdentity): FieldIdentityString;
|
|
35
|
-
export declare function parseIdentity(identity: string): FieldIdentity | null;
|
|
57
|
+
export declare const CUSTOM_NAMESPACE: string & z.$brand<"Namespace">;
|
|
36
58
|
//# sourceMappingURL=identity.d.ts.map
|
package/build/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,eAAO,MAAM,SAAS,eAAe,CAAC;AAEtC,eAAO,MAAM,SAAS,MAAM,CAAC;AAU7B,eAAO,MAAM,eAAe,iEAA4C,CAAC;AACzE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,SAAS,2DAAgC,CAAC;AACvD,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAE5C,eAAO,MAAM,UAAU,4DAAkC,CAAC;AAC1D,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;iBAIzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAEvD,sFAAsF;AACtF,eAAO,MAAM,kBAAkB;;;;kBAQ7B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,gCAAkC,CAAC"}
|
package/build/identity.js
CHANGED
|
@@ -1,40 +1,63 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
1
2
|
/**
|
|
2
|
-
* How a
|
|
3
|
-
*
|
|
3
|
+
* How a metafield is named, in the words every surface uses for it, and the checks that
|
|
4
|
+
* produce each word.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* - A **namespace** is who declared the field: `custom` for the fields a site's own staff
|
|
7
|
+
* define, and an app's own name for the fields it declares.
|
|
8
|
+
* - A **key** names the field within its namespace.
|
|
9
|
+
* - A **part** names one attribute of a record type's value, such as an address's
|
|
10
|
+
* `country`. A record inside a record takes a part for each level.
|
|
11
|
+
* - An **identity** is the namespace, the key and any parts, in that order, joined by dots:
|
|
12
|
+
* `custom.company` names a field, and `custom.shipping_address.country` one part of its
|
|
13
|
+
* value.
|
|
9
14
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
15
|
+
* Every one of them is a segment, and every segment follows the same rule: lowercase
|
|
16
|
+
* letters, digits and underscores. Filters, CSV columns, email replacement strings and
|
|
17
|
+
* themes all accept those and disagree about everything else. No segment can contain the
|
|
18
|
+
* dot, so an identity splits back into its segments by position.
|
|
19
|
+
*
|
|
20
|
+
* `metafields` is the qualifier, not part of an identity: it names the container, and each
|
|
21
|
+
* context writes it once, as the payload key, the route prefix, the CSV column prefix or the
|
|
22
|
+
* filter relation.
|
|
13
23
|
*/
|
|
14
24
|
export const QUALIFIER = 'metafields';
|
|
15
25
|
export const SEPARATOR = '.';
|
|
26
|
+
function segment(noun) {
|
|
27
|
+
return z.string().check(z.regex(/^[a-z0-9_]+$/, {
|
|
28
|
+
error: `A ${noun} can only contain lowercase letters, numbers and underscores.`,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
export const NamespaceSchema = segment('namespace').brand();
|
|
32
|
+
export const KeySchema = segment('key').brand();
|
|
33
|
+
export const PartSchema = segment('part').brand();
|
|
34
|
+
/**
|
|
35
|
+
* An identity's segments, each checked. A field's own identity has no parts, so reading one
|
|
36
|
+
* whose segments arrive apart, such as a route's namespace and key, can leave `parts` out.
|
|
37
|
+
* What it reads always has them.
|
|
38
|
+
*/
|
|
39
|
+
export const IdentitySchema = z.object({
|
|
40
|
+
namespace: NamespaceSchema,
|
|
41
|
+
key: KeySchema,
|
|
42
|
+
parts: z._default(z.array(PartSchema), () => []),
|
|
43
|
+
});
|
|
44
|
+
/** An identity read from its text, checking every segment, and written back to it. */
|
|
45
|
+
export const IdentityTextSchema = z.codec(z.string(), IdentitySchema, {
|
|
46
|
+
decode: (text) => {
|
|
47
|
+
const [namespace = '', key = '', ...parts] = text.split(SEPARATOR);
|
|
48
|
+
return { namespace, key, parts };
|
|
49
|
+
},
|
|
50
|
+
// Zod types the argument as what the schema reads, where `parts` can be left out, but `z.encode`
|
|
51
|
+
// refuses an identity without them before this runs.
|
|
52
|
+
encode: ({ namespace, key, parts = [] }) => [namespace, key, ...parts].join(SEPARATOR),
|
|
53
|
+
});
|
|
16
54
|
/**
|
|
17
55
|
* The namespace holding the fields a site's own staff define.
|
|
18
56
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* namespace, not an error.
|
|
57
|
+
* Every field records its namespace, so reading and writing fields never needs this. It
|
|
58
|
+
* is for code that speaks only for the publisher's fields: who may define fields where,
|
|
59
|
+
* and the surfaces that name a publisher's field by key alone. Another namespace is not
|
|
60
|
+
* an error for not being this one: a namespace nobody has declared fields in is empty.
|
|
24
61
|
*/
|
|
25
|
-
export const CUSTOM_NAMESPACE = 'custom';
|
|
26
|
-
export const IDENTITY_SEGMENT = /^[a-z0-9_]+$/;
|
|
27
|
-
export function formatIdentity({ namespace, key, partPath }) {
|
|
28
|
-
const identity = `${namespace}${SEPARATOR}${key}`;
|
|
29
|
-
return partPath ? `${identity}${SEPARATOR}${partPath}` : identity;
|
|
30
|
-
}
|
|
31
|
-
export function parseIdentity(identity) {
|
|
32
|
-
const [namespace, key, ...parts] = identity.split(SEPARATOR);
|
|
33
|
-
if (namespace === undefined ||
|
|
34
|
-
key === undefined ||
|
|
35
|
-
![namespace, key, ...parts].every((segment) => IDENTITY_SEGMENT.test(segment))) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
return { namespace, key, partPath: parts.length > 0 ? parts.join(SEPARATOR) : null };
|
|
39
|
-
}
|
|
62
|
+
export const CUSTOM_NAMESPACE = NamespaceSchema.parse('custom');
|
|
40
63
|
//# sourceMappingURL=identity.js.map
|
package/build/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC;AAEtC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAE7B,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CACrB,CAAC,CAAC,KAAK,CAAC,cAAc,EAAE;QACtB,KAAK,EAAE,KAAK,IAAI,+DAA+D;KAChF,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,KAAK,EAAe,CAAC;AAGzE,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAS,CAAC;AAGvD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAU,CAAC;AAG1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE,eAAe;IAC1B,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CAAC;AAGH,sFAAsF;AACtF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE;IACpE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QACf,MAAM,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACnE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;IACD,iGAAiG;IACjG,qDAAqD;IACrD,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;CACvF,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { type FieldType } from './structure.js';
|
|
3
|
-
export { FIELD_KINDS, FIELD_PARTS, FIELD_TYPE_IDS, PART_TYPE_IDS, partTypesOf,
|
|
3
|
+
export { FIELD_KINDS, FIELD_PARTS, FIELD_TYPE_IDS, PART_TYPE_IDS, partTypesOf, partsOf, type FieldKind, type FieldType, type PartsOf, type PartType, } from './structure.js';
|
|
4
4
|
/**
|
|
5
5
|
* The shared catalog of member metafield types.
|
|
6
6
|
*
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,O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M,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,KAAK,GAAG,MAAM;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,qBAAqB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC9C,UAAU,EAAE,yBAAyB,EAAE,CAAC;IACxC,UAAU,EAAE,KAAK,CAAC;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AA2BzC;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;CAwBiB,CAAC;AA+BzC,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,IAAI,EAAE,OAAO,gBAAgB,EAAE,SAAS,CAAC;IACzC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;CAClB;AA2CD,eAAO,MAAM,WAAW;;;;;;;;;;cAHP,QAAQ;;;;;;;;;;CAevB,CAAC;AAEH,6FAA6F;AAC7F,eAAO,MAAM,YAAY;;;;;;;kBAA4B,CAAC;AACtD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;KAAG,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;CAAE,CAAC,SAAS,CAAC,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { FIELD_PARTS, FIELD_TYPE_IDS } from './structure.js';
|
|
3
3
|
// Re-exported so a caller that needs both halves still has one import. The split is
|
|
4
4
|
// about what a bundle pays for, not about where the catalog lives.
|
|
5
|
-
export { FIELD_KINDS, FIELD_PARTS, FIELD_TYPE_IDS, PART_TYPE_IDS, partTypesOf,
|
|
5
|
+
export { FIELD_KINDS, FIELD_PARTS, FIELD_TYPE_IDS, PART_TYPE_IDS, partTypesOf, partsOf, } from './structure.js';
|
|
6
6
|
/**
|
|
7
7
|
* The shared catalog of member metafield types.
|
|
8
8
|
*
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAiC,MAAM,gBAAgB,CAAC;AAE5F,oFAAoF;AACpF,mEAAmE;AACnE,OAAO,EACL,WAAW,EACX,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAiC,MAAM,gBAAgB,CAAC;AAE5F,oFAAoF;AACpF,mEAAmE;AACnE,OAAO,EACL,WAAW,EACX,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,OAAO,GAKR,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAEvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,C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QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAC3E,CAAC;IAElB,uFAAuF;IACvF,gDAAgD;IAChD,MAAM,KAAK,GAAG,CAAC;SACZ,YAAY,CAAC,KAAK,CAAC;SACnB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAEjG,OAAO,EAAE,IAAI,EAAE,QAAiB,EAAE,KAAK,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;IAC1C,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,EAAE;IAC1D,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAC9C,iFAAiF;IACjF,8EAA8E;IAC9E,EAAE;IACF,kFAAkF;IAClF,mFAAmF;IACnF,6EAA6E;IAC7E,kFAAkF;IAClF,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,yCAAyC,EAAE,CAAC;CACjF,CAAC,CAAC;AAEH,6FAA6F;AAC7F,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC"}
|
package/build/structure.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export type PartsOf<T extends FieldType> = T extends FieldType ? (typeof FIELD_P
|
|
|
72
72
|
* Typed to the parts the caller's type declares, so a caller holding one of these can
|
|
73
73
|
* index a value of that type without restating which parts exist.
|
|
74
74
|
*/
|
|
75
|
-
export declare function
|
|
75
|
+
export declare function partsOf<T extends FieldType>(type: T): PartsOf<T>[] | null;
|
|
76
76
|
/** Each part's declared type, keyed by part; null for a type with none, and for one this build has never heard of. */
|
|
77
77
|
export declare function partTypesOf<T extends FieldType>(type: T): Record<PartsOf<T>, PartType> | null;
|
|
78
78
|
//# sourceMappingURL=structure.d.ts.map
|
package/build/structure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../src/structure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,oFAAoF;AACpF,eAAO,MAAM,cAAc,YAAI,YAAY,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC;AAC9E,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,YAAI,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AACzE,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,aAAa,YAAI,YAAY,EAAE,aAAa,EAAE,cAAc,CAAU,CAAC;AACpF,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW;;;;iBAIpB,KAAK,EAAE,YAAY;iBACnB,KAAK,EAAE,YAAY;iBACnB,IAAI,EAAE,YAAY;iBAClB,KAAK,EAAE,YAAY;iBACnB,WAAW,EAAE,aAAa;iBAC1B,OAAO,EAAE,cAAc;;CAEsD,CAAC;AAElF;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS,SAAS,GAC1D,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAClC,KAAK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C;AAEV;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAKzE;AAED,sHAAsH;AACtH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAI,CAG7F"}
|
package/build/structure.js
CHANGED
|
@@ -62,7 +62,7 @@ export const FIELD_PARTS = {
|
|
|
62
62
|
* Typed to the parts the caller's type declares, so a caller holding one of these can
|
|
63
63
|
* index a value of that type without restating which parts exist.
|
|
64
64
|
*/
|
|
65
|
-
export function
|
|
65
|
+
export function partsOf(type) {
|
|
66
66
|
// Optional because a caller built against an older catalog than the server it talks
|
|
67
67
|
// to reaches here with a type this build has never heard of, which reads as no parts.
|
|
68
68
|
const parts = FIELD_PARTS[type];
|
package/build/structure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure.js","sourceRoot":"","sources":["../src/structure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC;AAG9E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAGzE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,cAAc,CAAU,CAAC;AAGpF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE;QACP,KAAK,EAAE,YAAY;QACnB,KAA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