@actuate-media/plugin-commerce 0.0.12 → 0.0.14

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 CHANGED
@@ -1,5 +1,55 @@
1
1
  # @actuate-media/plugin-commerce
2
2
 
3
+ ## 0.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - c231dd0: Add `definePlugin` and migrate all 10 plugins onto the canonical `PluginDefinition` contract.
8
+
9
+ cms-core already exported `PluginDefinition`, but every plugin hand-rolled a
10
+ local `ActuatePlugin` interface — a lossy subset that dropped `version`/`init`
11
+ and, in blocks/email/ai, widened hook payloads to `unknown[]`/`event: string`.
12
+ That's copy-paste drift with no shared source of truth.
13
+
14
+ `cms-core` now exports `definePlugin(plugin: PluginDefinition)` (an identity
15
+ helper like `defineConfig`), and each plugin imports the canonical type instead
16
+ of its own: the local `ActuatePlugin` interfaces are deleted, factory return
17
+ types are `PluginDefinition`, and the widened `hooks.ts` types are retyped as
18
+ `PluginHook[]`. Type-only change — no runtime behavior, plugin `name`, or config
19
+ options changed. Net −69 lines.
20
+
21
+ - 325694f: Import `definePlugin` from the lightweight `@actuate-media/cms-core/config`
22
+ entry instead of the barrel.
23
+
24
+ The plugin-definition migration imported the `definePlugin` **value** from
25
+ `@actuate-media/cms-core`, which pulls the entire cms-core barrel (graphql,
26
+ sharp, sentry, codegen) into every plugin's runtime — bundle bloat for
27
+ consumers and, under parallel test load, a timeout. The `/config` subpath exists
28
+ precisely to avoid the barrel. Types stay as erased `import type`, so nothing
29
+ heavy is loaded. No API or behavior change.
30
+
31
+ ## 0.0.13
32
+
33
+ ### Patch Changes
34
+
35
+ - 041a228: Add the MIT `license` field to every published package (previously missing) and correct `repository.url` to `github.com/actuate-media/actuatecms` (13 packages carried the wrong org).
36
+ - de419f2: Give plugin hooks a frozen, typed event contract. cms-core now exports
37
+ `PluginHook`, `PluginHookEvent`, and `PluginHookPayload` (document + upload
38
+ variants) as the single source of truth, and dispatches a complete, consistent
39
+ set of events: `afterCreate` / `afterUpdate` / `afterDelete` — each also in a
40
+ collection-namespaced form (`afterUpdate:navigations`, `afterCreate:orders`) —
41
+ plus `afterUpload` (fired post-upload from the media route). Every handler now
42
+ receives one typed payload; document field values live on `payload.data`.
43
+
44
+ Previously core fired only bare `afterCreate`/`afterUpdate` with the raw row, so
45
+ several shipped plugins' hooks were dead: `plugin-media`'s `afterUpload` never
46
+ fired, `plugin-navigation` read fields that didn't exist, and the namespaced
47
+ events `plugin-forms`/`plugin-commerce` declared were never dispatched. Each
48
+ plugin has been aligned to the shared type and dispatched events (and
49
+ `plugin-redirects`' request-time `onRedirectMatch` hook — which the lifecycle
50
+ bus never dispatched — was removed). Undispatched event names are now a
51
+ compile-time error.
52
+
3
53
  ## 0.0.12
4
54
 
5
55
  ### Patch Changes
