@nixxie-cms/fields-oembed 1.0.1 → 2.0.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 ADDED
@@ -0,0 +1,15 @@
1
+ # @nixxie-cms/fields-oembed
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 450043a:
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [0fe028d]
12
+ - Updated dependencies [690e433]
13
+ - Updated dependencies [2c0d28c]
14
+ - Updated dependencies [450043a]
15
+ - @nixxie-cms/core@2.0.0
@@ -1,5 +1,5 @@
1
1
  import type { TextFieldConfig } from '@nixxie-cms/core/fields';
2
- import type { BaseListTypeInfo, FieldTypeFunc } from '@nixxie-cms/core/types';
2
+ import type { BaseCollectionTypeInfo, FieldTypeFunc } from '@nixxie-cms/core/types';
3
3
  export type OembedData = {
4
4
  url: string;
5
5
  type?: string;
@@ -9,7 +9,7 @@ export type OembedData = {
9
9
  providerName?: string;
10
10
  raw?: any;
11
11
  };
12
- export type OembedFieldConfig<ListTypeInfo extends BaseListTypeInfo> = Omit<TextFieldConfig<ListTypeInfo>, 'validation'> & {
12
+ export type OembedFieldConfig<CollectionTypeInfo extends BaseCollectionTypeInfo> = Omit<TextFieldConfig<CollectionTypeInfo>, 'validation'> & {
13
13
  validation?: {
14
14
  isRequired?: boolean;
15
15
  };
@@ -27,5 +27,5 @@ export declare function fetchOembed(url: string, endpoint?: string, timeoutMs?:
27
27
  * An oEmbed field for embeddable media URLs (YouTube, Vimeo, tweets, etc.). By default it stores a
28
28
  * validated URL string. Set `resolve: true` to fetch and store the full oEmbed payload as JSON.
29
29
  */
30
- export declare function oembed<ListTypeInfo extends BaseListTypeInfo>(config?: OembedFieldConfig<ListTypeInfo>): FieldTypeFunc<ListTypeInfo>;
30
+ export declare function oembed<CollectionTypeInfo extends BaseCollectionTypeInfo>(config?: OembedFieldConfig<CollectionTypeInfo>): FieldTypeFunc<CollectionTypeInfo>;
31
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE7E,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,GAAG,CAAA;CACV,CAAA;AAED,MAAM,MAAM,iBAAiB,CAAC,YAAY,SAAS,gBAAgB,IAAI,IAAI,CACzE,eAAe,CAAC,YAAY,CAAC,EAC7B,YAAY,CACb,GAAG;IACF,UAAU,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CACzC,CAAA;AAWD,0FAA0F;AAC1F,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,QAAQ,SAA8B,EACtC,SAAS,SAAO,GACf,OAAO,CAAC,UAAU,CAAC,CAqBrB;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,YAAY,SAAS,gBAAgB,EAC1D,MAAM,GAAE,iBAAiB,CAAC,YAAY,CAAM,GAC3C,aAAa,CAAC,YAAY,CAAC,CA2C7B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEnF,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,GAAG,CAAA;CACV,CAAA;AAED,MAAM,MAAM,iBAAiB,CAAC,kBAAkB,SAAS,sBAAsB,IAAI,IAAI,CACrF,eAAe,CAAC,kBAAkB,CAAC,EACnC,YAAY,CACb,GAAG;IACF,UAAU,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CACzC,CAAA;AAWD,0FAA0F;AAC1F,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,QAAQ,SAA8B,EACtC,SAAS,SAAO,GACf,OAAO,CAAC,UAAU,CAAC,CAqBrB;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,kBAAkB,SAAS,sBAAsB,EACtE,MAAM,GAAE,iBAAiB,CAAC,kBAAkB,CAAM,GACjD,aAAa,CAAC,kBAAkB,CAAC,CA6CnC"}
@@ -56,6 +56,8 @@ function oembed(config = {}) {
56
56
  ...rest,
57
57
  defaultValue: null,
58
58
  hooks: {
59
+ // The user's hooks are typed against the text field's String shape; the json
60
+ // field's hook signatures are JSON-typed, so re-cast them for this branch.
59
61
  ...hooks,
60
62
  resolveInput: async args => {
61
63
  const value = args.resolvedData[args.fieldKey];
@@ -52,6 +52,8 @@ function oembed(config = {}) {
52
52
  ...rest,
53
53
  defaultValue: null,
54
54
  hooks: {
55
+ // The user's hooks are typed against the text field's String shape; the json
56
+ // field's hook signatures are JSON-typed, so re-cast them for this branch.
55
57
  ...hooks,
56
58
  resolveInput: async args => {
57
59
  const value = args.resolvedData[args.fieldKey];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nixxie-cms/fields-oembed",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/nixxie-cms-fields-oembed.cjs.js",
6
6
  "module": "dist/nixxie-cms-fields-oembed.esm.js",
@@ -16,10 +16,10 @@
16
16
  "@babel/runtime": "^7.24.7"
17
17
  },
18
18
  "devDependencies": {
19
- "@nixxie-cms/core": "^1.0.1"
19
+ "@nixxie-cms/core": "^2.0.0"
20
20
  },
21
21
  "peerDependencies": {
22
- "@nixxie-cms/core": "^1.0.1"
22
+ "@nixxie-cms/core": "^2.0.0"
23
23
  },
24
24
  "preconstruct": {
25
25
  "entrypoints": [
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { json, text } from '@nixxie-cms/core/fields'
2
2
  import type { JsonFieldConfig, TextFieldConfig } from '@nixxie-cms/core/fields'
3
- import type { BaseListTypeInfo, FieldTypeFunc } from '@nixxie-cms/core/types'
3
+ import type { BaseCollectionTypeInfo, FieldTypeFunc } from '@nixxie-cms/core/types'
4
4
 
5
5
  export type OembedData = {
6
6
  url: string
@@ -12,8 +12,8 @@ export type OembedData = {
12
12
  raw?: any
13
13
  }
14
14
 
15
- export type OembedFieldConfig<ListTypeInfo extends BaseListTypeInfo> = Omit<
16
- TextFieldConfig<ListTypeInfo>,
15
+ export type OembedFieldConfig<CollectionTypeInfo extends BaseCollectionTypeInfo> = Omit<
16
+ TextFieldConfig<CollectionTypeInfo>,
17
17
  'validation'
18
18
  > & {
19
19
  validation?: { isRequired?: boolean }
@@ -65,19 +65,21 @@ export async function fetchOembed(
65
65
  * An oEmbed field for embeddable media URLs (YouTube, Vimeo, tweets, etc.). By default it stores a
66
66
  * validated URL string. Set `resolve: true` to fetch and store the full oEmbed payload as JSON.
67
67
  */
68
- export function oembed<ListTypeInfo extends BaseListTypeInfo>(
69
- config: OembedFieldConfig<ListTypeInfo> = {}
70
- ): FieldTypeFunc<ListTypeInfo> {
68
+ export function oembed<CollectionTypeInfo extends BaseCollectionTypeInfo>(
69
+ config: OembedFieldConfig<CollectionTypeInfo> = {}
70
+ ): FieldTypeFunc<CollectionTypeInfo> {
71
71
  const { validation, resolve, hooks, ...rest } = config
72
72
  const endpoint =
73
73
  resolve && typeof resolve === 'object' ? resolve.endpoint : 'https://noembed.com/embed'
74
74
 
75
75
  if (resolve) {
76
- return json<ListTypeInfo>({
77
- ...(rest as unknown as JsonFieldConfig<ListTypeInfo>),
76
+ return json<CollectionTypeInfo>({
77
+ ...(rest as unknown as JsonFieldConfig<CollectionTypeInfo>),
78
78
  defaultValue: null,
79
79
  hooks: {
80
- ...hooks,
80
+ // The user's hooks are typed against the text field's String shape; the json
81
+ // field's hook signatures are JSON-typed, so re-cast them for this branch.
82
+ ...(hooks as unknown as JsonFieldConfig<CollectionTypeInfo>['hooks']),
81
83
  resolveInput: async (args: any) => {
82
84
  const value = args.resolvedData[args.fieldKey]
83
85
  if (value === undefined) return undefined
@@ -94,8 +96,8 @@ export function oembed<ListTypeInfo extends BaseListTypeInfo>(
94
96
  })
95
97
  }
96
98
 
97
- return text<ListTypeInfo>({
98
- ...(rest as TextFieldConfig<ListTypeInfo>),
99
+ return text<CollectionTypeInfo>({
100
+ ...(rest as TextFieldConfig<CollectionTypeInfo>),
99
101
  validation: { isRequired: validation?.isRequired },
100
102
  ui: { description: 'An embeddable media URL', ...rest.ui },
101
103
  hooks: {