@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 +50 -0
- package/dist/hooks.d.ts +2 -4
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +11 -10
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +2 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
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
package/dist/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,
|
|
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 (
|
|
5
|
-
|
|
6
|
-
const orderId =
|
|
7
|
-
const total =
|
|
8
|
-
const currency =
|
|
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 (
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
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.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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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):
|
|
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';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
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":"
|
|
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.
|
|
3
|
+
"version": "0.0.14",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
|
-
"url": "https://github.com/
|
|
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.
|
|
31
|
+
"@actuate-media/cms-core": "0.93.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"@actuate-media/cms-core": ">=0.1.0",
|