package/dist/hooks.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- export declare const commerceHooks: {
2
- event: string;
3
- handler: (...args: unknown[]) => Promise<void>;
4
- }[];
1
+ import type { PluginHook } from '@actuate-media/cms-core';
2
+ export declare const commerceHooks: PluginHook[];
5
3
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;uBAGG,OAAO,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC;GA+BrD,CAAA"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,yBAAyB,CAAA;AAEhC,eAAO,MAAM,aAAa,EAAE,UAAU,EAmCrC,CAAA"}
package/dist/hooks.js CHANGED
@@ -1,11 +1,11 @@
1
1
  export const commerceHooks = [
2
2
  {
3
3
  event: 'afterCreate:orders',
4
- handler: async (...args) => {
5
- const [order] = args;
6
- const orderId = order?.['id'];
7
- const total = order?.['total'];
8
- const currency = order?.['currency'] ?? 'USD';
4
+ handler: async (payload) => {
5
+ // Document-lifecycle event: payload is the document; field values live in payload.data.
6
+ const { id: orderId, data } = payload;
7
+ const total = data?.['total'];
8
+ const currency = data?.['currency'] ?? 'USD';
9
9
  if (!orderId || total === undefined)
10
10
  return;
11
11
  // TODO: Integrate with Stripe payment intent creation
@@ -14,11 +14,12 @@ export const commerceHooks = [
14
14
  },
15
15
  {
16
16
  event: 'afterUpdate:products',
17
- handler: async (...args) => {
18
- const [product] = args;
19
- const name = product?.['name'];
20
- const trackInventory = product?.['trackInventory'];
21
- const inventoryCount = product?.['inventoryCount'];
17
+ handler: async (payload) => {
18
+ // Document-lifecycle event: payload is the document; field values live in payload.data.
19
+ const { data } = payload;
20
+ const name = data?.['name'];
21
+ const trackInventory = data?.['trackInventory'];
22
+ const inventoryCount = data?.['inventoryCount'];
22
23
  if (!trackInventory || inventoryCount === undefined)
23
24
  return;
24
25
  const LOW_STOCK_THRESHOLD = 5;
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;QACE,KAAK,EAAE,oBAAoB;QAC3B,OAAO,EAAE,KAAK,EAAE,GAAG,IAAe,EAAiB,EAAE;YACnD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAiC,CAAA;YACjD,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC,IAAI,CAAuB,CAAA;YACnD,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC,OAAO,CAAuB,CAAA;YACpD,MAAM,QAAQ,GAAI,KAAK,EAAE,CAAC,UAAU,CAAY,IAAI,KAAK,CAAA;YAEzD,IAAI,CAAC,OAAO,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAM;YAE3C,sDAAsD;YACtD,OAAO,CAAC,IAAI,CAAC,4BAA4B,OAAO,gBAAgB,QAAQ,IAAI,KA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;KACF;IACD;QACE,KAAK,EAAE,sBAAsB;QAC7B,OAAO,EAAE,KAAK,EAAE,OAA0B,EAAiB,EAAE;YAC3D,wFAAwF;YACxF,MAAM,EAAE,IAAI,EAAE,GAAG,OAAoC,CAAA;YACrD,MAAM,IAAI,GAAG,IAAI,EAAE,CAAC,MAAM,CAAuB,CAAA;YACjD,MAAM,cAAc,GAAG,IAAI,EAAE,CAAC,gBAAgB,CAAwB,CAAA;YACtE,MAAM,cAAc,GAAG,IAAI,EAAE,CAAC,gBAAgB,CAAuB,CAAA;YAErE,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;gBAAE,OAAM;YAE3D,MAAM,mBAAmB,GAAG,CAAC,CAAA;YAC7B,IAAI,cAAc,IAAI,mBAAmB,EAAE,CAAC;gBAC1C,qDAAqD;gBACrD,OAAO,CAAC,IAAI,CACV,gCAAgC,IAAI,SAAS,cAAc,oBAAoB,CAChF,CAAA;YACH,CAAC;QACH,CAAC;KACF;CACF,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { FieldDefinition, CollectionDefinition } from '@actuate-media/cms-core';
1
+ import { type PluginDefinition } from '@actuate-media/cms-core/config';
2
2
  export interface CommercePluginConfig {
3
3
  stripe?: {
4
4
  secretKey: string;
@@ -12,22 +12,8 @@ export interface CommercePluginConfig {
12
12
  enabled?: boolean;
13
13
  };
14
14
  }
15
- interface ActuatePlugin {
16
- name: string;
17
- fields?: Record<string, FieldDefinition>;
18
- collections?: Record<string, CollectionDefinition>;
19
- adminNavItems?: Array<{
20
- label: string;
21
- icon: string;
22
- path: string;
23
- }>;
24
- hooks?: Array<{
25
- event: string;
26
- handler: (...args: unknown[]) => Promise<void> | void;
27
- }>;
28
- }
29
15
  /** Creates the Actuate Commerce plugin with optional Stripe, tax, and shipping configuration. */
30
- export declare function commercePlugin(config?: CommercePluginConfig): ActuatePlugin;
16
+ export declare function commercePlugin(config?: CommercePluginConfig): PluginDefinition;
31
17
  export type { CommercePluginConfig as CommerceConfig };
32
18
  export { commerceFields } from './fields.js';
33
19
  export { commerceCollections } from './collections.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAKpF,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE;QACP,SAAS,EAAE,MAAM,CAAA;QACjB,aAAa,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,GAAG,CAAC,EAAE;QACJ,aAAa,CAAC,EAAE,OAAO,CAAA;KACxB,CAAA;IACD,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;CACF;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IAClD,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACpE,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;KACtD,CAAC,CAAA;CACH;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,MAAM,GAAE,oBAAyB,GAAG,aAAa,CAiB/E;AAED,YAAY,EAAE,oBAAoB,IAAI,cAAc,EAAE,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAKpF,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE;QACP,SAAS,EAAE,MAAM,CAAA;QACjB,aAAa,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,GAAG,CAAC,EAAE;QACJ,aAAa,CAAC,EAAE,OAAO,CAAA;KACxB,CAAA;IACD,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;CACF;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,MAAM,GAAE,oBAAyB,GAAG,gBAAgB,CAiBlF;AAED,YAAY,EAAE,oBAAoB,IAAI,cAAc,EAAE,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
+ import { definePlugin } from '@actuate-media/cms-core/config';
1
2
  import { commerceFields } from './fields.js';
2
3
  import { commerceCollections } from './collections.js';
3
4
  import { commerceHooks } from './hooks.js';
4
5
  /** Creates the Actuate Commerce plugin with optional Stripe, tax, and shipping configuration. */
5
6
  export function commercePlugin(config = {}) {
6
- return {
7
+ return definePlugin({
7
8
  name: 'commerce',
8
9
  fields: commerceFields,
9
10
  collections: commerceCollections,
@@ -18,7 +19,7 @@ export function commercePlugin(config = {}) {
18
19
  },
19
20
  ],
20
21
  hooks: commerceHooks,
21
- };
22
+ });
22
23
  }
23
24
  export { commerceFields } from './fields.js';
24
25
  export { commerceCollections } from './collections.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AA2B1C,iGAAiG;AACjG,MAAM,UAAU,cAAc,CAAC,SAA+B,EAAE;IAC9D,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,cAAc;QACtB,WAAW,EAAE,mBAAmB;QAChC,aAAa,EAAE;YACb,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE;YAClE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,kBAAkB,EAAE;YACpE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,qBAAqB,EAAE;YACpE;gBACE,KAAK,EAAE,oBAAoB;gBAC3B,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,KAAK,EAAE,aAAa;KACrB,CAAA;AACH,CAAC;AAGD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyB,MAAM,gCAAgC,CAAA;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAgB1C,iGAAiG;AACjG,MAAM,UAAU,cAAc,CAAC,SAA+B,EAAE;IAC9D,OAAO,YAAY,CAAC;QAClB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,cAAc;QACtB,WAAW,EAAE,mBAAmB;QAChC,aAAa,EAAE;YACb,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE;YAClE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,kBAAkB,EAAE;YACpE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,qBAAqB,EAAE;YACpE;gBACE,KAAK,EAAE,oBAAoB;gBAC3B,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,KAAK,EAAE,aAAa;KACrB,CAAC,CAAA;AACJ,CAAC;AAGD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@actuate-media/plugin-commerce",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
+ "license": "MIT",
4
5
  "repository": {
5
6
  "type": "git",
6
- "url": "https://github.com/actuatecms/actuatecms.git",
7
+ "url": "https://github.com/actuate-media/actuatecms.git",
7
8
  "directory": "packages/plugin-commerce"
8
9
  },
9
10
  "publishConfig": {
@@ -27,7 +28,7 @@
27
28
  "@types/react": "^19.0.0",
28
29
  "typescript": "^5.7.0",
29
30
  "vitest": "^4.1.0",
30
- "@actuate-media/cms-core": "0.61.0"
31
+ "@actuate-media/cms-core": "0.93.0"
31
32
  },
32
33
  "peerDependencies": {
33
34
  "@actuate-media/cms-core": ">=0.1.0",